@@ -44,13 +44,15 @@ interface BatchFlowProps {
4444 centerBoards ?: string [ ] ;
4545 centerMediums ?: string [ ] ;
4646 centerGrades ?: string [ ] ;
47+ centerType ?: string | null ;
4748}
4849
4950const BatchFlow : React . FC < BatchFlowProps > = ( {
5051 initialParentId,
5152 centerBoards = [ ] ,
5253 centerMediums = [ ] ,
5354 centerGrades = [ ] ,
55+ centerType = null ,
5456} ) => {
5557 const theme = useTheme < any > ( ) ;
5658 const [ isLoading , setIsLoading ] = useState ( false ) ;
@@ -144,6 +146,24 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
144146 overrideEnum ( 'medium' , centerMediums ) ;
145147 overrideEnum ( 'grade' , centerGrades ) ;
146148
149+ // Modify batch_type based on centerType
150+ if ( centerType && alterSchema ?. properties ?. batch_type ) {
151+ if ( centerType === 'remote' ) {
152+ // For remote center: set default to "remote" and disable the field
153+ alterSchema . properties . batch_type . default = 'remote' ;
154+ if ( alterUiSchema ?. batch_type ) {
155+ alterUiSchema . batch_type [ 'ui:disabled' ] = true ;
156+ }
157+ } else if ( centerType === 'regular' ) {
158+ // For regular center: show only "regular" and "contact" options
159+ alterSchema . properties . batch_type . enum = [ 'regular' , 'contact' ] ;
160+ alterSchema . properties . batch_type . enumNames = [ 'REGULAR' , 'CONTACT' ] ;
161+ if ( alterUiSchema ?. batch_type ?. [ 'ui:disabled' ] ) {
162+ delete alterUiSchema . batch_type [ 'ui:disabled' ] ;
163+ }
164+ }
165+ }
166+
147167 if ( ! isEditMode ) {
148168 if ( centerBoards ?. length === 1 && alterUiSchema ?. board ) {
149169 alterUiSchema . board [ 'ui:disabled' ] = true ;
@@ -188,7 +208,7 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
188208 ) ;
189209 setPrefilledFormData ( withParent ) ;
190210 fetchData ( ) ;
191- } , [ initialParentId ] ) ;
211+ } , [ initialParentId , centerType , centerBoards , centerMediums , centerGrades ] ) ;
192212
193213 const updatedUiSchema = {
194214 ...uiSchema ,
@@ -351,6 +371,10 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
351371 } ;
352372 buildSchemaAndUi ( true , existingValues ) ;
353373 let tempFormData = extractMatchingKeys ( row , addSchema ) ;
374+ // Force batch_type to "remote" if centerType is "remote"
375+ if ( centerType === 'remote' ) {
376+ tempFormData . batch_type = 'remote' ;
377+ }
354378 setPrefilledAddFormData ( tempFormData ) ;
355379 setIsEdit ( true ) ;
356380 setEditableUserId ( row ?. cohortId ) ;
@@ -419,7 +443,7 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
419443 const failureUpdateMessage = 'BATCH.BATCH_UPDATE_FAILED' ;
420444 const successCreateMessage = 'BATCH.BATCH_CREATED_SUCCESSFULLY' ;
421445 const telemetryCreateKey = 'batch-created-successfully' ;
422- const failureCreateMessage = 'BATCH.BATCH_UPDATE_FAILED ' ;
446+ const failureCreateMessage = 'BATCH.BATCH_CREATE_FAILED ' ;
423447
424448 return (
425449 < >
@@ -461,6 +485,11 @@ const BatchFlow: React.FC<BatchFlowProps> = ({
461485 if ( centerGrades ?. length === 1 )
462486 prefillWithBMGS . grade = [ centerGrades [ 0 ] ] ;
463487
488+ // Prefill batch_type for remote center
489+ if ( centerType === 'remote' ) {
490+ prefillWithBMGS . batch_type = 'remote' ;
491+ }
492+
464493 buildSchemaAndUi ( false ) ;
465494
466495 setPrefilledAddFormData ( prefillWithBMGS ) ;
0 commit comments