@@ -12,7 +12,7 @@ import {
1212} from "antd" ;
1313import { selectProps } from "../../../lib" ;
1414import { api } from "../../../lib" ;
15- import { SegmentForm } from "." ;
15+ import { MAX_SEGMENT , SegmentForm } from "." ;
1616
1717const SegmentConfigurationForm = ( {
1818 uploadResult = { } ,
@@ -96,6 +96,51 @@ const SegmentConfigurationForm = ({
9696 } ) ;
9797 } ;
9898
99+ const segmentNumericalWarning = useMemo ( ( ) => {
100+ // Extra message for numerical variable
101+ if (
102+ variableType === "numerical" &&
103+ segmentFields ?. length < numberOfSegments
104+ ) {
105+ return (
106+ < Col span = { 24 } >
107+ < Alert
108+ message = {
109+ < >
110+ The variable { segmentationVariable } includes too many 0 or
111+ missing values to meaningfully create { numberOfSegments } segment
112+ { numberOfSegments > 1 ? "s" : "" } . < br />
113+ Consider using a different variable, or adjust the thresholds
114+ manually.
115+ </ >
116+ }
117+ type = "warning"
118+ />
119+ </ Col >
120+ ) ;
121+ }
122+ return null ;
123+ } , [ variableType , segmentFields , numberOfSegments , segmentationVariable ] ) ;
124+
125+ const maxSegmentWarning = useMemo ( ( ) => {
126+ if ( segmentFields ?. length > MAX_SEGMENT ) {
127+ return (
128+ < Col span = { 24 } >
129+ < Alert
130+ message = {
131+ < >
132+ The variable { segmentationVariable } includes more than five
133+ unique values. To proceed, please keep only up to 5 segments.
134+ </ >
135+ }
136+ type = "warning"
137+ />
138+ </ Col >
139+ ) ;
140+ }
141+ return null ;
142+ } , [ segmentFields , segmentationVariable ] ) ;
143+
99144 return (
100145 < Row gutter = { [ 16 , 16 ] } >
101146 { /* SEGMENT CONFIGURATION */ }
@@ -163,27 +208,8 @@ const SegmentConfigurationForm = ({
163208 Please review or adjust thresholds for separating segments below:
164209 </ h3 >
165210 < Row gutter = { [ 20 , 20 ] } >
166- {
167- // Extra message for numerical variable
168- variableType === "numerical" &&
169- segmentFields ?. length < numberOfSegments ? (
170- < Col span = { 24 } >
171- < Alert
172- message = {
173- < >
174- The variable { segmentationVariable } includes too many 0
175- or missing values to meaningfully create{ " " }
176- { numberOfSegments } segment
177- { numberOfSegments > 1 ? "s" : "" } . < br />
178- Consider using a different variable, or adjust the
179- thresholds manually.
180- </ >
181- }
182- type = "warning"
183- />
184- </ Col >
185- ) : null
186- }
211+ { segmentNumericalWarning }
212+ { maxSegmentWarning }
187213 < Col span = { 24 } >
188214 < SegmentForm
189215 deletedSegmentIds = { deletedSegmentIds }
0 commit comments