@constructor-io/constructorio-ui-quizzes 1.3.11 → 1.4.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.
Files changed (124) hide show
  1. package/dist/constructorio-ui-quizzes-bundled.js +20 -20
  2. package/lib/cjs/components/BackButton/BackButton.js +12 -7
  3. package/lib/cjs/components/CTAButton/CTAButton.js +4 -3
  4. package/lib/cjs/components/CioQuiz/actions.js +1 -0
  5. package/lib/cjs/components/CioQuiz/index.js +16 -9
  6. package/lib/cjs/components/CioQuiz/quizApiReducer.js +15 -9
  7. package/lib/cjs/components/CioQuiz/quizLocalReducer.js +36 -8
  8. package/lib/cjs/components/ControlBar/ControlBar.js +6 -4
  9. package/lib/cjs/components/CoverTypeQuestion/CoverTypeQuestion.js +2 -7
  10. package/lib/cjs/components/OpenTextTypeQuestion/OpenTextTypeQuestion.js +4 -32
  11. package/lib/cjs/components/RedoButton/RedoButton.js +11 -4
  12. package/lib/cjs/components/ResultCard/ResultCard.js +3 -18
  13. package/lib/cjs/components/ResultContainer/ResultContainer.js +2 -2
  14. package/lib/cjs/components/ResultCtaButton/ResultCtaButton.js +8 -7
  15. package/lib/cjs/components/ResultHeroCard/ResultHeroCard.js +36 -0
  16. package/lib/cjs/components/SelectTypeQuestion/SelectTypeQuestion.js +6 -56
  17. package/lib/cjs/components/SessionPromptModal/SessionPromptModal.js +18 -6
  18. package/lib/cjs/components/ZeroResults/ZeroResults.js +5 -4
  19. package/lib/cjs/constants.js +40 -5
  20. package/lib/cjs/hooks/useConsoleErrors.js +2 -1
  21. package/lib/cjs/hooks/usePropsGetters/index.js +85 -0
  22. package/lib/cjs/hooks/usePropsGetters/useCoverQuestionProps.js +13 -0
  23. package/lib/cjs/hooks/usePropsGetters/useNextQuestionButtonProps.js +24 -0
  24. package/lib/cjs/hooks/usePropsGetters/useOpenTextInputProps.js +47 -0
  25. package/lib/cjs/hooks/usePropsGetters/usePreviousQuestionButtonProps.js +18 -0
  26. package/lib/cjs/hooks/usePropsGetters/useSelectInputProps.js +84 -0
  27. package/lib/cjs/hooks/useQuiz.js +14 -28
  28. package/lib/cjs/hooks/useQuizEvents/index.js +21 -16
  29. package/lib/cjs/hooks/useQuizEvents/useHydrateQuizLocalState.js +18 -0
  30. package/lib/cjs/hooks/useQuizEvents/useQuizAddToCart.js +2 -2
  31. package/lib/cjs/hooks/useQuizEvents/useQuizAnswerChangeHandler.js +48 -0
  32. package/lib/cjs/hooks/useQuizEvents/useQuizBackClick.js +5 -5
  33. package/lib/cjs/hooks/useQuizEvents/useQuizNextClick.js +13 -39
  34. package/lib/cjs/hooks/useQuizEvents/useQuizResetClick.js +20 -0
  35. package/lib/cjs/hooks/useQuizEvents/useQuizResultClick.js +2 -2
  36. package/lib/cjs/hooks/useQuizState/index.js +21 -0
  37. package/lib/cjs/hooks/{useQuizApiState.js → useQuizState/useQuizApiState.js} +15 -29
  38. package/lib/cjs/hooks/useQuizState/useQuizLocalState.js +30 -0
  39. package/lib/cjs/index.js +25 -0
  40. package/lib/cjs/services/index.js +3 -3
  41. package/lib/cjs/stories/Quiz/tests/mocks.js +69 -14
  42. package/lib/cjs/utils.js +23 -1
  43. package/lib/mjs/components/BackButton/BackButton.js +12 -7
  44. package/lib/mjs/components/CTAButton/CTAButton.js +4 -3
  45. package/lib/mjs/components/CioQuiz/actions.js +1 -0
  46. package/lib/mjs/components/CioQuiz/index.js +16 -9
  47. package/lib/mjs/components/CioQuiz/quizApiReducer.js +19 -7
  48. package/lib/mjs/components/CioQuiz/quizLocalReducer.js +36 -7
  49. package/lib/mjs/components/ControlBar/ControlBar.js +6 -4
  50. package/lib/mjs/components/CoverTypeQuestion/CoverTypeQuestion.js +2 -7
  51. package/lib/mjs/components/OpenTextTypeQuestion/OpenTextTypeQuestion.js +5 -32
  52. package/lib/mjs/components/RedoButton/RedoButton.js +11 -4
  53. package/lib/mjs/components/ResultCard/ResultCard.js +3 -15
  54. package/lib/mjs/components/ResultContainer/ResultContainer.js +2 -2
  55. package/lib/mjs/components/ResultCtaButton/ResultCtaButton.js +8 -7
  56. package/lib/mjs/components/ResultHeroCard/ResultHeroCard.js +31 -0
  57. package/lib/mjs/components/SelectTypeQuestion/SelectTypeQuestion.js +6 -55
  58. package/lib/mjs/components/SessionPromptModal/SessionPromptModal.js +18 -6
  59. package/lib/mjs/components/ZeroResults/ZeroResults.js +5 -4
  60. package/lib/mjs/constants.js +39 -4
  61. package/lib/mjs/hooks/useConsoleErrors.js +2 -1
  62. package/lib/mjs/hooks/usePropsGetters/index.js +72 -0
  63. package/lib/mjs/hooks/usePropsGetters/useCoverQuestionProps.js +10 -0
  64. package/lib/mjs/hooks/usePropsGetters/useNextQuestionButtonProps.js +20 -0
  65. package/lib/mjs/hooks/usePropsGetters/useOpenTextInputProps.js +43 -0
  66. package/lib/mjs/hooks/usePropsGetters/usePreviousQuestionButtonProps.js +14 -0
  67. package/lib/mjs/hooks/usePropsGetters/useSelectInputProps.js +79 -0
  68. package/lib/mjs/hooks/useQuiz.js +13 -21
  69. package/lib/mjs/hooks/useQuizEvents/index.js +21 -16
  70. package/lib/mjs/hooks/useQuizEvents/useHydrateQuizLocalState.js +16 -0
  71. package/lib/mjs/hooks/useQuizEvents/useQuizAddToCart.js +2 -2
  72. package/lib/mjs/hooks/useQuizEvents/useQuizAnswerChangeHandler.js +45 -0
  73. package/lib/mjs/hooks/useQuizEvents/useQuizBackClick.js +5 -5
  74. package/lib/mjs/hooks/useQuizEvents/useQuizNextClick.js +12 -38
  75. package/lib/mjs/hooks/useQuizEvents/useQuizResetClick.js +18 -0
  76. package/lib/mjs/hooks/useQuizEvents/useQuizResultClick.js +2 -2
  77. package/lib/mjs/hooks/useQuizState/index.js +18 -0
  78. package/lib/mjs/hooks/{useQuizApiState.js → useQuizState/useQuizApiState.js} +15 -28
  79. package/lib/mjs/hooks/useQuizState/useQuizLocalState.js +26 -0
  80. package/lib/mjs/index.js +14 -0
  81. package/lib/mjs/services/index.js +1 -1
  82. package/lib/mjs/stories/Quiz/tests/mocks.js +75 -12
  83. package/lib/mjs/utils.js +17 -0
  84. package/lib/styles.css +13 -2
  85. package/lib/types/components/BackButton/BackButton.d.ts +2 -2
  86. package/lib/types/components/CTAButton/CTAButton.d.ts +1 -0
  87. package/lib/types/components/CioQuiz/actions.d.ts +5 -6
  88. package/lib/types/components/CioQuiz/context.d.ts +13 -6
  89. package/lib/types/components/CioQuiz/quizApiReducer.d.ts +2 -2
  90. package/lib/types/components/CioQuiz/quizLocalReducer.d.ts +3 -5
  91. package/lib/types/components/ControlBar/ControlBar.d.ts +0 -4
  92. package/lib/types/components/OpenTextTypeQuestion/OpenTextTypeQuestion.d.ts +2 -6
  93. package/lib/types/components/RedoButton/RedoButton.d.ts +1 -1
  94. package/lib/types/components/ResultCtaButton/ResultCtaButton.d.ts +1 -2
  95. package/lib/types/components/ResultHeroCard/ResultHeroCard.d.ts +7 -0
  96. package/lib/types/components/SelectTypeQuestion/SelectTypeQuestion.d.ts +3 -0
  97. package/lib/types/components/ZeroResults/ZeroResults.d.ts +2 -5
  98. package/lib/types/constants.d.ts +5 -4
  99. package/lib/types/hooks/useConsoleErrors.d.ts +2 -2
  100. package/lib/types/hooks/usePropsGetters/index.d.ts +18 -0
  101. package/lib/types/hooks/usePropsGetters/useCoverQuestionProps.d.ts +2 -0
  102. package/lib/types/hooks/usePropsGetters/useNextQuestionButtonProps.d.ts +4 -0
  103. package/lib/types/hooks/usePropsGetters/useOpenTextInputProps.d.ts +2 -0
  104. package/lib/types/hooks/usePropsGetters/usePreviousQuestionButtonProps.d.ts +3 -0
  105. package/lib/types/hooks/usePropsGetters/useSelectInputProps.d.ts +2 -0
  106. package/lib/types/hooks/useQuizEvents/index.d.ts +4 -16
  107. package/lib/types/hooks/useQuizEvents/useHydrateQuizLocalState.d.ts +4 -0
  108. package/lib/types/hooks/useQuizEvents/useQuizAnswerChangeHandler.d.ts +5 -0
  109. package/lib/types/hooks/useQuizEvents/useQuizBackClick.d.ts +2 -1
  110. package/lib/types/hooks/useQuizEvents/useQuizNextClick.d.ts +2 -1
  111. package/lib/types/hooks/useQuizEvents/useQuizResetClick.d.ts +4 -0
  112. package/lib/types/hooks/useQuizState/index.d.ts +16 -0
  113. package/lib/types/hooks/useQuizState/useQuizApiState.d.ts +12 -0
  114. package/lib/types/hooks/useQuizState/useQuizLocalState.d.ts +8 -0
  115. package/lib/types/index.d.ts +11 -0
  116. package/lib/types/services/index.d.ts +1 -1
  117. package/lib/types/stories/Quiz/tests/mocks.d.ts +5 -2
  118. package/lib/types/types.d.ts +121 -11
  119. package/lib/types/utils.d.ts +4 -0
  120. package/package.json +1 -1
  121. package/lib/cjs/hooks/useQuizLocalState.js +0 -54
  122. package/lib/mjs/hooks/useQuizLocalState.js +0 -48
  123. package/lib/types/hooks/useQuizApiState.d.ts +0 -11
  124. package/lib/types/hooks/useQuizLocalState.d.ts +0 -10
