@@ -244,30 +244,30 @@ const flattenSchemaToUidMap = (
244244 result : Record < string , { item : ContentTypesSchema ; label : string } > = { }
245245) : Record < string , { item : ContentTypesSchema ; label : string } > => {
246246 for ( const item of schema ?? [ ] ) {
247- const label = parentLabel ? `${ parentLabel } > ${ item . display_name } ` : item . display_name ;
247+ const label = parentLabel ? `${ parentLabel } > ${ item ? .display_name } ` : item ? .display_name ;
248248 // Index by uid so we can do O(1) lookup
249- if ( item . uid ) {
249+ if ( item ? .uid ) {
250250 // Only store the first occurrence to avoid overwriting with a deeper-nested
251251 // duplicate uid. The label stored here is the full display path.
252- if ( ! result [ item . uid ] ) {
253- result [ item . uid ] = { item, label } ;
252+ if ( ! result [ item ? .uid ] ) {
253+ result [ item ? .uid ] = { item, label } ;
254254 }
255255 }
256256
257257 // Recurse into groups
258- if ( item . schema && Array . isArray ( item . schema ) ) {
259- flattenSchemaToUidMap ( item . schema , label , result ) ;
258+ if ( item ? .schema && Array . isArray ( item ? .schema ) ) {
259+ flattenSchemaToUidMap ( item ? .schema , label , result ) ;
260260 }
261261
262262 // Recurse into modular block children
263- if ( item . data_type === 'blocks' && item . blocks && Array . isArray ( item . blocks ) ) {
264- for ( const block of item . blocks ) {
265- const blockLabel = `${ label } > ${ block . uid || block . display_name } ` ;
266- if ( block . uid && ! result [ block . uid ] ) {
267- result [ block . uid ] = { item : block as unknown as ContentTypesSchema , label : blockLabel } ;
263+ if ( item ? .data_type === 'blocks' && item ? .blocks && Array . isArray ( item ? .blocks ) ) {
264+ for ( const block of item ? .blocks ) {
265+ const blockLabel = `${ label } > ${ block ? .uid || block ? .display_name } ` ;
266+ if ( block ? .uid && ! result [ block ? .uid ] ) {
267+ result [ block ? .uid ] = { item : block as unknown as ContentTypesSchema , label : blockLabel } ;
268268 }
269- if ( block . schema && Array . isArray ( block . schema ) ) {
270- flattenSchemaToUidMap ( block . schema , blockLabel , result ) ;
269+ if ( block ? .schema && Array . isArray ( block ? .schema ) ) {
270+ flattenSchemaToUidMap ( block ? .schema , blockLabel , result ) ;
271271 }
272272 }
273273 }
@@ -798,13 +798,13 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
798798 if ( idx !== - 1 ) nextSelectedOptions . splice ( idx , 1 ) ;
799799 }
800800 delete nextExistingField [ backupFieldUid ] ;
801- nextTableData = nextTableData . map ( ( row : FieldMapType ) => {
802- if ( row . backupFieldUid === backupFieldUid ) {
801+ nextTableData = nextTableData ? .map ( ( row : FieldMapType ) => {
802+ if ( row ? .backupFieldUid === backupFieldUid ) {
803803 return {
804804 ...row ,
805- contentstackField : row . otherCmsField ,
806- contentstackFieldUid : row . backupFieldUid ,
807- contentstackFieldType : row . backupFieldType ,
805+ contentstackField : row ? .otherCmsField ,
806+ contentstackFieldUid : row ? .backupFieldUid ,
807+ contentstackFieldType : row ? .backupFieldType ,
808808 } ;
809809 }
810810 return row ;
@@ -836,11 +836,11 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
836836 const schemaEntry = schemaUidMap [ mappedItemUid ] ;
837837 if ( schemaEntry ) {
838838 nextExistingField [ backupFieldUid ] = {
839- label : schemaEntry . label ,
840- value : schemaEntry . item ,
839+ label : schemaEntry ? .label ,
840+ value : schemaEntry ? .item ,
841841 } ;
842- if ( ! nextSelectedOptions . includes ( schemaEntry . label ) ) {
843- nextSelectedOptions . push ( schemaEntry . label ) ;
842+ if ( ! nextSelectedOptions . includes ( schemaEntry ? .label ) ) {
843+ nextSelectedOptions . push ( schemaEntry ? .label ) ;
844844 }
845845 }
846846 }
0 commit comments