@@ -44,7 +44,8 @@ import {
4444 ICMSType ,
4545 ILegacyCMSComponent ,
4646 DEFAULT_CMS_TYPE ,
47- TestStacks
47+ TestStacks ,
48+ FileDetails
4849} from '../../context/app/app.interface' ;
4950import { ContentTypeSaveHandles } from '../../components/ContentMapper/contentMapper.interface' ;
5051import { ICardType } from '../../components/Common/Card/card.interface' ;
@@ -60,7 +61,6 @@ import TestMigration from '../../components/TestMigration';
6061import MigrationExecution from '../../components/MigrationExecution' ;
6162import SaveChangesModal from '../../components/Common/SaveChangesModal' ;
6263import { getMigratedStacks } from '../../services/api/project.service' ;
63- import { getStackLocales } from '../../services/api/stacks.service' ;
6464import { getConfig } from '../../services/api/upload.service' ;
6565
6666type StepperComponentRef = {
@@ -69,6 +69,9 @@ type StepperComponentRef = {
6969type LegacyCmsRef = {
7070 getInternalActiveStepIndex : ( ) => number ;
7171} ;
72+ type LocalesType = {
73+ [ key : string ] : any
74+ }
7275
7376const Migration = ( ) => {
7477 const params : Params < string > = useParams ( ) ;
@@ -190,18 +193,18 @@ const Migration = () => {
190193
191194 // Use regex to extract the file extension
192195 const match = normalizedPath ?. match ( / \. ( [ a - z A - Z 0 - 9 ] + ) $ / ) ;
193- const ext = match ? match [ 1 ] ?. toLowerCase ( ) : "" ;
196+ const ext = match ? match ?. [ 1 ] ?. toLowerCase ( ) : "" ;
194197
195- const fileName = filePath ?. split ( '/' ) ?. pop ( ) ;
198+ // const fileName = filePath?.split('/')?.pop();
196199 //const ext = fileName?.split('.')?.pop();
197200 const validExtensionRegex = / \. ( p d f | z i p | x m l | j s o n ) $ / i;
198201 return ext && validExtensionRegex ?. test ( `.${ ext } ` ) ? `${ ext } ` : '' ;
199202 } ;
200-
203+
201204 // funcrion to form file format object from config response
202- const fetchFileFormat = ( data :any ) => {
205+ const fetchFileFormat = ( data : FileDetails ) => {
203206 const filePath = data ?. localPath ?. toLowerCase ( ) ;
204- const fileFormat = getFileExtension ( filePath ) ;
207+ const fileFormat = getFileExtension ( filePath ?? '' ) ;
205208 const selectedFileFormatObj = {
206209 description : "" ,
207210 fileformat_id : fileFormat ,
@@ -213,11 +216,11 @@ const Migration = () => {
213216 }
214217
215218// funcrion to form upload object from config response
216- const getFileInfo = ( data :any ) => {
219+ const getFileInfo = ( data : FileDetails ) => {
217220 const newMigrationDataObj = {
218221 name : data ?. localPath ,
219222 url : data ?. localPath ,
220- isValidated : data ?. localePath !== newMigrationData ?. legacy_cms ?. uploadedFile ?. file_details ?. localPath ? false : newMigrationData ?. legacy_cms ?. uploadedFile ?. isValidated ,
223+ isValidated : data ?. localPath !== newMigrationData ?. legacy_cms ?. uploadedFile ?. file_details ?. localPath ? false : newMigrationData ?. legacy_cms ?. uploadedFile ?. isValidated ,
221224 file_details : {
222225 isLocalPath : data ?. isLocalPath ,
223226 cmsType : data ?. cmsType ,
@@ -534,11 +537,11 @@ const Migration = () => {
534537 ( value ) => value !== '' && value !== null && value !== undefined
535538 ) ;
536539
537- const master_locale : any = { } ;
538- const locales : any = { } ;
539- Object . entries ( newMigrationData ?. destination_stack ?. localeMapping ) . forEach ( ( [ key , value ] ) => {
540- if ( key . includes ( 'master_locale' ) ) {
541- master_locale [ key . replace ( '-master_locale' , '' ) ] = value ;
540+ const master_locale : LocalesType = { } ;
541+ const locales : LocalesType = { } ;
542+ Object . entries ( newMigrationData ?. destination_stack ?. localeMapping ) ? .forEach ( ( [ key , value ] ) => {
543+ if ( key ? .includes ( 'master_locale' ) ) {
544+ master_locale [ key ? .replace ( '-master_locale' , '' ) ] = value ;
542545 } else {
543546 locales [ key ] = value ;
544547 }
0 commit comments