@@ -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.componentDescription = exports.quizSessionStateKey = exports.quizId = exports.apiKey = void 0;
3
+ exports.RequestStates = 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,41 @@ exports.componentDescription = `- import \`CioQuiz\` to render in your JSX.
23
23
 
24
24
  > Note: \`cioJsClient\` refers to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)
25
25
  `;
26
+ exports.hookDescription = `- import \`useCioQuiz\` and call this custom hook in a functional component.
27
+ - This hook leaves rendering logic up to you, while handling:
28
+ - state management
29
+ - data fetching
30
+ - keyboard navigation
31
+ - mouse interactions
32
+ - focus and submit event handling
33
+ - Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure
34
+ - To use this hook, an \`apiKey\` and \`quizId\` are required, and \`resultsPageOptions\` must be passed to the \`useCioQuiz\` hook to configure behavior. All other values are optional.
35
+ - use the <a href="https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters" target="__blank">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions
36
+
37
+ Calling the \`useCioQuiz\` hook returns an object with the following keys:
38
+
39
+ \`\`\`jsx
40
+ const {
41
+ // must be used for a hooks integrations
42
+ state: QuizReturnState, // Quiz state
43
+ events: [{...}], // array of quiz events
44
+ getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,
45
+ getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,
46
+ getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,
47
+ getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,
48
+ getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz,
49
+ getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,
50
+ getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,
51
+ getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,
52
+ getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,
53
+ getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,
54
+ getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,
55
+ cioClient, // instance of constructorio-client-javascript
56
+ } = useCioQuiz(args);
57
+ \`\`\`
58
+
59
+ > Note: when we say \`cioClient\`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)
60
+ `;
26
61
  /// //////////////////////////////
