@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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {Slide as SlideFromAPI} from '../../types/slides';
|
|
2
|
+
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
export const STORE_FIRST_SLIDE = '@@slide/STORE_FIRST_SLIDE';
|
|
6
|
+
export const UPDATE_SLIDES_ON_VALIDATION = '@@slide/UPDATE_SLIDES_ON_VALIDATION';
|
|
7
|
+
export const UPDATE_SLIDES_ON_NEXT = '@@slide/UPDATE_SLIDES_ON_NEXT';
|
|
8
|
+
export const VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
9
|
+
export const FETCH_NEXT_CONTENT = '@@slide/FETCH_NEXT_CONTENT';
|
|
10
|
+
|
|
11
|
+
// -----------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
type SlideUIAnimations = 'unstack' | 'restack';
|
|
14
|
+
|
|
15
|
+
export type Slide = SlideFromAPI & {
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
position: number;
|
|
18
|
+
animationType?: SlideUIAnimations;
|
|
19
|
+
isCorrect?: boolean;
|
|
20
|
+
endReview?: boolean;
|
|
21
|
+
nextSlide?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextSlide'>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ValidationPayload = {
|
|
25
|
+
slideNumber: number;
|
|
26
|
+
newSlideContent: Slide;
|
|
27
|
+
numberOfFinishedSlides: number;
|
|
28
|
+
nextSlide: Slide;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type OnNextPayload = Omit<ValidationPayload, 'nextSlide'>;
|
|
32
|
+
|
|
33
|
+
export type FetchNextPayload = {
|
|
34
|
+
answer: string[];
|
|
35
|
+
content: {
|
|
36
|
+
ref: string;
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// -----------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
export type StoreFirstSlide = {
|
|
44
|
+
type: typeof STORE_FIRST_SLIDE;
|
|
45
|
+
payload: SlideFromAPI;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type UpdateSlidesOnValidation = {
|
|
49
|
+
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
50
|
+
payload: ValidationPayload;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type UpdateSlidesOnNext = {
|
|
54
|
+
type: typeof UPDATE_SLIDES_ON_NEXT;
|
|
55
|
+
payload: OnNextPayload;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type ValidateSlide = {
|
|
59
|
+
type: typeof VALIDATE_SLIDE;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// TODO
|
|
63
|
+
export type FetchNextContent = {
|
|
64
|
+
type: typeof FETCH_NEXT_CONTENT;
|
|
65
|
+
payload: FetchNextPayload;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
69
|
+
|
|
70
|
+
// -----------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
export const storeFirstSlide = (slide: SlideFromAPI): StoreFirstSlide => ({
|
|
73
|
+
type: STORE_FIRST_SLIDE,
|
|
74
|
+
payload: slide
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const updateSlidesOnValidation = (payload: ValidationPayload): UpdateSlidesOnValidation => ({
|
|
78
|
+
type: UPDATE_SLIDES_ON_VALIDATION,
|
|
79
|
+
payload
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const updateSlidesOnNext = (payload: OnNextPayload): UpdateSlidesOnNext => ({
|
|
83
|
+
type: UPDATE_SLIDES_ON_NEXT,
|
|
84
|
+
payload
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const validateSlide = (): ValidateSlide => ({
|
|
88
|
+
type: VALIDATE_SLIDE
|
|
89
|
+
});
|
package/src/actions/index.ts
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
StoreFirstSlide,
|
|
3
|
+
updateSlidesOnValidation,
|
|
4
|
+
updateSlidesOnNext,
|
|
5
|
+
validateSlide
|
|
6
|
+
} from './data/slides';
|
|
7
|
+
import {ErrorFetchingSkills, ReceivedSkills} from './data/skills';
|
|
8
|
+
import {StoreToken} from './data/token';
|
|
9
|
+
|
|
10
|
+
import {updateFinishedSlides} from './ui/finished-slides';
|
|
11
|
+
import {navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp} from './ui/navigation';
|
|
12
|
+
import {updateReviewStatus} from './ui/review-status';
|
|
13
|
+
import {updateStepItemsOnValidation, updateStepItemsOnNext} from './ui/step-items';
|
|
5
14
|
|
|
6
15
|
export type Action =
|
|
7
16
|
| NavigateBack
|
|
8
17
|
| NavigateTo
|
|
9
|
-
|
|
|
18
|
+
| ReceivedSkills
|
|
19
|
+
| ErrorFetchingSkills
|
|
10
20
|
| StartApp
|
|
11
21
|
| StoreFirstSlide
|
|
12
22
|
| StoreToken;
|
|
23
|
+
|
|
24
|
+
export type Dispatchers = {
|
|
25
|
+
navigateTo: typeof navigateTo;
|
|
26
|
+
navigateBack: typeof navigateBack;
|
|
27
|
+
validateSlide: typeof validateSlide;
|
|
28
|
+
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
29
|
+
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
30
|
+
updateReviewStatus: typeof updateReviewStatus;
|
|
31
|
+
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
32
|
+
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
33
|
+
updateFinishedSlides: typeof updateFinishedSlides;
|
|
34
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// Stores only successful slides
|
|
2
|
+
|
|
3
|
+
export type FinishedSlide = {slideNumber: number; value: true};
|
|
2
4
|
|
|
3
5
|
// -----------------------------------------------------------------------------
|
|
4
6
|
|
|
@@ -8,14 +10,12 @@ export const UPDATE_FINISHED_SLIDES = '@@finished-slides/UPDATE_FINISHED_SLIDES'
|
|
|
8
10
|
|
|
9
11
|
export type UpdateFinishedSlides = {
|
|
10
12
|
type: typeof UPDATE_FINISHED_SLIDES;
|
|
11
|
-
payload:
|
|
13
|
+
payload: FinishedSlide;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
// -----------------------------------------------------------------------------
|
|
15
17
|
|
|
16
|
-
export const updateFinishedSlides = (
|
|
17
|
-
payload: UpdateFinishedSlidesPayload
|
|
18
|
-
): UpdateFinishedSlides => ({
|
|
18
|
+
export const updateFinishedSlides = (payload: FinishedSlide): UpdateFinishedSlides => ({
|
|
19
19
|
type: UPDATE_FINISHED_SLIDES,
|
|
20
20
|
payload
|
|
21
21
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
export const START_FETCHING = '@@ui/START_FETCHING';
|
|
4
|
+
export const STOP_FETCHING = '@@ui/STOP_FETCHING';
|
|
5
|
+
|
|
6
|
+
// -----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
export type StartFetching = {
|
|
9
|
+
type: typeof START_FETCHING;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type StopFetching = {
|
|
13
|
+
type: typeof STOP_FETCHING;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// -----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
export const startFetching = (): StartFetching => ({type: START_FETCHING});
|
|
19
|
+
export const stopFetching = (): StopFetching => ({type: STOP_FETCHING});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {AppOptions} from '
|
|
1
|
+
import {AppOptions} from '../../types/common';
|
|
2
2
|
|
|
3
3
|
export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
|
|
4
4
|
export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
|
|
5
5
|
export const START_APP = '@@navigation/START_APP';
|
|
6
6
|
|
|
7
|
-
export type ViewPath = '
|
|
7
|
+
export type ViewPath = 'skills' | 'onboarding' | 'slides';
|
|
8
8
|
|
|
9
9
|
export type NavigateTo = {
|
|
10
10
|
type: '@@navigation/NAVIGATE_TO';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {UpdateReviewStatusPayload} from '../types/review-status';
|
|
2
|
-
|
|
3
1
|
// -----------------------------------------------------------------------------
|
|
4
2
|
|
|
5
3
|
export const UPDATE_REVIEW_STATUS = '@@review-status/UPDATE_REVIEW_STATUS';
|
|
6
4
|
|
|
7
5
|
// -----------------------------------------------------------------------------
|
|
8
6
|
|
|
7
|
+
export type FinishedStatus = 'finished';
|
|
8
|
+
|
|
9
9
|
export type UpdateReviewStatus = {
|
|
10
10
|
type: typeof UPDATE_REVIEW_STATUS;
|
|
11
|
-
payload:
|
|
11
|
+
payload: FinishedStatus;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// -----------------------------------------------------------------------------
|
|
15
15
|
|
|
16
|
-
export const updateReviewStatus = (payload:
|
|
16
|
+
export const updateReviewStatus = (payload: FinishedStatus): UpdateReviewStatus => ({
|
|
17
17
|
type: UPDATE_REVIEW_STATUS,
|
|
18
18
|
payload
|
|
19
19
|
});
|
|
@@ -1,13 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UpdateStepItemsOnNextClickPayload,
|
|
3
|
-
UpdateStepItemsOnValidationClickPayload
|
|
4
|
-
} from '../types/step-items';
|
|
1
|
+
import {FinishedSlidesState} from '../../reducers/ui/finished-slides';
|
|
5
2
|
|
|
6
3
|
// -----------------------------------------------------------------------------
|
|
7
4
|
|
|
8
5
|
export const UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
|
|
9
6
|
export const UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
|
|
10
7
|
|
|
8
|
+
const ICON_VALUES = {
|
|
9
|
+
right: 'right',
|
|
10
|
+
wrong: 'wrong',
|
|
11
|
+
'no-answer': 'no-answer'
|
|
12
|
+
} as const;
|
|
13
|
+
|
|
14
|
+
// -----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export type IconValue = keyof typeof ICON_VALUES;
|
|
17
|
+
|
|
18
|
+
type UpdateStepItemsOnValidationClickPayload = {
|
|
19
|
+
stepNumber: number;
|
|
20
|
+
icon: IconValue;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type UpdateStepItemsOnNextClickPayload = {
|
|
24
|
+
stepNumber: number;
|
|
25
|
+
finishedSlides: FinishedSlidesState;
|
|
26
|
+
current: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
11
29
|
// -----------------------------------------------------------------------------
|
|
12
30
|
|
|
13
31
|
export type UpdateStepItemsOnValidation = {
|
package/src/common/index.ts
CHANGED
|
@@ -2,11 +2,11 @@ export const TOTAL_SLIDES_STACK = 5;
|
|
|
2
2
|
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
3
3
|
|
|
4
4
|
export const VIEWS: {
|
|
5
|
-
readonly
|
|
5
|
+
readonly skills: 'skills';
|
|
6
6
|
readonly onboarding: 'onboarding';
|
|
7
7
|
readonly slides: 'slides';
|
|
8
8
|
} = {
|
|
9
|
-
|
|
9
|
+
skills: 'skills',
|
|
10
10
|
onboarding: 'onboarding',
|
|
11
11
|
slides: 'slides'
|
|
12
12
|
};
|
package/src/configure-store.ts
CHANGED
|
@@ -1,19 +1,51 @@
|
|
|
1
|
-
import {AnyAction, applyMiddleware, compose, createStore,
|
|
1
|
+
import {AnyAction, applyMiddleware, compose, createStore, Store} from 'redux';
|
|
2
2
|
import thunk from 'redux-thunk';
|
|
3
3
|
|
|
4
4
|
import rootReducer from './reducers';
|
|
5
|
-
|
|
6
5
|
import onStartApp from './middlewares/on-start-app';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import {SkillsState} from './reducers/data/skills';
|
|
8
|
+
import {SlidesState} from './reducers/data/slides';
|
|
9
|
+
import {TokenState} from './reducers/data/token';
|
|
10
|
+
import {NavigationState} from './reducers/ui/navigation';
|
|
11
|
+
import {ReviewStatusState} from './reducers/ui/review-status';
|
|
12
|
+
import {StepItemsState} from './reducers/ui/step-items';
|
|
13
|
+
import {FinishedSlidesState} from './reducers/ui/finished-slides';
|
|
14
|
+
|
|
15
|
+
import {AnswerUI} from './types/slides';
|
|
16
|
+
|
|
17
|
+
// -----------------------------------------------------------------------------
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
type DataState = {
|
|
20
|
+
isFetching?: boolean;
|
|
21
|
+
progression?: {
|
|
22
|
+
slideNumber: number;
|
|
23
|
+
isCorrect?: boolean;
|
|
24
|
+
// pass down the successExitNode if all slides are finished, not before
|
|
25
|
+
exitNode?: 'successExitNode' | 'failExitNode';
|
|
26
|
+
nextSlide?: {
|
|
27
|
+
questionText?: string;
|
|
28
|
+
answerUI?: AnswerUI;
|
|
29
|
+
};
|
|
30
|
+
} | null;
|
|
31
|
+
skills: SkillsState;
|
|
32
|
+
slides: SlidesState;
|
|
33
|
+
token?: TokenState;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type StoreState = {
|
|
37
|
+
ui: {
|
|
38
|
+
navigation: NavigationState;
|
|
39
|
+
stepItems: StepItemsState;
|
|
40
|
+
finishedSlides: FinishedSlidesState;
|
|
41
|
+
reviewStatus: ReviewStatusState;
|
|
42
|
+
};
|
|
43
|
+
data: DataState;
|
|
44
|
+
};
|
|
11
45
|
|
|
12
46
|
// -----------------------------------------------------------------------------
|
|
13
47
|
|
|
14
|
-
export default function configureStore(): Store<
|
|
15
|
-
dispatch: {};
|
|
16
|
-
} {
|
|
48
|
+
export default function configureStore(): Store<StoreState, AnyAction> {
|
|
17
49
|
const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
18
50
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
19
51
|
name: 'app-review',
|
|
@@ -23,7 +55,7 @@ export default function configureStore(): Store<EmptyObject & StoreState, AnyAct
|
|
|
23
55
|
: compose;
|
|
24
56
|
|
|
25
57
|
const enhancer = _compose(applyMiddleware(thunk, onStartApp));
|
|
26
|
-
const store = createStore(rootReducer,
|
|
58
|
+
const store = createStore(rootReducer, undefined, enhancer);
|
|
27
59
|
|
|
28
60
|
return store;
|
|
29
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import noop from 'lodash/fp/noop';
|
|
1
2
|
import {Slide} from '../types/slides';
|
|
2
3
|
|
|
3
4
|
export const slide: Slide = {
|
|
@@ -11,19 +12,22 @@ export const slide: Slide = {
|
|
|
11
12
|
selected: false,
|
|
12
13
|
title: 'choix1',
|
|
13
14
|
help: '(help choix1)',
|
|
14
|
-
ariaLabel: '__ariaLabel1'
|
|
15
|
+
ariaLabel: '__ariaLabel1',
|
|
16
|
+
onClick: noop
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
19
|
selected: false,
|
|
18
20
|
title: 'choix2',
|
|
19
21
|
help: '(help choix2)',
|
|
20
|
-
ariaLabel: '__ariaLabel2'
|
|
22
|
+
ariaLabel: '__ariaLabel2',
|
|
23
|
+
onClick: noop
|
|
21
24
|
},
|
|
22
25
|
{
|
|
23
26
|
selected: false,
|
|
24
27
|
title: 'choix3',
|
|
25
28
|
help: '(help choix3)',
|
|
26
|
-
ariaLabel: '__ariaLabel3'
|
|
29
|
+
ariaLabel: '__ariaLabel3',
|
|
30
|
+
onClick: noop
|
|
27
31
|
}
|
|
28
32
|
]
|
|
29
33
|
}
|
package/src/index.test.tsx
CHANGED
|
@@ -72,7 +72,7 @@ test('should validate all the slides (all correct scenario)', async t => {
|
|
|
72
72
|
const wrapper = container.querySelector('[data-name="slides-revision-container"]');
|
|
73
73
|
t.truthy(wrapper);
|
|
74
74
|
|
|
75
|
-
const stackedSlidesContainer = wrapper
|
|
75
|
+
const stackedSlidesContainer = wrapper?.querySelector('[data-name="stacked-slides-container"]');
|
|
76
76
|
|
|
77
77
|
t.truthy(stackedSlidesContainer);
|
|
78
78
|
|
package/src/index.tsx
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import React, {useEffect, useState} from 'react';
|
|
2
|
+
import {AnyAction, Store} from 'redux';
|
|
2
3
|
import {connect, Provider} from 'react-redux';
|
|
3
4
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
4
5
|
|
|
5
|
-
import configureStore from './configure-store';
|
|
6
|
-
import {navigateTo, navigateBack, startApp} from './actions/navigation';
|
|
7
|
-
import {updateSlidesOnNext, updateSlidesOnValidation} from './actions/slides';
|
|
8
|
-
import {getCurrentViewName} from './reducers/navigation';
|
|
9
|
-
import type {SlidesViewStaticProps} from './types/views';
|
|
10
|
-
import type {AppOptions} from './types/common';
|
|
11
|
-
import type {StoreState} from './types/store-state';
|
|
6
|
+
import configureStore, {StoreState} from './configure-store';
|
|
12
7
|
import {congratsProps, correctionPopinProps} from './fixtures/temp-fixture';
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import type {
|
|
17
|
-
|
|
8
|
+
|
|
9
|
+
import type {AppOptions} from './types/common';
|
|
10
|
+
import {SkillsProps} from './types/views/skills';
|
|
11
|
+
import type {SlidesViewStaticProps} from './types/views/slides';
|
|
12
|
+
|
|
13
|
+
import {Dispatchers} from './actions';
|
|
14
|
+
import {updateSlidesOnNext, updateSlidesOnValidation, validateSlide} from './actions/data/slides';
|
|
15
|
+
import {navigateTo, navigateBack, startApp, ViewPath} from './actions/ui/navigation';
|
|
16
|
+
import {updateFinishedSlides} from './actions/ui/finished-slides';
|
|
17
|
+
import {updateReviewStatus} from './actions/ui/review-status';
|
|
18
|
+
import {updateStepItemsOnValidation, updateStepItemsOnNext} from './actions/ui/step-items';
|
|
18
19
|
|
|
19
20
|
// -----------------------------------------------------------------------------
|
|
20
21
|
|
|
21
22
|
type StaticProps = {
|
|
22
|
-
viewName: '
|
|
23
|
+
viewName: 'skills' | 'onboarding' | 'slides';
|
|
23
24
|
slides: SlidesViewStaticProps;
|
|
25
|
+
skills: SkillsProps;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
// -----------------------------------------------------------------------------
|
|
@@ -37,33 +39,56 @@ const mapDispatchToProps: Dispatchers = {
|
|
|
37
39
|
updateFinishedSlides
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
const getCurrentViewName = (storeState: StoreState): ViewPath =>
|
|
43
|
+
storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
44
|
+
|
|
45
|
+
const mapStateToSkillsProps = (state: StoreState): SkillsProps => ({
|
|
46
|
+
title: '@todo title',
|
|
47
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
48
|
+
textNoSkills: '@todo textNoSkills',
|
|
49
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
50
|
+
isLoading: false,
|
|
51
|
+
isLoadingAriaLabel: '@todo loading',
|
|
52
|
+
listSkills: state.data.skills.map(skill => ({
|
|
53
|
+
'aria-label': '',
|
|
54
|
+
isCustom: skill.custom,
|
|
55
|
+
skillTitle: skill.name,
|
|
56
|
+
skillAriaLabel: '@todo skill aria label',
|
|
57
|
+
buttonLabel: '@todo button',
|
|
58
|
+
buttonAriaLabel: '@todo button aria label',
|
|
59
|
+
reviseLabel: '@todo revise',
|
|
60
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
63
|
+
}))
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const mapStateToProps = (state: StoreState): StaticProps => ({
|
|
67
|
+
viewName: getCurrentViewName(state),
|
|
68
|
+
slides: {
|
|
69
|
+
headerProps: {
|
|
70
|
+
mode: '__revision_mode',
|
|
71
|
+
skillName: '__agility',
|
|
72
|
+
onQuitClick: (): void => {
|
|
73
|
+
// eslint-disable-next-line no-console
|
|
74
|
+
console.log('onQuitClick');
|
|
53
75
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
'aria-label': 'aria-header-wrapper',
|
|
77
|
+
closeButtonAriaLabel: 'aria-close-button'
|
|
78
|
+
},
|
|
79
|
+
slides: state.data.slides,
|
|
80
|
+
validate: {
|
|
81
|
+
label: '__validate'
|
|
82
|
+
},
|
|
83
|
+
finishedSlides: state.ui.finishedSlides,
|
|
84
|
+
stepItems: state.ui.stepItems,
|
|
85
|
+
reviewStatus: state.ui.reviewStatus,
|
|
86
|
+
correctionPopinProps,
|
|
87
|
+
congratsProps,
|
|
88
|
+
progression: state.data.progression
|
|
89
|
+
},
|
|
90
|
+
skills: mapStateToSkillsProps(state)
|
|
91
|
+
});
|
|
67
92
|
|
|
68
93
|
// Props = StaticProps && Dispatchers
|
|
69
94
|
|
|
@@ -72,8 +97,8 @@ const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
|
72
97
|
// -----------------------------------------------------------------------------
|
|
73
98
|
|
|
74
99
|
const AppReview = ({options}: {options: AppOptions}): JSX.Element => {
|
|
75
|
-
const [store, setStore] = useState(null);
|
|
76
|
-
const [appStarted, setAppStarted] = useState(false);
|
|
100
|
+
const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
|
|
101
|
+
const [appStarted, setAppStarted] = useState<boolean>(false);
|
|
77
102
|
|
|
78
103
|
useEffect(() => {
|
|
79
104
|
if (store) {
|
|
@@ -81,14 +106,14 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element => {
|
|
|
81
106
|
setAppStarted(true);
|
|
82
107
|
} else {
|
|
83
108
|
const _configure = async (): Promise<void> => {
|
|
84
|
-
const
|
|
85
|
-
setStore(
|
|
109
|
+
const newStore = await configureStore();
|
|
110
|
+
setStore(newStore);
|
|
86
111
|
};
|
|
87
112
|
_configure();
|
|
88
113
|
}
|
|
89
114
|
}, [options, store]);
|
|
90
115
|
|
|
91
|
-
if (!store || !appStarted) return
|
|
116
|
+
if (!store || !appStarted) return <div />;
|
|
92
117
|
|
|
93
118
|
return (
|
|
94
119
|
<Provider store={store}>
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
-
import type {Middleware} from 'redux';
|
|
1
|
+
import type {Middleware, Store} from 'redux';
|
|
2
2
|
import {Dispatch} from 'redux';
|
|
3
3
|
|
|
4
|
-
import {Action} from '../actions';
|
|
5
|
-
// import fetchCourse from '../services/fetch-demo';
|
|
6
4
|
import {VIEWS} from '../common';
|
|
7
|
-
import {
|
|
8
|
-
import {storeToken} from '../actions/token';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
5
|
+
import {Action} from '../actions';
|
|
6
|
+
import {storeToken} from '../actions/data/token';
|
|
7
|
+
import {receivedSkills, errorFetchingSkills} from '../actions/data/skills';
|
|
8
|
+
import {storeFirstSlide} from '../actions/data/slides';
|
|
9
|
+
import {navigateTo, START_APP, ViewPath} from '../actions/ui/navigation';
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
12
|
+
import fetchSkills from '../services/fetch-skills';
|
|
12
13
|
|
|
13
|
-
const onStartApp: Middleware<{},
|
|
14
|
+
const onStartApp: Middleware<{}, Store, Dispatch<Action>> =
|
|
14
15
|
({dispatch}) =>
|
|
15
16
|
next =>
|
|
16
17
|
(action: Action) => {
|
|
17
18
|
if (action.type === START_APP) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const {slide, token} = action.payload;
|
|
20
|
+
|
|
21
|
+
dispatch(storeToken(token));
|
|
22
|
+
|
|
21
23
|
if (slide) {
|
|
22
|
-
const {token} = action.payload;
|
|
23
|
-
dispatch(storeToken(token));
|
|
24
24
|
dispatch(storeFirstSlide(slide));
|
|
25
|
+
} else {
|
|
26
|
+
fetchSkills(token)
|
|
27
|
+
.then(skills => {
|
|
28
|
+
return dispatch(receivedSkills(skills));
|
|
29
|
+
})
|
|
30
|
+
.catch(err => {
|
|
31
|
+
return dispatch(errorFetchingSkills(err));
|
|
32
|
+
});
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
const initialView: ViewPath = slide ? VIEWS.slides : VIEWS.
|
|
28
|
-
|
|
35
|
+
const initialView: ViewPath = slide ? VIEWS.slides : VIEWS.skills;
|
|
29
36
|
dispatch(navigateTo(initialView));
|
|
30
|
-
|
|
31
|
-
// --------------
|
|
32
|
-
// demo service
|
|
33
|
-
|
|
34
|
-
// const language = 'fr';
|
|
35
|
-
// const universalRef = 'dis_xxx15';
|
|
36
|
-
|
|
37
|
-
// fetchCourse(token, language, universalRef).then(course => {
|
|
38
|
-
// dispatch(receivedCourse(course));
|
|
39
|
-
// });
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
return next(action);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {combineReducers} from 'redux';
|
|
2
|
+
|
|
3
|
+
import progression from './progression';
|
|
4
|
+
import skills from './skills';
|
|
5
|
+
import slides from './slides';
|
|
6
|
+
import token from './token';
|
|
7
|
+
|
|
8
|
+
export default combineReducers({
|
|
9
|
+
progression,
|
|
10
|
+
skills,
|
|
11
|
+
slides,
|
|
12
|
+
token
|
|
13
|
+
});
|