@@ -50,6 +50,7 @@ const Centers = () => {
5050 const [ uiSchema , setUiSchema ] = useState ( CohortSearchUISchema ) ;
5151 const [ addSchema , setAddSchema ] = useState ( null ) ;
5252 const [ addUiSchema , setAddUiSchema ] = useState ( null ) ;
53+ const [ originalAddUiSchema , setOriginalAddUiSchema ] = useState ( null ) ;
5354 const [ prefilledAddFormData , setPrefilledAddFormData ] = useState ( { } ) ;
5455 const [ pageLimit , setPageLimit ] = useState < number > ( 10 ) ;
5556 const [ pageOffset , setPageOffset ] = useState < number > ( 0 ) ;
@@ -164,6 +165,7 @@ const Centers = () => {
164165 alterUISchema = enhanceUiSchemaWithGrid ( alterUISchema ) ;
165166
166167 setAddUiSchema ( alterUISchema ) ;
168+ setOriginalAddUiSchema ( alterUISchema ) ;
167169
168170 // Uncomment for remote center changes
169171 // // console.log('####1:', alterSchema);
@@ -495,6 +497,32 @@ const Centers = () => {
495497 callback : ( row : any ) => {
496498 let tempFormData = extractMatchingKeys ( row , addSchema ) ;
497499 console . log ( '######## images value tempFormData' , tempFormData ) ;
500+ // console.log('######## images value row', row);
501+ // console.log('######## images value addSchema', addSchema);
502+
503+ // Hide address and google_map_link fields when center_type is 'remote'
504+ if ( tempFormData . center_type === 'remote' ) {
505+ const modifiedUiSchema = JSON . parse (
506+ JSON . stringify ( originalAddUiSchema || addUiSchema )
507+ ) ;
508+ if ( modifiedUiSchema . address ) {
509+ modifiedUiSchema . address = {
510+ ...modifiedUiSchema . address ,
511+ 'ui:widget' : 'hidden' ,
512+ } ;
513+ }
514+ if ( modifiedUiSchema . google_map_link ) {
515+ modifiedUiSchema . google_map_link = {
516+ ...modifiedUiSchema . google_map_link ,
517+ 'ui:widget' : 'hidden' ,
518+ } ;
519+ }
520+ setAddUiSchema ( modifiedUiSchema ) ;
521+ } else {
522+ // Restore original UI schema for non-remote centers
523+ setAddUiSchema ( originalAddUiSchema || addUiSchema ) ;
524+ }
525+
498526 setPrefilledAddFormData ( tempFormData ) ;
499527 setIsEdit ( true ) ;
500528 setEditableUserId ( row ?. cohortId ) ;
@@ -577,6 +605,10 @@ const Centers = () => {
577605 const handleOpenModal = ( ) => setOpenModal ( true ) ;
578606
579607 const handleCloseModal = ( ) => {
608+ // Restore original UI schema when closing modal
609+ if ( originalAddUiSchema ) {
610+ setAddUiSchema ( originalAddUiSchema ) ;
611+ }
580612 setOpenModal ( false ) ;
581613 } ;
582614
@@ -622,6 +654,10 @@ const Centers = () => {
622654 width : '200px' ,
623655 } }
624656 onClick = { ( ) => {
657+ // Restore original UI schema when creating new center
658+ if ( originalAddUiSchema ) {
659+ setAddUiSchema ( originalAddUiSchema ) ;
660+ }
625661 setPrefilledAddFormData ( initialFormData ) ;
626662 setIsEdit ( false ) ;
627663 setEditableUserId ( '' ) ;
0 commit comments