|
1 | 1 | // Libraries |
2 | | -import React, { useState, useImperativeHandle, forwardRef, useEffect } from 'react'; |
| 2 | +import React, { useState, useImperativeHandle, forwardRef, useEffect, useRef } from 'react'; |
3 | 3 | import { useNavigate, useParams } from 'react-router-dom'; |
4 | 4 | import './HorizontalStepper.scss'; |
5 | 5 | import { cbModal, Notification, Button, CircularLoader } from '@contentstack/venus-components'; |
@@ -46,6 +46,7 @@ export type stepperProps = { |
46 | 46 | handleSaveCT?: () => void; |
47 | 47 | changeDropdownState: () => void; |
48 | 48 | projectData: MigrationResponse; |
| 49 | + isProjectMapped: boolean; |
49 | 50 | }; |
50 | 51 |
|
51 | 52 | export type HorizontalStepperHandles = { |
@@ -88,16 +89,21 @@ const HorizontalStepper = forwardRef( |
88 | 89 |
|
89 | 90 | const navigate = useNavigate(); |
90 | 91 | const { projectId = '' } = useParams(); |
| 92 | + const newMigrationDataRef = useRef(newMigrationData); |
91 | 93 |
|
92 | 94 | const handleSaveCT = props?.handleSaveCT; |
93 | 95 | const handleDropdownChange = props?.changeDropdownState; |
94 | 96 | useBlockNavigation(isModalOpen); |
95 | 97 |
|
| 98 | + useEffect(() => { |
| 99 | + newMigrationDataRef.current = newMigrationData; |
| 100 | + }, [newMigrationData]); |
| 101 | + |
96 | 102 | useEffect(() => { |
97 | 103 | const stepIndex = parseInt(stepId || '', 10) - 1; |
98 | 104 |
|
99 | 105 | if (!Number.isNaN(stepIndex) && stepIndex >= 0 && stepIndex < steps?.length) { |
100 | | - !newMigrationData?.isprojectMapped && setShowStep(stepIndex); |
| 106 | + !newMigrationDataRef?.current?.isprojectMapped && setShowStep(stepIndex); |
101 | 107 | setStepsCompleted((prev) => { |
102 | 108 | const updatedStepsCompleted = [...prev]; |
103 | 109 | if ( |
@@ -266,7 +272,7 @@ const HorizontalStepper = forwardRef( |
266 | 272 | <> |
267 | 273 | {!hideTabView && <StepsTitleCreator />} |
268 | 274 | <div className={`stepContent ${props.stepContentClassName}`}> |
269 | | - {newMigrationData?.isprojectMapped ? ( |
| 275 | + {(newMigrationDataRef?.current?.isprojectMapped || props?.isProjectMapped)? ( |
270 | 276 | <div className={`stepper-loader `}> |
271 | 277 | <CircularLoader /> |
272 | 278 | </div> |
|
0 commit comments