@@ -94,20 +94,20 @@ const Mapper = ({
9494 useEffect ( ( ) => {
9595 setExistingField ( ( prevExisting : ExistingFieldType ) => {
9696 const updatedExisting = { ...prevExisting } ;
97- const validLabels = cmsLocaleOptions ?. map ( locale => locale . label ) || [ ] ;
98- Object . entries ( updatedExisting ) . forEach ( ( [ index , entry ] ) => {
97+ const validLabels = cmsLocaleOptions ?. map ( locale => locale ? .label ) || [ ] ;
98+ Object ? .entries ( updatedExisting ) ? .forEach ( ( [ index , entry ] ) => {
9999 const [ labelPart ] = entry . label . split ( '-' ) ;
100- if ( ! validLabels . includes ( labelPart ) ) {
100+ if ( ! validLabels ? .includes ( labelPart ) ) {
101101 delete updatedExisting [ index ] ;
102102 }
103103 } ) ;
104104
105105 setSelectedMappings ( ( prev ) => {
106106 const updated = { ...prev } ;
107107
108- Object . keys ( updated ) . forEach ( ( key ) => {
109- const [ labelPart ] = key . split ( '-' ) ;
110- if ( ! validLabels . includes ( labelPart ) ) {
108+ Object ? .keys ( updated ) ? .forEach ( ( key ) => {
109+ const [ labelPart ] = key ? .split ( '-' ) ;
110+ if ( ! validLabels ? .includes ( labelPart ) ) {
111111 delete updated [ key ] ;
112112 }
113113 } ) ;
@@ -167,7 +167,7 @@ const Mapper = ({
167167 ) ;
168168 const newValue : string = selectedValue ?. label ;
169169 if ( ! newSelectedOptions ?. includes ( newValue ) ) {
170- newSelectedOptions . push ( newValue ) ;
170+ newSelectedOptions ? .push ( newValue ) ;
171171 }
172172 return newSelectedOptions ;
173173 } ) ;
@@ -432,7 +432,7 @@ const LanguageMapper = () => {
432432 const fetchData = async ( ) => {
433433 try {
434434 setisLoading ( true ) ;
435- const allLocales : { label : string ; value : string } [ ] = Object . entries (
435+ const allLocales : { label : string ; value : string } [ ] = Object ? .entries (
436436 newMigrationData ?. destination_stack ?. csLocale ?? { }
437437 ) . map ( ( [ key ] ) => ( {
438438 label : key ,
@@ -444,20 +444,20 @@ const LanguageMapper = () => {
444444 } ) ) ;
445445 setsourceLocales ( sourceLocale ) ;
446446 setoptions ( allLocales ) ;
447- const keys = Object . keys ( newMigrationData ?. destination_stack ?. localeMapping || { } ) ?. find ( key => key === `${ newMigrationData ?. destination_stack ?. selectedStack ?. master_locale } -master_locale` ) ;
447+ const keys = Object ? .keys ( newMigrationData ?. destination_stack ?. localeMapping || { } ) ?. find ( key => key === `${ newMigrationData ?. destination_stack ?. selectedStack ?. master_locale } -master_locale` ) ;
448448
449449 ( Object ?. entries ( newMigrationData ?. destination_stack ?. localeMapping ) ?. length === 0 || keys !== `${ newMigrationData ?. destination_stack ?. selectedStack ?. master_locale } -master_locale` ) &&
450450 newMigrationData ?. project_current_step <= 2 &&
451451 setcmsLocaleOptions ( ( prevList : { label : string ; value : string } [ ] ) => {
452452 const newLabel = newMigrationData ?. destination_stack ?. selectedStack ?. master_locale ;
453453
454- const isPresent = prevList . filter (
454+ const isPresent = prevList ? .filter (
455455 ( item : { label : string ; value : string } ) => ( item ?. value === 'master_locale' )
456456 ) ;
457457
458- if ( isPresent [ 0 ] ?. label !== newLabel ) {
458+ if ( isPresent ?. [ 0 ] ?. label !== newLabel ) {
459459 return [
460- ...prevList . filter ( item => item . value !== 'master_locale' ) ,
460+ ...prevList ? .filter ( item => item ? .value !== 'master_locale' ) ,
461461 {
462462 label : newLabel ,
463463 value : 'master_locale' ,
@@ -477,7 +477,7 @@ const LanguageMapper = () => {
477477 return prevList ;
478478 } ) ;
479479 if ( newMigrationData ?. project_current_step > 2 ) {
480- Object . entries ( newMigrationData ?. destination_stack ?. localeMapping || { } ) ?. forEach (
480+ Object ? .entries ( newMigrationData ?. destination_stack ?. localeMapping || { } ) ?. forEach (
481481 ( [ key , value ] ) => {
482482 setcmsLocaleOptions ( ( prevList ) => {
483483 const labelKey = key ?. replace ( / - m a s t e r _ l o c a l e $ / , '' ) ;
0 commit comments