@constructor-io/constructorio-ui-quizzes 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constructorio-ui-quizzes-bundled.js +13 -13
- package/lib/cjs/components/CioQuiz/index.js +5 -8
- package/lib/cjs/constants.js +4 -1
- package/lib/cjs/hooks/useQuiz.js +9 -2
- package/lib/cjs/hooks/useQuizEvents/index.js +6 -7
- package/lib/cjs/hooks/useQuizEvents/useHydrateQuizLocalState.js +5 -5
- package/lib/cjs/hooks/useQuizEvents/useQuizNextClick.js +11 -2
- package/lib/cjs/hooks/useQuizState/index.js +10 -5
- package/lib/cjs/hooks/useQuizState/useQuizLocalState.js +1 -17
- package/lib/cjs/hooks/useQuizState/useSessionStorageState.js +26 -0
- package/lib/cjs/stories/Quiz/tests/mocks.js +5 -1
- package/lib/cjs/utils.js +8 -4
- package/lib/mjs/components/CioQuiz/index.js +5 -8
- package/lib/mjs/constants.js +3 -0
- package/lib/mjs/hooks/useQuiz.js +9 -2
- package/lib/mjs/hooks/useQuizEvents/index.js +6 -7
- package/lib/mjs/hooks/useQuizEvents/useHydrateQuizLocalState.js +5 -5
- package/lib/mjs/hooks/useQuizEvents/useQuizNextClick.js +11 -2
- package/lib/mjs/hooks/useQuizState/index.js +10 -5
- package/lib/mjs/hooks/useQuizState/useQuizLocalState.js +3 -17
- package/lib/mjs/hooks/useQuizState/useSessionStorageState.js +22 -0
- package/lib/mjs/stories/Quiz/tests/mocks.js +6 -2
- package/lib/mjs/utils.js +7 -4
- package/lib/types/constants.d.ts +2 -1
- package/lib/types/hooks/useQuizEvents/useHydrateQuizLocalState.d.ts +1 -1
- package/lib/types/hooks/useQuizEvents/useQuizNextClick.d.ts +2 -2
- package/lib/types/hooks/useQuizState/index.d.ts +2 -4
- package/lib/types/hooks/useQuizState/useQuizLocalState.d.ts +1 -5
- package/lib/types/hooks/useQuizState/useSessionStorageState.d.ts +8 -0
- package/lib/types/types.d.ts +21 -8
- package/lib/types/utils.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14,21 +14,18 @@ const utils_1 = require("../../utils");
|
|
|
14
14
|
const ProgressBar_1 = tslib_1.__importDefault(require("../ProgressBar/ProgressBar"));
|
|
15
15
|
function CioQuiz(props) {
|
|
16
16
|
var _a;
|
|
17
|
-
const { cioClient, state, events: { hydrateQuiz,
|
|
17
|
+
const { cioClient, state, events: { hydrateQuiz, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = (0, useQuiz_1.default)(props);
|
|
18
18
|
const [showSessionPrompt, setShowSessionPrompt] = (0, react_1.useState)(false);
|
|
19
19
|
const { resultsPageOptions, sessionStateOptions } = props;
|
|
20
|
+
const { quizSessionStorageState: { hasSessionStorageState, skipToResults }, } = state;
|
|
20
21
|
(0, react_1.useEffect)(() => {
|
|
21
22
|
// Respect showSessionModal if defined, else default to true.
|
|
22
23
|
if ((sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.showSessionModal) !== undefined) {
|
|
23
|
-
setShowSessionPrompt((sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.showSessionModal) &&
|
|
24
|
-
hasSessionStorageState() &&
|
|
25
|
-
!state.quiz.skipToResults);
|
|
24
|
+
setShowSessionPrompt((sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.showSessionModal) && hasSessionStorageState() && !skipToResults);
|
|
26
25
|
}
|
|
27
26
|
else {
|
|
28
|
-
setShowSessionPrompt(hasSessionStorageState() && !
|
|
27
|
+
setShowSessionPrompt(hasSessionStorageState() && !skipToResults);
|
|
29
28
|
}
|
|
30
|
-
if (state.quiz.skipToResults)
|
|
31
|
-
hydrateQuiz();
|
|
32
29
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
30
|
}, []);
|
|
34
31
|
const contextValue = {
|
|
@@ -65,7 +62,7 @@ function CioQuiz(props) {
|
|
|
65
62
|
".cio-quiz ",
|
|
66
63
|
(0, utils_1.convertPrimaryColorsToString)(primaryColorStyles)),
|
|
67
64
|
react_1.default.createElement(SessionPromptModal_1.default, { resetStoredState: resetSessionStorageState, continueSession: hydrateQuiz, showSessionPrompt: showSessionPrompt, setShowSessionPrompt: setShowSessionPrompt }),
|
|
68
|
-
react_1.default.createElement(context_1.default.Provider, { value: contextValue }, state.quiz.results ||
|
|
65
|
+
react_1.default.createElement(context_1.default.Provider, { value: contextValue }, state.quiz.results || skipToResults ? (react_1.default.createElement(ResultContainer_1.default, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
66
|
react_1.default.createElement(ProgressBar_1.default, null),
|
|
70
67
|
react_1.default.createElement(QuizQuestions_1.default, null),
|
|
71
68
|
react_1.default.createElement(ControlBar_1.default, { ctaButtonText: (questionData === null || questionData === void 0 ? void 0 : questionData.cta_text) || undefined })))))));
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestStates = exports.changePrimaryColorDescription = exports.smallContainerDescription = exports.cioJsClientDescription = exports.basicDescription = exports.hookDescription = exports.componentDescription = exports.quizSessionStateKey = exports.quizId = exports.apiKey = void 0;
|
|
3
|
+
exports.RequestStates = exports.callbacksDescription = exports.changePrimaryColorDescription = exports.smallContainerDescription = exports.cioJsClientDescription = exports.basicDescription = exports.hookDescription = exports.componentDescription = exports.quizSessionStateKey = exports.quizId = exports.apiKey = void 0;
|
|
4
4
|
// Autocomplete key index
|
|
5
5
|
exports.apiKey = 'key_wJSdZSiesX5hiVLt';
|
|
6
6
|
exports.quizId = 'coffee-quiz';
|
|
@@ -23,6 +23,8 @@ exports.componentDescription = `- import \`CioQuiz\` to render in your JSX.
|
|
|
23
23
|
- \`resultCardRatingScoreKey\` is an optional parameter that specifies the metadata field name for the ratings score
|
|
24
24
|
- \`renderResultCardPriceDetails\` is an optional render function to render custom prices section in result card
|
|
25
25
|
- \`numResultsToDisplay\` is an optional parameter that determines how many results should be displayed on results page
|
|
26
|
+
- \`callbacks\` lets you pass callback functions that will be called on certain actions
|
|
27
|
+
- \`onQuizNextQuestion\` is an optional callback function that will be called when user moves to the next question
|
|
26
28
|
- \`sessionStateOptions\` lets you configure the session modal behavior
|
|
27
29
|
- \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
|
|
28
30
|
- \`showSessionModalOnResults\` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal
|
|
@@ -87,6 +89,7 @@ In the example below, the \`primaryColor\` prop has been used to override this c
|
|
|
87
89
|
|
|
88
90
|
> Advanced Option: Instead of passing a primaryColor prop, you can also override \`--primary-color-h\`, \`--primary-color-s\`, and \`--primary-color-l\` CSS variables within a \`.cio-quiz\` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.
|
|
89
91
|
`;
|
|
92
|
+
exports.callbacksDescription = `Pass an \`apiKey\`, a \`quizId\`, and \`callbacks\``;
|
|
90
93
|
var RequestStates;
|
|
91
94
|
(function (RequestStates) {
|
|
92
95
|
RequestStates["Stale"] = "STALE";
|
package/lib/cjs/hooks/useQuiz.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
4
5
|
const useCioClient_1 = tslib_1.__importDefault(require("./useCioClient"));
|
|
5
6
|
const useConsoleErrors_1 = tslib_1.__importDefault(require("./useConsoleErrors"));
|
|
6
7
|
const usePropsGetters_1 = tslib_1.__importDefault(require("./usePropsGetters"));
|
|
@@ -18,9 +19,15 @@ const useQuiz = (quizOptions) => {
|
|
|
18
19
|
// Quiz callback events
|
|
19
20
|
const quizEvents = (0, useQuizEvents_1.default)(quizOptions, cioClient, quizState);
|
|
20
21
|
// Props getters
|
|
21
|
-
const { quizApiState, quizLocalState,
|
|
22
|
+
const { quizApiState, quizLocalState, quizSessionStorageState } = quizState;
|
|
23
|
+
const { skipToResults } = quizSessionStorageState;
|
|
22
24
|
const propGetters = (0, usePropsGetters_1.default)(quizEvents, quizApiState, quizLocalState);
|
|
23
25
|
const primaryColorStyles = (0, usePrimaryColorStyles_1.default)(primaryColor);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
if (skipToResults)
|
|
28
|
+
quizEvents.hydrateQuiz();
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, []);
|
|
24
31
|
return Object.assign(Object.assign({ cioClient, state: {
|
|
25
32
|
answers: {
|
|
26
33
|
inputs: quizLocalState.answerInputs,
|
|
@@ -30,11 +37,11 @@ const useQuiz = (quizOptions) => {
|
|
|
30
37
|
requestState: quizApiState.quizRequestState,
|
|
31
38
|
versionId: quizLocalState.quizVersionId,
|
|
32
39
|
sessionId: quizLocalState.quizSessionId,
|
|
33
|
-
skipToResults,
|
|
34
40
|
currentQuestion: quizApiState.quizCurrentQuestion,
|
|
35
41
|
results: quizApiState.quizResults,
|
|
36
42
|
selectedOptionsWithAttributes: quizApiState.selectedOptionsWithAttributes,
|
|
37
43
|
},
|
|
44
|
+
quizSessionStorageState,
|
|
38
45
|
}, events: Object.assign({}, quizEvents) }, propGetters), { primaryColorStyles });
|
|
39
46
|
};
|
|
40
47
|
exports.default = useQuiz;
|
|
@@ -12,13 +12,13 @@ const useHydrateQuizLocalState_1 = tslib_1.__importDefault(require("./useHydrate
|
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const useQuizAddToFavorites_1 = tslib_1.__importDefault(require("./useQuizAddToFavorites"));
|
|
14
14
|
const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
15
|
-
const { quizApiState, dispatchLocalState, dispatchApiState,
|
|
16
|
-
const { resultsPageOptions } = quizOptions;
|
|
15
|
+
const { quizApiState, dispatchLocalState, dispatchApiState, quizLocalState, quizSessionStorageState, } = quizState;
|
|
16
|
+
const { resultsPageOptions, callbacks } = quizOptions;
|
|
17
17
|
const { onAddToCartClick, onQuizResultClick, onQuizResultsLoaded, onAddToFavoritesClick } = resultsPageOptions;
|
|
18
18
|
// Quiz answer change
|
|
19
19
|
const quizAnswerChanged = (0, useQuizAnswerChangeHandler_1.default)(quizApiState, dispatchLocalState);
|
|
20
20
|
// Quiz Next button click callback
|
|
21
|
-
const nextQuestion = (0, useQuizNextClick_1.default)(quizApiState, quizLocalState, dispatchLocalState);
|
|
21
|
+
const nextQuestion = (0, useQuizNextClick_1.default)(quizApiState, quizLocalState, dispatchLocalState, callbacks === null || callbacks === void 0 ? void 0 : callbacks.onQuizNextQuestion);
|
|
22
22
|
// Quiz Back button click callback
|
|
23
23
|
const previousQuestion = (0, useQuizBackClick_1.default)(quizApiState, dispatchLocalState);
|
|
24
24
|
// Quiz result add to cart callback
|
|
@@ -29,9 +29,9 @@ const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
|
29
29
|
// Quiz results loaded event
|
|
30
30
|
(0, useQuizResultsLoaded_1.default)(cioClient, quizApiState, onQuizResultsLoaded);
|
|
31
31
|
// Quiz reset
|
|
32
|
-
const resetQuiz = (0, useQuizResetClick_1.default)((0, utils_1.resetQuizSessionStorageState)(
|
|
32
|
+
const resetQuiz = (0, useQuizResetClick_1.default)((0, utils_1.resetQuizSessionStorageState)(quizSessionStorageState.key), dispatchLocalState, dispatchApiState, quizApiState.quizResults);
|
|
33
33
|
// Quiz rehydrate
|
|
34
|
-
const hydrateQuizLocalState = (0, useHydrateQuizLocalState_1.default)(
|
|
34
|
+
const hydrateQuizLocalState = (0, useHydrateQuizLocalState_1.default)(quizSessionStorageState.key, dispatchLocalState);
|
|
35
35
|
return {
|
|
36
36
|
addToCart,
|
|
37
37
|
addToFavorites,
|
|
@@ -41,8 +41,7 @@ const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
|
41
41
|
nextQuestion,
|
|
42
42
|
resetQuiz,
|
|
43
43
|
hydrateQuiz: hydrateQuizLocalState,
|
|
44
|
-
|
|
45
|
-
resetSessionStorageState: (0, utils_1.resetQuizSessionStorageState)(quizStateKey),
|
|
44
|
+
resetSessionStorageState: (0, utils_1.resetQuizSessionStorageState)(quizSessionStorageState.key),
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
47
|
exports.default = useQuizEvents;
|
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const actions_1 = require("../../components/CioQuiz/actions");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
|
-
const useHydrateQuizLocalState = (
|
|
7
|
-
const
|
|
6
|
+
const useHydrateQuizLocalState = (quizSessionStorageStateKey, dispatchLocalState) => {
|
|
7
|
+
const sessionStorageQuizState = (0, utils_1.getStateFromSessionStorage)(quizSessionStorageStateKey);
|
|
8
8
|
const hydrateQuizLocalStateHandler = (0, react_1.useCallback)(() => {
|
|
9
|
-
if (
|
|
9
|
+
if (sessionStorageQuizState) {
|
|
10
10
|
dispatchLocalState({
|
|
11
11
|
type: actions_1.QuestionTypes.Hydrate,
|
|
12
|
-
payload:
|
|
12
|
+
payload: sessionStorageQuizState,
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
}, [dispatchLocalState,
|
|
15
|
+
}, [dispatchLocalState, sessionStorageQuizState]);
|
|
16
16
|
return hydrateQuizLocalStateHandler;
|
|
17
17
|
};
|
|
18
18
|
exports.default = useHydrateQuizLocalState;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const actions_1 = require("../../components/CioQuiz/actions");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const useQuizNextClick = (quizApiState, quizLocalState, dispatchLocalState, onQuizNextQuestion) => {
|
|
6
7
|
const quizNexClickHandler = (0, react_1.useCallback)(() => {
|
|
7
8
|
var _a, _b;
|
|
8
9
|
const currentQuestion = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question;
|
|
@@ -15,8 +16,16 @@ const useQuizNextClick = (quizApiState, quizLocalState, dispatchLocalState) => {
|
|
|
15
16
|
payload: quizApiState.quizCurrentQuestion,
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
if (currentQuestion && (0, utils_1.isFunction)(onQuizNextQuestion)) {
|
|
20
|
+
onQuizNextQuestion(Object.assign(Object.assign({}, currentQuestion), { answer: currentAnswerInput }));
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
|
-
}, [
|
|
23
|
+
}, [
|
|
24
|
+
dispatchLocalState,
|
|
25
|
+
quizApiState.quizCurrentQuestion,
|
|
26
|
+
quizLocalState.answerInputs,
|
|
27
|
+
onQuizNextQuestion,
|
|
28
|
+
]);
|
|
20
29
|
return quizNexClickHandler;
|
|
21
30
|
};
|
|
22
31
|
exports.default = useQuizNextClick;
|
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const useQuizApiState_1 = tslib_1.__importDefault(require("./useQuizApiState"));
|
|
5
5
|
const useQuizLocalState_1 = tslib_1.__importDefault(require("./useQuizLocalState"));
|
|
6
|
+
const useSessionStorageState_1 = tslib_1.__importDefault(require("./useSessionStorageState"));
|
|
6
7
|
const useQuizState = (quizOptions, cioClient) => {
|
|
7
|
-
const { sessionStateOptions } = quizOptions;
|
|
8
|
+
const { sessionStateOptions, enableHydration } = quizOptions;
|
|
8
9
|
// Quiz Local state
|
|
9
|
-
const { quizLocalState, dispatchLocalState
|
|
10
|
+
const { quizLocalState, dispatchLocalState } = (0, useQuizLocalState_1.default)();
|
|
11
|
+
// Quiz Session Storage state
|
|
12
|
+
const { skipToResults, quizSessionStorageStateKey, hasSessionStorageState } = (0, useSessionStorageState_1.default)(quizLocalState, sessionStateOptions, enableHydration === undefined ? true : enableHydration);
|
|
10
13
|
// Quiz API state
|
|
11
14
|
const { quizApiState, dispatchApiState } = (0, useQuizApiState_1.default)(quizOptions, cioClient, quizLocalState, skipToResults, dispatchLocalState);
|
|
12
15
|
return {
|
|
@@ -14,9 +17,11 @@ const useQuizState = (quizOptions, cioClient) => {
|
|
|
14
17
|
quizLocalState,
|
|
15
18
|
dispatchApiState,
|
|
16
19
|
dispatchLocalState,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
quizSessionStorageState: {
|
|
21
|
+
skipToResults,
|
|
22
|
+
key: quizSessionStorageStateKey,
|
|
23
|
+
hasSessionStorageState,
|
|
24
|
+
},
|
|
20
25
|
};
|
|
21
26
|
};
|
|
22
27
|
exports.default = useQuizState;
|
|
@@ -3,32 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const quizLocalReducer_1 = tslib_1.__importStar(require("../../components/CioQuiz/quizLocalReducer"));
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
6
|
const utils_1 = require("../../utils");
|
|
8
|
-
const useQuizLocalState = (
|
|
9
|
-
var _a;
|
|
7
|
+
const useQuizLocalState = () => {
|
|
10
8
|
const [quizLocalState, dispatch] = (0, react_1.useReducer)(quizLocalReducer_1.default, quizLocalReducer_1.initialState);
|
|
11
|
-
const quizStateKey = (sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.sessionStateKey) || constants_1.quizSessionStateKey;
|
|
12
|
-
(0, react_1.useEffect)(() => {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
// don't save state if initial state
|
|
15
|
-
if ((_a = quizLocalState === null || quizLocalState === void 0 ? void 0 : quizLocalState.answers) === null || _a === void 0 ? void 0 : _a.length) {
|
|
16
|
-
(_b = window === null || window === void 0 ? void 0 : window.sessionStorage) === null || _b === void 0 ? void 0 : _b.setItem(quizStateKey, JSON.stringify(quizLocalState));
|
|
17
|
-
}
|
|
18
|
-
}, [quizLocalState, quizStateKey]);
|
|
19
|
-
const hasQuizStoredState = () => (0, utils_1.getStateFromSessionStorage)(quizStateKey) !== null;
|
|
20
|
-
const skipToResults = !!((_a = (0, utils_1.getStateFromSessionStorage)(quizStateKey)) === null || _a === void 0 ? void 0 : _a.isQuizCompleted) &&
|
|
21
|
-
!(sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.showSessionModalOnResults);
|
|
22
9
|
const dispatchLocalState = (0, react_1.useCallback)((action) => {
|
|
23
10
|
(0, utils_1.logger)(action);
|
|
24
11
|
dispatch(action);
|
|
25
12
|
}, []);
|
|
26
13
|
return {
|
|
27
14
|
quizLocalState,
|
|
28
|
-
hasQuizStoredState,
|
|
29
15
|
dispatchLocalState,
|
|
30
|
-
skipToResults,
|
|
31
|
-
quizStateKey,
|
|
32
16
|
};
|
|
33
17
|
};
|
|
34
18
|
exports.default = useQuizLocalState;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const useSessionStorageState = (quizLocalState, sessionStateOptions, enableHydration) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const quizSessionStorageStateKey = (sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.sessionStateKey) || constants_1.quizSessionStateKey;
|
|
9
|
+
// Save state to session storage
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
// don't save state if initial state
|
|
13
|
+
if (enableHydration && ((_a = quizLocalState === null || quizLocalState === void 0 ? void 0 : quizLocalState.answers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
14
|
+
(_b = window === null || window === void 0 ? void 0 : window.sessionStorage) === null || _b === void 0 ? void 0 : _b.setItem(quizSessionStorageStateKey, JSON.stringify(quizLocalState));
|
|
15
|
+
}
|
|
16
|
+
}, [quizLocalState, quizSessionStorageStateKey, enableHydration]);
|
|
17
|
+
const skipToResults = !!enableHydration &&
|
|
18
|
+
!!((_a = (0, utils_1.getStateFromSessionStorage)(quizSessionStorageStateKey)) === null || _a === void 0 ? void 0 : _a.isQuizCompleted) &&
|
|
19
|
+
!(sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.showSessionModalOnResults);
|
|
20
|
+
return {
|
|
21
|
+
skipToResults,
|
|
22
|
+
quizSessionStorageStateKey,
|
|
23
|
+
hasSessionStorageState: () => (0, utils_1.getStateFromSessionStorage)(quizSessionStorageStateKey) !== null,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.default = useSessionStorageState;
|
|
@@ -55,7 +55,6 @@ const getMockState = (question) => ({
|
|
|
55
55
|
requestState: constants_1.RequestStates.Success,
|
|
56
56
|
versionId: '',
|
|
57
57
|
sessionId: '',
|
|
58
|
-
skipToResults: false,
|
|
59
58
|
currentQuestion: {
|
|
60
59
|
next_question: question,
|
|
61
60
|
isFirstQuestion: false,
|
|
@@ -121,6 +120,11 @@ const getMockState = (question) => ({
|
|
|
121
120
|
},
|
|
122
121
|
selectedOptionsWithAttributes: ['Chocolate', 'Medium'],
|
|
123
122
|
},
|
|
123
|
+
quizSessionStorageState: {
|
|
124
|
+
key: constants_1.quizSessionStateKey,
|
|
125
|
+
skipToResults: true,
|
|
126
|
+
hasSessionStorageState: () => true,
|
|
127
|
+
},
|
|
124
128
|
});
|
|
125
129
|
exports.getMockState = getMockState;
|
|
126
130
|
const mockElementProps = {
|
package/lib/cjs/utils.js
CHANGED
|
@@ -47,6 +47,7 @@ exports.functionStrings = {
|
|
|
47
47
|
onQuizResultClick: `(result, position) => console.dir(result, position)`,
|
|
48
48
|
onAddToFavoritesClick: `(item) => console.dir(item)`,
|
|
49
49
|
onQuizResultsLoaded: `(results) => console.dir(results)`,
|
|
50
|
+
onQuizNextQuestion: `(question) => console.dir(question)`,
|
|
50
51
|
cioJsClient: `cioJsClient`,
|
|
51
52
|
};
|
|
52
53
|
const stringifyWithDefaults = (obj) => {
|
|
@@ -121,10 +122,13 @@ const resetQuizSessionStorageState = (quizStateKey) => () => {
|
|
|
121
122
|
};
|
|
122
123
|
exports.resetQuizSessionStorageState = resetQuizSessionStorageState;
|
|
123
124
|
const logger = (action) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
var _a;
|
|
126
|
+
if ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.LOGGER) {
|
|
127
|
+
console.group(`%cAction:%c ${action.type}`, 'color: red; font-weight: bold;', 'color: green; font-weight: lighter;');
|
|
128
|
+
console.log('%c type:', 'color: #9E9E9E; font-weight: 700;', action.type);
|
|
129
|
+
console.log('%c payload:', 'color: #00A7F7; font-weight: 700;', action.payload);
|
|
130
|
+
console.groupEnd();
|
|
131
|
+
}
|
|
128
132
|
};
|
|
129
133
|
exports.logger = logger;
|
|
130
134
|
// Function to emulate pausing between interactions
|
|
@@ -10,21 +10,18 @@ import SessionPromptModal from '../SessionPromptModal/SessionPromptModal';
|
|
|
10
10
|
import { convertPrimaryColorsToString, renderImages } from '../../utils';
|
|
11
11
|
import ProgressBar from '../ProgressBar/ProgressBar';
|
|
12
12
|
export default function CioQuiz(props) {
|
|
13
|
-
const { cioClient, state, events: { hydrateQuiz,
|
|
13
|
+
const { cioClient, state, events: { hydrateQuiz, resetSessionStorageState }, getAddToCartButtonProps, getAddToFavoritesButtonProps, getCoverQuestionProps, getHydrateQuizButtonProps, getNextQuestionButtonProps, getOpenTextInputProps, getPreviousQuestionButtonProps, getQuizImageProps, getQuizResultButtonProps, getQuizResultLinkProps, getResetQuizButtonProps, getSelectInputProps, primaryColorStyles, } = useQuiz(props);
|
|
14
14
|
const [showSessionPrompt, setShowSessionPrompt] = useState(false);
|
|
15
15
|
const { resultsPageOptions, sessionStateOptions } = props;
|
|
16
|
+
const { quizSessionStorageState: { hasSessionStorageState, skipToResults }, } = state;
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
// Respect showSessionModal if defined, else default to true.
|
|
18
19
|
if (sessionStateOptions?.showSessionModal !== undefined) {
|
|
19
|
-
setShowSessionPrompt(sessionStateOptions?.showSessionModal &&
|
|
20
|
-
hasSessionStorageState() &&
|
|
21
|
-
!state.quiz.skipToResults);
|
|
20
|
+
setShowSessionPrompt(sessionStateOptions?.showSessionModal && hasSessionStorageState() && !skipToResults);
|
|
22
21
|
}
|
|
23
22
|
else {
|
|
24
|
-
setShowSessionPrompt(hasSessionStorageState() && !
|
|
23
|
+
setShowSessionPrompt(hasSessionStorageState() && !skipToResults);
|
|
25
24
|
}
|
|
26
|
-
if (state.quiz.skipToResults)
|
|
27
|
-
hydrateQuiz();
|
|
28
25
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
26
|
}, []);
|
|
30
27
|
const contextValue = {
|
|
@@ -61,7 +58,7 @@ export default function CioQuiz(props) {
|
|
|
61
58
|
".cio-quiz ",
|
|
62
59
|
convertPrimaryColorsToString(primaryColorStyles)),
|
|
63
60
|
React.createElement(SessionPromptModal, { resetStoredState: resetSessionStorageState, continueSession: hydrateQuiz, showSessionPrompt: showSessionPrompt, setShowSessionPrompt: setShowSessionPrompt }),
|
|
64
|
-
React.createElement(QuizContext.Provider, { value: contextValue }, state.quiz.results ||
|
|
61
|
+
React.createElement(QuizContext.Provider, { value: contextValue }, state.quiz.results || skipToResults ? (React.createElement(ResultContainer, { options: resultsPageOptions })) : (state.quiz.currentQuestion && (React.createElement(React.Fragment, null,
|
|
65
62
|
React.createElement(ProgressBar, null),
|
|
66
63
|
React.createElement(QuizQuestions, null),
|
|
67
64
|
React.createElement(ControlBar, { ctaButtonText: questionData?.cta_text || undefined })))))));
|
package/lib/mjs/constants.js
CHANGED
|
@@ -20,6 +20,8 @@ export const componentDescription = `- import \`CioQuiz\` to render in your JSX.
|
|
|
20
20
|
- \`resultCardRatingScoreKey\` is an optional parameter that specifies the metadata field name for the ratings score
|
|
21
21
|
- \`renderResultCardPriceDetails\` is an optional render function to render custom prices section in result card
|
|
22
22
|
- \`numResultsToDisplay\` is an optional parameter that determines how many results should be displayed on results page
|
|
23
|
+
- \`callbacks\` lets you pass callback functions that will be called on certain actions
|
|
24
|
+
- \`onQuizNextQuestion\` is an optional callback function that will be called when user moves to the next question
|
|
23
25
|
- \`sessionStateOptions\` lets you configure the session modal behavior
|
|
24
26
|
- \`showSessionModal\` is a boolean used to decide whether to show the session modal. The default behavior is to show the session modal
|
|
25
27
|
- \`showSessionModalOnResults\` is a boolean to decide whether to show the session modal after reaching the results page. The default behavior is to not show the session modal
|
|
@@ -84,6 +86,7 @@ In the example below, the \`primaryColor\` prop has been used to override this c
|
|
|
84
86
|
|
|
85
87
|
> Advanced Option: Instead of passing a primaryColor prop, you can also override \`--primary-color-h\`, \`--primary-color-s\`, and \`--primary-color-l\` CSS variables within a \`.cio-quiz\` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.
|
|
86
88
|
`;
|
|
89
|
+
export const callbacksDescription = `Pass an \`apiKey\`, a \`quizId\`, and \`callbacks\``;
|
|
87
90
|
export var RequestStates;
|
|
88
91
|
(function (RequestStates) {
|
|
89
92
|
RequestStates["Stale"] = "STALE";
|
package/lib/mjs/hooks/useQuiz.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import useCioClient from './useCioClient';
|
|
2
3
|
import useConsoleErrors from './useConsoleErrors';
|
|
3
4
|
import usePropsGetters from './usePropsGetters';
|
|
@@ -15,9 +16,15 @@ const useQuiz = (quizOptions) => {
|
|
|
15
16
|
// Quiz callback events
|
|
16
17
|
const quizEvents = useQuizEvents(quizOptions, cioClient, quizState);
|
|
17
18
|
// Props getters
|
|
18
|
-
const { quizApiState, quizLocalState,
|
|
19
|
+
const { quizApiState, quizLocalState, quizSessionStorageState } = quizState;
|
|
20
|
+
const { skipToResults } = quizSessionStorageState;
|
|
19
21
|
const propGetters = usePropsGetters(quizEvents, quizApiState, quizLocalState);
|
|
20
22
|
const primaryColorStyles = usePrimaryColorStyles(primaryColor);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (skipToResults)
|
|
25
|
+
quizEvents.hydrateQuiz();
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, []);
|
|
21
28
|
return {
|
|
22
29
|
cioClient,
|
|
23
30
|
state: {
|
|
@@ -29,11 +36,11 @@ const useQuiz = (quizOptions) => {
|
|
|
29
36
|
requestState: quizApiState.quizRequestState,
|
|
30
37
|
versionId: quizLocalState.quizVersionId,
|
|
31
38
|
sessionId: quizLocalState.quizSessionId,
|
|
32
|
-
skipToResults,
|
|
33
39
|
currentQuestion: quizApiState.quizCurrentQuestion,
|
|
34
40
|
results: quizApiState.quizResults,
|
|
35
41
|
selectedOptionsWithAttributes: quizApiState.selectedOptionsWithAttributes,
|
|
36
42
|
},
|
|
43
|
+
quizSessionStorageState,
|
|
37
44
|
},
|
|
38
45
|
events: {
|
|
39
46
|
...quizEvents,
|
|
@@ -9,13 +9,13 @@ import useHydrateQuizLocalState from './useHydrateQuizLocalState';
|
|
|
9
9
|
import { resetQuizSessionStorageState } from '../../utils';
|
|
10
10
|
import useQuizAddToFavorites from './useQuizAddToFavorites';
|
|
11
11
|
const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
12
|
-
const { quizApiState, dispatchLocalState, dispatchApiState,
|
|
13
|
-
const { resultsPageOptions } = quizOptions;
|
|
12
|
+
const { quizApiState, dispatchLocalState, dispatchApiState, quizLocalState, quizSessionStorageState, } = quizState;
|
|
13
|
+
const { resultsPageOptions, callbacks } = quizOptions;
|
|
14
14
|
const { onAddToCartClick, onQuizResultClick, onQuizResultsLoaded, onAddToFavoritesClick } = resultsPageOptions;
|
|
15
15
|
// Quiz answer change
|
|
16
16
|
const quizAnswerChanged = useQuizAnswerChangeHandler(quizApiState, dispatchLocalState);
|
|
17
17
|
// Quiz Next button click callback
|
|
18
|
-
const nextQuestion = useQuizNextClick(quizApiState, quizLocalState, dispatchLocalState);
|
|
18
|
+
const nextQuestion = useQuizNextClick(quizApiState, quizLocalState, dispatchLocalState, callbacks?.onQuizNextQuestion);
|
|
19
19
|
// Quiz Back button click callback
|
|
20
20
|
const previousQuestion = useQuizBackClick(quizApiState, dispatchLocalState);
|
|
21
21
|
// Quiz result add to cart callback
|
|
@@ -26,9 +26,9 @@ const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
|
26
26
|
// Quiz results loaded event
|
|
27
27
|
useQuizResultsLoaded(cioClient, quizApiState, onQuizResultsLoaded);
|
|
28
28
|
// Quiz reset
|
|
29
|
-
const resetQuiz = useQuizResetClick(resetQuizSessionStorageState(
|
|
29
|
+
const resetQuiz = useQuizResetClick(resetQuizSessionStorageState(quizSessionStorageState.key), dispatchLocalState, dispatchApiState, quizApiState.quizResults);
|
|
30
30
|
// Quiz rehydrate
|
|
31
|
-
const hydrateQuizLocalState = useHydrateQuizLocalState(
|
|
31
|
+
const hydrateQuizLocalState = useHydrateQuizLocalState(quizSessionStorageState.key, dispatchLocalState);
|
|
32
32
|
return {
|
|
33
33
|
addToCart,
|
|
34
34
|
addToFavorites,
|
|
@@ -38,8 +38,7 @@ const useQuizEvents = (quizOptions, cioClient, quizState) => {
|
|
|
38
38
|
nextQuestion,
|
|
39
39
|
resetQuiz,
|
|
40
40
|
hydrateQuiz: hydrateQuizLocalState,
|
|
41
|
-
|
|
42
|
-
resetSessionStorageState: resetQuizSessionStorageState(quizStateKey),
|
|
41
|
+
resetSessionStorageState: resetQuizSessionStorageState(quizSessionStorageState.key),
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
44
|
export default useQuizEvents;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { QuestionTypes } from '../../components/CioQuiz/actions';
|
|
3
3
|
import { getStateFromSessionStorage } from '../../utils';
|
|
4
|
-
const useHydrateQuizLocalState = (
|
|
5
|
-
const
|
|
4
|
+
const useHydrateQuizLocalState = (quizSessionStorageStateKey, dispatchLocalState) => {
|
|
5
|
+
const sessionStorageQuizState = getStateFromSessionStorage(quizSessionStorageStateKey);
|
|
6
6
|
const hydrateQuizLocalStateHandler = useCallback(() => {
|
|
7
|
-
if (
|
|
7
|
+
if (sessionStorageQuizState) {
|
|
8
8
|
dispatchLocalState({
|
|
9
9
|
type: QuestionTypes.Hydrate,
|
|
10
|
-
payload:
|
|
10
|
+
payload: sessionStorageQuizState,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
-
}, [dispatchLocalState,
|
|
13
|
+
}, [dispatchLocalState, sessionStorageQuizState]);
|
|
14
14
|
return hydrateQuizLocalStateHandler;
|
|
15
15
|
};
|
|
16
16
|
export default useHydrateQuizLocalState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { QuestionTypes } from '../../components/CioQuiz/actions';
|
|
3
|
-
|
|
3
|
+
import { isFunction } from '../../utils';
|
|
4
|
+
const useQuizNextClick = (quizApiState, quizLocalState, dispatchLocalState, onQuizNextQuestion) => {
|
|
4
5
|
const quizNexClickHandler = useCallback(() => {
|
|
5
6
|
const currentQuestion = quizApiState.quizCurrentQuestion?.next_question;
|
|
6
7
|
const currentQuestionId = currentQuestion?.id;
|
|
@@ -12,8 +13,16 @@ const useQuizNextClick = (quizApiState, quizLocalState, dispatchLocalState) => {
|
|
|
12
13
|
payload: quizApiState.quizCurrentQuestion,
|
|
13
14
|
});
|
|
14
15
|
}
|
|
16
|
+
if (currentQuestion && isFunction(onQuizNextQuestion)) {
|
|
17
|
+
onQuizNextQuestion({ ...currentQuestion, answer: currentAnswerInput });
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
|
-
}, [
|
|
20
|
+
}, [
|
|
21
|
+
dispatchLocalState,
|
|
22
|
+
quizApiState.quizCurrentQuestion,
|
|
23
|
+
quizLocalState.answerInputs,
|
|
24
|
+
onQuizNextQuestion,
|
|
25
|
+
]);
|
|
17
26
|
return quizNexClickHandler;
|
|
18
27
|
};
|
|
19
28
|
export default useQuizNextClick;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import useQuizApiState from './useQuizApiState';
|
|
2
2
|
import useQuizLocalState from './useQuizLocalState';
|
|
3
|
+
import useSessionStorageState from './useSessionStorageState';
|
|
3
4
|
const useQuizState = (quizOptions, cioClient) => {
|
|
4
|
-
const { sessionStateOptions } = quizOptions;
|
|
5
|
+
const { sessionStateOptions, enableHydration } = quizOptions;
|
|
5
6
|
// Quiz Local state
|
|
6
|
-
const { quizLocalState, dispatchLocalState
|
|
7
|
+
const { quizLocalState, dispatchLocalState } = useQuizLocalState();
|
|
8
|
+
// Quiz Session Storage state
|
|
9
|
+
const { skipToResults, quizSessionStorageStateKey, hasSessionStorageState } = useSessionStorageState(quizLocalState, sessionStateOptions, enableHydration === undefined ? true : enableHydration);
|
|
7
10
|
// Quiz API state
|
|
8
11
|
const { quizApiState, dispatchApiState } = useQuizApiState(quizOptions, cioClient, quizLocalState, skipToResults, dispatchLocalState);
|
|
9
12
|
return {
|
|
@@ -11,9 +14,11 @@ const useQuizState = (quizOptions, cioClient) => {
|
|
|
11
14
|
quizLocalState,
|
|
12
15
|
dispatchApiState,
|
|
13
16
|
dispatchLocalState,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
quizSessionStorageState: {
|
|
18
|
+
skipToResults,
|
|
19
|
+
key: quizSessionStorageStateKey,
|
|
20
|
+
hasSessionStorageState,
|
|
21
|
+
},
|
|
17
22
|
};
|
|
18
23
|
};
|
|
19
24
|
export default useQuizState;
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useReducer } from 'react';
|
|
2
2
|
import quizLocalReducer, { initialState } from '../../components/CioQuiz/quizLocalReducer';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const useQuizLocalState = (sessionStateOptions) => {
|
|
3
|
+
import { logger } from '../../utils';
|
|
4
|
+
const useQuizLocalState = () => {
|
|
6
5
|
const [quizLocalState, dispatch] = useReducer(quizLocalReducer, initialState);
|
|
7
|
-
const quizStateKey = sessionStateOptions?.sessionStateKey || quizSessionStateKey;
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
// don't save state if initial state
|
|
10
|
-
if (quizLocalState?.answers?.length) {
|
|
11
|
-
window?.sessionStorage?.setItem(quizStateKey, JSON.stringify(quizLocalState));
|
|
12
|
-
}
|
|
13
|
-
}, [quizLocalState, quizStateKey]);
|
|
14
|
-
const hasQuizStoredState = () => getStateFromSessionStorage(quizStateKey) !== null;
|
|
15
|
-
const skipToResults = !!getStateFromSessionStorage(quizStateKey)?.isQuizCompleted &&
|
|
16
|
-
!sessionStateOptions?.showSessionModalOnResults;
|
|
17
6
|
const dispatchLocalState = useCallback((action) => {
|
|
18
7
|
logger(action);
|
|
19
8
|
dispatch(action);
|
|
20
9
|
}, []);
|
|
21
10
|
return {
|
|
22
11
|
quizLocalState,
|
|
23
|
-
hasQuizStoredState,
|
|
24
12
|
dispatchLocalState,
|
|
25
|
-
skipToResults,
|
|
26
|
-
quizStateKey,
|
|
27
13
|
};
|
|
28
14
|
};
|
|
29
15
|
export default useQuizLocalState;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { getStateFromSessionStorage } from '../../utils';
|
|
3
|
+
import { quizSessionStateKey } from '../../constants';
|
|
4
|
+
const useSessionStorageState = (quizLocalState, sessionStateOptions, enableHydration) => {
|
|
5
|
+
const quizSessionStorageStateKey = sessionStateOptions?.sessionStateKey || quizSessionStateKey;
|
|
6
|
+
// Save state to session storage
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
// don't save state if initial state
|
|
9
|
+
if (enableHydration && quizLocalState?.answers?.length) {
|
|
10
|
+
window?.sessionStorage?.setItem(quizSessionStorageStateKey, JSON.stringify(quizLocalState));
|
|
11
|
+
}
|
|
12
|
+
}, [quizLocalState, quizSessionStorageStateKey, enableHydration]);
|
|
13
|
+
const skipToResults = !!enableHydration &&
|
|
14
|
+
!!getStateFromSessionStorage(quizSessionStorageStateKey)?.isQuizCompleted &&
|
|
15
|
+
!sessionStateOptions?.showSessionModalOnResults;
|
|
16
|
+
return {
|
|
17
|
+
skipToResults,
|
|
18
|
+
quizSessionStorageStateKey,
|
|
19
|
+
hasSessionStorageState: () => getStateFromSessionStorage(quizSessionStorageStateKey) !== null,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default useSessionStorageState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestStates } from '../../../constants';
|
|
1
|
+
import { quizSessionStateKey, RequestStates } from '../../../constants';
|
|
2
2
|
import useOpenTextInputProps from '../../../hooks/usePropsGetters/useOpenTextInputProps';
|
|
3
3
|
import useCoverQuestionProps from '../../../hooks/usePropsGetters/useCoverQuestionProps';
|
|
4
4
|
import useSelectInputProps from '../../../hooks/usePropsGetters/useSelectInputProps';
|
|
@@ -67,7 +67,6 @@ export const getMockState = (question) => ({
|
|
|
67
67
|
requestState: RequestStates.Success,
|
|
68
68
|
versionId: '',
|
|
69
69
|
sessionId: '',
|
|
70
|
-
skipToResults: false,
|
|
71
70
|
currentQuestion: {
|
|
72
71
|
next_question: question,
|
|
73
72
|
isFirstQuestion: false,
|
|
@@ -133,6 +132,11 @@ export const getMockState = (question) => ({
|
|
|
133
132
|
},
|
|
134
133
|
selectedOptionsWithAttributes: ['Chocolate', 'Medium'],
|
|
135
134
|
},
|
|
135
|
+
quizSessionStorageState: {
|
|
136
|
+
key: quizSessionStateKey,
|
|
137
|
+
skipToResults: true,
|
|
138
|
+
hasSessionStorageState: () => true,
|
|
139
|
+
},
|
|
136
140
|
});
|
|
137
141
|
const mockElementProps = {
|
|
138
142
|
className: '',
|