@@ -821,13 +821,13 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
821821 }
822822
823823 const modifiedObj = ( obj : FieldMapType ) => {
824- const { otherCmsType , uid, id} = obj
824+ const { backupFieldType , uid, id} = obj
825825 const excludeArr = [ "group" ]
826826 return {
827827 id,
828- otherCmsType ,
828+ backupFieldType ,
829829 uid,
830- parentId : excludeArr ?. includes ( otherCmsType ?. toLowerCase ( ) ) ? '' : getParentId ( uid ?. split ( '.' ) [ 0 ] )
830+ parentId : excludeArr ?. includes ( backupFieldType ?. toLowerCase ( ) ) ? '' : getParentId ( uid ?. split ( '.' ) [ 0 ] ?. toLowerCase ( ) )
831831 }
832832 }
833833
@@ -897,9 +897,10 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
897897 // Get the latest action performed row
898898 const latestRow = findLatest ( rowHistoryObj ) ;
899899
900- if ( latestRow ?. otherCmsType ?. toLowerCase ( ) === "group" && latestRow ?. parentId === '' ) {
900+ if ( latestRow ?. backupFieldType ?. toLowerCase ( ) === "group" && latestRow ?. parentId === '' ) {
901901 // get all child rows of group
902- const childItems = tableData ?. filter ( ( entry ) => entry ?. uid ?. startsWith ( latestRow ?. uid + '.' ) ) ;
902+ const groupUid = latestRow ?. uid ?. toLowerCase ( ) ;
903+ const childItems = tableData ?. filter ( ( entry ) => entry ?. uid ?. toLowerCase ( ) ?. startsWith ( groupUid + '.' ) ) ;
903904 if ( childItems && validateArray ( childItems ) ) {
904905 if ( latestRow ?. checked ) {
905906 const lastEle = getLastElements ( rowHistoryObj )
@@ -930,19 +931,19 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
930931 }
931932 } else if ( latestRow ?. parentId && ! [ "title" , "url" ] ?. includes ( latestRow ?. uid ?. toLowerCase ( ) ) ) {
932933 // Extract the group UID if item is child of any group
933- const uidBeforeDot = latestRow ?. uid ?. split ( '.' ) [ 0 ] ;
934- const groupItem = tableData ?. find ( ( entry ) => entry ?. uid === uidBeforeDot ) ;
935- const childItems = tableData ?. filter ( ( entry ) => entry ?. uid ?. startsWith ( groupItem ?. uid + '.' ) ) ;
934+ const uidBeforeDot = latestRow ?. uid ?. split ( '.' ) [ 0 ] ?. toLowerCase ( ) ;
935+ const groupItem = tableData ?. find ( ( entry ) => entry ?. uid === uidBeforeDot ) ;
936+ const childItems = tableData ?. filter ( ( entry ) => entry ?. uid ?. toLowerCase ( ) ?. startsWith ( groupItem ?. uid + '.' ) ) ;
936937
937- if ( latestRow ?. checked ) {
938+ if ( latestRow ?. checked ) {
938939 if ( ! selectedObj [ latestRow ?. parentId ] ) {
939940 selectedObj [ latestRow ?. parentId ] = true
940941 }
941942 if ( ! selectedObj [ latestRow ?. id ] ) {
942943 selectedObj [ latestRow ?. id ] = true
943944 }
944- } else {
945- const lastEle = getLastElements ( rowHistoryObj )
945+ } else {
946+ const lastEle = getLastElements ( rowHistoryObj ) ;
946947
947948 let allChildFalse = 0
948949 childItems ?. forEach ( ( child ) => {
@@ -976,7 +977,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
976977 const handleValueChange = ( value : FieldTypes , rowIndex : string ) => {
977978 setIsDropDownChanged ( true ) ;
978979 setFieldValue ( value ) ;
979- const updatedRows : FieldMapType [ ] = tableData ?. map ( ( row ) => {
980+ const updatedRows : FieldMapType [ ] = selectedEntries ?. map ( ( row ) => {
980981 if ( row ?. uid === rowIndex ) {
981982 return { ...row , contentstackFieldType : value ?. value } ;
982983 }
@@ -1124,8 +1125,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11241125 item ?. child ?. some ( e => e ?. id )
11251126 )
11261127
1127- if ( groupArray ?. [ 0 ] ?. child && previousSelectedValue !== selectedValue ?. label && groupArray [ 0 ] ?. uid === rowIndex ) {
1128- for ( const item of groupArray [ 0 ] ?. child ?? [ ] ) {
1128+ if ( groupArray ?. [ 0 ] ?. child && previousSelectedValue !== selectedValue ?. label && groupArray ?. [ 0 ] ?. uid === rowIndex ) {
1129+ for ( const item of groupArray ?. [ 0 ] ?. child ?? [ ] ) {
11291130 deletedExstingField [ item ?. uid ] = {
11301131 label :item ?. uid ,
11311132 value :existingField [ item ?. uid ]
@@ -1298,7 +1299,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12981299 OptionsForRow . push ( getMatchingOption ( value , true , updatedDisplayName , uid ?? '' ) ) ;
12991300 }
13001301
1301- const existingLabel = existingField [ groupArray [ 0 ] ?. uid ] ?. label ?? '' ;
1302+ const existingLabel = existingField [ groupArray ?. [ 0 ] ?. uid ] ?. label ?? '' ;
13021303 const lastLabelSegment = existingLabel . includes ( '>' )
13031304 ? existingLabel ?. split ( '>' ) ?. pop ( ) ?. trim ( )
13041305 : existingLabel ;
@@ -1309,7 +1310,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
13091310 for ( const item of array ) {
13101311 const fieldTypeToMatch = Fields [ item ?. backupFieldType as keyof Mapping ] ?. type ;
13111312 if ( item ?. id === data ?. id ) {
1312- for ( const key of existingField [ groupArray [ 0 ] ?. uid ] ?. value ?. schema || [ ] ) {
1313+ for ( const key of existingField [ groupArray ?. [ 0 ] ?. uid ] ?. value ?. schema || [ ] ) {
13131314
13141315 if ( checkConditions ( fieldTypeToMatch , key , item ) ) {
13151316 OptionsForRow . push ( getMatchingOption ( key , true , `${ updatedDisplayName } > ${ key ?. display_name } ` || '' , `${ uid } .${ key ?. uid } ` ) ) ;
@@ -1422,7 +1423,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14221423 item ?. child ?. some ( e => e ?. id === data ?. id )
14231424 ) ;
14241425
1425- const array = groupArray [ 0 ] ?. child || [ ]
1426+ const array = groupArray ?. [ 0 ] ?. child || [ ]
14261427
14271428 if ( value . data_type === 'group' ) {
14281429 processSchema ( value , data , array , groupArray , OptionsForRow , fieldsOfContentstack )
@@ -1440,33 +1441,33 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14401441
14411442 // Handle case where there is exactly one match and it is auto-mapped
14421443 if ( OptionsForRow ?. length === 1 &&
1443- ( OptionsForRow [ 0 ] ?. value ?. uid === 'url' || OptionsForRow [ 0 ] ?. value ?. uid === 'title' || OptionsForRow [ 0 ] ?. value ?. data_type === 'group' || OptionsForRow [ 0 ] ?. value ?. data_type === 'reference'
1444+ ( OptionsForRow ?. [ 0 ] ?. value ?. uid === 'url' || OptionsForRow ?. [ 0 ] ?. value ?. uid === 'title' || OptionsForRow ?. [ 0 ] ?. value ?. data_type === 'group' || OptionsForRow ?. [ 0 ] ?. value ?. data_type === 'reference'
14441445 ) )
14451446 {
14461447 updatedRows = updatedRows . map ( ( row : FieldMapType ) => {
14471448 if ( row ?. uid === data ?. uid ) {
14481449 return {
14491450 ...row ,
1450- contentstackField : OptionsForRow [ 0 ] ?. value ?. display_name ?? '' ,
1451- contentstackFieldUid : OptionsForRow [ 0 ] ?. value ?. uid ?? '' ,
1451+ contentstackField : OptionsForRow ?. [ 0 ] ?. value ?. display_name ?? '' ,
1452+ contentstackFieldUid : OptionsForRow ?. [ 0 ] ?. value ?. uid ?? '' ,
14521453 advanced : {
1453- validationRegex : OptionsForRow [ 0 ] ?. value ?. format ?? '' ,
1454- mandatory : OptionsForRow [ 0 ] ?. value ?. mandatory ,
1455- multiple : OptionsForRow [ 0 ] ?. value ?. multiple ,
1456- unique : OptionsForRow [ 0 ] ?. value ?. unique ,
1457- nonLocalizable : OptionsForRow [ 0 ] ?. value ?. non_localizable ,
1454+ validationRegex : OptionsForRow ?. [ 0 ] ?. value ?. format ?? '' ,
1455+ mandatory : OptionsForRow ?. [ 0 ] ?. value ?. mandatory ,
1456+ multiple : OptionsForRow ?. [ 0 ] ?. value ?. multiple ,
1457+ unique : OptionsForRow ?. [ 0 ] ?. value ?. unique ,
1458+ nonLocalizable : OptionsForRow ?. [ 0 ] ?. value ?. non_localizable ,
14581459 } ,
14591460 } ;
14601461 }
14611462 return row ;
14621463 } ) ;
14631464
14641465 // Disable option if it's not already in existingField
1465- if ( ! existingField [ data ?. uid ] && OptionsForRow [ 0 ] ) {
1466+ if ( ! existingField [ data ?. uid ] && OptionsForRow ?. [ 0 ] ) {
14661467 OptionsForRow [ 0 ] . isDisabled = true ;
14671468 }
1468- const newLabel = OptionsForRow [ 0 ] ?. value ?. display_name ;
1469- const newvalue = OptionsForRow [ 0 ] ?. value ;
1469+ const newLabel = OptionsForRow ?. [ 0 ] ?. value ?. display_name ;
1470+ const newvalue = OptionsForRow ?. [ 0 ] ?. value ;
14701471
14711472 // Check if there's already a matching entry in updatedExstingField
14721473 const hasMatchingEntry = Object . values ( updatedExstingField ) ?. some (
@@ -1483,7 +1484,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14831484 existingField [ data ?. uid ] = { label : newLabel , value : newvalue }
14841485 }
14851486
1486- const newValue : string = OptionsForRow [ 0 ] ?. value ?. display_name ;
1487+ const newValue : string = OptionsForRow ?. [ 0 ] ?. value ?. display_name ;
14871488 if ( ! updatedSelectedOptions ?. includes ( newValue ) ) {
14881489 updatedSelectedOptions . push ( newValue ) ;
14891490 }
@@ -1512,12 +1513,12 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15121513
15131514 const OptionValue : FieldTypes =
15141515 OptionsForRow ?. length === 1 && ( existingField [ data ?. uid ] || updatedExstingField [ data ?. uid ] ) &&
1515- ( OptionsForRow [ 0 ] ?. value ?. uid === 'url' || OptionsForRow [ 0 ] ?. value ?. uid === 'title' || OptionsForRow [ 0 ] ?. value ?. data_type === 'group' || OptionsForRow [ 0 ] ?. value ?. data_type === 'reference'
1516+ ( OptionsForRow ?. [ 0 ] ?. value ?. uid === 'url' || OptionsForRow ?. [ 0 ] ?. value ?. uid === 'title' || OptionsForRow ?. [ 0 ] ?. value ?. data_type === 'group' || OptionsForRow ?. [ 0 ] ?. value ?. data_type === 'reference'
15161517
15171518 )
15181519 ? {
1519- label : OptionsForRow [ 0 ] ?. value ?. display_name ,
1520- value : OptionsForRow [ 0 ] ?. value ,
1520+ label : OptionsForRow ?. [ 0 ] ?. value ?. display_name ,
1521+ value : OptionsForRow ?. [ 0 ] ?. value ,
15211522 isDisabled : true
15221523 }
15231524 : ( OptionsForRow ?. length === 0 || ( OptionsForRow ?. length > 0 && OptionsForRow ?. every ( ( item ) => item ?. isDisabled )
0 commit comments