Skip to content

Commit 2fdf26e

Browse files
committed
controller updates
1 parent 5c9fe22 commit 2fdf26e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/module/src/QuickStartController.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import * as React from 'react';
22
import QuickStartContent from './controller/QuickStartContent';
33
import QuickStartFooter from './controller/QuickStartFooter';
4-
import { QuickStartContext, QuickStartContextValues } from './utils/quick-start-context';
4+
import {
5+
getDefaultQuickStartState,
6+
QuickStartContext,
7+
QuickStartContextValues,
8+
} from './utils/quick-start-context';
59
import { QuickStart, QuickStartStatus, QuickStartTaskStatus } from './utils/quick-start-types';
610

711
interface QuickStartControllerProps {
@@ -35,13 +39,26 @@ export const QuickStartController: React.FC<QuickStartControllerProps> = ({
3539
} = quickStart;
3640
const totalTasks = tasks?.length;
3741
const {
42+
activeQuickStartID,
43+
allQuickStartStates,
44+
setAllQuickStartStates,
3845
activeQuickStartState,
3946
setActiveQuickStart,
4047
setQuickStartTaskNumber,
4148
setQuickStartTaskStatus,
4249
nextStep,
4350
previousStep,
4451
} = React.useContext<QuickStartContextValues>(QuickStartContext);
52+
React.useEffect(() => {
53+
// If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
54+
if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
55+
setAllQuickStartStates({
56+
...allQuickStartStates,
57+
[activeQuickStartID]: getDefaultQuickStartState(),
58+
});
59+
}
60+
}, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
61+
4562
const status = activeQuickStartState?.status as QuickStartStatus;
4663
const taskNumber = activeQuickStartState?.taskNumber as number;
4764
const allTaskStatuses = tasks.map(

0 commit comments

Comments
 (0)