@coorpacademy/app-review 0.1.5 → 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 +7 -24
- package/es/actions/data/slides.js +0 -6
- package/es/actions/data/token.d.ts +2 -2
- package/es/actions/data/token.js +1 -1
- package/es/actions/index.d.ts +5 -3
- 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 -34
- package/es/configure-store.js +4 -4
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +78 -42
- package/es/reducers/data/index.d.ts +16 -5
- package/es/reducers/data/progression.d.ts +14 -9
- package/es/reducers/data/progression.js +18 -58
- 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 +14 -9
- 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 +3 -16
- package/es/services/fetch-slide.d.ts +2 -0
- package/es/services/fetch-slide.js +11 -0
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +8 -0
- package/es/services/post-progression.d.ts +2 -0
- package/es/services/post-progression.js +21 -0
- package/es/services/test/fetch-skills.test.js +29 -0
- package/es/services/test/post-progression.test.js +35 -0
- package/es/services/tools/fetch-responses.d.ts +1 -1
- package/es/services/tools/sleep.d.ts +1 -0
- package/es/services/tools/sleep.js +3 -0
- package/es/{index.test.js → test/index.test.js} +18 -7
- 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 +66 -2
- package/es/types/common.js +5 -0
- package/es/types/slides.d.ts +1 -1
- package/es/types/ui-progression.d.ts +10 -0
- 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 +7 -24
- package/lib/actions/data/slides.js +0 -6
- package/lib/actions/data/token.d.ts +2 -2
- package/lib/actions/data/token.js +1 -1
- package/lib/actions/index.d.ts +5 -3
- 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 -34
- package/lib/configure-store.js +4 -4
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +78 -86
- package/lib/reducers/data/index.d.ts +16 -5
- package/lib/reducers/data/progression.d.ts +14 -9
- package/lib/reducers/data/progression.js +18 -58
- 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 +14 -9
- 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 +5 -20
- package/lib/services/fetch-slide.d.ts +2 -0
- package/lib/services/fetch-slide.js +57 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +8 -0
- package/lib/services/post-progression.d.ts +2 -0
- package/lib/services/post-progression.js +65 -0
- package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
- package/lib/services/test/post-progression.test.js +89 -0
- package/lib/services/tools/fetch-responses.d.ts +1 -1
- package/lib/services/tools/sleep.d.ts +1 -0
- package/lib/services/tools/sleep.js +5 -0
- package/lib/test/index.test.d.ts +1 -0
- package/lib/{index.test.js → test/index.test.js} +23 -15
- 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 +66 -2
- package/lib/types/common.js +5 -0
- package/lib/types/slides.d.ts +1 -1
- package/lib/types/ui-progression.d.ts +10 -0
- package/lib/types/ui-progression.js +1 -0
- package/lib/types/views/slides.d.ts +1 -1
- package/package.json +6 -5
- package/readme.md +4 -5
- 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 +8 -32
- package/src/actions/data/token.ts +2 -2
- package/src/actions/index.ts +7 -10
- package/src/actions/ui/navigation.ts +0 -5
- package/src/actions/ui/step-items.ts +2 -14
- package/src/configure-store.ts +6 -45
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/index.tsx +94 -45
- package/src/reducers/data/index.ts +12 -4
- package/src/reducers/data/progression.ts +34 -79
- package/src/reducers/data/skills.ts +5 -10
- package/src/reducers/data/slides.ts +16 -15
- 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 -30
- package/src/services/fetch-slide.ts +15 -0
- package/src/services/index.ts +10 -0
- package/src/services/post-progression.ts +28 -0
- package/src/services/test/fetch-skills.test.ts +39 -0
- package/src/services/test/post-progression.test.ts +45 -0
- package/src/services/tools/fetch-responses.ts +1 -1
- package/src/services/tools/sleep.ts +4 -0
- package/src/{index.test.tsx → test/index.test.tsx} +16 -10
- package/src/test/util/services.mock.ts +70 -0
- package/src/types/common.ts +78 -2
- package/src/types/globals.d.ts +2 -0
- package/src/types/slides.ts +1 -1
- package/src/types/ui-progression.ts +25 -0
- package/src/types/views/slides.ts +1 -1
- package/es/actions/data/skills.d.ts +0 -13
- package/es/actions/data/skills.js +0 -10
- package/es/middlewares/on-start-app.d.ts +0 -5
- package/es/middlewares/on-start-app.js +0 -29
- 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/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/lib/actions/data/skills.d.ts +0 -13
- package/lib/actions/data/skills.js +0 -10
- package/lib/middlewares/on-start-app.d.ts +0 -5
- package/lib/middlewares/on-start-app.js +0 -34
- package/lib/services/fetch-skills.mock.d.ts +0 -3
- package/lib/services/fetch-skills.mock.js +0 -17
- 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/src/actions/data/skills.ts +0 -24
- package/src/middlewares/on-start-app.ts +0 -42
- package/src/services/fetch-skills.mock.ts +0 -21
- package/src/services/fetch-skills.test.ts +0 -32
- 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/{index.test.d.ts → services/test/post-progression.test.d.ts} +0 -0
- /package/{lib → es/test}/index.test.d.ts +0 -0
- /package/es/types/{skills.js → ui-progression.js} +0 -0
- /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/lib/{types/skills.js → services/test/post-progression.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,36 +1,24 @@
|
|
|
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
6
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
8
|
-
export declare type Slide =
|
|
7
|
+
export declare type Slide = UISlide & {
|
|
9
8
|
hidden?: boolean;
|
|
10
9
|
position: number;
|
|
11
10
|
animationType?: SlideUIAnimations;
|
|
12
11
|
isCorrect?: boolean;
|
|
13
12
|
endReview?: boolean;
|
|
14
|
-
|
|
13
|
+
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
15
14
|
};
|
|
16
15
|
export declare type ValidationPayload = {
|
|
17
16
|
slideNumber: number;
|
|
18
17
|
newSlideContent: Slide;
|
|
19
18
|
numberOfFinishedSlides: number;
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export declare type OnNextPayload = Omit<ValidationPayload, 'nextSlide'>;
|
|
23
|
-
export declare type FetchNextPayload = {
|
|
24
|
-
answer: string[];
|
|
25
|
-
content: {
|
|
26
|
-
ref: string;
|
|
27
|
-
type: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export declare type StoreFirstSlide = {
|
|
31
|
-
type: typeof STORE_FIRST_SLIDE;
|
|
32
|
-
payload: SlideFromAPI;
|
|
19
|
+
nextContent: Slide;
|
|
33
20
|
};
|
|
21
|
+
export declare type OnNextPayload = Omit<ValidationPayload, 'nextContent'>;
|
|
34
22
|
export declare type UpdateSlidesOnValidation = {
|
|
35
23
|
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
36
24
|
payload: ValidationPayload;
|
|
@@ -42,12 +30,7 @@ export declare type UpdateSlidesOnNext = {
|
|
|
42
30
|
export declare type ValidateSlide = {
|
|
43
31
|
type: typeof VALIDATE_SLIDE;
|
|
44
32
|
};
|
|
45
|
-
export declare type
|
|
46
|
-
type: typeof FETCH_NEXT_CONTENT;
|
|
47
|
-
payload: FetchNextPayload;
|
|
48
|
-
};
|
|
49
|
-
export declare type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
50
|
-
export declare const storeFirstSlide: (slide: SlideFromAPI) => StoreFirstSlide;
|
|
33
|
+
export declare type SlidesAction = ReceivedSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
51
34
|
export declare const updateSlidesOnValidation: (payload: ValidationPayload) => UpdateSlidesOnValidation;
|
|
52
35
|
export declare const updateSlidesOnNext: (payload: OnNextPayload) => UpdateSlidesOnNext;
|
|
53
36
|
export declare const validateSlide: () => ValidateSlide;
|
|
@@ -1,14 +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
5
|
// -----------------------------------------------------------------------------
|
|
8
|
-
export const storeFirstSlide = (slide) => ({
|
|
9
|
-
type: STORE_FIRST_SLIDE,
|
|
10
|
-
payload: slide
|
|
11
|
-
});
|
|
12
6
|
export const updateSlidesOnValidation = (payload) => ({
|
|
13
7
|
type: UPDATE_SLIDES_ON_VALIDATION,
|
|
14
8
|
payload
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const STORE_TOKEN = "@@token/STORE_TOKEN";
|
|
1
|
+
export declare const STORE_TOKEN = "@@data/token/STORE_TOKEN";
|
|
2
2
|
export declare type StoreToken = {
|
|
3
|
-
type:
|
|
3
|
+
type: typeof STORE_TOKEN;
|
|
4
4
|
payload: string;
|
|
5
5
|
};
|
|
6
6
|
export declare const storeToken: (token: string) => StoreToken;
|
package/es/actions/data/token.js
CHANGED
package/es/actions/index.d.ts
CHANGED
|
@@ -1,11 +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
|
-
|
|
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;
|
|
9
11
|
export declare type Dispatchers = {
|
|
10
12
|
navigateTo: typeof navigateTo;
|
|
11
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,35 +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 { AnswerUI } from './types/slides';
|
|
10
|
-
declare type DataState = {
|
|
11
|
-
isFetching?: boolean;
|
|
12
|
-
progression?: {
|
|
13
|
-
slideNumber: number;
|
|
14
|
-
isCorrect?: boolean;
|
|
15
|
-
exitNode?: 'successExitNode' | 'failExitNode';
|
|
16
|
-
nextSlide?: {
|
|
17
|
-
questionText?: string;
|
|
18
|
-
answerUI?: AnswerUI;
|
|
19
|
-
};
|
|
20
|
-
} | null;
|
|
21
|
-
skills: SkillsState;
|
|
22
|
-
slides: SlidesState;
|
|
23
|
-
token?: TokenState;
|
|
24
|
-
};
|
|
25
|
-
export declare type StoreState = {
|
|
26
|
-
ui: {
|
|
27
|
-
navigation: NavigationState;
|
|
28
|
-
stepItems: StepItemsState;
|
|
29
|
-
finishedSlides: FinishedSlidesState;
|
|
30
|
-
reviewStatus: ReviewStatusState;
|
|
31
|
-
};
|
|
32
|
-
data: DataState;
|
|
33
|
-
};
|
|
34
|
-
export default function configureStore(): Store<StoreState, AnyAction>;
|
|
35
|
-
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,9 +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
|
-
export default function configureStore() {
|
|
4
|
+
import { getServices } from './services';
|
|
5
|
+
export default function configureStore(options) {
|
|
7
6
|
const _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
8
7
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
|
9
8
|
name: 'app-review',
|
|
@@ -11,7 +10,8 @@ export default function configureStore() {
|
|
|
11
10
|
traceLimit: 25
|
|
12
11
|
})
|
|
13
12
|
: compose;
|
|
14
|
-
const
|
|
13
|
+
const thunkMiddleware = thunk.withExtraArgument({ services: options.services || getServices() });
|
|
14
|
+
const enhancer = _compose(applyMiddleware(thunkMiddleware));
|
|
15
15
|
const store = createStore(rootReducer, undefined, enhancer);
|
|
16
16
|
return store;
|
|
17
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.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { connect, Provider } from 'react-redux';
|
|
3
3
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
4
|
+
import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
|
|
4
5
|
import configureStore from './configure-store';
|
|
5
6
|
import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
|
|
6
7
|
import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
|
|
7
|
-
import { navigateTo, navigateBack
|
|
8
|
+
import { navigateTo, navigateBack } from './actions/ui/navigation';
|
|
9
|
+
import { storeToken } from './actions/data/token';
|
|
8
10
|
import { updateFinishedSlides } from './actions/ui/finished-slides';
|
|
9
11
|
import { updateReviewStatus } from './actions/ui/review-status';
|
|
10
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';
|
|
11
16
|
// -----------------------------------------------------------------------------
|
|
12
17
|
const mapDispatchToProps = {
|
|
13
18
|
navigateTo,
|
|
@@ -21,29 +26,38 @@ const mapDispatchToProps = {
|
|
|
21
26
|
updateFinishedSlides
|
|
22
27
|
};
|
|
23
28
|
const getCurrentViewName = (storeState) => storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
// -----------------------------------------------------------------------------
|
|
30
|
+
const mapStateToSkillsProps = (state) => {
|
|
31
|
+
if (!state.data.skills) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
title: '@todo title',
|
|
36
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
37
|
+
textNoSkills: '@todo textNoSkills',
|
|
38
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
39
|
+
isLoading: false,
|
|
40
|
+
isLoadingAriaLabel: '@todo loading',
|
|
41
|
+
listSkills: state.data.skills.map(skill => ({
|
|
42
|
+
'aria-label': '',
|
|
43
|
+
isCustom: skill.custom,
|
|
44
|
+
skillTitle: skill.name,
|
|
45
|
+
skillAriaLabel: '@todo skill aria label',
|
|
46
|
+
buttonLabel: '@todo button',
|
|
47
|
+
buttonAriaLabel: '@todo button aria label',
|
|
48
|
+
reviseLabel: '@todo revise',
|
|
49
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
// -----------------------------------------------------------------------------
|
|
56
|
+
const mapStateToSlidesProps = (state) => {
|
|
57
|
+
if (!state.data.slides) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
47
61
|
headerProps: {
|
|
48
62
|
mode: '__revision_mode',
|
|
49
63
|
skillName: '__agility',
|
|
@@ -64,32 +78,54 @@ const mapStateToProps = (state) => ({
|
|
|
64
78
|
correctionPopinProps,
|
|
65
79
|
congratsProps,
|
|
66
80
|
progression: state.data.progression
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
// -----------------------------------------------------------------------------
|
|
84
|
+
const mapStateToProps = (state) => {
|
|
85
|
+
return {
|
|
86
|
+
viewName: getCurrentViewName(state),
|
|
87
|
+
slides: mapStateToSlidesProps(state),
|
|
88
|
+
skills: mapStateToSkillsProps(state)
|
|
89
|
+
};
|
|
90
|
+
};
|
|
70
91
|
// Props = StaticProps && Dispatchers
|
|
71
92
|
const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
72
93
|
// -----------------------------------------------------------------------------
|
|
73
94
|
const AppReview = ({ options }) => {
|
|
74
95
|
const [store, setStore] = useState(null);
|
|
75
|
-
const [appStarted, setAppStarted] = useState(false);
|
|
76
96
|
useEffect(() => {
|
|
77
|
-
if (store)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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));
|
|
88
122
|
}, [options, store]);
|
|
89
|
-
if (!store
|
|
90
|
-
return
|
|
123
|
+
if (!store)
|
|
124
|
+
return null;
|
|
125
|
+
const { templateContext: values } = options;
|
|
91
126
|
return (React.createElement(Provider, { store: store },
|
|
92
|
-
React.createElement(
|
|
127
|
+
React.createElement(TemplateContext, { values: values },
|
|
128
|
+
React.createElement(App, null))));
|
|
93
129
|
};
|
|
94
130
|
// -----------------------------------------------------------------------------
|
|
95
131
|
export default AppReview;
|
|
@@ -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/slides").ValidateSlide | import("../../actions/data/slides").SlidesAction | import("../../actions/
|
|
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,14 +1,19 @@
|
|
|
1
1
|
import { ValidateSlide } from '../../actions/data/slides';
|
|
2
|
-
import {
|
|
2
|
+
import { ReceiveProgression } from '../../actions/api/post-progression';
|
|
3
3
|
export declare type ProgressionState = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
_id?: string;
|
|
5
|
+
state: {
|
|
6
|
+
isCorrect: boolean;
|
|
7
|
+
nextContent: {
|
|
8
|
+
ref: 'successExitNode' | string;
|
|
9
|
+
type: 'success' | 'slide';
|
|
10
|
+
};
|
|
11
|
+
pendingSlides: string[];
|
|
12
|
+
step: {
|
|
13
|
+
current: number;
|
|
14
|
+
};
|
|
10
15
|
};
|
|
16
|
+
slideNumber?: number;
|
|
11
17
|
} | null;
|
|
12
|
-
|
|
13
|
-
declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide) => ProgressionState;
|
|
18
|
+
declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
|
|
14
19
|
export default reducer;
|
|
@@ -1,75 +1,35 @@
|
|
|
1
|
-
import { getOr
|
|
1
|
+
import { getOr } from 'lodash/fp';
|
|
2
2
|
import { VALIDATE_SLIDE } from '../../actions/data/slides';
|
|
3
|
-
|
|
4
|
-
export const initialState = null;
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
3
|
+
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
6
4
|
const reducer = (
|
|
7
5
|
// eslint-disable-next-line default-param-last
|
|
8
|
-
state =
|
|
6
|
+
state = null, action) => {
|
|
9
7
|
switch (action.type) {
|
|
10
8
|
case VALIDATE_SLIDE: {
|
|
11
9
|
const previousSlideNumber = getOr(-1, 'slideNumber', state);
|
|
12
10
|
// hard coded for now
|
|
11
|
+
// TODO: fix on VALIDATE ticket
|
|
13
12
|
return {
|
|
13
|
+
_id: '1234',
|
|
14
14
|
// virtual field
|
|
15
15
|
slideNumber: previousSlideNumber + 1,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
questionText: 'Test',
|
|
26
|
-
answerUI: {
|
|
27
|
-
model: {
|
|
28
|
-
answers: [
|
|
29
|
-
{
|
|
30
|
-
title: 'There is no need for a password',
|
|
31
|
-
// TODO: onClick of each answer should use a dispatcher to
|
|
32
|
-
// update selected answers (in order to use them on validation)
|
|
33
|
-
// in each retrieval, the answers of answerUI need to be augmented
|
|
34
|
-
// for the onClick prop to achieve this.
|
|
35
|
-
onClick: noop,
|
|
36
|
-
selected: false,
|
|
37
|
-
help: 'help'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
title: 'Lorem ipsum',
|
|
41
|
-
onClick: noop,
|
|
42
|
-
selected: false,
|
|
43
|
-
help: 'help'
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
title: 'Lorem',
|
|
47
|
-
onClick: noop,
|
|
48
|
-
selected: true,
|
|
49
|
-
order: 1,
|
|
50
|
-
help: 'help'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: 'You need to have a password',
|
|
54
|
-
onClick: noop,
|
|
55
|
-
selected: false,
|
|
56
|
-
help: 'help'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
title: 'Pouet',
|
|
60
|
-
onClick: noop,
|
|
61
|
-
selected: true,
|
|
62
|
-
order: 0,
|
|
63
|
-
help: 'help'
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
type: 'qcmDrag'
|
|
67
|
-
},
|
|
68
|
-
help: 'Help text will appear here'
|
|
16
|
+
state: {
|
|
17
|
+
pendingSlides: [],
|
|
18
|
+
step: {
|
|
19
|
+
current: Number.NaN
|
|
20
|
+
},
|
|
21
|
+
isCorrect: true,
|
|
22
|
+
nextContent: {
|
|
23
|
+
ref: 'sli_V1gKpYYZ2',
|
|
24
|
+
type: 'slide'
|
|
69
25
|
}
|
|
70
26
|
}
|
|
71
27
|
};
|
|
72
28
|
}
|
|
29
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
30
|
+
const progression = action.payload;
|
|
31
|
+
return progression;
|
|
32
|
+
}
|
|
73
33
|
default:
|
|
74
34
|
return state;
|
|
75
35
|
}
|
|
@@ -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;
|