27
62
  // Storybook Stories
28
63
  /// //////////////////////////////
@@ -44,8 +79,8 @@ In the example below, the \`primaryColor\` prop has been used to override this c
44
79
  `;
45
80
  var RequestStates;
46
81
  (function (RequestStates) {
47
- RequestStates[RequestStates["Stale"] = 0] = "Stale";
48
- RequestStates[RequestStates["Loading"] = 1] = "Loading";
49
- RequestStates[RequestStates["Success"] = 2] = "Success";
50
- RequestStates[RequestStates["Error"] = 3] = "Error";
82
+ RequestStates["Stale"] = "STALE";
83
+ RequestStates["Loading"] = "LOADING";
84
+ RequestStates["Success"] = "SUCCESS";
85
+ RequestStates["Error"] = "ERROR";
51
86
  })(RequestStates = exports.RequestStates || (exports.RequestStates = {}));
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_1 = require("react");
4
- const useConsoleErrors = (quizId, resultsPageOptions) => {
4
+ const useConsoleErrors = (quizOptions) => {
5
+ const { quizId, resultsPageOptions } = quizOptions;
5
6
  (0, react_1.useEffect)(() => {
6
7
  if (!quizId) {
7
8
  // eslint-disable-next-line no-console
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = require("react");
5
+ const useSelectInputProps_1 = tslib_1.__importDefault(require("./useSelectInputProps"));
6
+ const useCoverQuestionProps_1 = tslib_1.__importDefault(require("./useCoverQuestionProps"));
7
+ const useOpenTextInputProps_1 = tslib_1.__importDefault(require("./useOpenTextInputProps"));
8
+ const useNextQuestionButtonProps_1 = tslib_1.__importDefault(require("./useNextQuestionButtonProps"));
9
+ const usePreviousQuestionButtonProps_1 = tslib_1.__importDefault(require("./usePreviousQuestionButtonProps"));
10
+ const usePropsGetters = (quizEvents, quizApiState, quizLocalState) => {
11
+ var _a, _b, _c;
12
+ const { quizAnswerChanged, nextQuestion, previousQuestion, resetQuiz, hydrateQuiz, addToCart, resultClick, } = quizEvents;
13
+ const getOpenTextInputProps = (0, useOpenTextInputProps_1.default)(quizAnswerChanged, nextQuestion, (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question, quizLocalState.answerInputs);
14
+ const getCoverQuestionProps = (0, useCoverQuestionProps_1.default)(quizAnswerChanged, (_b = quizApiState.quizCurrentQuestion) === null || _b === void 0 ? void 0 : _b.next_question);
15
+ const getSelectInputProps = (0, useSelectInputProps_1.default)(quizAnswerChanged, nextQuestion, (_c = quizApiState.quizCurrentQuestion) === null || _c === void 0 ? void 0 : _c.next_question, quizLocalState.answerInputs);
16
+ const getNextQuestionButtonProps = (0, useNextQuestionButtonProps_1.default)(nextQuestion, quizApiState, quizLocalState);
17
+ const getPreviousQuestionButtonProps = (0, usePreviousQuestionButtonProps_1.default)(quizApiState, previousQuestion);
18
+ const getResetQuizButtonProps = (0, react_1.useCallback)(() => ({
19
+ className: 'cio-question-redo-button',
20
+ type: 'button',
21
+ onClick: () => resetQuiz(),
22
+ }), [resetQuiz]);
23
+ const getHydrateQuizButtonProps = (0, react_1.useCallback)(() => ({
24
+ className: '',
25
+ type: 'button',
26
+ onClick: () => hydrateQuiz(),
27
+ }), [hydrateQuiz]);
28
+ const getAddToCartButtonProps = (0, react_1.useCallback)((result, price) => ({
29
+ className: 'cio-result-card-cta-button',
30
+ type: 'button',
31
+ onClick: (e) => addToCart(e, result, price),
32
+ }), [addToCart]);
33
+ const quizResultClickDown = (0, react_1.useCallback)((event, result, position) => {
34
+ if ((event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.key) === 'Enter') {
35
+ if (resultClick) {
36
+ resultClick(result, position);
37
+ }
38
+ }
39
+ }, [resultClick]);
40
+ const getQuizResultButtonProps = (0, react_1.useCallback)(({ result, position }) => ({
41
+ className: 'cio-result-card-container',
42
+ role: 'button',
43
+ tabIndex: 0,
44
+ onClick: () => resultClick(result, position),
45
+ onKeyDown: (event) => quizResultClickDown(event, result, position),
46
+ }), [quizResultClickDown, resultClick]);
47
+ const getQuizResultLinkProps = (0, react_1.useCallback)(({ result, position }) => {
48
+ var _a;
49
+ return ({
50
+ href: (_a = result.data) === null || _a === void 0 ? void 0 : _a.url,
51
+ onClick: () => resultClick(result, position),
52
+ onKeyDown: (event) => quizResultClickDown(event, result, position),
53
+ });
54
+ }, [quizResultClickDown, resultClick]);
55
+ const getQuizImageProps = (0, react_1.useCallback)(() => {
56
+ var _a, _b, _c, _d, _e, _f;
57
+ return ({
58
+ src: (_c = (_b = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question) === null || _b === void 0 ? void 0 : _b.images) === null || _c === void 0 ? void 0 : _c.primary_url,
59
+ alt: (_f = (_e = (_d = quizApiState.quizCurrentQuestion) === null || _d === void 0 ? void 0 : _d.next_question) === null || _e === void 0 ? void 0 : _e.images) === null || _f === void 0 ? void 0 : _f.primary_alt,
60
+ });
61
+ }, [quizApiState.quizCurrentQuestion]);
62
+ const getSelectQuestionImageProps = (0, react_1.useCallback)((option) => {
63
+ var _a, _b;
64
+ return ({
65
+ className: 'cio-question-option-image',
66
+ src: (_a = option === null || option === void 0 ? void 0 : option.images) === null || _a === void 0 ? void 0 : _a.primary_url,
67
+ alt: (_b = option === null || option === void 0 ? void 0 : option.images) === null || _b === void 0 ? void 0 : _b.primary_alt,
68
+ });
69
+ }, []);
70
+ return {
71
+ getOpenTextInputProps,
72
+ getNextQuestionButtonProps,
73
+ getPreviousQuestionButtonProps,
74
+ getQuizImageProps,
75
+ getSelectQuestionImageProps,
76
+ getSelectInputProps,
77
+ getCoverQuestionProps,
78
+ getResetQuizButtonProps,
79
+ getHydrateQuizButtonProps,
80
+ getAddToCartButtonProps,
81
+ getQuizResultButtonProps,
82
+ getQuizResultLinkProps,
83
+ };
84
+ };
85
+ exports.default = usePropsGetters;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function useCoverQuestionProps(setQuizAnswers, currentQuestionData) {
5
+ (0, react_1.useEffect)(() => {
6
+ if ((currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'cover') {
7
+ setQuizAnswers('');
8
+ }
9
+ }, [setQuizAnswers, currentQuestionData]);
10
+ const getCoverQuestionProps = (0, react_1.useCallback)(() => ({}), []);
11
+ return getCoverQuestionProps;
12
+ }
13
+ exports.default = useCoverQuestionProps;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function useNextQuestionButtonProps(nextQuestion, quizApiState, quizLocalState) {
5
+ const getNextQuestionButtonProps = (0, react_1.useCallback)(() => {
6
+ var _a, _b, _c, _d, _e;
7
+ const currentQuestionId = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question.id;
8
+ let buttonDisabled;
9
+ if (currentQuestionId && !((_b = quizApiState.quizCurrentQuestion) === null || _b === void 0 ? void 0 : _b.isCoverQuestion)) {
10
+ buttonDisabled =
11
+ !((_c = quizLocalState.answerInputs[currentQuestionId]) === null || _c === void 0 ? void 0 : _c.value) ||
12
+ !((_e = (_d = quizLocalState.answerInputs[currentQuestionId]) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.length);
13
+ }
14
+ return {
15
+ className: buttonDisabled ? 'cio-question-cta-button disabled' : 'cio-question-cta-button',
16
+ type: 'button',
17
+ onClick: () => {
18
+ nextQuestion();
19
+ },
20
+ };
21
+ }, [quizApiState.quizCurrentQuestion, quizLocalState.answerInputs, nextQuestion]);
22
+ return getNextQuestionButtonProps;
23
+ }
24
+ exports.default = useNextQuestionButtonProps;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function useOpenTextInputProps(setQuizAnswers, nextQuestion, currentQuestionData, answerInputs) {
5
+ const [input, setInput] = (0, react_1.useState)('');
6
+ const onChangeHandler = (0, react_1.useCallback)((e) => {
7
+ setInput(e.target.value);
8
+ }, []);
9
+ const onKeyDownHandler = (0, react_1.useCallback)((e) => {
10
+ const { key } = e;
11
+ if (key === 'Enter') {
12
+ if (input && (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'open') {
13
+ nextQuestion();
14
+ }
15
+ }
16
+ }, [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type, input, nextQuestion]);
17
+ (0, react_1.useEffect)(() => {
18
+ if ((currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'open') {
19
+ setQuizAnswers(input);
20
+ }
21
+ }, [input, currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type, currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id, setQuizAnswers]);
22
+ // Reset input for new open text questions
23
+ (0, react_1.useEffect)(() => {
24
+ var _a;
25
+ if (answerInputs && (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id)) {
26
+ const questionAnswer = (_a = answerInputs[currentQuestionData.id]) === null || _a === void 0 ? void 0 : _a.value;
27
+ if (questionAnswer) {
28
+ setInput(questionAnswer);
29
+ }
30
+ else {
31
+ setInput('');
32
+ }
33
+ }
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ }, [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id]);
36
+ const getOpenTextInputProps = (0, react_1.useCallback)(() => ({
37
+ className: 'cio-question-input-text',
38
+ placeholder: (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.input_placeholder) || 'Answer here...',
39
+ value: input,
40
+ onChange: onChangeHandler,
41
+ onKeyDown: onKeyDownHandler,
42
+ }),
43
+ // eslint-disable-next-line react-hooks/exhaustive-deps
44
+ [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.input_placeholder, currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id, input, onKeyDownHandler]);
45
+ return getOpenTextInputProps;
46
+ }
47
+ exports.default = useOpenTextInputProps;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function usePreviousQuestionButtonProps(quizApiState, previousQuestion) {
5
+ const getPreviousQuestionButtonProps = (0, react_1.useCallback)(() => {
6
+ var _a;
7
+ const buttonDisabled = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.isFirstQuestion;
8
+ return {
9
+ title: 'Quiz Back Button',
10
+ role: 'button',
11
+ className: `cio-question-back-button ${buttonDisabled ? 'disabled' : ''}`,
12
+ type: 'button',
13
+ onClick: () => previousQuestion(),
14
+ };
15
+ }, [quizApiState, previousQuestion]);
16
+ return getPreviousQuestionButtonProps;
17
+ }
18
+ exports.default = usePreviousQuestionButtonProps;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const actions_1 = require("../../components/CioQuiz/actions");
5
+ // eslint-disable-next-line max-params
6
+ function useSelectInputProps(quizAnswerChanged, nextQuestion, currentQuestionData, answerInputs) {
7
+ var _a;
8
+ const type = currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type;
9
+ const hasImages = (_a = currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.options) === null || _a === void 0 ? void 0 : _a.some((option) => option.images);
10
+ const [selected, setSelected] = (0, react_1.useState)({});
11
+ const singleSelectClicked = (0, react_1.useRef)({});
12
+ const toggleIdSelected = (0, react_1.useCallback)((id) => {
13
+ if (type === actions_1.QuestionTypes.SingleSelect) {
14
+ singleSelectClicked.current = true;
15
+ setSelected({ [id]: true });
16
+ }
17
+ else if (type === actions_1.QuestionTypes.MultipleSelect) {
18
+ if (selected[id]) {
19
+ const newState = Object.assign({}, selected);
20
+ delete newState[id];
21
+ setSelected(newState);
22
+ }
23
+ else {
24
+ setSelected(Object.assign(Object.assign({}, selected), { [id]: true }));
25
+ }
26
+ }
27
+ }, [selected, type]);
28
+ const onOptionKeyDown = (event, id) => {
29
+ if ((event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.key) === 'Enter') {
30
+ toggleIdSelected(id);
31
+ }
32
+ };
33
+ // Update component local state
34
+ (0, react_1.useEffect)(() => {
35
+ var _a;
36
+ if (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) {
37
+ const nextQuestionId = currentQuestionData.id;
38
+ const currentAnswer = answerInputs === null || answerInputs === void 0 ? void 0 : answerInputs[nextQuestionId];
39
+ const prevSelected = {};
40
+ if (Array.isArray(currentAnswer === null || currentAnswer === void 0 ? void 0 : currentAnswer.value)) {
41
+ (_a = currentAnswer === null || currentAnswer === void 0 ? void 0 : currentAnswer.value) === null || _a === void 0 ? void 0 : _a.forEach((answer) => {
42
+ prevSelected[Number(answer)] = true;
43
+ setSelected(prevSelected);
44
+ });
45
+ }
46
+ }
47
+ singleSelectClicked.current = false;
48
+ return function clearState() {
49
+ setSelected({});
50
+ };
51
+ // eslint-disable-next-line react-hooks/exhaustive-deps
52
+ }, [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id]);
53
+ // Update global state
54
+ (0, react_1.useEffect)(() => {
55
+ if ((currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'multiple' || (currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'single') {
56
+ const selectedAnswers = Object.keys(selected).filter((key) => selected[Number(key)]);
57
+ quizAnswerChanged(selectedAnswers);
58
+ }
59
+ }, [selected, currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id, currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type, quizAnswerChanged]);
60
+ // Go to next question only every time answerInputs (answers input state) changes...
61
+ // and it's a singleSelectQuestion and user has just clicked on an option
62
+ (0, react_1.useEffect)(() => {
63
+ if ((currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.type) === 'single' && singleSelectClicked.current) {
64
+ nextQuestion();
65
+ }
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, [answerInputs]);
68
+ const getSelectInputProps = (0, react_1.useCallback)((option) => ({
69
+ className: `${!hasImages ? 'cio-question-option-container-text-only' : 'cio-question-option-container'} ${selected[option.id] ? 'selected' : ''}`,
70
+ onClick: () => {
71
+ toggleIdSelected(option.id);
72
+ },
73
+ onKeyDown: (event) => {
74
+ onOptionKeyDown(event, option.id);
75
+ },
76
+ role: 'button',
77
+ tabIndex: 0,
78
+ key: option.id,
79
+ }),
80
+ // eslint-disable-next-line react-hooks/exhaustive-deps
81
+ [currentQuestionData === null || currentQuestionData === void 0 ? void 0 : currentQuestionData.id, selected]);
82
+ return getSelectInputProps;
83
+ }
84
+ exports.default = useSelectInputProps;
@@ -3,35 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const useCioClient_1 = tslib_1.__importDefault(require("./useCioClient"));
5
5
  const useConsoleErrors_1 = tslib_1.__importDefault(require("./useConsoleErrors"));
6
+ const usePropsGetters_1 = tslib_1.__importDefault(require("./usePropsGetters"));
6
7
  const usePrimaryColorStyles_1 = tslib_1.__importDefault(require("./usePrimaryColorStyles"));
7
- const useQuizApiState_1 = tslib_1.__importDefault(require("./useQuizApiState"));
8
8
  const useQuizEvents_1 = tslib_1.__importDefault(require("./useQuizEvents"));
9
- const useQuizLocalState_1 = tslib_1.__importDefault(require("./useQuizLocalState"));
10
- const useQuiz = ({ quizId, apiKey, cioJsClient, quizVersionId, resultsPageOptions, sessionStateOptions, primaryColor, }) => {
9
+ const useQuizState_1 = tslib_1.__importDefault(require("./useQuizState"));
10
+ const useQuiz = (quizOptions) => {
11
+ const { apiKey, cioJsClient, primaryColor } = quizOptions;
11
12
  // Log console errors for required parameters quizId and resultsPageOptions
12
- (0, useConsoleErrors_1.default)(quizId, resultsPageOptions);
13
- // Quiz Local state
14
- const { quizLocalState, resetQuizLocalState, dispatchLocalState, hydrateQuizLocalState, hasQuizStoredState, resetQuizStoredState, } = (0, useQuizLocalState_1.default)(sessionStateOptions === null || sessionStateOptions === void 0 ? void 0 : sessionStateOptions.sessionStateKey);
13
+ (0, useConsoleErrors_1.default)(quizOptions);
15
14
  // Quiz Cio Client
16
15
  const cioClient = (0, useCioClient_1.default)({ apiKey, cioJsClient });
17
- // Quiz API state
18
- const { isFirstQuestion, quizApiState, resetQuizApiState } = (0, useQuizApiState_1.default)(quizId, quizLocalState, dispatchLocalState, resultsPageOptions, quizVersionId, cioClient);
16
+ // Quiz state (Local and API)
17
+ const quizState = (0, useQuizState_1.default)(quizOptions, cioClient);
19
18
  // Quiz callback events
20
- const quizEvents = (0, useQuizEvents_1.default)({
21
- cioClient,
22
- quizApiState,
23
- resultsPageOptions,
24
- dispatchLocalState,
25
- resetQuizApiState,
26
- resetQuizLocalState,
27
- hydrateQuizLocalState,
28
- resetQuizStoredState,
29
- hasQuizStoredState,
30
- });
19
+ const quizEvents = (0, useQuizEvents_1.default)(quizOptions, cioClient, quizState);
20
+ // Props getters
21
+ const { quizApiState, quizLocalState } = quizState;
22
+ const propGetters = (0, usePropsGetters_1.default)(quizEvents, quizApiState, quizLocalState);
31
23
  const primaryColorStyles = (0, usePrimaryColorStyles_1.default)(primaryColor);
32
- return {
33
- cioClient,
34
- state: {
24
+ console.log('quizLocalState.answerInputs', quizLocalState.answerInputs);
25
+ return Object.assign(Object.assign({ cioClient, state: {
35
26
  answers: {
36
27
  inputs: quizLocalState.answerInputs,
37
28
  isLastAnswer: quizLocalState.isLastAnswer,
@@ -40,15 +31,10 @@ const useQuiz = ({ quizId, apiKey, cioJsClient, quizVersionId, resultsPageOption
40
31
  requestState: quizApiState.quizRequestState,
41
32
  versionId: quizLocalState.quizVersionId,
42
33
  sessionId: quizLocalState.quizSessionId,
43
- firstQuestion: quizApiState.quizFirstQuestion,
44
34
  currentQuestion: quizApiState.quizCurrentQuestion,
45
35
  results: quizApiState.quizResults,
46
36
  resultsFilters: quizApiState.quizResultsFilters,
47
- isFirstQuestion,
48
37
  },
49
- },
50
- events: Object.assign({}, quizEvents),
51
- primaryColorStyles,
52
- };
38
+ }, events: Object.assign({}, quizEvents) }, propGetters), { primaryColorStyles });
53
39
  };
54
40
  exports.default = useQuiz;
@@ -4,37 +4,42 @@ const tslib_1 = require("tslib");
4
4
  const useQuizResultsLoaded_1 = tslib_1.__importDefault(require("./useQuizResultsLoaded"));
5
5
  const useQuizResultClick_1 = tslib_1.__importDefault(require("./useQuizResultClick"));
6
6
  const useQuizAddToCart_1 = tslib_1.__importDefault(require("./useQuizAddToCart"));
7
- const useQuizNextClick_1 = tslib_1.__importDefault(require("./useQuizNextClick"));
8
7
  const useQuizBackClick_1 = tslib_1.__importDefault(require("./useQuizBackClick"));
9
- const useQuizEvents = (options) => {
10
- const { cioClient, quizApiState, resultsPageOptions, dispatchLocalState, resetQuizApiState, resetQuizLocalState, hydrateQuizLocalState, resetQuizStoredState, hasQuizStoredState, } = options;
8
+ const useQuizAnswerChangeHandler_1 = tslib_1.__importDefault(require("./useQuizAnswerChangeHandler"));
9
+ const useQuizNextClick_1 = tslib_1.__importDefault(require("./useQuizNextClick"));
10
+ const useQuizResetClick_1 = tslib_1.__importDefault(require("./useQuizResetClick"));
11
+ const useHydrateQuizLocalState_1 = tslib_1.__importDefault(require("./useHydrateQuizLocalState"));
12
+ const utils_1 = require("../../utils");
13
+ const useQuizEvents = (quizOptions, cioClient, quizState) => {
14
+ const { quizApiState, dispatchLocalState, dispatchApiState, hasQuizStoredState, quizStateKey, quizLocalState, } = quizState;
15
+ const { resultsPageOptions } = quizOptions;
11
16
  const { onAddToCartClick, onQuizResultClick, onQuizResultsLoaded } = resultsPageOptions;
12
- // Quiz Next button click
13
- const nextQuestion = (0, useQuizNextClick_1.default)(quizApiState, dispatchLocalState);
17
+ // Quiz answer change
18
+ const quizAnswerChanged = (0, useQuizAnswerChangeHandler_1.default)(quizApiState, dispatchLocalState);
19
+ // Quiz Next button click callback
20
+ const nextQuestion = (0, useQuizNextClick_1.default)(quizApiState, quizLocalState, dispatchLocalState);
14
21
  // Quiz Back button click callback
15
- const previousQuestion = (0, useQuizBackClick_1.default)(dispatchLocalState);
22
+ const previousQuestion = (0, useQuizBackClick_1.default)(quizApiState, dispatchLocalState);
16
23
  // Quiz result add to cart callback
17
24
  const addToCart = (0, useQuizAddToCart_1.default)(cioClient, quizApiState, onAddToCartClick);
18
25
  // Quiz result click callback
19
26
  const resultClick = (0, useQuizResultClick_1.default)(cioClient, quizApiState, onQuizResultClick);
20
27
  // Quiz results loaded event
21
28
  (0, useQuizResultsLoaded_1.default)(cioClient, quizApiState, onQuizResultsLoaded);
22
- const resetQuiz = () => {
23
- if (quizApiState.quizResults) {
24
- resetQuizApiState();
25
- resetQuizLocalState();
26
- resetQuizStoredState();
27
- }
28
- };
29
+ // Quiz reset
30
+ const resetQuiz = (0, useQuizResetClick_1.default)(quizStateKey, dispatchLocalState, dispatchApiState, quizApiState.quizResults);
31
+ // Quiz rehydrate
32
+ const hydrateQuizLocalState = (0, useHydrateQuizLocalState_1.default)(quizStateKey, dispatchLocalState);
29
33
  return {
30
34
  addToCart,
31
35
  resultClick,
32
- nextQuestion,
36
+ quizAnswerChanged,
33
37
  previousQuestion,
38
+ nextQuestion,
34
39
  resetQuiz,
35
40
  hydrateQuiz: hydrateQuizLocalState,
36
- hasStoredState: hasQuizStoredState,
37
- resetStoredState: resetQuizStoredState,
41
+ hasSessionStorageState: hasQuizStoredState,
42
+ resetSessionStorageState: (0, utils_1.resetQuizSessionStorageState)(quizStateKey),
38
43
  };
39
44
  };
40
45
  exports.default = useQuizEvents;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const actions_1 = require("../../components/CioQuiz/actions");
5
+ const utils_1 = require("../../utils");
6
+ const useHydrateQuizLocalState = (quizStateKey, dispatchLocalState) => {
7
+ const quizState = (0, utils_1.getStateFromSessionStorage)(quizStateKey);
8
+ const hydrateQuizLocalStateHandler = (0, react_1.useCallback)(() => {
9
+ if (quizState) {
10
+ dispatchLocalState({
11
+ type: actions_1.QuestionTypes.Hydrate,
12
+ payload: quizState,
13
+ });
14
+ }
15
+ }, [dispatchLocalState, quizState]);
16
+ return hydrateQuizLocalStateHandler;
17
+ };
18
+ exports.default = useHydrateQuizLocalState;
@@ -4,7 +4,7 @@ const react_1 = require("react");
4
4
  const services_1 = require("../../services");
5
5
  const utils_1 = require("../../utils");
6
6
  const useQuizAddToCart = (cioClient, quizApiState, onAddToCartClick) => {
7
- const addToCartClickHandler = (0, react_1.useCallback)((e, result, price) => {
7
+ const quizAddToCartClickHandler = (0, react_1.useCallback)((e, result, price) => {
8
8
  e.preventDefault();
9
9
  if (quizApiState.quizResults) {
10
10
  // Tracking call
@@ -15,6 +15,6 @@ const useQuizAddToCart = (cioClient, quizApiState, onAddToCartClick) => {
15
15
  }
16
16
  }
17
17
  }, [quizApiState, cioClient, onAddToCartClick]);
18
- return addToCartClickHandler;
18
+ return quizAddToCartClickHandler;
19
19
  };
20
20
  exports.default = useQuizAddToCart;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ const actions_1 = require("../../components/CioQuiz/actions");
5
+ const useQuizAnswerChangeHandler = (quizApiState, dispatchLocalState) => {
6
+ const quizAnswerChangedHandler = (0, react_1.useCallback)((payload) => {
7
+ var _a;
8
+ const questionType = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question.type;
9
+ const currentQuestion = quizApiState.quizCurrentQuestion;
10
+ switch (questionType) {
11
+ case actions_1.QuestionTypes.Cover:
12
+ dispatchLocalState({
13
+ type: actions_1.QuestionTypes.Cover,
14
+ payload: {
15
+ questionId: currentQuestion.next_question.id,
16
+ input: '',
17
+ isLastQuestion: currentQuestion.is_last_question,
18
+ },
19
+ });
20
+ break;
21
+ case actions_1.QuestionTypes.OpenText:
22
+ dispatchLocalState({
23
+ type: actions_1.QuestionTypes.OpenText,
24
+ payload: {
25
+ questionId: currentQuestion.next_question.id,
26
+ input: payload,
27
+ isLastQuestion: currentQuestion.is_last_question,
28
+ },
29
+ });
30
+ break;
31
+ case actions_1.QuestionTypes.SingleSelect:
32
+ case actions_1.QuestionTypes.MultipleSelect:
33
+ dispatchLocalState({
34
+ type: currentQuestion.next_question.type,
35
+ payload: {
36
+ questionId: currentQuestion.next_question.id,
37
+ input: payload,
38
+ isLastQuestion: currentQuestion.is_last_question,
39
+ },
40
+ });
41
+ break;
42
+ default:
43
+ break;
44
+ }
45
+ }, [quizApiState, dispatchLocalState]);
46
+ return quizAnswerChangedHandler;
47
+ };
48
+ exports.default = useQuizAnswerChangeHandler;
@@ -2,12 +2,12 @@
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 useQuizBackClick = (dispatchLocalState) => {
6
- const quizBackHandler = (0, react_1.useCallback)(() => {
5
+ const useQuizBackClick = (quizApiState, dispatchLocalState) => {
6
+ const quizBackClickHandler = (0, react_1.useCallback)(() => {
7
7
  if (dispatchLocalState) {
8
- dispatchLocalState({ type: actions_1.QuestionTypes.Back });
8
+ dispatchLocalState({ type: actions_1.QuestionTypes.Back, payload: quizApiState.quizCurrentQuestion });
9
9
  }
10
- }, [dispatchLocalState]);
11
- return quizBackHandler;
10
+ }, [dispatchLocalState, quizApiState.quizCurrentQuestion]);
11
+ return quizBackClickHandler;
12
12
  };
13
13
  exports.default = useQuizBackClick;
@@ -2,47 +2,21 @@
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 useQuizNextClick = (quizApiState, dispatchLocalState) => {
6
- const quizNextHandler = (0, react_1.useCallback)((payload) => {
7
- var _a;
8
- const questionType = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question.type;
9
- const currentQuestion = quizApiState.quizCurrentQuestion;
10
- switch (questionType) {
11
- case actions_1.QuestionTypes.Cover:
5
+ const useQuizNextClick = (quizApiState, quizLocalState, dispatchLocalState) => {
6
+ const quizNexClickHandler = (0, react_1.useCallback)(() => {
7
+ var _a, _b;
8
+ const currentQuestion = (_a = quizApiState.quizCurrentQuestion) === null || _a === void 0 ? void 0 : _a.next_question;
9
+ const currentQuestionId = currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.id;
10
+ if (dispatchLocalState && currentQuestionId) {
11
+ const currentAnswerInput = quizLocalState.answerInputs[currentQuestionId];
12
+ if (((_b = currentAnswerInput === null || currentAnswerInput === void 0 ? void 0 : currentAnswerInput.value) === null || _b === void 0 ? void 0 : _b.length) || (currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.type) === 'cover') {
12
13
  dispatchLocalState({
13
- type: actions_1.QuestionTypes.Cover,
14
- payload: {
15
- isLastQuestion: currentQuestion.is_last_question,
16
- },
14
+ type: actions_1.QuestionTypes.Next,
15
+ payload: quizApiState.quizCurrentQuestion,
17
16
  });
18
- break;
19
- case actions_1.QuestionTypes.OpenText:
20
- dispatchLocalState({
21
- type: actions_1.QuestionTypes.OpenText,
22
- payload: {
23
- questionId: currentQuestion.next_question.id,
24
- input: payload,
25
- isLastQuestion: currentQuestion.is_last_question,
26
- },
27
- });
28
- break;
29
- case actions_1.QuestionTypes.SingleSelect:
30
- case actions_1.QuestionTypes.MultipleSelect:
31
- dispatchLocalState({
32
- type: currentQuestion.next_question.type === actions_1.QuestionTypes.SingleSelect
33
- ? actions_1.QuestionTypes.SingleSelect
34
- : actions_1.QuestionTypes.MultipleSelect,
35
- payload: {
36
- questionId: currentQuestion.next_question.id,
37
- input: payload,
38
- isLastQuestion: currentQuestion.is_last_question,
39
- },
40
- });
41
- break;
42
- default:
43
- break;
17
+ }
44
18
  }
45
- }, [quizApiState, dispatchLocalState]);
46
- return quizNextHandler;
19
+ }, [dispatchLocalState, quizApiState.quizCurrentQuestion, quizLocalState.answerInputs]);
20
+ return quizNexClickHandler;
47
21
  };
48
22
  exports.default = useQuizNextClick;