@@ -333,7 +333,6 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
333333
334334 // useEffect for rendering mapped fields with existing stack
335335 useEffect ( ( ) => {
336- console . log ( otherContentType ) ;
337336
338337 if ( newMigrationData ?. content_mapping ?. content_type_mapping ?. [ selectedContentType ?. contentstackUid || '' ] === otherContentType ?. id ) {
339338 tableData ?. forEach ( ( row ) => {
@@ -464,7 +463,43 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
464463 matchedKeys . add ( key ) ;
465464 setExistingField ( ( prevOptions : ExistingFieldType ) => ( {
466465 ...prevOptions ,
467- [ key ] : { label : schemaItem ?. display_name , value : schemaItem } ,
466+ [ key ] : { label : `${ item ?. display_name } > ${ schemaItem ?. display_name } ` , value : schemaItem } ,
467+ } ) ) ;
468+ }
469+ } ) ;
470+ }
471+ }
472+ } ) ;
473+
474+ if ( newMigrationData ?. content_mapping ?. content_type_mapping ?. [ otherCmsTitle ] !== otherContentType ?. label ) {
475+ setSelectedOptions ( [ ] ) ;
476+ }
477+
478+ }
479+
480+ } , [ contentTypeSchema ] ) ;
481+ useEffect ( ( ) => {
482+ if ( existingField ) {
483+ const matchedKeys = new Set < string > ( ) ;
484+
485+ contentTypeSchema ?. forEach ( ( item ) => {
486+ for ( const [ key , value ] of Object . entries ( existingField ) ) {
487+ if ( value ?. value ?. uid === item ?. uid ) {
488+ matchedKeys . add ( key ) ;
489+
490+ setExistingField ( ( prevOptions : ExistingFieldType ) => ( {
491+ ...prevOptions ,
492+ [ key ] : { label : item ?. display_name , value : item } ,
493+ } ) ) ;
494+ }
495+ if ( item ?. data_type === "group" && Array . isArray ( item ?. schema ) ) {
496+ item . schema . forEach ( ( schemaItem ) => {
497+ if ( value ?. value ?. uid === schemaItem ?. uid ) {
498+
499+ matchedKeys . add ( key ) ;
500+ setExistingField ( ( prevOptions : ExistingFieldType ) => ( {
501+ ...prevOptions ,
502+ [ key ] : { label : `${ item ?. display_name } > ${ schemaItem ?. display_name } ` , value : schemaItem } ,
468503 } ) ) ;
469504 }
470505 } ) ;
@@ -493,7 +528,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
493528 } ) ;
494529
495530 }
496- } , [ contentTypeSchema ] ) ;
531+
532+ } , [ otherContentType ] ) ;
497533
498534 // To dispatch the changed dropdown state
499535 // useEffect(() => {
@@ -1029,6 +1065,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
10291065 ...row ,
10301066 contentstackField : selectedValue ?. label ,
10311067 contentstackFieldUid : selectedValue ?. uid ,
1068+ contentstackFieldType : selectedValue ?. value ?. field_metadata ?. allow_rich_text ? 'html' : row ?. contentstackFieldType ,
10321069 advanced : {
10331070 validationRegex : selectedValue ?. value ?. format ,
10341071 mandatory : selectedValue ?. value ?. mandatory ,
@@ -1127,6 +1164,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11271164 return value ?. data_type === 'reference' ;
11281165 case 'boolean' :
11291166 return value ?. data_type === 'boolean' ;
1167+ case 'link' :
1168+ return value ?. data_type === 'link' ;
11301169 default :
11311170 return false ;
11321171 }
@@ -1457,21 +1496,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14571496 ) {
14581497 setContentTypeMapped ( ( prevState : ContentTypeMap ) => ( {
14591498 ...prevState ,
1460- [ otherCmsTitle ] : otherContentType ?. label
1499+ [ selectedContentType ?. contentstackUid ] : otherContentType ?. id ?? ''
14611500 } ) ) ;
14621501
1463- const newMigrationDataObj : INewMigration = {
1464- ...newMigrationData ,
1465- content_mapping : {
1466- ...newMigrationData ?. content_mapping ,
1467- content_type_mapping : {
1468-
1469- ...newMigrationData ?. content_mapping ?. content_type_mapping ?? { } ,
1470- [ selectedContentType ?. contentstackUid ] : otherContentType ?. id || ''
1471- }
1472- }
1473- } ;
1474- dispatch ( updateNewMigrationData ( newMigrationDataObj ) ) ;
14751502 }
14761503
14771504 if ( orgId && contentTypeUid && selectedContentType ) {
@@ -1506,13 +1533,21 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15061533 type : 'success'
15071534 } ) ;
15081535 setIsDropDownChanged ( false ) ;
1509-
15101536 const newMigrationDataObj : INewMigration = {
15111537 ...newMigrationData ,
1512- content_mapping : { ...newMigrationData ?. content_mapping , isDropDownChanged : false }
1538+ content_mapping : {
1539+ ...newMigrationData ?. content_mapping ,
1540+ content_type_mapping : {
1541+
1542+ ...newMigrationData ?. content_mapping ?. content_type_mapping ,
1543+ [ selectedContentType ?. contentstackUid ] : otherContentType ?. id ?? ''
1544+ } ,
1545+ isDropDownChanged : false
1546+ }
15131547 } ;
1514-
1515- dispatch ( updateNewMigrationData ( ( newMigrationDataObj ) ) ) ;
1548+ dispatch ( updateNewMigrationData ( newMigrationDataObj ) ) ;
1549+
1550+
15161551
15171552 const savedCT = filteredContentTypes ?. map ( ct =>
15181553 ct ?. id === data ?. data ?. updatedContentType ?. id ? { ...ct , status : data ?. data ?. updatedContentType ?. status } : ct
@@ -1597,7 +1632,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15971632 setContentTypeMapped ( ( prevState : ContentTypeMap ) => {
15981633 const newState = { ...prevState } ;
15991634
1600- delete newState [ otherCmsTitle ] ;
1635+ delete newState [ selectedContentType ?. contentstackUid ?? '' ] ;
16011636 newstate = newState ;
16021637
16031638 return newstate ;
@@ -1804,12 +1839,16 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
18041839 } ) ;
18051840 }
18061841
1807- const options = contentModels ?. map ( ( item ) => ( {
1808- label : item ?. title ,
1809- value : item ?. title ,
1810- id : item ?. uid ,
1811- isDisabled : false
1812- } ) ) ;
1842+ const options = contentModels ?. map ( ( item ) => {
1843+ return {
1844+ label : item ?. title ,
1845+ value : item ?. title ,
1846+ id : item ?. uid ,
1847+ isDisabled : ( contentTypeMapped && Object . values ( contentTypeMapped ) . includes ( item ?. uid ) )
1848+ } ;
1849+ } ) ;
1850+
1851+
18131852
18141853 const adjustedOption = options ?. map ( ( option ) => ( {
18151854 ...option ,
0 commit comments