@coorpacademy/app-review 0.1.2 → 0.1.4
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/es/actions/data/skills.d.ts +13 -0
- package/es/actions/data/skills.js +10 -0
- package/es/actions/data/slides.d.ts +54 -0
- package/es/actions/{slides.js → data/slides.js} +5 -0
- package/es/actions/index.d.ts +19 -5
- package/es/actions/ui/finished-slides.d.ts +10 -0
- package/es/actions/{finished-slides.js → ui/finished-slides.js} +1 -0
- package/es/actions/ui/is-fetching.d.ts +10 -0
- package/es/actions/ui/is-fetching.js +6 -0
- package/{lib/actions → es/actions/ui}/navigation.d.ts +2 -2
- package/es/actions/ui/review-status.d.ts +7 -0
- package/{lib/actions → es/actions/ui}/step-items.d.ts +17 -1
- package/es/actions/{step-items.js → ui/step-items.js} +5 -0
- package/es/common/index.d.ts +1 -1
- package/es/common/index.js +1 -1
- package/es/configure-store.d.ts +34 -4
- package/es/configure-store.js +1 -2
- package/es/fixtures/qcm-slide.js +7 -3
- package/es/fixtures/temp-fixture.d.ts +1 -1
- package/es/index.js +54 -36
- package/es/index.test.js +1 -1
- package/es/middlewares/on-start-app.d.ts +2 -3
- package/es/middlewares/on-start-app.js +18 -17
- package/es/reducers/data/index.d.ts +7 -0
- package/es/reducers/data/index.js +11 -0
- package/es/reducers/data/progression.d.ts +14 -0
- package/es/reducers/data/progression.js +78 -0
- package/es/reducers/data/skills.d.ts +6 -0
- package/es/reducers/{courses.js → data/skills.js} +3 -4
- package/es/reducers/data/slides.d.ts +8 -0
- package/es/reducers/{slides.js → data/slides.js} +4 -3
- package/es/reducers/data/token.d.ts +5 -0
- package/es/reducers/data/token.js +15 -0
- package/es/reducers/index.d.ts +11 -8
- package/es/reducers/index.js +3 -16
- package/es/reducers/ui/finished-slides.d.ts +8 -0
- package/es/reducers/{finished-slides.js → ui/finished-slides.js} +9 -6
- package/es/reducers/ui/index.d.ts +7 -0
- package/es/reducers/ui/index.js +11 -0
- package/es/reducers/ui/navigation.d.ts +5 -0
- package/es/reducers/{navigation.js → ui/navigation.js} +4 -7
- package/es/reducers/ui/review-status.d.ts +5 -0
- package/es/reducers/{review-status.js → ui/review-status.js} +3 -2
- package/es/reducers/ui/step-items.d.ts +14 -0
- package/es/reducers/{step-items.js → ui/step-items.js} +7 -7
- package/es/services/fetch-skills.d.ts +8 -0
- package/es/services/fetch-skills.js +23 -0
- package/es/services/fetch-skills.mock.d.ts +3 -0
- package/es/services/fetch-skills.mock.js +17 -0
- package/es/services/fetch-skills.test.js +22 -0
- package/es/services/tools/fetch-responses.d.ts +7 -0
- package/es/services/tools/fetch.mocks.d.ts +8 -0
- package/es/services/{fetch.mocks.js → tools/fetch.mocks.js} +1 -0
- package/es/types/common.d.ts +12 -0
- package/es/types/skills.d.ts +7 -0
- package/es/types/slides.d.ts +3 -21
- package/es/types/views/skills.d.ts +24 -0
- package/{lib/types/views.d.ts → es/types/views/slides.d.ts} +7 -11
- package/lib/actions/data/skills.d.ts +13 -0
- package/lib/actions/data/skills.js +10 -0
- package/lib/actions/data/slides.d.ts +54 -0
- package/lib/actions/{slides.js → data/slides.js} +5 -0
- package/lib/actions/index.d.ts +19 -5
- package/lib/actions/ui/finished-slides.d.ts +10 -0
- package/lib/actions/{finished-slides.js → ui/finished-slides.js} +1 -0
- package/lib/actions/ui/is-fetching.d.ts +10 -0
- package/lib/actions/ui/is-fetching.js +6 -0
- package/{es/actions → lib/actions/ui}/navigation.d.ts +2 -2
- package/lib/actions/ui/review-status.d.ts +7 -0
- package/{es/actions → lib/actions/ui}/step-items.d.ts +17 -1
- package/lib/actions/{step-items.js → ui/step-items.js} +5 -0
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +1 -1
- package/lib/configure-store.d.ts +34 -4
- package/lib/configure-store.js +1 -2
- package/lib/fixtures/qcm-slide.js +7 -3
- package/lib/fixtures/temp-fixture.d.ts +1 -1
- package/lib/index.js +57 -37
- package/lib/index.test.js +1 -1
- package/lib/middlewares/on-start-app.d.ts +2 -3
- package/lib/middlewares/on-start-app.js +18 -17
- package/lib/reducers/data/index.d.ts +7 -0
- package/lib/reducers/data/index.js +11 -0
- package/lib/reducers/data/progression.d.ts +14 -0
- package/lib/reducers/data/progression.js +79 -0
- package/lib/reducers/data/skills.d.ts +6 -0
- package/lib/reducers/data/skills.js +15 -0
- package/lib/reducers/data/slides.d.ts +8 -0
- package/lib/reducers/{slides.js → data/slides.js} +4 -3
- package/lib/reducers/data/token.d.ts +5 -0
- package/lib/reducers/data/token.js +16 -0
- package/lib/reducers/index.d.ts +11 -8
- package/lib/reducers/index.js +3 -16
- package/lib/reducers/ui/finished-slides.d.ts +8 -0
- package/lib/reducers/{finished-slides.js → ui/finished-slides.js} +9 -6
- package/lib/reducers/ui/index.d.ts +7 -0
- package/lib/reducers/ui/index.js +11 -0
- package/lib/reducers/ui/navigation.d.ts +5 -0
- package/lib/reducers/{courses.js → ui/navigation.js} +9 -3
- package/lib/reducers/ui/review-status.d.ts +5 -0
- package/lib/reducers/{review-status.js → ui/review-status.js} +3 -2
- package/lib/reducers/ui/step-items.d.ts +14 -0
- package/lib/reducers/{step-items.js → ui/step-items.js} +7 -7
- package/lib/services/fetch-skills.d.ts +8 -0
- package/lib/services/{fetch-demo.js → fetch-skills.js} +28 -35
- package/lib/services/fetch-skills.mock.d.ts +3 -0
- package/lib/services/fetch-skills.mock.js +17 -0
- package/lib/services/{fetch-demo.test.js → fetch-skills.test.js} +31 -12
- package/lib/services/tools/fetch-responses.d.ts +7 -0
- package/lib/services/tools/fetch.mocks.d.ts +8 -0
- package/lib/services/{fetch.mocks.js → tools/fetch.mocks.js} +1 -0
- package/lib/types/common.d.ts +12 -0
- package/lib/types/skills.d.ts +7 -0
- package/lib/types/slides.d.ts +3 -21
- package/lib/types/views/skills.d.ts +24 -0
- package/{es/types/views.d.ts → lib/types/views/slides.d.ts} +7 -11
- package/package.json +3 -3
- package/src/actions/data/skills.ts +24 -0
- package/src/actions/data/slides.ts +89 -0
- package/src/actions/index.ts +27 -5
- package/src/actions/{finished-slides.ts → ui/finished-slides.ts} +5 -5
- package/src/actions/ui/is-fetching.ts +19 -0
- package/src/actions/{navigation.ts → ui/navigation.ts} +2 -2
- package/src/actions/{review-status.ts → ui/review-status.ts} +4 -4
- package/src/actions/{step-items.ts → ui/step-items.ts} +22 -4
- package/src/common/index.ts +2 -2
- package/src/configure-store.ts +40 -8
- package/src/fixtures/qcm-slide.ts +7 -3
- package/src/fixtures/temp-fixture.ts +1 -1
- package/src/index.test.tsx +1 -1
- package/src/index.tsx +69 -44
- package/src/middlewares/on-start-app.ts +23 -26
- package/src/reducers/data/index.ts +13 -0
- package/src/reducers/data/progression.ts +106 -0
- package/src/reducers/data/skills.ts +21 -0
- package/src/reducers/{slides.ts → data/slides.ts} +24 -21
- package/src/reducers/{review-status.ts → data/token.ts} +8 -6
- package/src/reducers/index.ts +3 -17
- package/src/reducers/{finished-slides.ts → ui/finished-slides.ts} +24 -14
- package/src/reducers/ui/index.ts +13 -0
- package/src/reducers/ui/navigation.ts +36 -0
- package/src/reducers/ui/review-status.ts +26 -0
- package/src/reducers/{step-items.ts → ui/step-items.ts} +34 -21
- package/src/services/fetch-skills.mock.ts +21 -0
- package/src/services/fetch-skills.test.ts +32 -0
- package/src/services/fetch-skills.ts +40 -0
- package/src/services/{fetch-responses.ts → tools/fetch-responses.ts} +3 -16
- package/src/services/{fetch.mocks.ts → tools/fetch.mocks.ts} +10 -10
- package/src/types/common.ts +15 -0
- package/src/types/globals.d.ts +2 -0
- package/src/types/skills.ts +8 -0
- package/src/types/slides.ts +3 -26
- package/src/types/views/skills.ts +27 -0
- package/src/types/{views.tsx → views/slides.ts} +7 -11
- package/es/actions/courses.d.ts +0 -6
- package/es/actions/courses.js +0 -5
- package/es/actions/data/is-fetching.d.ts +0 -5
- package/es/actions/data/is-fetching.js +0 -4
- package/es/actions/data/validate-slide.d.ts +0 -5
- package/es/actions/data/validate-slide.js +0 -6
- package/es/actions/finished-slides.d.ts +0 -7
- package/es/actions/review-status.d.ts +0 -7
- package/es/actions/slides.d.ts +0 -20
- package/es/reducers/courses.d.ts +0 -5
- package/es/reducers/data.d.ts +0 -7
- package/es/reducers/data.js +0 -76
- package/es/reducers/finished-slides.d.ts +0 -6
- package/es/reducers/navigation.d.ts +0 -8
- package/es/reducers/review-status.d.ts +0 -5
- package/es/reducers/slides.d.ts +0 -6
- package/es/reducers/step-items.d.ts +0 -6
- package/es/reducers/token.d.ts +0 -5
- package/es/reducers/token.js +0 -8
- package/es/services/fetch-demo.d.ts +0 -11
- package/es/services/fetch-demo.js +0 -26
- package/es/services/fetch-demo.test.js +0 -12
- package/es/services/fetch-responses.d.ts +0 -19
- package/es/services/fetch.mocks.d.ts +0 -9
- package/es/types/data/index.d.ts +0 -14
- package/es/types/dispatchers.d.ts +0 -17
- package/es/types/finished-slides.d.ts +0 -9
- package/es/types/review-status.d.ts +0 -1
- package/es/types/states.d.ts +0 -6
- package/es/types/step-items.d.ts +0 -26
- package/es/types/step-items.js +0 -5
- package/es/types/store-state.d.ts +0 -12
- package/es/types/utils.d.ts +0 -3
- package/es/types/views.js +0 -1
- package/lib/actions/courses.d.ts +0 -6
- package/lib/actions/courses.js +0 -5
- package/lib/actions/data/is-fetching.d.ts +0 -5
- package/lib/actions/data/is-fetching.js +0 -4
- package/lib/actions/data/validate-slide.d.ts +0 -5
- package/lib/actions/data/validate-slide.js +0 -6
- package/lib/actions/finished-slides.d.ts +0 -7
- package/lib/actions/review-status.d.ts +0 -7
- package/lib/actions/slides.d.ts +0 -20
- package/lib/reducers/courses.d.ts +0 -5
- package/lib/reducers/data.d.ts +0 -7
- package/lib/reducers/data.js +0 -77
- package/lib/reducers/finished-slides.d.ts +0 -6
- package/lib/reducers/navigation.d.ts +0 -8
- package/lib/reducers/navigation.js +0 -36
- package/lib/reducers/review-status.d.ts +0 -5
- package/lib/reducers/slides.d.ts +0 -6
- package/lib/reducers/step-items.d.ts +0 -6
- package/lib/reducers/token.d.ts +0 -5
- package/lib/reducers/token.js +0 -8
- package/lib/services/fetch-demo.d.ts +0 -11
- package/lib/services/fetch-demo.test.d.ts +0 -1
- package/lib/services/fetch-responses.d.ts +0 -19
- package/lib/services/fetch.mocks.d.ts +0 -9
- package/lib/types/data/index.d.ts +0 -14
- package/lib/types/data/index.js +0 -1
- package/lib/types/dispatchers.d.ts +0 -17
- package/lib/types/dispatchers.js +0 -1
- package/lib/types/finished-slides.d.ts +0 -9
- package/lib/types/finished-slides.js +0 -1
- package/lib/types/review-status.d.ts +0 -1
- package/lib/types/review-status.js +0 -1
- package/lib/types/states.d.ts +0 -6
- package/lib/types/states.js +0 -1
- package/lib/types/step-items.d.ts +0 -26
- package/lib/types/step-items.js +0 -5
- package/lib/types/store-state.d.ts +0 -12
- package/lib/types/store-state.js +0 -1
- package/lib/types/utils.d.ts +0 -3
- package/lib/types/utils.js +0 -1
- package/lib/types/views.js +0 -1
- package/src/actions/courses.ts +0 -11
- package/src/actions/data/is-fetching.ts +0 -12
- package/src/actions/data/validate-slide.ts +0 -15
- package/src/actions/slides.ts +0 -45
- package/src/reducers/courses.ts +0 -23
- package/src/reducers/data.ts +0 -88
- package/src/reducers/navigation.ts +0 -36
- package/src/reducers/token.ts +0 -17
- package/src/services/fetch-demo.test.ts +0 -16
- package/src/services/fetch-demo.ts +0 -57
- package/src/types/data/index.ts +0 -16
- package/src/types/dispatchers.ts +0 -18
- package/src/types/finished-slides.ts +0 -9
- package/src/types/review-status.ts +0 -1
- package/src/types/states.ts +0 -6
- package/src/types/step-items.ts +0 -31
- package/src/types/store-state.ts +0 -20
- package/src/types/utils.ts +0 -4
- /package/es/actions/{token.d.ts → data/token.d.ts} +0 -0
- /package/es/actions/{token.js → data/token.js} +0 -0
- /package/es/actions/{navigation.js → ui/navigation.js} +0 -0
- /package/es/actions/{review-status.js → ui/review-status.js} +0 -0
- /package/es/services/{fetch-demo.test.d.ts → fetch-skills.test.d.ts} +0 -0
- /package/es/services/{fetch-responses.js → tools/fetch-responses.js} +0 -0
- /package/es/types/{data/index.js → skills.js} +0 -0
- /package/es/types/{dispatchers.js → views/skills.js} +0 -0
- /package/es/types/{finished-slides.js → views/slides.js} +0 -0
- /package/lib/actions/{token.d.ts → data/token.d.ts} +0 -0
- /package/lib/actions/{token.js → data/token.js} +0 -0
- /package/lib/actions/{navigation.js → ui/navigation.js} +0 -0
- /package/lib/actions/{review-status.js → ui/review-status.js} +0 -0
- /package/{es/types/review-status.js → lib/services/fetch-skills.test.d.ts} +0 -0
- /package/lib/services/{fetch-responses.js → tools/fetch-responses.js} +0 -0
- /package/{es/types/states.js → lib/types/skills.js} +0 -0
- /package/{es/types/store-state.js → lib/types/views/skills.js} +0 -0
- /package/{es/types/utils.js → lib/types/views/slides.js} +0 -0
- /package/src/actions/{token.ts → data/token.ts} +0 -0
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
2
|
|
|
3
3
|
export const toResponse = (
|
|
4
4
|
statusCode: number,
|
|
5
5
|
statusText: string,
|
|
6
6
|
body: string
|
|
7
|
-
): Promise<
|
|
7
|
+
): Promise<Response> =>
|
|
8
8
|
Promise.resolve({
|
|
9
9
|
ok: statusCode < 400,
|
|
10
10
|
status: statusCode,
|
|
11
11
|
statusText,
|
|
12
12
|
json: (): Promise<unknown> => Promise.resolve(body).then(JSON.parse),
|
|
13
13
|
text: (): Promise<string> => Promise.resolve(body)
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
type FetchFunction = () => Promise<_Response>;
|
|
14
|
+
} as Response);
|
|
17
15
|
|
|
18
16
|
export const okJSONResponse =
|
|
19
|
-
(body: unknown):
|
|
17
|
+
(body: unknown): typeof crossFetch =>
|
|
20
18
|
() =>
|
|
21
19
|
toResponse(200, 'OK', JSON.stringify(body));
|
|
22
20
|
|
|
23
21
|
export const internalServerErrorJSONResponse =
|
|
24
|
-
(body: unknown):
|
|
22
|
+
(body: unknown): typeof crossFetch =>
|
|
25
23
|
() =>
|
|
26
24
|
toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
27
25
|
|
|
28
26
|
export const notFoundJSONResponse =
|
|
29
|
-
(body: unknown):
|
|
27
|
+
(body: unknown): typeof crossFetch =>
|
|
30
28
|
() =>
|
|
31
29
|
toResponse(404, 'Not Found', JSON.stringify(body));
|
|
32
30
|
|
|
33
31
|
export const okTextResponse =
|
|
34
|
-
(body: string):
|
|
32
|
+
(body: string): typeof crossFetch =>
|
|
35
33
|
() =>
|
|
36
34
|
toResponse(200, 'OK', body);
|
|
37
35
|
|
|
38
36
|
export const internalServerErrorTextResponse =
|
|
39
|
-
(body: string):
|
|
37
|
+
(body: string): typeof crossFetch =>
|
|
40
38
|
() =>
|
|
41
39
|
toResponse(500, 'InternalServerError', body);
|
|
40
|
+
|
|
41
|
+
export const token: string = process.env.API_TEST_TOKEN || 'no-API_TEST_TOKEN';
|
package/src/types/common.ts
CHANGED
|
@@ -6,3 +6,18 @@ export type AppOptions = {
|
|
|
6
6
|
translations?: unknown;
|
|
7
7
|
slide?: Slide;
|
|
8
8
|
};
|
|
9
|
+
|
|
10
|
+
export type JWT = {
|
|
11
|
+
exp: number;
|
|
12
|
+
iat: number;
|
|
13
|
+
grants: unknown;
|
|
14
|
+
iss: string;
|
|
15
|
+
user: string;
|
|
16
|
+
usage: string;
|
|
17
|
+
host: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
21
|
+
// the "-" is a Mapping Modifier, removes optionality from a prop
|
|
22
|
+
[P in K]-?: T[P];
|
|
23
|
+
};
|
package/src/types/globals.d.ts
CHANGED
package/src/types/slides.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {WithRequired} from './utils';
|
|
2
|
-
|
|
3
1
|
export type Choice = {
|
|
4
2
|
order?: number;
|
|
5
3
|
selected: boolean;
|
|
6
4
|
title: string;
|
|
7
5
|
help: string;
|
|
6
|
+
onClick: Function;
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
export type QcmDrag = {
|
|
11
10
|
type: 'qcmDrag';
|
|
12
|
-
|
|
13
|
-
help
|
|
11
|
+
answers: Choice[];
|
|
12
|
+
help?: string;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
export type Qcm = {
|
|
@@ -77,31 +76,9 @@ export type AnswerUI = {
|
|
|
77
76
|
help: string;
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
export type SlideNumber = number;
|
|
81
|
-
|
|
82
79
|
export type SlideUIAnimations = 'unstack' | 'restack';
|
|
83
80
|
|
|
84
81
|
export type Slide = {
|
|
85
|
-
hidden?: boolean;
|
|
86
|
-
position?: number;
|
|
87
|
-
animationType?: SlideUIAnimations;
|
|
88
|
-
validationResult?: 'success' | 'failure';
|
|
89
|
-
endReview?: boolean;
|
|
90
82
|
questionText?: string;
|
|
91
83
|
answerUI?: AnswerUI;
|
|
92
|
-
nextSlide?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextSlide'>;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type Slides = {
|
|
96
|
-
slideNumbers: SlideNumber[];
|
|
97
|
-
[key: SlideNumber]: Slide;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type UpdateSlidesOnValidationPayload = {
|
|
101
|
-
slideNumber: SlideNumber;
|
|
102
|
-
newSlideContent: Slide;
|
|
103
|
-
numberOfFinishedSlides: number;
|
|
104
|
-
nextSlide: WithRequired<Slide['nextSlide'], 'answerUI' | 'questionText'>;
|
|
105
84
|
};
|
|
106
|
-
|
|
107
|
-
export type UpdateSlidesOnNextPayload = Omit<UpdateSlidesOnValidationPayload, 'nextSlide'>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type SkillCard = {
|
|
2
|
+
'aria-label': string;
|
|
3
|
+
skillTitle: string;
|
|
4
|
+
skillAriaLabel: string;
|
|
5
|
+
buttonLabel: string;
|
|
6
|
+
buttonAriaLabel: string;
|
|
7
|
+
reviseLabel: string;
|
|
8
|
+
reviseAriaLabel: string;
|
|
9
|
+
isCustom: boolean;
|
|
10
|
+
onClick: Function;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type NoSkillsProps = {
|
|
14
|
+
titleNoSkills: string;
|
|
15
|
+
textNoSkills: string;
|
|
16
|
+
iconSkillAriaLabel: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type SkillsProps = NoSkillsProps & {
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
title: string;
|
|
22
|
+
isLoading?: boolean;
|
|
23
|
+
isLoadingAriaLabel: string;
|
|
24
|
+
listSkills: SkillCard[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export {SkillsProps};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {Dispatchers} from './dispatchers';
|
|
5
|
-
import {FinishedSlides} from './finished-slides';
|
|
6
|
-
import {Slides} from './slides';
|
|
7
|
-
import {StepItems} from './step-items';
|
|
2
|
+
import {Dispatchers} from '../../actions';
|
|
3
|
+
import {StoreState} from '../../configure-store';
|
|
8
4
|
|
|
9
5
|
type SlidesViewStaticProps = {
|
|
10
|
-
slides:
|
|
6
|
+
slides: StoreState['data']['slides'];
|
|
11
7
|
headerProps: {
|
|
12
8
|
mode: string;
|
|
13
9
|
skillName: string;
|
|
@@ -15,9 +11,9 @@ type SlidesViewStaticProps = {
|
|
|
15
11
|
'aria-label'?: string;
|
|
16
12
|
closeButtonAriaLabel: string;
|
|
17
13
|
};
|
|
18
|
-
finishedSlides:
|
|
19
|
-
stepItems:
|
|
20
|
-
reviewStatus:
|
|
14
|
+
finishedSlides: StoreState['ui']['finishedSlides'];
|
|
15
|
+
stepItems: StoreState['ui']['stepItems'];
|
|
16
|
+
reviewStatus: StoreState['ui']['reviewStatus'];
|
|
21
17
|
validate: {
|
|
22
18
|
label: string;
|
|
23
19
|
};
|
|
@@ -59,7 +55,7 @@ type SlidesViewStaticProps = {
|
|
|
59
55
|
failureLabel: string;
|
|
60
56
|
};
|
|
61
57
|
reviewBackgroundAriaLabel?: string;
|
|
62
|
-
|
|
58
|
+
progression: StoreState['data']['progression'];
|
|
63
59
|
};
|
|
64
60
|
|
|
65
61
|
type SlidesViewDispatcherProps = Omit<Dispatchers, 'navigateTo' | 'navigateBack'>;
|
package/es/actions/courses.d.ts
DELETED
package/es/actions/courses.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
export const IS_FETCHING_TRUE = '@@is-fetching/TRUE';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
export const setIsFetching = () => ({ type: IS_FETCHING_TRUE });
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
export const VALIDATE_SLIDE = '@@api/VALIDATE_SLIDE';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
export const validateSlide = () => ({
|
|
5
|
-
type: VALIDATE_SLIDE
|
|
6
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UpdateFinishedSlidesPayload } from '../types/finished-slides';
|
|
2
|
-
export declare const UPDATE_FINISHED_SLIDES = "@@finished-slides/UPDATE_FINISHED_SLIDES";
|
|
3
|
-
export declare type UpdateFinishedSlides = {
|
|
4
|
-
type: typeof UPDATE_FINISHED_SLIDES;
|
|
5
|
-
payload: UpdateFinishedSlidesPayload;
|
|
6
|
-
};
|
|
7
|
-
export declare const updateFinishedSlides: (payload: UpdateFinishedSlidesPayload) => UpdateFinishedSlides;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UpdateReviewStatusPayload } from '../types/review-status';
|
|
2
|
-
export declare const UPDATE_REVIEW_STATUS = "@@review-status/UPDATE_REVIEW_STATUS";
|
|
3
|
-
export declare type UpdateReviewStatus = {
|
|
4
|
-
type: typeof UPDATE_REVIEW_STATUS;
|
|
5
|
-
payload: UpdateReviewStatusPayload;
|
|
6
|
-
};
|
|
7
|
-
export declare const updateReviewStatus: (payload: UpdateReviewStatusPayload) => UpdateReviewStatus;
|
package/es/actions/slides.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Slide, UpdateSlidesOnNextPayload, UpdateSlidesOnValidationPayload } from '../types/slides';
|
|
2
|
-
export declare const STORE_FIRST_SLIDE = "@@slide/STORE_FIRST_SLIDE";
|
|
3
|
-
export declare const UPDATE_SLIDES_ON_VALIDATION = "@@slide/UPDATE_SLIDES_ON_VALIDATION";
|
|
4
|
-
export declare const UPDATE_SLIDES_ON_NEXT = "@@slide/UPDATE_SLIDES_ON_NEXT";
|
|
5
|
-
export declare type StoreFirstSlide = {
|
|
6
|
-
type: typeof STORE_FIRST_SLIDE;
|
|
7
|
-
payload: Slide;
|
|
8
|
-
};
|
|
9
|
-
export declare type UpdateSlidesOnValidation = {
|
|
10
|
-
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
11
|
-
payload: UpdateSlidesOnValidationPayload;
|
|
12
|
-
};
|
|
13
|
-
export declare type UpdateSlidesOnNext = {
|
|
14
|
-
type: typeof UPDATE_SLIDES_ON_NEXT;
|
|
15
|
-
payload: UpdateSlidesOnNextPayload;
|
|
16
|
-
};
|
|
17
|
-
export declare type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
18
|
-
export declare const storeFirstSlide: (slide: Slide) => StoreFirstSlide;
|
|
19
|
-
export declare const updateSlidesOnValidation: (payload: UpdateSlidesOnValidationPayload) => UpdateSlidesOnValidation;
|
|
20
|
-
export declare const updateSlidesOnNext: (payload: UpdateSlidesOnNextPayload) => UpdateSlidesOnNext;
|
package/es/reducers/courses.d.ts
DELETED
package/es/reducers/data.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StoreToken } from '../actions/token';
|
|
2
|
-
import { IsFetching } from '../actions/data/is-fetching';
|
|
3
|
-
import { ValidateSlide } from '../actions/data/validate-slide';
|
|
4
|
-
import { DataState } from '../types/data';
|
|
5
|
-
declare type ApiActions = IsFetching | ValidateSlide | StoreToken;
|
|
6
|
-
declare const data: (state: DataState, action: ApiActions) => DataState;
|
|
7
|
-
export default data;
|
package/es/reducers/data.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import getOr from 'lodash/fp/getOr';
|
|
2
|
-
import noop from 'lodash/fp/noop';
|
|
3
|
-
import set from 'lodash/fp/set';
|
|
4
|
-
import { STORE_TOKEN } from '../actions/token';
|
|
5
|
-
import { IS_FETCHING_TRUE } from '../actions/data/is-fetching';
|
|
6
|
-
import { VALIDATE_SLIDE } from '../actions/data/validate-slide';
|
|
7
|
-
import { setToken } from './token';
|
|
8
|
-
const defaultState = {
|
|
9
|
-
isFetching: true,
|
|
10
|
-
slideValidationResult: null,
|
|
11
|
-
token: null
|
|
12
|
-
};
|
|
13
|
-
// eslint-disable-next-line default-param-last
|
|
14
|
-
const data = (state = defaultState, action) => {
|
|
15
|
-
switch (action.type) {
|
|
16
|
-
case STORE_TOKEN: {
|
|
17
|
-
return setToken(action.payload, state);
|
|
18
|
-
}
|
|
19
|
-
case VALIDATE_SLIDE: {
|
|
20
|
-
const previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
|
|
21
|
-
// hard coded for now
|
|
22
|
-
return set('slideValidationResult', {
|
|
23
|
-
slideNumber: previousSlideNumber + 1,
|
|
24
|
-
result: 'success',
|
|
25
|
-
// exitNode
|
|
26
|
-
nextSlide: {
|
|
27
|
-
questionText: 'Test',
|
|
28
|
-
answerUI: {
|
|
29
|
-
model: {
|
|
30
|
-
answers: [
|
|
31
|
-
{
|
|
32
|
-
title: 'There is no need for a password',
|
|
33
|
-
onClick: noop,
|
|
34
|
-
selected: false
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
title: 'Lorem ipsum',
|
|
38
|
-
onClick: noop,
|
|
39
|
-
selected: false
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: 'Lorem',
|
|
43
|
-
onClick: noop,
|
|
44
|
-
selected: true,
|
|
45
|
-
order: 1
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
title: 'You need to have a password',
|
|
49
|
-
onClick: noop,
|
|
50
|
-
selected: false
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: 'Pouet',
|
|
54
|
-
onClick: noop,
|
|
55
|
-
selected: true,
|
|
56
|
-
order: 0
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
type: 'qcmDrag'
|
|
60
|
-
},
|
|
61
|
-
help: 'Help text will appear here'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}, state);
|
|
65
|
-
}
|
|
66
|
-
case IS_FETCHING_TRUE: {
|
|
67
|
-
return set('isFetching', true, state);
|
|
68
|
-
}
|
|
69
|
-
// case VALIDATE_SLIDE_FAILURE: {
|
|
70
|
-
// return set('entities.isFetching', false, state);
|
|
71
|
-
// }
|
|
72
|
-
default:
|
|
73
|
-
return state;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
export default data;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { UpdateFinishedSlides } from '../actions/finished-slides';
|
|
2
|
-
import { FinishedSlides } from '../types/finished-slides';
|
|
3
|
-
export declare type State = FinishedSlides;
|
|
4
|
-
export declare const initialState: State;
|
|
5
|
-
declare const reducer: (state: State, action: UpdateFinishedSlides) => State;
|
|
6
|
-
export default reducer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ViewPath } from '../actions/navigation';
|
|
2
|
-
import type { NavigateTo, NavigateBack } from '../actions/navigation';
|
|
3
|
-
import { StoreState } from '../types/store-state';
|
|
4
|
-
import { NavigationState as State } from '../types/states';
|
|
5
|
-
export declare const initialState: State;
|
|
6
|
-
declare const reducer: (state: State, action: NavigateTo | NavigateBack) => State;
|
|
7
|
-
export declare const getCurrentViewName: (appState: StoreState) => ViewPath;
|
|
8
|
-
export default reducer;
|
package/es/reducers/slides.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SlidesAction } from '../actions/slides';
|
|
2
|
-
import { Slides } from '../types/slides';
|
|
3
|
-
export declare type State = Slides;
|
|
4
|
-
export declare const initialState: State;
|
|
5
|
-
declare const reducer: (state: State, action: SlidesAction) => State;
|
|
6
|
-
export default reducer;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { StepItemsAction } from '../actions/step-items';
|
|
2
|
-
import { StepItems } from '../types/step-items';
|
|
3
|
-
export declare type State = StepItems;
|
|
4
|
-
export declare const initialState: State;
|
|
5
|
-
declare const reducer: (state: State, action: StepItemsAction) => State;
|
|
6
|
-
export default reducer;
|
package/es/reducers/token.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { StoreState } from '../types/store-state';
|
|
2
|
-
import { DataState } from '../types/data';
|
|
3
|
-
export declare const initialState: DataState['token'];
|
|
4
|
-
export declare const setToken: (token: string, state: DataState) => DataState;
|
|
5
|
-
export declare const getToken: (appState: StoreState) => StoreState['data']['token'];
|
package/es/reducers/token.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import set from 'lodash/fp/set';
|
|
2
|
-
// -----------------------------------------------------------------------------
|
|
3
|
-
export const initialState = null;
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
|
-
export const setToken = (token, state) => set('token', token, state);
|
|
6
|
-
// -----------------------------------------------------------------------------
|
|
7
|
-
export const getToken = (appState) => appState.data.token;
|
|
8
|
-
// -----------------------------------------------------------------------------
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Fetch } from './fetch-responses';
|
|
2
|
-
declare const fetchCourse: (fetch: Fetch) => (token: any, language: any, universalRef: any) => Promise<Course>;
|
|
3
|
-
export declare type Course = {
|
|
4
|
-
title: any;
|
|
5
|
-
};
|
|
6
|
-
export declare type CatalogHits = {
|
|
7
|
-
hits: Course[];
|
|
8
|
-
};
|
|
9
|
-
export { fetchCourse };
|
|
10
|
-
declare const _default: (token: any, language: any, universalRef: any) => Promise<Course>;
|
|
11
|
-
export default _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import decode from 'jwt-decode';
|
|
3
|
-
import { toJSON } from './fetch-responses';
|
|
4
|
-
const buildUrlQueryParams = (params) => Object.keys(params)
|
|
5
|
-
.map(key => {
|
|
6
|
-
const value = params[key].toString();
|
|
7
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
8
|
-
})
|
|
9
|
-
.join('&');
|
|
10
|
-
// -----------------------------------------------------------------------------
|
|
11
|
-
const fetchCourse = (fetch) => async (token, language, universalRef) => {
|
|
12
|
-
const jwt = decode(token);
|
|
13
|
-
const query = {
|
|
14
|
-
type: 'course',
|
|
15
|
-
universalRef,
|
|
16
|
-
lang: language
|
|
17
|
-
};
|
|
18
|
-
const response = await fetch(`${jwt.host}/api/v2/contents?${buildUrlQueryParams(query)}`, {
|
|
19
|
-
headers: { authorization: token }
|
|
20
|
-
});
|
|
21
|
-
const { hits } = (await toJSON(response));
|
|
22
|
-
return hits?.[0];
|
|
23
|
-
};
|
|
24
|
-
// -----------------------------------------------------------------------------
|
|
25
|
-
export { fetchCourse };
|
|
26
|
-
export default fetchCourse(crossFetch);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import { fetchCourse as _fetchCourse } from './fetch-demo';
|
|
3
|
-
import { okJSONResponse } from './fetch.mocks';
|
|
4
|
-
test('should fetch a demo course', async (t) => {
|
|
5
|
-
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
|
|
6
|
-
const language = 'fr';
|
|
7
|
-
const universalRef = 'bar';
|
|
8
|
-
const result = { hits: [{ title: 'Digital IQ test' }] };
|
|
9
|
-
const fetchCourse = _fetchCourse(okJSONResponse(result));
|
|
10
|
-
const course = await fetchCourse(token, language, universalRef);
|
|
11
|
-
t.is(course.title, 'Digital IQ test');
|
|
12
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare type _Response = {
|
|
2
|
-
ok: boolean;
|
|
3
|
-
status: number;
|
|
4
|
-
statusText: string;
|
|
5
|
-
json: () => Promise<unknown>;
|
|
6
|
-
text: () => Promise<string>;
|
|
7
|
-
};
|
|
8
|
-
export declare type Fetch = (url?: string, options?: {
|
|
9
|
-
headers: {
|
|
10
|
-
authorization: string;
|
|
11
|
-
};
|
|
12
|
-
}) => Promise<_Response>;
|
|
13
|
-
export declare class ResponseError extends Error {
|
|
14
|
-
statusCode: number;
|
|
15
|
-
constructor(statusCode: number, statusText: string, body?: string);
|
|
16
|
-
}
|
|
17
|
-
export declare const toJSON: (response: _Response) => Promise<unknown>;
|
|
18
|
-
export declare const toText: (response: _Response) => Promise<string>;
|
|
19
|
-
export declare const toVoid: (response: _Response) => Promise<void>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { _Response } from './fetch-responses';
|
|
2
|
-
export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<_Response>;
|
|
3
|
-
declare type FetchFunction = () => Promise<_Response>;
|
|
4
|
-
export declare const okJSONResponse: (body: unknown) => FetchFunction;
|
|
5
|
-
export declare const internalServerErrorJSONResponse: (body: unknown) => FetchFunction;
|
|
6
|
-
export declare const notFoundJSONResponse: (body: unknown) => FetchFunction;
|
|
7
|
-
export declare const okTextResponse: (body: string) => FetchFunction;
|
|
8
|
-
export declare const internalServerErrorTextResponse: (body: string) => FetchFunction;
|
|
9
|
-
export {};
|
package/es/types/data/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AnswerUI } from '../slides';
|
|
2
|
-
export declare type DataState = {
|
|
3
|
-
isFetching?: boolean;
|
|
4
|
-
slideValidationResult?: {
|
|
5
|
-
slideNumber: number;
|
|
6
|
-
result: 'success' | 'failure';
|
|
7
|
-
exitNode?: 'successExitNode' | 'failExitNode';
|
|
8
|
-
nextSlide: {
|
|
9
|
-
questionText?: string;
|
|
10
|
-
answerUI?: AnswerUI;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
token?: string;
|
|
14
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { validateSlide } from '../actions/data/validate-slide';
|
|
2
|
-
import { updateFinishedSlides } from '../actions/finished-slides';
|
|
3
|
-
import { navigateBack, navigateTo } from '../actions/navigation';
|
|
4
|
-
import { updateReviewStatus } from '../actions/review-status';
|
|
5
|
-
import { updateSlidesOnValidation, updateSlidesOnNext } from '../actions/slides';
|
|
6
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from '../actions/step-items';
|
|
7
|
-
export declare type Dispatchers = {
|
|
8
|
-
navigateTo: typeof navigateTo;
|
|
9
|
-
navigateBack: typeof navigateBack;
|
|
10
|
-
validateSlide: typeof validateSlide;
|
|
11
|
-
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
12
|
-
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
13
|
-
updateReviewStatus: typeof updateReviewStatus;
|
|
14
|
-
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
15
|
-
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
16
|
-
updateFinishedSlides: typeof updateFinishedSlides;
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type UpdateReviewStatusPayload = 'finished';
|
package/es/types/states.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { Slides as SlidesState } from './slides';
|
|
2
|
-
export { DataState } from './data';
|
|
3
|
-
export { StepItems as StepItemsState } from './step-items';
|
|
4
|
-
export { FinishedSlides as FinishedSlidesState } from './finished-slides';
|
|
5
|
-
export { State as ReviewStatusState } from '../reducers/review-status';
|
|
6
|
-
export declare type NavigationState = Array<'home' | 'onboarding' | 'slides'>;
|
package/es/types/step-items.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SlideNumber } from './slides';
|
|
2
|
-
import { FinishedSlides } from './finished-slides';
|
|
3
|
-
declare const ICON_VALUES: {
|
|
4
|
-
readonly right: "right";
|
|
5
|
-
readonly wrong: "wrong";
|
|
6
|
-
};
|
|
7
|
-
declare type IconValue = keyof typeof ICON_VALUES;
|
|
8
|
-
export declare type StepItem = {
|
|
9
|
-
current: boolean;
|
|
10
|
-
icon: IconValue;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
export declare type StepItems = {
|
|
14
|
-
slideNumbers: SlideNumber[];
|
|
15
|
-
[key: SlideNumber]: StepItem;
|
|
16
|
-
};
|
|
17
|
-
export declare type UpdateStepItemsOnValidationClickPayload = {
|
|
18
|
-
stepNumber: SlideNumber;
|
|
19
|
-
icon: IconValue;
|
|
20
|
-
};
|
|
21
|
-
export declare type UpdateStepItemsOnNextClickPayload = {
|
|
22
|
-
stepNumber: SlideNumber;
|
|
23
|
-
finishedSlides: FinishedSlides;
|
|
24
|
-
current: boolean;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
package/es/types/step-items.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DataState, FinishedSlidesState, NavigationState, ReviewStatusState, SlidesState, StepItemsState } from './states';
|
|
2
|
-
export declare type StoreState = {
|
|
3
|
-
ui: {
|
|
4
|
-
courses: unknown;
|
|
5
|
-
navigation: NavigationState;
|
|
6
|
-
slides: SlidesState;
|
|
7
|
-
stepItems: StepItemsState;
|
|
8
|
-
finishedSlides: FinishedSlidesState;
|
|
9
|
-
reviewStatus: ReviewStatusState;
|
|
10
|
-
};
|
|
11
|
-
data: DataState;
|
|
12
|
-
};
|
package/es/types/utils.d.ts
DELETED
package/es/types/views.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/actions/courses.d.ts
DELETED