@coorpacademy/app-review 0.7.5-alpha.32 → 0.7.6-alpha.24
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 +2 -2
- package/es/actions/api/post-progression.d.ts +3 -0
- package/es/index.js +7 -5
- package/es/reducers/data/corrections.d.ts +2 -1
- package/es/reducers/data/corrections.js +4 -0
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -2
- package/es/reducers/data/progression.js +6 -2
- package/es/reducers/data/rank.d.ts +2 -2
- package/es/reducers/data/rank.js +2 -2
- package/es/reducers/data/skills.d.ts +2 -2
- package/es/reducers/data/skills.js +3 -1
- package/es/reducers/data/slides.d.ts +2 -1
- package/es/reducers/data/slides.js +6 -1
- package/es/reducers/index.d.ts +1 -1
- package/es/reducers/ui/answers.d.ts +2 -1
- package/es/reducers/ui/answers.js +4 -0
- package/es/reducers/ui/current-slide-ref.d.ts +2 -1
- package/es/reducers/ui/current-slide-ref.js +4 -0
- package/es/reducers/ui/index.d.ts +1 -1
- package/es/reducers/ui/positions.d.ts +2 -2
- package/es/reducers/ui/positions.js +4 -1
- package/es/reducers/ui/show-button-revising.d.ts +2 -1
- package/es/reducers/ui/show-button-revising.js +4 -0
- package/es/reducers/ui/show-congrats.d.ts +2 -2
- package/es/reducers/ui/show-congrats.js +2 -2
- package/es/reducers/ui/slide.d.ts +2 -1
- package/es/reducers/ui/slide.js +4 -0
- package/es/services/fetch-skills.d.ts +2 -2
- package/es/types/common.d.ts +5 -5
- package/es/views/slides/index.js +25 -8
- package/lib/actions/api/fetch-skills.d.ts +2 -2
- package/lib/actions/api/post-progression.d.ts +3 -0
- package/lib/index.js +7 -5
- package/lib/reducers/data/corrections.d.ts +2 -1
- package/lib/reducers/data/corrections.js +4 -0
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -2
- package/lib/reducers/data/progression.js +5 -1
- package/lib/reducers/data/rank.d.ts +2 -2
- package/lib/reducers/data/rank.js +1 -1
- package/lib/reducers/data/skills.d.ts +2 -2
- package/lib/reducers/data/skills.js +3 -1
- package/lib/reducers/data/slides.d.ts +2 -1
- package/lib/reducers/data/slides.js +6 -1
- package/lib/reducers/index.d.ts +1 -1
- package/lib/reducers/ui/answers.d.ts +2 -1
- package/lib/reducers/ui/answers.js +4 -0
- package/lib/reducers/ui/current-slide-ref.d.ts +2 -1
- package/lib/reducers/ui/current-slide-ref.js +4 -0
- package/lib/reducers/ui/index.d.ts +1 -1
- package/lib/reducers/ui/positions.d.ts +2 -2
- package/lib/reducers/ui/positions.js +3 -0
- package/lib/reducers/ui/show-button-revising.d.ts +2 -1
- package/lib/reducers/ui/show-button-revising.js +4 -0
- package/lib/reducers/ui/show-congrats.d.ts +2 -2
- package/lib/reducers/ui/show-congrats.js +1 -1
- package/lib/reducers/ui/slide.d.ts +2 -1
- package/lib/reducers/ui/slide.js +4 -0
- package/lib/services/fetch-skills.d.ts +2 -2
- package/lib/types/common.d.ts +5 -5
- package/lib/views/slides/index.js +25 -8
- package/locales/cs/review.json +45 -9
- package/locales/de/review.json +45 -9
- package/locales/es/review.json +44 -8
- package/locales/fr/review.json +44 -8
- package/locales/hr/review.json +45 -9
- package/locales/hu/review.json +44 -8
- package/locales/id/review.json +54 -0
- package/locales/it/review.json +45 -9
- package/locales/ja/review.json +45 -9
- package/locales/ko/review.json +45 -9
- package/locales/nl/review.json +45 -9
- package/locales/pl/review.json +45 -9
- package/locales/pt/review.json +45 -9
- package/locales/ro/review.json +43 -7
- package/locales/ru/review.json +43 -7
- package/locales/sk/review.json +44 -8
- package/locales/th/review.json +54 -0
- package/locales/tl/review.json +45 -9
- package/locales/tr/review.json +43 -7
- package/locales/uk/review.json +44 -8
- package/locales/vi/review.json +45 -9
- package/locales/zh/review.json +44 -8
- package/locales/zh_TW/review.json +45 -9
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
-
import type { ThunkOptions,
|
|
3
|
+
import type { ThunkOptions, SkillToReview } from '../../types/common';
|
|
4
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
5
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
6
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
7
7
|
export declare type ReceivedSkills = {
|
|
8
8
|
type: typeof SKILLS_FETCH_SUCCESS;
|
|
9
|
-
payload:
|
|
9
|
+
payload: SkillToReview[];
|
|
10
10
|
};
|
|
11
11
|
export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => ReceivedSkills;
|
|
@@ -4,6 +4,9 @@ import type { StoreState } from '../../reducers';
|
|
|
4
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
5
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
6
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
7
|
+
export declare type FetchProgression = {
|
|
8
|
+
type: typeof POST_PROGRESSION_REQUEST;
|
|
9
|
+
};
|
|
7
10
|
export declare type ReceivedProgression = {
|
|
8
11
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
9
12
|
payload: ProgressionFromAPI;
|
package/es/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const ConnectedApp = (options) => {
|
|
|
24
24
|
const AppReview = ({ options }) => {
|
|
25
25
|
const [store, setStore] = useState(null);
|
|
26
26
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
27
|
-
const { translate, onQuitClick
|
|
27
|
+
const { translate, onQuitClick } = options;
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
if (store)
|
|
30
30
|
return;
|
|
@@ -49,23 +49,25 @@ const AppReview = ({ options }) => {
|
|
|
49
49
|
const token = get('token', options);
|
|
50
50
|
if (store === null || isEmpty(token))
|
|
51
51
|
return;
|
|
52
|
+
const skillRef = get('skillRef', options);
|
|
52
53
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
53
54
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
54
|
-
|
|
55
|
+
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
55
56
|
}, [options, store]);
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
if (store === null)
|
|
58
59
|
return;
|
|
59
|
-
|
|
60
|
+
const { skillRef } = options;
|
|
61
|
+
if (skillRef && !isProgressionCreated) {
|
|
60
62
|
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
63
|
-
const initialView =
|
|
65
|
+
const initialView = skillRef ? 'slides' : 'skills';
|
|
64
66
|
store.dispatch(navigateTo(initialView));
|
|
65
67
|
}, [isProgressionCreated, options, store]);
|
|
66
68
|
if (!store)
|
|
67
69
|
return null;
|
|
68
70
|
return (React.createElement(Provider, { store: store },
|
|
69
|
-
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate
|
|
71
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
|
|
70
72
|
};
|
|
71
73
|
export default AppReview;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
4
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
4
5
|
export declare type CorrectionsAction = ReceivedCorrection | FetchCorrection;
|
|
5
|
-
declare const reducer: (state: CorrectionsState | undefined, action: CorrectionsAction) => CorrectionsState;
|
|
6
|
+
declare const reducer: (state: CorrectionsState | undefined, action: CorrectionsAction | FetchProgression) => CorrectionsState;
|
|
6
7
|
export default reducer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import set from 'lodash/fp/set';
|
|
2
2
|
import { CORRECTION_FETCH_SUCCESS, CORRECTION_FETCH_REQUEST } from '../../actions/api/fetch-correction';
|
|
3
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
3
4
|
const initialState = {};
|
|
4
5
|
const reducer = (
|
|
5
6
|
// eslint-disable-next-line default-param-last
|
|
@@ -14,6 +15,9 @@ state = initialState, action) => {
|
|
|
14
15
|
const correction = action.payload;
|
|
15
16
|
return set([meta.slideRef], correction, state);
|
|
16
17
|
}
|
|
18
|
+
case POST_PROGRESSION_REQUEST: {
|
|
19
|
+
return initialState;
|
|
20
|
+
}
|
|
17
21
|
default:
|
|
18
22
|
return state;
|
|
19
23
|
}
|
|
@@ -19,5 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
19
19
|
slides: SlidesState;
|
|
20
20
|
token: string;
|
|
21
21
|
rank: RankState;
|
|
22
|
-
}>, import("
|
|
22
|
+
}>, import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
23
23
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
|
|
2
|
-
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
2
|
+
import { FetchProgression, ReceivedProgression } from '../../actions/api/post-progression';
|
|
3
3
|
import { ProgressionFromAPI } from '../../types/common';
|
|
4
4
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
5
|
-
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction) => ProgressionState;
|
|
5
|
+
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction | FetchProgression) => ProgressionState;
|
|
6
6
|
export default reducer;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { POST_ANSWER_SUCCESS } from '../../actions/api/post-answer';
|
|
2
|
-
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
2
|
+
import { POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
3
|
+
const initialState = null;
|
|
3
4
|
const reducer = (
|
|
4
5
|
// eslint-disable-next-line default-param-last
|
|
5
|
-
state =
|
|
6
|
+
state = initialState, action) => {
|
|
6
7
|
switch (action.type) {
|
|
7
8
|
case POST_ANSWER_SUCCESS:
|
|
8
9
|
case POST_PROGRESSION_SUCCESS: {
|
|
9
10
|
const progression = action.payload;
|
|
10
11
|
return progression;
|
|
11
12
|
}
|
|
13
|
+
case POST_PROGRESSION_REQUEST: {
|
|
14
|
+
return initialState;
|
|
15
|
+
}
|
|
12
16
|
default:
|
|
13
17
|
return state;
|
|
14
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FetchProgression } from '../../actions/api/post-progression';
|
|
2
2
|
import { RankAction } from '../../actions/api/fetch-rank';
|
|
3
3
|
export declare type RankState = {
|
|
4
4
|
start: number;
|
|
5
5
|
end: number;
|
|
6
6
|
};
|
|
7
|
-
declare const reducer: (state: RankState | undefined, action: RankAction |
|
|
7
|
+
declare const reducer: (state: RankState | undefined, action: RankAction | FetchProgression) => RankState;
|
|
8
8
|
export default reducer;
|
package/es/reducers/data/rank.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import set from 'lodash/fp/set';
|
|
2
|
-
import {
|
|
2
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
3
3
|
import { RANK_FETCH_START_SUCCESS, RANK_FETCH_END_SUCCESS } from '../../actions/api/fetch-rank';
|
|
4
4
|
const initialState = {
|
|
5
5
|
start: Number.NaN,
|
|
@@ -9,7 +9,7 @@ const reducer = (
|
|
|
9
9
|
// eslint-disable-next-line default-param-last
|
|
10
10
|
state = initialState, action) => {
|
|
11
11
|
switch (action.type) {
|
|
12
|
-
case
|
|
12
|
+
case POST_PROGRESSION_REQUEST: {
|
|
13
13
|
return initialState;
|
|
14
14
|
}
|
|
15
15
|
case RANK_FETCH_START_SUCCESS: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SkillToReview } from '../../types/common';
|
|
2
2
|
import { ReceivedSkills } from '../../actions/api/fetch-skills';
|
|
3
|
-
export declare type SkillsState =
|
|
3
|
+
export declare type SkillsState = SkillToReview[];
|
|
4
4
|
declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
|
|
5
5
|
export default reducer;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SKILLS_FETCH_SUCCESS } from '../../actions/api/fetch-skills';
|
|
2
|
+
const initialState = [];
|
|
3
|
+
const reducer = (
|
|
2
4
|
// eslint-disable-next-line default-param-last
|
|
3
|
-
|
|
5
|
+
state = initialState, action) => {
|
|
4
6
|
switch (action.type) {
|
|
5
7
|
case SKILLS_FETCH_SUCCESS:
|
|
6
8
|
return action.payload;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
2
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
2
3
|
import { SlideFromAPI } from '../../types/common';
|
|
3
4
|
export declare type SlidesAction = FetchSlide | ReceivedSlide;
|
|
4
5
|
export declare type SlidesState = Record<string, SlideFromAPI | null>;
|
|
5
6
|
export declare const initialState: SlidesState;
|
|
6
|
-
declare const reducer: (state: SlidesState | undefined, action: SlidesAction) => SlidesState;
|
|
7
|
+
declare const reducer: (state: SlidesState | undefined, action: SlidesAction | FetchProgression) => SlidesState;
|
|
7
8
|
export default reducer;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import set from 'lodash/fp/set';
|
|
2
2
|
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
3
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
3
4
|
export const initialState = {};
|
|
5
|
+
const reducer = (
|
|
4
6
|
// eslint-disable-next-line default-param-last
|
|
5
|
-
|
|
7
|
+
state = initialState, action) => {
|
|
6
8
|
switch (action.type) {
|
|
7
9
|
case SLIDE_FETCH_REQUEST: {
|
|
8
10
|
const { meta } = action;
|
|
@@ -12,6 +14,9 @@ const reducer = (state = initialState, action) => {
|
|
|
12
14
|
const slide = action.payload;
|
|
13
15
|
return set([slide._id], slide, state);
|
|
14
16
|
}
|
|
17
|
+
case POST_PROGRESSION_REQUEST: {
|
|
18
|
+
return initialState;
|
|
19
|
+
}
|
|
15
20
|
default:
|
|
16
21
|
return state;
|
|
17
22
|
}
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
23
23
|
showButtonRevising: boolean;
|
|
24
24
|
showCongrats: boolean;
|
|
25
25
|
}>;
|
|
26
|
-
}>, import("
|
|
26
|
+
}>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
|
|
27
27
|
type: "@@ui/OPEN_POPIN";
|
|
28
28
|
} | {
|
|
29
29
|
type: "@@ui/CLOSE_POPIN";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
2
|
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
4
|
export declare type UISlideAnswer = string[];
|
|
4
5
|
export declare type UIAnswerState = Record<string, UISlideAnswer>;
|
|
5
6
|
export declare const initialState: UIAnswerState;
|
|
6
|
-
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlideAction) => UIAnswerState;
|
|
7
|
+
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlideAction | FetchProgression) => UIAnswerState;
|
|
7
8
|
export default reducer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { set } from 'lodash/fp';
|
|
2
2
|
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
3
3
|
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
4
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
4
5
|
export const initialState = {};
|
|
5
6
|
const reducer = (
|
|
6
7
|
// eslint-disable-next-line default-param-last
|
|
@@ -17,6 +18,9 @@ state = initialState, action) => {
|
|
|
17
18
|
case NEXT_SLIDE: {
|
|
18
19
|
return set([action.payload.nextSlideRef], [], state);
|
|
19
20
|
}
|
|
21
|
+
case POST_PROGRESSION_REQUEST: {
|
|
22
|
+
return initialState;
|
|
23
|
+
}
|
|
20
24
|
default:
|
|
21
25
|
return state;
|
|
22
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
2
2
|
import { SetCurrentSlideAction } from '../../actions/ui/slides';
|
|
3
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
4
|
export declare type CurrentSlideRefState = string;
|
|
4
|
-
declare const reducer: (state: string | undefined, action: SetCurrentSlideAction | NextSlideAction) => CurrentSlideRefState;
|
|
5
|
+
declare const reducer: (state: string | undefined, action: SetCurrentSlideAction | NextSlideAction | FetchProgression) => CurrentSlideRefState;
|
|
5
6
|
export default reducer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
2
2
|
import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
|
|
3
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
3
4
|
const reducer = (
|
|
4
5
|
// eslint-disable-next-line default-param-last
|
|
5
6
|
state = '', action) => {
|
|
@@ -9,6 +10,9 @@ state = '', action) => {
|
|
|
9
10
|
case SET_CURRENT_SLIDE: {
|
|
10
11
|
return action.payload._id;
|
|
11
12
|
}
|
|
13
|
+
case POST_PROGRESSION_REQUEST: {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
12
16
|
default:
|
|
13
17
|
return state;
|
|
14
18
|
}
|
|
@@ -25,7 +25,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
25
25
|
showQuitPopin: boolean;
|
|
26
26
|
showButtonRevising: boolean;
|
|
27
27
|
showCongrats: boolean;
|
|
28
|
-
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/
|
|
28
|
+
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
|
|
29
29
|
type: "@@ui/OPEN_POPIN";
|
|
30
30
|
} | {
|
|
31
31
|
type: "@@ui/CLOSE_POPIN";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
1
|
+
import { FetchProgression, ReceivedProgression } from '../../actions/api/post-progression';
|
|
2
2
|
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
3
|
export declare type UIPositionState = number[];
|
|
4
|
-
declare const reducer: (state: UIPositionState | undefined, action: NextSlideAction | ReceivedProgression) => UIPositionState;
|
|
4
|
+
declare const reducer: (state: UIPositionState | undefined, action: NextSlideAction | ReceivedProgression | FetchProgression) => UIPositionState;
|
|
5
5
|
export default reducer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import findIndex from 'lodash/fp/findIndex';
|
|
2
2
|
import map from 'lodash/fp/map';
|
|
3
3
|
import set from 'lodash/fp/set';
|
|
4
|
-
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
4
|
+
import { POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
5
5
|
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
6
6
|
const initialState = [0, 1, 2, 3, 4];
|
|
7
7
|
const reducer = (
|
|
@@ -20,6 +20,9 @@ state = initialState, action) => {
|
|
|
20
20
|
const newState = map(position => (position === -1 ? position : position - 1), state);
|
|
21
21
|
return set([`${currentSlideIndex}`], nextCurrentSlidePosition)(newState);
|
|
22
22
|
}
|
|
23
|
+
case POST_PROGRESSION_REQUEST: {
|
|
24
|
+
return initialState;
|
|
25
|
+
}
|
|
23
26
|
default:
|
|
24
27
|
return state;
|
|
25
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReceivedSlidesToReviewBySkillRef } from '../../actions/api/fetch-slides-to-review-by-skill-ref';
|
|
2
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
2
3
|
export declare type UIShowButtonRevisingState = boolean;
|
|
3
|
-
declare const reducer: (state: boolean | undefined, action: ReceivedSlidesToReviewBySkillRef) => UIShowButtonRevisingState;
|
|
4
|
+
declare const reducer: (state: boolean | undefined, action: ReceivedSlidesToReviewBySkillRef | FetchProgression) => UIShowButtonRevisingState;
|
|
4
5
|
export default reducer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SLIDES_TO_REVIEW_FETCH_SUCCESS } from '../../actions/api/fetch-slides-to-review-by-skill-ref';
|
|
2
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
2
3
|
const reducer = (
|
|
3
4
|
// eslint-disable-next-line default-param-last
|
|
4
5
|
state = false, action) => {
|
|
@@ -6,6 +7,9 @@ state = false, action) => {
|
|
|
6
7
|
case SLIDES_TO_REVIEW_FETCH_SUCCESS: {
|
|
7
8
|
return action.payload.length === 5;
|
|
8
9
|
}
|
|
10
|
+
case POST_PROGRESSION_REQUEST: {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
9
13
|
default:
|
|
10
14
|
return state;
|
|
11
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
2
|
-
import {
|
|
2
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
3
|
export declare type UIShowCongratsState = boolean;
|
|
4
|
-
declare const reducer: (state: boolean | undefined, action: NextSlideAction |
|
|
4
|
+
declare const reducer: (state: boolean | undefined, action: NextSlideAction | FetchProgression) => UIShowCongratsState;
|
|
5
5
|
export default reducer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
2
|
-
import {
|
|
2
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
3
3
|
const reducer = (
|
|
4
4
|
// eslint-disable-next-line default-param-last
|
|
5
5
|
state = false, action) => {
|
|
6
6
|
switch (action.type) {
|
|
7
|
-
case
|
|
7
|
+
case POST_PROGRESSION_REQUEST: {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
case NEXT_SLIDE: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
2
|
import { PostAnswerRequestAction } from '../../actions/api/post-answer';
|
|
3
3
|
import { ReceivedCorrection } from '../../actions/api/fetch-correction';
|
|
4
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
4
5
|
import { FetchSlide } from '../../actions/api/fetch-slide';
|
|
5
6
|
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
6
7
|
import { SlideUIAnimations } from '../../types/slides';
|
|
@@ -12,5 +13,5 @@ export declare type UISlide = {
|
|
|
12
13
|
};
|
|
13
14
|
export declare type UISlideState = Record<string, UISlide>;
|
|
14
15
|
export declare const initialState: UISlideState;
|
|
15
|
-
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlideAction) => UISlideState;
|
|
16
|
+
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlideAction | FetchProgression) => UISlideState;
|
|
16
17
|
export default reducer;
|
package/es/reducers/ui/slide.js
CHANGED
|
@@ -6,6 +6,7 @@ import unset from 'lodash/fp/unset';
|
|
|
6
6
|
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
7
7
|
import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
|
|
8
8
|
import { CORRECTION_FETCH_SUCCESS } from '../../actions/api/fetch-correction';
|
|
9
|
+
import { POST_PROGRESSION_REQUEST } from '../../actions/api/post-progression';
|
|
9
10
|
import { SLIDE_FETCH_REQUEST } from '../../actions/api/fetch-slide';
|
|
10
11
|
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
11
12
|
export const initialState = {};
|
|
@@ -40,6 +41,9 @@ state = initialState, action) => {
|
|
|
40
41
|
return state;
|
|
41
42
|
return pipe(set([currentSlideRef, 'animateCorrectionPopin'], false), set([currentSlideRef, 'animationType'], action.payload.animationType))(state);
|
|
42
43
|
}
|
|
44
|
+
case POST_PROGRESSION_REQUEST: {
|
|
45
|
+
return initialState;
|
|
46
|
+
}
|
|
43
47
|
default:
|
|
44
48
|
return state;
|
|
45
49
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const fetchSkills: (token: string) => Promise<
|
|
1
|
+
import { SkillToReview } from '../types/common';
|
|
2
|
+
export declare const fetchSkills: (token: string) => Promise<SkillToReview[]>;
|
package/es/types/common.d.ts
CHANGED
|
@@ -122,18 +122,18 @@ export declare type CorrectionFromAPI = {
|
|
|
122
122
|
correctAnswer: string[];
|
|
123
123
|
corrections: CorrectedChoice[];
|
|
124
124
|
};
|
|
125
|
-
export declare type
|
|
125
|
+
export declare type SkillToReview = {
|
|
126
126
|
skillRef: string;
|
|
127
127
|
slidesToReview: number;
|
|
128
128
|
custom: boolean;
|
|
129
129
|
name: string;
|
|
130
130
|
};
|
|
131
|
-
export declare type
|
|
131
|
+
export declare type Skill = {
|
|
132
132
|
name: string;
|
|
133
|
-
|
|
133
|
+
skillRef: string;
|
|
134
134
|
};
|
|
135
135
|
export declare type Services = {
|
|
136
|
-
fetchSkills(token: string): Promise<
|
|
136
|
+
fetchSkills(token: string): Promise<SkillToReview[]>;
|
|
137
137
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
138
138
|
postProgression(skillRef: string, token: string): Promise<ProgressionFromAPI>;
|
|
139
139
|
postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
|
|
@@ -147,10 +147,10 @@ export declare type Options = {
|
|
|
147
147
|
export declare type ConnectedOptions = {
|
|
148
148
|
translate: (key: string, data?: unknown) => string;
|
|
149
149
|
onQuitClick: () => void;
|
|
150
|
-
skill: SkillOptions;
|
|
151
150
|
};
|
|
152
151
|
export declare type AppOptions = ConnectedOptions & {
|
|
153
152
|
token: string;
|
|
153
|
+
skillRef?: string;
|
|
154
154
|
services: Services;
|
|
155
155
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
156
156
|
};
|
package/es/views/slides/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import join from 'lodash/fp/join';
|
|
|
9
9
|
import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
|
|
10
10
|
import { getProgressionSlidesRefs } from '../../common';
|
|
11
11
|
import { postAnswer } from '../../actions/api/post-answer';
|
|
12
|
+
import { postProgression } from '../../actions/api/post-progression';
|
|
12
13
|
import { nextSlide } from '../../actions/ui/next-slide';
|
|
13
14
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
14
15
|
const ICON_VALUES = {
|
|
@@ -235,9 +236,10 @@ const buildRankCard = (rank, translate) => {
|
|
|
235
236
|
timerAnimation: 200
|
|
236
237
|
};
|
|
237
238
|
};
|
|
238
|
-
const buildCongratsProps = (state,
|
|
239
|
+
const buildCongratsProps = (state, dispatch, options) => {
|
|
239
240
|
if (!state.ui.showCongrats)
|
|
240
241
|
return;
|
|
242
|
+
const { translate, onQuitClick } = options;
|
|
241
243
|
const progression = state.data.progression;
|
|
242
244
|
const stars = progression.state.stars;
|
|
243
245
|
const cardCongratsStar = {
|
|
@@ -265,6 +267,23 @@ const buildCongratsProps = (state, translate) => {
|
|
|
265
267
|
const { start, end } = state.data.rank;
|
|
266
268
|
const newRank = start - end;
|
|
267
269
|
const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
|
|
270
|
+
const skillRef = progression.content.ref;
|
|
271
|
+
const buttonRevising = state.ui.showButtonRevising
|
|
272
|
+
? {
|
|
273
|
+
'aria-label': translate('Continue reviewing'),
|
|
274
|
+
label: translate('Continue reviewing'),
|
|
275
|
+
onClick: () => {
|
|
276
|
+
dispatch(postProgression(skillRef));
|
|
277
|
+
},
|
|
278
|
+
type: 'tertiary'
|
|
279
|
+
}
|
|
280
|
+
: undefined;
|
|
281
|
+
const buttonRevisingSkill = {
|
|
282
|
+
'aria-label': translate('Revise another skill'),
|
|
283
|
+
label: translate('Revise another skill'),
|
|
284
|
+
onClick: onQuitClick,
|
|
285
|
+
type: 'primary'
|
|
286
|
+
};
|
|
268
287
|
return {
|
|
269
288
|
'aria-label': 'Review Congratulations',
|
|
270
289
|
'data-name': 'review-congrats',
|
|
@@ -272,8 +291,8 @@ const buildCongratsProps = (state, translate) => {
|
|
|
272
291
|
title: translate('Congratulations!'),
|
|
273
292
|
cardCongratsStar,
|
|
274
293
|
cardCongratsRank,
|
|
275
|
-
buttonRevising
|
|
276
|
-
buttonRevisingSkill
|
|
294
|
+
buttonRevising,
|
|
295
|
+
buttonRevisingSkill
|
|
277
296
|
};
|
|
278
297
|
};
|
|
279
298
|
const isEndOfProgression = (progression) => {
|
|
@@ -282,7 +301,7 @@ const isEndOfProgression = (progression) => {
|
|
|
282
301
|
return progression.state.nextContent.ref === 'successExitNode';
|
|
283
302
|
};
|
|
284
303
|
export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
285
|
-
const { translate, onQuitClick
|
|
304
|
+
const { translate, onQuitClick } = options;
|
|
286
305
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
287
306
|
const endReview = isEndOfProgression(state.data.progression);
|
|
288
307
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
@@ -290,12 +309,10 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
290
309
|
const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
291
310
|
const showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
292
311
|
const showCongrats = get(['ui', 'showCongrats'], state);
|
|
293
|
-
// eslint-disable-next-line no-console
|
|
294
|
-
console.log(skill.name);
|
|
295
312
|
return {
|
|
296
313
|
header: {
|
|
297
314
|
mode: translate('Review Title'),
|
|
298
|
-
skillName:
|
|
315
|
+
skillName: '__agility',
|
|
299
316
|
onQuitClick: () => dispatch(openQuitPopin),
|
|
300
317
|
'aria-label': 'aria-header-wrapper',
|
|
301
318
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -315,7 +332,7 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
315
332
|
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
|
|
316
333
|
endReview: endReview && state.ui.showCongrats
|
|
317
334
|
},
|
|
318
|
-
congrats: buildCongratsProps(state,
|
|
335
|
+
congrats: buildCongratsProps(state, dispatch, options),
|
|
319
336
|
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick, translate) : undefined
|
|
320
337
|
};
|
|
321
338
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
-
import type { ThunkOptions,
|
|
3
|
+
import type { ThunkOptions, SkillToReview } from '../../types/common';
|
|
4
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
5
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
6
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
7
7
|
export declare type ReceivedSkills = {
|
|
8
8
|
type: typeof SKILLS_FETCH_SUCCESS;
|
|
9
|
-
payload:
|
|
9
|
+
payload: SkillToReview[];
|
|
10
10
|
};
|
|
11
11
|
export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => ReceivedSkills;
|
|
@@ -4,6 +4,9 @@ import type { StoreState } from '../../reducers';
|
|
|
4
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
5
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
6
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
7
|
+
export declare type FetchProgression = {
|
|
8
|
+
type: typeof POST_PROGRESSION_REQUEST;
|
|
9
|
+
};
|
|
7
10
|
export declare type ReceivedProgression = {
|
|
8
11
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
9
12
|
payload: ProgressionFromAPI;
|
package/lib/index.js
CHANGED
|
@@ -52,7 +52,7 @@ const ConnectedApp = (options) => {
|
|
|
52
52
|
const AppReview = ({ options }) => {
|
|
53
53
|
const [store, setStore] = (0, react_1.useState)(null);
|
|
54
54
|
const [isProgressionCreated, setIsProgressionCreated] = (0, react_1.useState)(false);
|
|
55
|
-
const { translate, onQuitClick
|
|
55
|
+
const { translate, onQuitClick } = options;
|
|
56
56
|
(0, react_1.useEffect)(() => {
|
|
57
57
|
if (store)
|
|
58
58
|
return;
|
|
@@ -77,23 +77,25 @@ const AppReview = ({ options }) => {
|
|
|
77
77
|
const token = (0, get_1.default)('token', options);
|
|
78
78
|
if (store === null || (0, isEmpty_1.default)(token))
|
|
79
79
|
return;
|
|
80
|
+
const skillRef = (0, get_1.default)('skillRef', options);
|
|
80
81
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
81
82
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
82
|
-
|
|
83
|
+
skillRef ? store.dispatch((0, post_progression_1.postProgression)(skillRef)) : store.dispatch(fetch_skills_1.fetchSkills);
|
|
83
84
|
}, [options, store]);
|
|
84
85
|
(0, react_1.useEffect)(() => {
|
|
85
86
|
if (store === null)
|
|
86
87
|
return;
|
|
87
|
-
|
|
88
|
+
const { skillRef } = options;
|
|
89
|
+
if (skillRef && !isProgressionCreated) {
|
|
88
90
|
store.dispatch((0, navigation_1.navigateTo)('loader')); // use loader while posting progression
|
|
89
91
|
return;
|
|
90
92
|
}
|
|
91
|
-
const initialView =
|
|
93
|
+
const initialView = skillRef ? 'slides' : 'skills';
|
|
92
94
|
store.dispatch((0, navigation_1.navigateTo)(initialView));
|
|
93
95
|
}, [isProgressionCreated, options, store]);
|
|
94
96
|
if (!store)
|
|
95
97
|
return null;
|
|
96
98
|
return (react_1.default.createElement(react_redux_1.Provider, { store: store },
|
|
97
|
-
react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate
|
|
99
|
+
react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
|
|
98
100
|
};
|
|
99
101
|
exports.default = AppReview;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
|
+
import { FetchProgression } from '../../actions/api/post-progression';
|
|
3
4
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
4
5
|
export declare type CorrectionsAction = ReceivedCorrection | FetchCorrection;
|
|
5
|
-
declare const reducer: (state: CorrectionsState | undefined, action: CorrectionsAction) => CorrectionsState;
|
|
6
|
+
declare const reducer: (state: CorrectionsState | undefined, action: CorrectionsAction | FetchProgression) => CorrectionsState;
|
|
6
7
|
export default reducer;
|