@@ -324,7 +324,8 @@ const Migration = () => {
324324 isLocalPath : projectData ?. legacy_cms ?. is_localPath
325325 } ,
326326 isValidated : projectData ?. legacy_cms ?. is_fileValid ,
327- reValidate : newMigrationData ?. legacy_cms ?. uploadedFile ?. reValidate
327+ reValidate : newMigrationData ?. legacy_cms ?. uploadedFile ?. reValidate ,
328+ file_revalidated : newMigrationData ?. legacy_cms ?. uploadedFile ?. file_revalidated
328329 } : uploadObj ,
329330 isFileFormatCheckboxChecked : true ,
330331 isRestictedKeywordCheckboxChecked : true ,
@@ -373,7 +374,7 @@ const Migration = () => {
373374 */
374375 const createStepper = (
375376 projectData : MigrationResponse ,
376- handleStepChange : ( currentStep : number ) => void
377+ handleStepChange : ( step : number ) => void
377378 ) => {
378379 const steps = [
379380 {
@@ -450,7 +451,7 @@ const Migration = () => {
450451 const handleOnClickLegacyCms = async ( event : MouseEvent ) => {
451452 setIsLoading ( true ) ;
452453
453- if ( isCompleted ) {
454+ if ( isCompleted && newMigrationData ?. project_current_step === 1 ) {
454455 event . preventDefault ( ) ;
455456
456457 //Update Data in backend
@@ -493,6 +494,26 @@ const Migration = () => {
493494 type : 'error'
494495 } ) ;
495496 }
497+ }
498+ else if ( newMigrationData ?. project_current_step > 1 && ( ! newMigrationData ?. legacy_cms ?. uploadedFile ?. reValidate || newMigrationData ?. legacy_cms ?. uploadedFile ?. reValidate ) ) {
499+ if ( ! newMigrationData ?. legacy_cms ?. uploadedFile ?. file_revalidated ) {
500+ setIsLoading ( false ) ;
501+ Notification ( {
502+ notificationContent : {
503+ text : 'Please reValidate the file to procced furthur'
504+ } ,
505+ type : 'warning'
506+ } ) ;
507+ }
508+ else {
509+ setIsLoading ( false ) ;
510+ handleStepChange ( 2 ) ;
511+ const url = `/projects/${ projectId } /migration/steps/3` ;
512+ navigate ( url , { replace : true } ) ;
513+
514+ }
515+
516+
496517 } else {
497518 setIsLoading ( false ) ;
498519
@@ -623,12 +644,21 @@ const Migration = () => {
623644 }
624645 } ) ;
625646 } else {
626- event . preventDefault ( ) ;
627- const url = `/projects/${ projectId } /migration/steps/4` ;
628- navigate ( url , { replace : true } ) ;
629647
630- await updateCurrentStepData ( selectedOrganisation . value , projectId ) ;
631- handleStepChange ( 3 ) ;
648+ const res = await updateCurrentStepData ( selectedOrganisation . value , projectId ) ;
649+ if ( res ?. status === 200 ) {
650+ setIsLoading ( false ) ;
651+ event . preventDefault ( ) ;
652+ const url = `/projects/${ projectId } /migration/steps/4` ;
653+ navigate ( url , { replace : true } ) ;
654+ } else {
655+ setIsLoading ( false ) ;
656+ Notification ( {
657+ notificationContent : { text : res ?. data ?. error ?. message } ,
658+ type : 'error'
659+ } ) ;
660+ }
661+
632662 }
633663 } ;
634664
@@ -722,7 +752,7 @@ const Migration = () => {
722752 < div className = "steps-wrapper" >
723753 < HorizontalStepper
724754 ref = { stepperRef }
725- steps = { createStepper ( projectData ?? defaultMigrationResponse , handleClick ) }
755+ steps = { createStepper ( projectData ?? defaultMigrationResponse , handleStepChange ) }
726756 handleSaveCT = { saveRef ?. current ?. handleSaveContentType }
727757 changeDropdownState = { changeDropdownState }
728758 projectData = { projectData || defaultMigrationResponse }
0 commit comments