Skip to content

Commit 1dc726a

Browse files
committed
Merge branch 'master' into TD-2435-generic-assessment-ui
2 parents f80a94a + 6d7f1b1 commit 1dc726a

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/survey/cognitive/instructions.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Instructions({
2323
surveyID,
2424
translate
2525
}) {
26-
const {allow: allowSkip, trigger: onSkip} = useSkipAssessment();
26+
const {allow: allowSkip, dismiss: dismissSkip, trigger: onSkip} = useSkipAssessment();
2727
const [width] = useWindowSize();
2828
const [disability, setDisability] = useState(initialLearningDisability || false);
2929
const [step, setStep] = useState(1);
@@ -40,6 +40,10 @@ function Instructions({
4040

4141
const example = practiceExamples[step - 1];
4242
const instructionOptions = {id: surveyID, minimal, timeTrial, timed, translate, type};
43+
const onContinue = () => {
44+
dismissSkip();
45+
setStep(step + 1);
46+
};
4347

4448
if(showAccommodation) {
4549
return (
@@ -70,7 +74,7 @@ function Instructions({
7074
{step === 1 && allowSkip && (
7175
<button className={style.btnBack} onClick={() => setShowAccommodation(true)} type="button">{translate("survey.accommodation.request")}</button>
7276
)}
73-
<button className={`traitify--response-button ${style.btnBlue}`} onClick={() => setStep(step + 1)} type="button">{button}</button>
77+
<button className={`traitify--response-button ${style.btnBlue}`} onClick={onContinue} type="button">{button}</button>
7478
</div>
7579
</div>
7680
);

src/components/survey/personality/instructions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function Instructions({
1111
instructionsHTML = null,
1212
onNext
1313
}) {
14-
const {allow: allowSkip, trigger: onSkip} = useSkipAssessment();
14+
const {allow: allowSkip, dismiss: dismissSkip, trigger: onSkip} = useSkipAssessment();
1515
const [showAccommodation, setShowAccommodation] = useState(false);
1616
const translate = useTranslate();
1717

@@ -34,6 +34,11 @@ function Instructions({
3434
);
3535
}
3636

37+
const onContinue = () => {
38+
dismissSkip();
39+
onNext();
40+
};
41+
3742
return (
3843
<>
3944
{instructionsHTML ? (
@@ -47,7 +52,7 @@ function Instructions({
4752
{translate("survey.accommodation.request")}
4853
</button>
4954
)}
50-
<button className={style.btnNext} onClick={onNext} type="button">
55+
<button className={style.btnNext} onClick={onContinue} type="button">
5156
{translate("get_started")}
5257
</button>
5358
</div>

src/lib/hooks/use-skip-assessment.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import {useCallback} from "react";
2-
import {useSetRecoilState} from "recoil";
2+
import {useRecoilState, useSetRecoilState} from "recoil";
33
import useActive from "lib/hooks/use-active";
44
import useCache from "lib/hooks/use-cache";
55
import useCacheKey from "lib/hooks/use-cache-key";
66
import useGraphql from "lib/hooks/use-graphql";
77
import useHttp from "lib/hooks/use-http";
88
import useOrder from "lib/hooks/use-order";
99
import useSetting from "lib/hooks/use-setting";
10-
import {orderState} from "lib/recoil";
10+
import {orderState, skipDismissedState} from "lib/recoil";
1111

1212
export default function useSkipAssessment() {
1313
const active = useActive();
1414
const assessmentCacheKey = useCacheKey("assessment");
1515
const cache = useCache();
16+
const [dismissed, setDismissed] = useRecoilState(skipDismissedState);
1617
const graphQL = useGraphql();
1718
const http = useHttp();
1819
const order = useOrder();
1920
const setOrder = useSetRecoilState(orderState);
2021

2122
const allow = useSetting("skipAssessmentAccommodation", {fallback: false});
23+
const dismiss = () => { setDismissed(true); };
2224
const trigger = useCallback(async() => {
2325
if(!active) { return; }
2426
if(!order) { return; }
@@ -79,5 +81,5 @@ export default function useSkipAssessment() {
7981
setOrder((_order) => ({..._order, completed: true, status: "skipped"}));
8082
}, [active, order]);
8183

82-
return {allow, trigger};
84+
return {allow: dismissed ? false : allow, dismiss, trigger};
8385
}

src/lib/recoil/base.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const optionsState = atom({default: null, key: "options"});
2424
export const orderIDState = atom({default: null, key: "order-id"});
2525
export const packageIDState = atom({default: null, key: "package-id"});
2626
export const profileIDState = atom({default: null, key: "profile-id"});
27+
export const skipDismissedState = atom({default: false, key: "skip-dismissed"});
2728

2829
// NOTE: Breaking up state prevents over-triggering selectors
2930
export const activeIDState = selector({

0 commit comments

Comments
 (0)