@coorpacademy/app-review 0.1.7 → 0.1.8
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/api/fetch-skills.d.ts +10 -0
- package/es/actions/api/fetch-skills.js +8 -0
- package/es/actions/api/fetch-slide.d.ts +10 -0
- package/es/actions/api/fetch-slide.js +8 -0
- package/es/actions/api/post-progression.d.ts +10 -0
- package/es/actions/api/post-progression.js +15 -0
- package/es/actions/data/slides.d.ts +3 -24
- package/es/actions/data/slides.js +0 -11
- package/es/actions/index.d.ts +5 -4
- package/es/actions/ui/navigation.d.ts +0 -1
- package/es/actions/ui/navigation.js +0 -4
- package/es/actions/ui/step-items.d.ts +2 -8
- package/es/actions/ui/step-items.js +0 -6
- package/es/configure-store.d.ts +3 -26
- package/es/configure-store.js +4 -5
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/index.js +38 -19
- package/es/reducers/data/index.d.ts +16 -5
- package/es/reducers/data/progression.d.ts +1 -2
- package/es/reducers/data/progression.js +4 -7
- package/es/reducers/data/skills.d.ts +4 -5
- package/es/reducers/data/skills.js +3 -6
- package/es/reducers/data/slides.d.ts +2 -1
- package/es/reducers/data/slides.js +3 -3
- package/es/reducers/data/token.d.ts +0 -1
- package/es/reducers/data/token.js +1 -5
- package/es/reducers/index.d.ts +9 -3
- package/es/reducers/ui/finished-slides.d.ts +0 -1
- package/es/reducers/ui/finished-slides.js +1 -3
- package/es/reducers/ui/index.d.ts +14 -4
- package/es/reducers/ui/navigation.d.ts +0 -1
- package/es/reducers/ui/navigation.js +1 -3
- package/es/reducers/ui/review-status.d.ts +0 -1
- package/es/reducers/ui/review-status.js +1 -4
- package/es/reducers/ui/step-items.d.ts +5 -5
- package/es/reducers/ui/step-items.js +0 -1
- package/es/services/fetch-skills.d.ts +2 -8
- package/es/services/fetch-skills.js +2 -14
- package/es/services/fetch-slide.d.ts +2 -8
- package/es/services/fetch-slide.js +9 -24
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +8 -0
- package/es/services/post-progression.d.ts +2 -8
- package/es/services/post-progression.js +2 -14
- package/es/services/test/fetch-skills.test.js +29 -0
- package/es/services/test/post-progression.test.js +35 -0
- package/es/{index.test.js → test/index.test.js} +15 -4
- package/es/test/util/services.mock.d.ts +2 -0
- package/es/test/util/services.mock.js +68 -0
- package/es/types/common.d.ts +58 -0
- package/es/types/common.js +5 -0
- package/es/types/slides.d.ts +1 -1
- package/es/types/views/slides.d.ts +1 -1
- package/lib/actions/api/fetch-skills.d.ts +10 -0
- package/lib/actions/api/fetch-skills.js +13 -0
- package/lib/actions/api/fetch-slide.d.ts +10 -0
- package/lib/actions/api/fetch-slide.js +13 -0
- package/lib/actions/api/post-progression.d.ts +10 -0
- package/lib/actions/api/post-progression.js +18 -0
- package/lib/actions/data/slides.d.ts +3 -24
- package/lib/actions/data/slides.js +0 -11
- package/lib/actions/index.d.ts +5 -4
- package/lib/actions/ui/navigation.d.ts +0 -1
- package/lib/actions/ui/navigation.js +0 -4
- package/lib/actions/ui/step-items.d.ts +2 -8
- package/lib/actions/ui/step-items.js +0 -6
- package/lib/configure-store.d.ts +3 -26
- package/lib/configure-store.js +4 -5
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/index.js +38 -63
- package/lib/reducers/data/index.d.ts +16 -5
- package/lib/reducers/data/progression.d.ts +1 -2
- package/lib/reducers/data/progression.js +4 -7
- package/lib/reducers/data/skills.d.ts +4 -5
- package/lib/reducers/data/skills.js +3 -6
- package/lib/reducers/data/slides.d.ts +2 -1
- package/lib/reducers/data/slides.js +3 -3
- package/lib/reducers/data/token.d.ts +0 -1
- package/lib/reducers/data/token.js +1 -5
- package/lib/reducers/index.d.ts +9 -3
- package/lib/reducers/ui/finished-slides.d.ts +0 -1
- package/lib/reducers/ui/finished-slides.js +1 -3
- package/lib/reducers/ui/index.d.ts +14 -4
- package/lib/reducers/ui/navigation.d.ts +0 -1
- package/lib/reducers/ui/navigation.js +1 -3
- package/lib/reducers/ui/review-status.d.ts +0 -1
- package/lib/reducers/ui/review-status.js +1 -4
- package/lib/reducers/ui/step-items.d.ts +5 -5
- package/lib/reducers/ui/step-items.js +0 -1
- package/lib/services/fetch-skills.d.ts +2 -8
- package/lib/services/fetch-skills.js +3 -15
- package/lib/services/fetch-slide.d.ts +2 -8
- package/lib/services/fetch-slide.js +18 -25
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +8 -0
- package/lib/services/post-progression.d.ts +2 -8
- package/lib/services/post-progression.js +3 -15
- package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
- package/lib/services/{post-progression.test.js → test/post-progression.test.js} +28 -23
- package/lib/{index.test.js → test/index.test.js} +20 -10
- package/lib/test/util/services.mock.d.ts +2 -0
- package/lib/test/util/services.mock.js +68 -0
- package/lib/types/common.d.ts +58 -0
- package/lib/types/common.js +5 -0
- package/lib/types/slides.d.ts +1 -1
- package/lib/types/views/slides.d.ts +1 -1
- package/package.json +5 -3
- package/src/actions/api/fetch-skills.ts +20 -0
- package/src/actions/api/fetch-slide.ts +20 -0
- package/src/actions/api/post-progression.ts +26 -0
- package/src/actions/data/slides.ts +3 -35
- package/src/actions/index.ts +5 -11
- package/src/actions/ui/navigation.ts +0 -5
- package/src/actions/ui/step-items.ts +2 -14
- package/src/configure-store.ts +6 -37
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/index.tsx +43 -19
- package/src/reducers/data/index.ts +12 -4
- package/src/reducers/data/progression.ts +5 -15
- package/src/reducers/data/skills.ts +5 -10
- package/src/reducers/data/slides.ts +4 -8
- package/src/reducers/data/token.ts +1 -11
- package/src/reducers/index.ts +7 -2
- package/src/reducers/ui/finished-slides.ts +1 -7
- package/src/reducers/ui/index.ts +11 -4
- package/src/reducers/ui/navigation.ts +1 -6
- package/src/reducers/ui/review-status.ts +1 -8
- package/src/reducers/ui/step-items.ts +5 -14
- package/src/services/fetch-skills.ts +4 -29
- package/src/services/fetch-slide.ts +10 -38
- package/src/services/index.ts +10 -0
- package/src/services/post-progression.ts +6 -28
- package/src/services/test/fetch-skills.test.ts +39 -0
- package/src/services/test/post-progression.test.ts +45 -0
- package/src/{index.test.tsx → test/index.test.tsx} +13 -5
- package/src/test/util/services.mock.ts +70 -0
- package/src/types/common.ts +70 -0
- package/src/types/globals.d.ts +1 -0
- package/src/types/slides.ts +1 -1
- package/src/types/views/slides.ts +1 -1
- package/es/actions/data/progression.d.ts +0 -30
- package/es/actions/data/progression.js +0 -12
- package/es/actions/data/skills.d.ts +0 -13
- package/es/actions/data/skills.js +0 -10
- package/es/middlewares/on-receive-progression.d.ts +0 -6
- package/es/middlewares/on-receive-progression.js +0 -22
- package/es/middlewares/on-receive-progression.test.d.ts +0 -1
- package/es/middlewares/on-receive-progression.test.js +0 -43
- package/es/middlewares/on-start-app.d.ts +0 -5
- package/es/middlewares/on-start-app.js +0 -37
- package/es/middlewares/on-start-app.test.d.ts +0 -1
- package/es/middlewares/on-start-app.test.js +0 -53
- package/es/services/fetch-skills.mock.d.ts +0 -3
- package/es/services/fetch-skills.mock.js +0 -17
- package/es/services/fetch-skills.test.js +0 -22
- package/es/services/post-progression.mock.d.ts +0 -5
- package/es/services/post-progression.mock.js +0 -31
- package/es/services/post-progression.test.js +0 -30
- package/es/services/tools/fetch.mocks.d.ts +0 -8
- package/es/services/tools/fetch.mocks.js +0 -13
- package/es/types/skills.d.ts +0 -7
- package/es/types/skills.js +0 -1
- package/lib/actions/data/progression.d.ts +0 -30
- package/lib/actions/data/progression.js +0 -12
- package/lib/actions/data/skills.d.ts +0 -13
- package/lib/actions/data/skills.js +0 -10
- package/lib/middlewares/on-receive-progression.d.ts +0 -6
- package/lib/middlewares/on-receive-progression.js +0 -27
- package/lib/middlewares/on-receive-progression.test.d.ts +0 -1
- package/lib/middlewares/on-receive-progression.test.js +0 -88
- package/lib/middlewares/on-start-app.d.ts +0 -5
- package/lib/middlewares/on-start-app.js +0 -42
- package/lib/middlewares/on-start-app.test.d.ts +0 -1
- package/lib/middlewares/on-start-app.test.js +0 -98
- package/lib/services/fetch-skills.mock.d.ts +0 -3
- package/lib/services/fetch-skills.mock.js +0 -17
- package/lib/services/post-progression.mock.d.ts +0 -5
- package/lib/services/post-progression.mock.js +0 -31
- package/lib/services/tools/fetch.mocks.d.ts +0 -8
- package/lib/services/tools/fetch.mocks.js +0 -35
- package/lib/types/skills.d.ts +0 -7
- package/lib/types/skills.js +0 -1
- package/src/actions/data/progression.ts +0 -50
- package/src/actions/data/skills.ts +0 -24
- package/src/middlewares/on-receive-progression.test.ts +0 -60
- package/src/middlewares/on-receive-progression.ts +0 -42
- package/src/middlewares/on-start-app.test.ts +0 -68
- package/src/middlewares/on-start-app.ts +0 -50
- package/src/services/fetch-skills.mock.ts +0 -21
- package/src/services/fetch-skills.test.ts +0 -32
- package/src/services/post-progression.mock.ts +0 -35
- package/src/services/post-progression.test.ts +0 -41
- package/src/services/tools/fetch.mocks.ts +0 -41
- package/src/types/skills.ts +0 -8
- /package/es/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/es/services/{post-progression.test.d.ts → test/post-progression.test.d.ts} +0 -0
- /package/es/{index.test.d.ts → test/index.test.d.ts} +0 -0
- /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/lib/services/{post-progression.test.d.ts → test/post-progression.test.d.ts} +0 -0
- /package/lib/{index.test.d.ts → test/index.test.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action } from 'redux';
|
|
2
|
+
import { Skill } from '../../types/common';
|
|
3
|
+
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
4
|
+
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
5
|
+
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
6
|
+
export declare type ReceivedSkills = {
|
|
7
|
+
type: '@@skills/FETCH_SUCCESS';
|
|
8
|
+
payload: Skill[];
|
|
9
|
+
};
|
|
10
|
+
export declare const fetchSkills: (token: string) => Action;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST';
|
|
3
|
+
export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS';
|
|
4
|
+
export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE';
|
|
5
|
+
export const fetchSkills = (token) => buildTask({
|
|
6
|
+
types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
|
|
7
|
+
task: (dispatch, getState, { services }) => services.fetchSkills(token)
|
|
8
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Action } from 'redux';
|
|
2
|
+
import { SlideFromAPI } from '../../types/common';
|
|
3
|
+
export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
|
|
4
|
+
export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
|
|
5
|
+
export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
|
|
6
|
+
export declare type ReceivedSlide = {
|
|
7
|
+
type: typeof SLIDE_FETCH_SUCCESS;
|
|
8
|
+
payload: SlideFromAPI;
|
|
9
|
+
};
|
|
10
|
+
export declare const fetchSlide: (slideRef: string, token: string) => Action;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
3
|
+
export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
4
|
+
export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
5
|
+
export const fetchSlide = (slideRef, token) => buildTask({
|
|
6
|
+
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
7
|
+
task: (dispatch, getState, { services }) => services.fetchSlide(slideRef, token)
|
|
8
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Action } from 'redux';
|
|
2
|
+
import { ProgressionFromAPI } from '../../types/common';
|
|
3
|
+
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
4
|
+
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
5
|
+
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
6
|
+
export declare type ReceiveProgression = {
|
|
7
|
+
type: typeof POST_PROGRESSION_SUCCESS;
|
|
8
|
+
payload: ProgressionFromAPI;
|
|
9
|
+
};
|
|
10
|
+
export declare const postProgression: (skillRef: string, token: string) => Action;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import { fetchSlide } from './fetch-slide';
|
|
3
|
+
export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST';
|
|
4
|
+
export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS';
|
|
5
|
+
export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE';
|
|
6
|
+
export const postProgression = (skillRef, token) => buildTask({
|
|
7
|
+
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
8
|
+
task: (dispatch, getState, { services }) => {
|
|
9
|
+
return services.postProgression(skillRef, token).then((progression) => {
|
|
10
|
+
const { ref } = progression.state.nextContent;
|
|
11
|
+
dispatch(fetchSlide(ref, token));
|
|
12
|
+
return progression;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { UISlide } from '../../types/slides';
|
|
2
|
+
import { ReceivedSlide } from '../api/fetch-slide';
|
|
3
3
|
export declare const UPDATE_SLIDES_ON_VALIDATION = "@@slide/UPDATE_SLIDES_ON_VALIDATION";
|
|
4
4
|
export declare const UPDATE_SLIDES_ON_NEXT = "@@slide/UPDATE_SLIDES_ON_NEXT";
|
|
5
5
|
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
6
|
-
export declare const FETCH_NEXT_CONTENT = "@@slide/FETCH_NEXT_CONTENT";
|
|
7
|
-
export declare const ERROR_FETCHING_SLIDE = "@@data/slide/ERROR_FETCHING_SLIDE";
|
|
8
6
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
9
7
|
export declare type Slide = UISlide & {
|
|
10
8
|
hidden?: boolean;
|
|
@@ -14,15 +12,6 @@ export declare type Slide = UISlide & {
|
|
|
14
12
|
endReview?: boolean;
|
|
15
13
|
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
16
14
|
};
|
|
17
|
-
export declare type SlideFromAPI = {
|
|
18
|
-
question: {
|
|
19
|
-
content: {
|
|
20
|
-
choices: Record<string, unknown>[];
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
klf: string;
|
|
24
|
-
universalRef: string;
|
|
25
|
-
};
|
|
26
15
|
export declare type ValidationPayload = {
|
|
27
16
|
slideNumber: number;
|
|
28
17
|
newSlideContent: Slide;
|
|
@@ -30,10 +19,6 @@ export declare type ValidationPayload = {
|
|
|
30
19
|
nextContent: Slide;
|
|
31
20
|
};
|
|
32
21
|
export declare type OnNextPayload = Omit<ValidationPayload, 'nextContent'>;
|
|
33
|
-
export declare type StoreFirstSlide = {
|
|
34
|
-
type: typeof STORE_FIRST_SLIDE;
|
|
35
|
-
payload: SlideFromAPI;
|
|
36
|
-
};
|
|
37
22
|
export declare type UpdateSlidesOnValidation = {
|
|
38
23
|
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
39
24
|
payload: ValidationPayload;
|
|
@@ -45,14 +30,8 @@ export declare type UpdateSlidesOnNext = {
|
|
|
45
30
|
export declare type ValidateSlide = {
|
|
46
31
|
type: typeof VALIDATE_SLIDE;
|
|
47
32
|
};
|
|
48
|
-
export declare type
|
|
49
|
-
type: typeof ERROR_FETCHING_SLIDE;
|
|
50
|
-
payload: Error;
|
|
51
|
-
};
|
|
52
|
-
export declare type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
53
|
-
export declare const storeFirstSlide: (slide: SlideFromAPI) => StoreFirstSlide;
|
|
33
|
+
export declare type SlidesAction = ReceivedSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
54
34
|
export declare const updateSlidesOnValidation: (payload: ValidationPayload) => UpdateSlidesOnValidation;
|
|
55
35
|
export declare const updateSlidesOnNext: (payload: OnNextPayload) => UpdateSlidesOnNext;
|
|
56
36
|
export declare const validateSlide: () => ValidateSlide;
|
|
57
|
-
export declare const errorFetchingSlide: (error: Error) => ErrorFetchingSlide;
|
|
58
37
|
export {};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
// -----------------------------------------------------------------------------
|
|
2
|
-
export const STORE_FIRST_SLIDE = '@@slide/STORE_FIRST_SLIDE';
|
|
3
2
|
export const UPDATE_SLIDES_ON_VALIDATION = '@@slide/UPDATE_SLIDES_ON_VALIDATION';
|
|
4
3
|
export const UPDATE_SLIDES_ON_NEXT = '@@slide/UPDATE_SLIDES_ON_NEXT';
|
|
5
4
|
export const VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
6
|
-
export const FETCH_NEXT_CONTENT = '@@slide/FETCH_NEXT_CONTENT';
|
|
7
|
-
export const ERROR_FETCHING_SLIDE = '@@data/slide/ERROR_FETCHING_SLIDE';
|
|
8
5
|
// -----------------------------------------------------------------------------
|
|
9
|
-
export const storeFirstSlide = (slide) => ({
|
|
10
|
-
type: STORE_FIRST_SLIDE,
|
|
11
|
-
payload: slide
|
|
12
|
-
});
|
|
13
6
|
export const updateSlidesOnValidation = (payload) => ({
|
|
14
7
|
type: UPDATE_SLIDES_ON_VALIDATION,
|
|
15
8
|
payload
|
|
@@ -21,7 +14,3 @@ export const updateSlidesOnNext = (payload) => ({
|
|
|
21
14
|
export const validateSlide = () => ({
|
|
22
15
|
type: VALIDATE_SLIDE
|
|
23
16
|
});
|
|
24
|
-
export const errorFetchingSlide = (error) => ({
|
|
25
|
-
type: ERROR_FETCHING_SLIDE,
|
|
26
|
-
payload: error
|
|
27
|
-
});
|
package/es/actions/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ErrorFetchingSkills, ReceivedSkills } from './data/skills';
|
|
1
|
+
import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
|
|
3
2
|
import { StoreToken } from './data/token';
|
|
4
3
|
import { updateFinishedSlides } from './ui/finished-slides';
|
|
5
4
|
import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
|
|
6
5
|
import { updateReviewStatus } from './ui/review-status';
|
|
7
6
|
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
import { ReceivedSlide } from './api/fetch-slide';
|
|
8
|
+
import { ReceiveProgression } from './api/post-progression';
|
|
9
|
+
import { ReceivedSkills } from './api/fetch-skills';
|
|
10
|
+
export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
|
|
10
11
|
export declare type Dispatchers = {
|
|
11
12
|
navigateTo: typeof navigateTo;
|
|
12
13
|
navigateBack: typeof navigateBack;
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FinishedSlides, IconValue } from '../../types/common';
|
|
2
2
|
export declare const UPDATE_STEP_ITEMS_ON_VALIDATION = "@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION";
|
|
3
3
|
export declare const UPDATE_STEP_ITEMS_ON_NEXT = "@@step-items/UPDATE_STEP_ITEMS_ON_NEXT";
|
|
4
|
-
declare const ICON_VALUES: {
|
|
5
|
-
readonly right: "right";
|
|
6
|
-
readonly wrong: "wrong";
|
|
7
|
-
readonly 'no-answer': "no-answer";
|
|
8
|
-
};
|
|
9
|
-
export declare type IconValue = keyof typeof ICON_VALUES;
|
|
10
4
|
declare type UpdateStepItemsOnValidationClickPayload = {
|
|
11
5
|
stepNumber: number;
|
|
12
6
|
icon: IconValue;
|
|
13
7
|
};
|
|
14
8
|
declare type UpdateStepItemsOnNextClickPayload = {
|
|
15
9
|
stepNumber: number;
|
|
16
|
-
finishedSlides:
|
|
10
|
+
finishedSlides: FinishedSlides;
|
|
17
11
|
current: boolean;
|
|
18
12
|
};
|
|
19
13
|
export declare type UpdateStepItemsOnValidation = {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
1
|
export const UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
|
|
3
2
|
export const UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
|
|
4
|
-
const ICON_VALUES = {
|
|
5
|
-
right: 'right',
|
|
6
|
-
wrong: 'wrong',
|
|
7
|
-
'no-answer': 'no-answer'
|
|
8
|
-
};
|
|
9
3
|
// -----------------------------------------------------------------------------
|
|
10
4
|
export const updateStepItemsOnValidation = (payload) => ({
|
|
11
5
|
type: UPDATE_STEP_ITEMS_ON_VALIDATION,
|
package/es/configure-store.d.ts
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
import { AnyAction, Store } from 'redux';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { NavigationState } from './reducers/ui/navigation';
|
|
6
|
-
import { ReviewStatusState } from './reducers/ui/review-status';
|
|
7
|
-
import { StepItemsState } from './reducers/ui/step-items';
|
|
8
|
-
import { FinishedSlidesState } from './reducers/ui/finished-slides';
|
|
9
|
-
import { ProgressionState } from './reducers/data/progression';
|
|
10
|
-
declare type DataState = {
|
|
11
|
-
isFetching?: boolean;
|
|
12
|
-
progression?: ProgressionState;
|
|
13
|
-
skills: SkillsState;
|
|
14
|
-
slides: SlidesState;
|
|
15
|
-
token?: TokenState;
|
|
16
|
-
};
|
|
17
|
-
export declare type StoreState = {
|
|
18
|
-
ui: {
|
|
19
|
-
navigation: NavigationState;
|
|
20
|
-
stepItems: StepItemsState;
|
|
21
|
-
finishedSlides: FinishedSlidesState;
|
|
22
|
-
reviewStatus: ReviewStatusState;
|
|
23
|
-
};
|
|
24
|
-
data: DataState;
|
|
25
|
-
};
|
|
26
|
-
export default function configureStore(): Store<StoreState, AnyAction>;
|
|
27
|
-
export {};
|
|
2
|
+
import { StoreState } from './reducers';
|
|
3
|
+
import { AppOptions } from './types/common';
|
|
4
|
+
export default function configureStore(options: AppOptions): Store<StoreState, AnyAction>;
|
package/es/configure-store.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { applyMiddleware, compose, createStore } from 'redux';
|
|
2
2
|
import thunk from 'redux-thunk';
|
|
3
3
|
import rootReducer from './reducers';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
// -----------------------------------------------------------------------------
|
|
7
|
-
export default function configureStore() {
|
|
4
|
+
import { getServices } from './services';
|
|
5
|
+
export default function configureStore(options) {
|
|
8
6
|
const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
9
7
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
10
8
|
name: 'app-review',
|
|
@@ -12,7 +10,8 @@ export default function configureStore() {
|
|
|
12
10
|
traceLimit: 25
|
|
13
11
|
})
|
|
14
12
|
: compose;
|
|
15
|
-
const
|
|
13
|
+
const thunkMiddleware = thunk.withExtraArgument({ services: options.services || getServices() });
|
|
14
|
+
const enhancer = _compose(applyMiddleware(thunkMiddleware));
|
|
16
15
|
const store = createStore(rootReducer, undefined, enhancer);
|
|
17
16
|
return store;
|
|
18
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const slide:
|
|
1
|
+
import { UISlide } from '../types/slides';
|
|
2
|
+
export declare const slide: UISlide;
|
package/es/index.js
CHANGED
|
@@ -5,10 +5,14 @@ import { TemplateContext } from '@coorpacademy/components/es/template/app-review
|
|
|
5
5
|
import configureStore from './configure-store';
|
|
6
6
|
import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
|
|
7
7
|
import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
|
|
8
|
-
import { navigateTo, navigateBack
|
|
8
|
+
import { navigateTo, navigateBack } from './actions/ui/navigation';
|
|
9
|
+
import { storeToken } from './actions/data/token';
|
|
9
10
|
import { updateFinishedSlides } from './actions/ui/finished-slides';
|
|
10
11
|
import { updateReviewStatus } from './actions/ui/review-status';
|
|
11
12
|
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui/step-items';
|
|
13
|
+
import { fetchSkills } from './actions/api/fetch-skills';
|
|
14
|
+
import { postProgression } from './actions/api/post-progression';
|
|
15
|
+
import { VIEWS } from './common';
|
|
12
16
|
// -----------------------------------------------------------------------------
|
|
13
17
|
const mapDispatchToProps = {
|
|
14
18
|
navigateTo,
|
|
@@ -77,31 +81,46 @@ const mapStateToSlidesProps = (state) => {
|
|
|
77
81
|
};
|
|
78
82
|
};
|
|
79
83
|
// -----------------------------------------------------------------------------
|
|
80
|
-
const mapStateToProps = (state) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
const mapStateToProps = (state) => {
|
|
85
|
+
return {
|
|
86
|
+
viewName: getCurrentViewName(state),
|
|
87
|
+
slides: mapStateToSlidesProps(state),
|
|
88
|
+
skills: mapStateToSkillsProps(state)
|
|
89
|
+
};
|
|
90
|
+
};
|
|
85
91
|
// Props = StaticProps && Dispatchers
|
|
86
92
|
const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
87
93
|
// -----------------------------------------------------------------------------
|
|
88
94
|
const AppReview = ({ options }) => {
|
|
89
95
|
const [store, setStore] = useState(null);
|
|
90
|
-
const [appStarted, setAppStarted] = useState(false);
|
|
91
96
|
useEffect(() => {
|
|
92
|
-
if (store)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
if (store)
|
|
98
|
+
return;
|
|
99
|
+
const newStore = configureStore(options);
|
|
100
|
+
setStore(newStore);
|
|
101
|
+
}, [options, store]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (store === null)
|
|
104
|
+
return;
|
|
105
|
+
const { skillRef } = options;
|
|
106
|
+
const initialView = skillRef ? VIEWS.slides : VIEWS.skills;
|
|
107
|
+
store.dispatch(navigateTo(initialView));
|
|
108
|
+
}, [options, store]);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (store === null)
|
|
111
|
+
return;
|
|
112
|
+
const { token } = options;
|
|
113
|
+
store.dispatch(storeToken(token));
|
|
114
|
+
}, [options, store]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (store === null)
|
|
117
|
+
return;
|
|
118
|
+
const { skillRef, token } = options;
|
|
119
|
+
skillRef
|
|
120
|
+
? store.dispatch(postProgression(skillRef, token))
|
|
121
|
+
: store.dispatch(fetchSkills(token));
|
|
103
122
|
}, [options, store]);
|
|
104
|
-
if (!store
|
|
123
|
+
if (!store)
|
|
105
124
|
return null;
|
|
106
125
|
const { templateContext: values } = options;
|
|
107
126
|
return (React.createElement(Provider, { store: store },
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { ProgressionState } from './progression';
|
|
2
|
+
import { SkillsState } from './skills';
|
|
3
|
+
import { SlidesState } from './slides';
|
|
4
|
+
import { TokenState } from './token';
|
|
5
|
+
export declare type DataState = {
|
|
6
|
+
isFetching?: boolean;
|
|
7
|
+
progression?: ProgressionState;
|
|
8
|
+
skills: SkillsState;
|
|
9
|
+
slides: SlidesState;
|
|
10
|
+
token?: TokenState;
|
|
11
|
+
};
|
|
1
12
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
-
progression:
|
|
3
|
-
skills:
|
|
4
|
-
slides:
|
|
5
|
-
token:
|
|
6
|
-
}>, import("../../actions/data/
|
|
13
|
+
progression: ProgressionState;
|
|
14
|
+
skills: SkillsState;
|
|
15
|
+
slides: SlidesState;
|
|
16
|
+
token: TokenState;
|
|
17
|
+
}>, import("../../actions/data/slides").ValidateSlide | import("../../actions/data/slides").SlidesAction | import("../../actions/api/post-progression").ReceiveProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("../../actions/data/token").StoreToken>;
|
|
7
18
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReceiveProgression } from '../../actions/data/progression';
|
|
2
1
|
import { ValidateSlide } from '../../actions/data/slides';
|
|
2
|
+
import { ReceiveProgression } from '../../actions/api/post-progression';
|
|
3
3
|
export declare type ProgressionState = {
|
|
4
4
|
_id?: string;
|
|
5
5
|
state: {
|
|
@@ -15,6 +15,5 @@ export declare type ProgressionState = {
|
|
|
15
15
|
};
|
|
16
16
|
slideNumber?: number;
|
|
17
17
|
} | null;
|
|
18
|
-
export declare const initialState: ProgressionState;
|
|
19
18
|
declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
|
|
20
19
|
export default reducer;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { getOr } from 'lodash/fp';
|
|
2
|
-
import { RECEIVE_PROGRESSION } from '../../actions/data/progression';
|
|
3
2
|
import { VALIDATE_SLIDE } from '../../actions/data/slides';
|
|
4
|
-
|
|
5
|
-
export const initialState = null;
|
|
6
|
-
// -----------------------------------------------------------------------------
|
|
3
|
+
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
7
4
|
const reducer = (
|
|
8
5
|
// eslint-disable-next-line default-param-last
|
|
9
|
-
state =
|
|
6
|
+
state = null, action) => {
|
|
10
7
|
switch (action.type) {
|
|
11
8
|
case VALIDATE_SLIDE: {
|
|
12
9
|
const previousSlideNumber = getOr(-1, 'slideNumber', state);
|
|
@@ -29,8 +26,8 @@ state = initialState, action) => {
|
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
28
|
}
|
|
32
|
-
case
|
|
33
|
-
const
|
|
29
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
30
|
+
const progression = action.payload;
|
|
34
31
|
return progression;
|
|
35
32
|
}
|
|
36
33
|
default:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare type SkillsState =
|
|
4
|
-
|
|
5
|
-
declare const reducer: (state: Skills | undefined, action: ReceivedSkills) => Skills;
|
|
1
|
+
import { Skill } from '../../types/common';
|
|
2
|
+
import { ReceivedSkills } from '../../actions/api/fetch-skills';
|
|
3
|
+
export declare type SkillsState = Skill[];
|
|
4
|
+
declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
|
|
6
5
|
export default reducer;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const initialState = [];
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
1
|
+
import { SKILLS_FETCH_SUCCESS } from '../../actions/api/fetch-skills';
|
|
4
2
|
// eslint-disable-next-line default-param-last
|
|
5
|
-
const reducer = (state =
|
|
3
|
+
const reducer = (state = [], action) => {
|
|
6
4
|
switch (action.type) {
|
|
7
|
-
case
|
|
5
|
+
case SKILLS_FETCH_SUCCESS:
|
|
8
6
|
return action.payload;
|
|
9
7
|
default:
|
|
10
8
|
return state;
|
|
11
9
|
}
|
|
12
10
|
};
|
|
13
|
-
// -----------------------------------------------------------------------------
|
|
14
11
|
export default reducer;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import map from 'lodash/fp/map';
|
|
2
|
-
import {
|
|
2
|
+
import { UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../../actions/data/slides';
|
|
3
3
|
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
|
|
4
4
|
import { slide as qcmSlide } from '../../fixtures/qcm-slide';
|
|
5
|
-
|
|
5
|
+
import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
6
6
|
const getInitialState = () => {
|
|
7
7
|
const state = {
|
|
8
8
|
slideNumbers
|
|
@@ -97,7 +97,7 @@ const stateUpdateOnNext = (state, payload) => {
|
|
|
97
97
|
// eslint-disable-next-line default-param-last
|
|
98
98
|
const reducer = (state = initialState, action) => {
|
|
99
99
|
switch (action.type) {
|
|
100
|
-
case
|
|
100
|
+
case SLIDE_FETCH_SUCCESS: {
|
|
101
101
|
// TODO: An intermediate slide transform is needed here (or in fetchSlide)
|
|
102
102
|
// const apiSlide = action.payload;
|
|
103
103
|
// apiSlide adapt to uiSlide
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { STORE_TOKEN } from '../../actions/data/token';
|
|
2
|
-
// -----------------------------------------------------------------------------
|
|
3
|
-
export const initialState = null;
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
2
|
// eslint-disable-next-line default-param-last
|
|
6
|
-
const reducer = (state =
|
|
3
|
+
const reducer = (state = null, action) => {
|
|
7
4
|
switch (action.type) {
|
|
8
5
|
case STORE_TOKEN:
|
|
9
6
|
return action.payload;
|
|
@@ -11,5 +8,4 @@ const reducer = (state = initialState, action) => {
|
|
|
11
8
|
return state;
|
|
12
9
|
}
|
|
13
10
|
};
|
|
14
|
-
// -----------------------------------------------------------------------------
|
|
15
11
|
export default reducer;
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { DataState } from './data';
|
|
2
|
+
import { UIState } from './ui';
|
|
3
|
+
export declare type StoreState = {
|
|
4
|
+
ui: UIState;
|
|
5
|
+
data: DataState;
|
|
6
|
+
};
|
|
1
7
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
8
|
data: import("redux").CombinedState<{
|
|
3
9
|
progression: import("./data/progression").ProgressionState;
|
|
4
|
-
skills: import("
|
|
10
|
+
skills: import("./data/skills").SkillsState;
|
|
5
11
|
slides: import("./data/slides").SlidesState;
|
|
6
12
|
token: import("./data/token").TokenState;
|
|
7
13
|
}>;
|
|
@@ -9,7 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
9
15
|
finishedSlides: import("./ui/finished-slides").FinishedSlidesState;
|
|
10
16
|
navigation: import("./ui/navigation").NavigationState;
|
|
11
17
|
reviewStatus: import("./ui/review-status").ReviewStatusState;
|
|
12
|
-
stepItems: import("./ui/step-items").
|
|
18
|
+
stepItems: import("./ui/step-items").StepItemsState;
|
|
13
19
|
}>;
|
|
14
|
-
}>, import("../actions/data/
|
|
20
|
+
}>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("../actions/data/token").StoreToken | import("../actions/ui/finished-slides").UpdateFinishedSlides | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/review-status").UpdateReviewStatus | import("../actions/ui/step-items").StepItemsAction>;
|
|
15
21
|
export default _default;
|
|
@@ -3,6 +3,5 @@ export declare type FinishedSlidesState = {
|
|
|
3
3
|
slideNumbers: number[];
|
|
4
4
|
[key: number]: true;
|
|
5
5
|
};
|
|
6
|
-
export declare const initialState: FinishedSlidesState;
|
|
7
6
|
declare const reducer: (state: FinishedSlidesState | undefined, action: UpdateFinishedSlides) => FinishedSlidesState;
|
|
8
7
|
export default reducer;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import forEach from 'lodash/fp/forEach';
|
|
2
2
|
import { UPDATE_FINISHED_SLIDES } from '../../actions/ui/finished-slides';
|
|
3
3
|
import { slideNumbers } from '../../common';
|
|
4
|
-
|
|
5
|
-
export const initialState = {
|
|
4
|
+
const initialState = {
|
|
6
5
|
slideNumbers
|
|
7
6
|
};
|
|
8
|
-
// -----------------------------------------------------------------------------
|
|
9
7
|
const _forEach = forEach.convert({
|
|
10
8
|
cap: false
|
|
11
9
|
});
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { FinishedSlidesState } from './finished-slides';
|
|
2
|
+
import { NavigationState } from './navigation';
|
|
3
|
+
import { ReviewStatusState } from './review-status';
|
|
4
|
+
import { StepItemsState } from './step-items';
|
|
5
|
+
export declare type UIState = {
|
|
6
|
+
navigation: NavigationState;
|
|
7
|
+
stepItems: StepItemsState;
|
|
8
|
+
finishedSlides: FinishedSlidesState;
|
|
9
|
+
reviewStatus: ReviewStatusState;
|
|
10
|
+
};
|
|
1
11
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
-
finishedSlides:
|
|
3
|
-
navigation:
|
|
4
|
-
reviewStatus:
|
|
5
|
-
stepItems:
|
|
12
|
+
finishedSlides: FinishedSlidesState;
|
|
13
|
+
navigation: NavigationState;
|
|
14
|
+
reviewStatus: ReviewStatusState;
|
|
15
|
+
stepItems: StepItemsState;
|
|
6
16
|
}>, import("../../actions/ui/finished-slides").UpdateFinishedSlides | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/review-status").UpdateReviewStatus | import("../../actions/ui/step-items").StepItemsAction>;
|
|
7
17
|
export default _default;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
|
|
2
2
|
export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides'>;
|
|
3
|
-
export declare const initialState: NavigationState;
|
|
4
3
|
declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
|
|
5
4
|
export default reducer;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { NAVIGATE_BACK, NAVIGATE_TO } from '../../actions/ui/navigation';
|
|
2
|
-
export const initialState = [];
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
2
|
const reducer = (
|
|
5
3
|
// eslint-disable-next-line default-param-last
|
|
6
|
-
state =
|
|
4
|
+
state = [], action) => {
|
|
7
5
|
switch (action.type) {
|
|
8
6
|
case NAVIGATE_TO: {
|
|
9
7
|
return [...state, action.payload];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UpdateReviewStatus } from '../../actions/ui/review-status';
|
|
2
2
|
export declare type ReviewStatusState = 'finished' | 'ongoing';
|
|
3
|
-
export declare const initialState: ReviewStatusState;
|
|
4
3
|
declare const reducer: (state: ReviewStatusState | undefined, action: UpdateReviewStatus) => ReviewStatusState;
|
|
5
4
|
export default reducer;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { UPDATE_REVIEW_STATUS } from '../../actions/ui/review-status';
|
|
2
|
-
export const initialState = 'ongoing';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
2
|
const reducer = (
|
|
5
3
|
// eslint-disable-next-line default-param-last
|
|
6
|
-
state =
|
|
4
|
+
state = 'ongoing', action) => {
|
|
7
5
|
switch (action.type) {
|
|
8
6
|
case UPDATE_REVIEW_STATUS: {
|
|
9
7
|
return action.payload;
|
|
@@ -12,5 +10,4 @@ state = initialState, action) => {
|
|
|
12
10
|
return state;
|
|
13
11
|
}
|
|
14
12
|
};
|
|
15
|
-
// -----------------------------------------------------------------------------
|
|
16
13
|
export default reducer;
|