@coorpacademy/app-review 0.7.5-alpha.32 → 0.7.5
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/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.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/types/common.d.ts +1 -5
- package/es/views/slides/index.js +25 -8
- 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.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/types/common.d.ts +1 -5
- package/lib/views/slides/index.js +25 -8
- package/package.json +4 -4
|
@@ -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,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
|
}
|
package/es/types/common.d.ts
CHANGED
|
@@ -128,10 +128,6 @@ export declare type Skill = {
|
|
|
128
128
|
custom: boolean;
|
|
129
129
|
name: string;
|
|
130
130
|
};
|
|
131
|
-
export declare type SkillOptions = {
|
|
132
|
-
name: string;
|
|
133
|
-
ref: string;
|
|
134
|
-
};
|
|
135
131
|
export declare type Services = {
|
|
136
132
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
137
133
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
@@ -147,10 +143,10 @@ export declare type Options = {
|
|
|
147
143
|
export declare type ConnectedOptions = {
|
|
148
144
|
translate: (key: string, data?: unknown) => string;
|
|
149
145
|
onQuitClick: () => void;
|
|
150
|
-
skill: SkillOptions;
|
|
151
146
|
};
|
|
152
147
|
export declare type AppOptions = ConnectedOptions & {
|
|
153
148
|
token: string;
|
|
149
|
+
skillRef?: string;
|
|
154
150
|
services: Services;
|
|
155
151
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
156
152
|
};
|
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
|
};
|
|
@@ -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;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const set_1 = __importDefault(require("lodash/fp/set"));
|
|
7
7
|
const fetch_correction_1 = require("../../actions/api/fetch-correction");
|
|
8
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
8
9
|
const initialState = {};
|
|
9
10
|
const reducer = (
|
|
10
11
|
// eslint-disable-next-line default-param-last
|
|
@@ -19,6 +20,9 @@ state = initialState, action) => {
|
|
|
19
20
|
const correction = action.payload;
|
|
20
21
|
return (0, set_1.default)([meta.slideRef], correction, state);
|
|
21
22
|
}
|
|
23
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
24
|
+
return initialState;
|
|
25
|
+
}
|
|
22
26
|
default:
|
|
23
27
|
return state;
|
|
24
28
|
}
|
|
@@ -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;
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const post_answer_1 = require("../../actions/api/post-answer");
|
|
4
4
|
const post_progression_1 = require("../../actions/api/post-progression");
|
|
5
|
+
const initialState = null;
|
|
5
6
|
const reducer = (
|
|
6
7
|
// eslint-disable-next-line default-param-last
|
|
7
|
-
state =
|
|
8
|
+
state = initialState, action) => {
|
|
8
9
|
switch (action.type) {
|
|
9
10
|
case post_answer_1.POST_ANSWER_SUCCESS:
|
|
10
11
|
case post_progression_1.POST_PROGRESSION_SUCCESS: {
|
|
11
12
|
const progression = action.payload;
|
|
12
13
|
return progression;
|
|
13
14
|
}
|
|
15
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
16
|
+
return initialState;
|
|
17
|
+
}
|
|
14
18
|
default:
|
|
15
19
|
return state;
|
|
16
20
|
}
|
|
@@ -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;
|
|
@@ -14,7 +14,7 @@ const reducer = (
|
|
|
14
14
|
// eslint-disable-next-line default-param-last
|
|
15
15
|
state = initialState, action) => {
|
|
16
16
|
switch (action.type) {
|
|
17
|
-
case post_progression_1.
|
|
17
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
18
18
|
return initialState;
|
|
19
19
|
}
|
|
20
20
|
case fetch_rank_1.RANK_FETCH_START_SUCCESS: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fetch_skills_1 = require("../../actions/api/fetch-skills");
|
|
4
|
+
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 fetch_skills_1.SKILLS_FETCH_SUCCESS:
|
|
8
10
|
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;
|
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.initialState = void 0;
|
|
7
7
|
const set_1 = __importDefault(require("lodash/fp/set"));
|
|
8
8
|
const fetch_slide_1 = require("../../actions/api/fetch-slide");
|
|
9
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
9
10
|
exports.initialState = {};
|
|
11
|
+
const reducer = (
|
|
10
12
|
// eslint-disable-next-line default-param-last
|
|
11
|
-
|
|
13
|
+
state = exports.initialState, action) => {
|
|
12
14
|
switch (action.type) {
|
|
13
15
|
case fetch_slide_1.SLIDE_FETCH_REQUEST: {
|
|
14
16
|
const { meta } = action;
|
|
@@ -18,6 +20,9 @@ const reducer = (state = exports.initialState, action) => {
|
|
|
18
20
|
const slide = action.payload;
|
|
19
21
|
return (0, set_1.default)([slide._id], slide, state);
|
|
20
22
|
}
|
|
23
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
24
|
+
return exports.initialState;
|
|
25
|
+
}
|
|
21
26
|
default:
|
|
22
27
|
return state;
|
|
23
28
|
}
|
package/lib/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;
|
|
@@ -4,6 +4,7 @@ exports.initialState = void 0;
|
|
|
4
4
|
const fp_1 = require("lodash/fp");
|
|
5
5
|
const answers_1 = require("../../actions/ui/answers");
|
|
6
6
|
const next_slide_1 = require("../../actions/ui/next-slide");
|
|
7
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
7
8
|
exports.initialState = {};
|
|
8
9
|
const reducer = (
|
|
9
10
|
// eslint-disable-next-line default-param-last
|
|
@@ -20,6 +21,9 @@ state = exports.initialState, action) => {
|
|
|
20
21
|
case next_slide_1.NEXT_SLIDE: {
|
|
21
22
|
return (0, fp_1.set)([action.payload.nextSlideRef], [], state);
|
|
22
23
|
}
|
|
24
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
25
|
+
return exports.initialState;
|
|
26
|
+
}
|
|
23
27
|
default:
|
|
24
28
|
return state;
|
|
25
29
|
}
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const next_slide_1 = require("../../actions/ui/next-slide");
|
|
4
4
|
const slides_1 = require("../../actions/ui/slides");
|
|
5
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
5
6
|
const reducer = (
|
|
6
7
|
// eslint-disable-next-line default-param-last
|
|
7
8
|
state = '', action) => {
|
|
@@ -11,6 +12,9 @@ state = '', action) => {
|
|
|
11
12
|
case slides_1.SET_CURRENT_SLIDE: {
|
|
12
13
|
return action.payload._id;
|
|
13
14
|
}
|
|
15
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
14
18
|
default:
|
|
15
19
|
return state;
|
|
16
20
|
}
|
|
@@ -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;
|
|
@@ -25,6 +25,9 @@ state = initialState, action) => {
|
|
|
25
25
|
const newState = (0, map_1.default)(position => (position === -1 ? position : position - 1), state);
|
|
26
26
|
return (0, set_1.default)([`${currentSlideIndex}`], nextCurrentSlidePosition)(newState);
|
|
27
27
|
}
|
|
28
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
29
|
+
return initialState;
|
|
30
|
+
}
|
|
28
31
|
default:
|
|
29
32
|
return state;
|
|
30
33
|
}
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fetch_slides_to_review_by_skill_ref_1 = require("../../actions/api/fetch-slides-to-review-by-skill-ref");
|
|
4
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
4
5
|
const reducer = (
|
|
5
6
|
// eslint-disable-next-line default-param-last
|
|
6
7
|
state = false, action) => {
|
|
@@ -8,6 +9,9 @@ state = false, action) => {
|
|
|
8
9
|
case fetch_slides_to_review_by_skill_ref_1.SLIDES_TO_REVIEW_FETCH_SUCCESS: {
|
|
9
10
|
return action.payload.length === 5;
|
|
10
11
|
}
|
|
12
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
11
15
|
default:
|
|
12
16
|
return state;
|
|
13
17
|
}
|
|
@@ -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;
|
|
@@ -6,7 +6,7 @@ const reducer = (
|
|
|
6
6
|
// eslint-disable-next-line default-param-last
|
|
7
7
|
state = false, action) => {
|
|
8
8
|
switch (action.type) {
|
|
9
|
-
case post_progression_1.
|
|
9
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
case next_slide_1.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/lib/reducers/ui/slide.js
CHANGED
|
@@ -12,6 +12,7 @@ const unset_1 = __importDefault(require("lodash/fp/unset"));
|
|
|
12
12
|
const answers_1 = require("../../actions/ui/answers");
|
|
13
13
|
const post_answer_1 = require("../../actions/api/post-answer");
|
|
14
14
|
const fetch_correction_1 = require("../../actions/api/fetch-correction");
|
|
15
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
15
16
|
const fetch_slide_1 = require("../../actions/api/fetch-slide");
|
|
16
17
|
const next_slide_1 = require("../../actions/ui/next-slide");
|
|
17
18
|
exports.initialState = {};
|
|
@@ -46,6 +47,9 @@ state = exports.initialState, action) => {
|
|
|
46
47
|
return state;
|
|
47
48
|
return (0, pipe_1.default)((0, set_1.default)([currentSlideRef, 'animateCorrectionPopin'], false), (0, set_1.default)([currentSlideRef, 'animationType'], action.payload.animationType))(state);
|
|
48
49
|
}
|
|
50
|
+
case post_progression_1.POST_PROGRESSION_REQUEST: {
|
|
51
|
+
return exports.initialState;
|
|
52
|
+
}
|
|
49
53
|
default:
|
|
50
54
|
return state;
|
|
51
55
|
}
|
package/lib/types/common.d.ts
CHANGED
|
@@ -128,10 +128,6 @@ export declare type Skill = {
|
|
|
128
128
|
custom: boolean;
|
|
129
129
|
name: string;
|
|
130
130
|
};
|
|
131
|
-
export declare type SkillOptions = {
|
|
132
|
-
name: string;
|
|
133
|
-
ref: string;
|
|
134
|
-
};
|
|
135
131
|
export declare type Services = {
|
|
136
132
|
fetchSkills(token: string): Promise<Skill[]>;
|
|
137
133
|
fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
|
|
@@ -147,10 +143,10 @@ export declare type Options = {
|
|
|
147
143
|
export declare type ConnectedOptions = {
|
|
148
144
|
translate: (key: string, data?: unknown) => string;
|
|
149
145
|
onQuitClick: () => void;
|
|
150
|
-
skill: SkillOptions;
|
|
151
146
|
};
|
|
152
147
|
export declare type AppOptions = ConnectedOptions & {
|
|
153
148
|
token: string;
|
|
149
|
+
skillRef?: string;
|
|
154
150
|
services: Services;
|
|
155
151
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
156
152
|
};
|
|
@@ -15,6 +15,7 @@ const join_1 = __importDefault(require("lodash/fp/join"));
|
|
|
15
15
|
const quit_popin_1 = require("../../actions/ui/quit-popin");
|
|
16
16
|
const common_1 = require("../../common");
|
|
17
17
|
const post_answer_1 = require("../../actions/api/post-answer");
|
|
18
|
+
const post_progression_1 = require("../../actions/api/post-progression");
|
|
18
19
|
const next_slide_1 = require("../../actions/ui/next-slide");
|
|
19
20
|
const map_api_slide_to_ui_1 = require("./map-api-slide-to-ui");
|
|
20
21
|
const ICON_VALUES = {
|
|
@@ -242,9 +243,10 @@ const buildRankCard = (rank, translate) => {
|
|
|
242
243
|
timerAnimation: 200
|
|
243
244
|
};
|
|
244
245
|
};
|
|
245
|
-
const buildCongratsProps = (state,
|
|
246
|
+
const buildCongratsProps = (state, dispatch, options) => {
|
|
246
247
|
if (!state.ui.showCongrats)
|
|
247
248
|
return;
|
|
249
|
+
const { translate, onQuitClick } = options;
|
|
248
250
|
const progression = state.data.progression;
|
|
249
251
|
const stars = progression.state.stars;
|
|
250
252
|
const cardCongratsStar = {
|
|
@@ -272,6 +274,23 @@ const buildCongratsProps = (state, translate) => {
|
|
|
272
274
|
const { start, end } = state.data.rank;
|
|
273
275
|
const newRank = start - end;
|
|
274
276
|
const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
|
|
277
|
+
const skillRef = progression.content.ref;
|
|
278
|
+
const buttonRevising = state.ui.showButtonRevising
|
|
279
|
+
? {
|
|
280
|
+
'aria-label': translate('Continue reviewing'),
|
|
281
|
+
label: translate('Continue reviewing'),
|
|
282
|
+
onClick: () => {
|
|
283
|
+
dispatch((0, post_progression_1.postProgression)(skillRef));
|
|
284
|
+
},
|
|
285
|
+
type: 'tertiary'
|
|
286
|
+
}
|
|
287
|
+
: undefined;
|
|
288
|
+
const buttonRevisingSkill = {
|
|
289
|
+
'aria-label': translate('Revise another skill'),
|
|
290
|
+
label: translate('Revise another skill'),
|
|
291
|
+
onClick: onQuitClick,
|
|
292
|
+
type: 'primary'
|
|
293
|
+
};
|
|
275
294
|
return {
|
|
276
295
|
'aria-label': 'Review Congratulations',
|
|
277
296
|
'data-name': 'review-congrats',
|
|
@@ -279,8 +298,8 @@ const buildCongratsProps = (state, translate) => {
|
|
|
279
298
|
title: translate('Congratulations!'),
|
|
280
299
|
cardCongratsStar,
|
|
281
300
|
cardCongratsRank,
|
|
282
|
-
buttonRevising
|
|
283
|
-
buttonRevisingSkill
|
|
301
|
+
buttonRevising,
|
|
302
|
+
buttonRevisingSkill
|
|
284
303
|
};
|
|
285
304
|
};
|
|
286
305
|
const isEndOfProgression = (progression) => {
|
|
@@ -289,7 +308,7 @@ const isEndOfProgression = (progression) => {
|
|
|
289
308
|
return progression.state.nextContent.ref === 'successExitNode';
|
|
290
309
|
};
|
|
291
310
|
const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
292
|
-
const { translate, onQuitClick
|
|
311
|
+
const { translate, onQuitClick } = options;
|
|
293
312
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
294
313
|
const endReview = isEndOfProgression(state.data.progression);
|
|
295
314
|
const correction = (0, get_1.default)(['data', 'corrections', currentSlideRef], state);
|
|
@@ -297,12 +316,10 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
297
316
|
const klf = (0, getOr_1.default)('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
298
317
|
const showQuitPopin = (0, get_1.default)(['ui', 'showQuitPopin'], state);
|
|
299
318
|
const showCongrats = (0, get_1.default)(['ui', 'showCongrats'], state);
|
|
300
|
-
// eslint-disable-next-line no-console
|
|
301
|
-
console.log(skill.name);
|
|
302
319
|
return {
|
|
303
320
|
header: {
|
|
304
321
|
mode: translate('Review Title'),
|
|
305
|
-
skillName:
|
|
322
|
+
skillName: '__agility',
|
|
306
323
|
onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
|
|
307
324
|
'aria-label': 'aria-header-wrapper',
|
|
308
325
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -322,7 +339,7 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
322
339
|
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
|
|
323
340
|
endReview: endReview && state.ui.showCongrats
|
|
324
341
|
},
|
|
325
|
-
congrats: buildCongratsProps(state,
|
|
342
|
+
congrats: buildCongratsProps(state, dispatch, options),
|
|
326
343
|
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick, translate) : undefined
|
|
327
344
|
};
|
|
328
345
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.7.5
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"main": "lib/index.js",
|
|
36
36
|
"module": "es/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coorpacademy/components": "10.27.
|
|
38
|
+
"@coorpacademy/components": "10.27.4",
|
|
39
39
|
"@coorpacademy/redux-task": "1.1.6",
|
|
40
|
-
"@coorpacademy/translate": "6.1.5",
|
|
40
|
+
"@coorpacademy/translate": "^6.1.5",
|
|
41
41
|
"cross-fetch": "^3.1.5",
|
|
42
42
|
"jwt-decode": "^3.1.2",
|
|
43
43
|
"react-redux": "^7.2.9",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"webpack-cli": "^4.10.0",
|
|
72
72
|
"webpack-dev-server": "^4.11.1"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "9c50f52f6f8d847aeb2fcb6fe072a6311a6a5e56"
|
|
75
75
|
}
|