@coorpacademy/app-review 0.4.5 → 0.5.0
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/ui/next-slide.d.ts +4 -2
- package/es/actions/ui/next-slide.js +7 -4
- package/es/actions/ui/slides.d.ts +2 -3
- package/es/common/index.d.ts +2 -0
- package/es/common/index.js +9 -0
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/current-slide-ref.d.ts +3 -2
- package/es/reducers/ui/current-slide-ref.js +3 -0
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/positions.d.ts +5 -0
- package/es/reducers/ui/positions.js +25 -0
- package/es/reducers/ui/slide.d.ts +2 -2
- package/es/views/slides/index.d.ts +1 -2
- package/es/views/slides/index.js +15 -23
- package/lib/actions/ui/next-slide.d.ts +4 -2
- package/lib/actions/ui/next-slide.js +7 -4
- package/lib/actions/ui/slides.d.ts +2 -3
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +9 -0
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/current-slide-ref.d.ts +3 -2
- package/lib/reducers/ui/current-slide-ref.js +3 -0
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/positions.d.ts +5 -0
- package/lib/reducers/ui/positions.js +26 -0
- package/lib/reducers/ui/slide.d.ts +2 -2
- package/lib/views/slides/index.d.ts +1 -2
- package/lib/views/slides/index.js +15 -24
- package/package.json +3 -3
- package/src/actions/api/test/fetch-correction.test.ts +1 -0
- package/src/actions/api/test/fetch-rank.test.ts +1 -0
- package/src/actions/api/test/fetch-skills.test.ts +1 -0
- package/src/actions/api/test/fetch-slide.test.ts +1 -0
- package/src/actions/api/test/post-answer.test.ts +2 -0
- package/src/actions/api/test/post-progression.test.ts +1 -0
- package/src/actions/data/test/token.test.ts +1 -0
- package/src/actions/ui/next-slide.ts +15 -9
- package/src/actions/ui/slides.ts +2 -4
- package/src/actions/ui/test/answers.test.ts +1 -0
- package/src/actions/ui/test/next-slide.test.ts +7 -2
- package/src/actions/ui/test/slides.test.ts +1 -0
- package/src/common/index.ts +12 -0
- package/src/reducers/ui/answers.ts +2 -2
- package/src/reducers/ui/current-slide-ref.ts +5 -2
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/positions.ts +32 -0
- package/src/reducers/ui/slide.ts +7 -2
- package/src/reducers/ui/test/answers.test.ts +3 -1
- package/src/reducers/ui/test/current-slide-ref.test.ts +2 -2
- package/src/reducers/ui/test/positions.test.ts +68 -0
- package/src/reducers/ui/test/slide.test.ts +3 -1
- package/src/types/common.ts +0 -1
- package/src/views/skills/test/skills.test.ts +2 -0
- package/src/views/slides/index.ts +18 -29
- package/src/views/slides/test/index.test.ts +37 -31
- package/src/views/slides/test/slide.free-text.on-change.test.ts +1 -1
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +8 -1
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +1 -1
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +1 -1
- package/src/views/slides/test/slide.qcm.on-click.test.ts +1 -1
- package/src/views/slides/test/slide.slider.on-change.test.ts +1 -1
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +15 -3
- package/src/views/slides/test/slide.template.on-change.test.ts +9 -10
- package/es/actions/ui/is-fetching.d.ts +0 -10
- package/es/actions/ui/is-fetching.js +0 -4
- package/lib/actions/ui/is-fetching.d.ts +0 -10
- package/lib/actions/ui/is-fetching.js +0 -4
- package/src/actions/ui/is-fetching.ts +0 -13
|
@@ -5,10 +5,12 @@ declare type NextSlidePayload = {
|
|
|
5
5
|
currentSlideRef: string;
|
|
6
6
|
nextSlideRef: string;
|
|
7
7
|
animationType: string;
|
|
8
|
+
totalCorrectAnswers: number;
|
|
9
|
+
answeredSlides: string[];
|
|
8
10
|
};
|
|
9
|
-
export declare type
|
|
11
|
+
export declare type NextSlideAction = {
|
|
10
12
|
type: typeof NEXT_SLIDE;
|
|
11
13
|
payload: NextSlidePayload;
|
|
12
14
|
};
|
|
13
|
-
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) =>
|
|
15
|
+
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) => NextSlideAction;
|
|
14
16
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import filter from 'lodash/fp/filter';
|
|
1
2
|
import get from 'lodash/fp/get';
|
|
2
|
-
import getOr from 'lodash/fp/getOr';
|
|
3
3
|
export const NEXT_SLIDE = '@@slide/NEXT_SLIDE';
|
|
4
4
|
export const nextSlide = (dispatch, getState) => {
|
|
5
5
|
const state = getState();
|
|
6
|
+
const progression = state.data.progression;
|
|
7
|
+
const { isCorrect, allAnswers, slides } = progression.state;
|
|
8
|
+
const correctAnswers = filter((answer) => answer.isCorrect, allAnswers);
|
|
6
9
|
const payload = {
|
|
7
10
|
currentSlideRef: get(['ui', 'currentSlideRef'], state),
|
|
8
11
|
nextSlideRef: get(['state', 'nextContent', 'ref'], state.data.progression),
|
|
9
|
-
animationType:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
animationType: isCorrect ? 'unstack' : 'restack',
|
|
13
|
+
totalCorrectAnswers: correctAnswers.length,
|
|
14
|
+
answeredSlides: slides
|
|
12
15
|
};
|
|
13
16
|
const action = {
|
|
14
17
|
type: NEXT_SLIDE,
|
|
@@ -12,10 +12,9 @@ export declare type Slide = {
|
|
|
12
12
|
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
13
13
|
};
|
|
14
14
|
export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
|
|
15
|
-
export declare type
|
|
15
|
+
export declare type SetCurrentSlideAction = {
|
|
16
16
|
type: typeof SET_CURRENT_SLIDE;
|
|
17
17
|
payload: SlideFromAPI;
|
|
18
18
|
};
|
|
19
|
-
export declare const setCurrentSlide: (payload: SlideFromAPI) =>
|
|
20
|
-
export declare type UISlidesAction = SetCurrentSlide;
|
|
19
|
+
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlideAction;
|
|
21
20
|
export {};
|
package/es/common/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProgressionFromAPI } from '../types/common';
|
|
1
2
|
export declare const VIEWS: {
|
|
2
3
|
readonly skills: 'skills';
|
|
3
4
|
readonly onboarding: 'onboarding';
|
|
@@ -5,3 +6,4 @@ export declare const VIEWS: {
|
|
|
5
6
|
};
|
|
6
7
|
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
7
8
|
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
9
|
+
export declare const getProgressionSlidesRefs: (progression: ProgressionFromAPI) => string[];
|
package/es/common/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import concat from 'lodash/fp/concat';
|
|
2
|
+
import slice from 'lodash/fp/slice';
|
|
1
3
|
export const VIEWS = {
|
|
2
4
|
skills: 'skills',
|
|
3
5
|
onboarding: 'onboarding',
|
|
4
6
|
slides: 'slides'
|
|
5
7
|
};
|
|
6
8
|
export const slideIndexes = ['0', '1', '2', '3', '4'];
|
|
9
|
+
export const getProgressionSlidesRefs = (progression) => {
|
|
10
|
+
if (progression.state.step.current < 5) {
|
|
11
|
+
const slideRef = progression.state.nextContent.ref;
|
|
12
|
+
return concat(progression.state.slides, [slideRef]);
|
|
13
|
+
}
|
|
14
|
+
return slice(0, 5, progression.state.slides);
|
|
15
|
+
};
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
18
|
navigation: import("./ui/navigation").NavigationState;
|
|
19
19
|
answers: import("./ui/answers").UIAnswerState;
|
|
20
20
|
slide: import("./ui/slide").UISlideState;
|
|
21
|
+
positions: import("./ui/positions").UIPositionState;
|
|
21
22
|
}>;
|
|
22
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").
|
|
23
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | 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").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
23
24
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
-
import {
|
|
2
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
3
|
export declare type UISlideAnswer = string[];
|
|
4
4
|
export declare type UIAnswerState = Record<string, UISlideAnswer>;
|
|
5
5
|
export declare const initialState: UIAnswerState;
|
|
6
|
-
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction |
|
|
6
|
+
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlideAction) => UIAnswerState;
|
|
7
7
|
export default reducer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
2
|
+
import { SetCurrentSlideAction } from '../../actions/ui/slides';
|
|
2
3
|
export declare type CurrentSlideRefState = string;
|
|
3
|
-
declare const reducer: (state: string | undefined, action:
|
|
4
|
+
declare const reducer: (state: string | undefined, action: SetCurrentSlideAction | NextSlideAction) => CurrentSlideRefState;
|
|
4
5
|
export default reducer;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
1
2
|
import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
|
|
2
3
|
const reducer = (
|
|
3
4
|
// eslint-disable-next-line default-param-last
|
|
4
5
|
state = '', action) => {
|
|
5
6
|
switch (action.type) {
|
|
7
|
+
case NEXT_SLIDE:
|
|
8
|
+
return action.payload.nextSlideRef;
|
|
6
9
|
case SET_CURRENT_SLIDE: {
|
|
7
10
|
return action.payload._id;
|
|
8
11
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
3
|
import { UIAnswerState } from './answers';
|
|
4
|
+
import { UIPositionState } from './positions';
|
|
4
5
|
import { UISlideState } from './slide';
|
|
5
6
|
export declare type UIState = {
|
|
6
7
|
currentSlideRef: CurrentSlideRefState;
|
|
7
8
|
navigation: NavigationState;
|
|
8
9
|
answers: UIAnswerState;
|
|
9
10
|
slide: UISlideState;
|
|
11
|
+
positions: UIPositionState;
|
|
10
12
|
};
|
|
11
13
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
12
14
|
currentSlideRef: string;
|
|
13
15
|
navigation: NavigationState;
|
|
14
16
|
answers: UIAnswerState;
|
|
15
17
|
slide: UISlideState;
|
|
16
|
-
|
|
18
|
+
positions: UIPositionState;
|
|
19
|
+
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
17
20
|
export default _default;
|
package/es/reducers/ui/index.js
CHANGED
|
@@ -2,10 +2,12 @@ import { combineReducers } from 'redux';
|
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
4
|
import answers from './answers';
|
|
5
|
+
import positions from './positions';
|
|
5
6
|
import slide from './slide';
|
|
6
7
|
export default combineReducers({
|
|
7
8
|
currentSlideRef,
|
|
8
9
|
navigation,
|
|
9
10
|
answers,
|
|
10
|
-
slide
|
|
11
|
+
slide,
|
|
12
|
+
positions
|
|
11
13
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
2
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
|
+
export declare type UIPositionState = number[];
|
|
4
|
+
declare const reducer: (state: UIPositionState | undefined, action: NextSlideAction | ReceivedProgression) => UIPositionState;
|
|
5
|
+
export default reducer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import findIndex from 'lodash/fp/findIndex';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import set from 'lodash/fp/set';
|
|
4
|
+
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
5
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
6
|
+
const initialState = [0, 1, 2, 3, 4];
|
|
7
|
+
const reducer = (
|
|
8
|
+
// eslint-disable-next-line default-param-last
|
|
9
|
+
state = initialState, action) => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
12
|
+
return initialState;
|
|
13
|
+
}
|
|
14
|
+
case NEXT_SLIDE: {
|
|
15
|
+
const { totalCorrectAnswers, answeredSlides, currentSlideRef, animationType } = action.payload;
|
|
16
|
+
const nextCurrentSlidePosition = animationType === 'unstack' ? -1 : 4 - totalCorrectAnswers;
|
|
17
|
+
const currentSlideIndex = findIndex(ref => ref === currentSlideRef, answeredSlides);
|
|
18
|
+
const newState = map(position => (position === -1 ? position : position - 1), state);
|
|
19
|
+
return set([`${currentSlideIndex}`], nextCurrentSlidePosition)(newState);
|
|
20
|
+
}
|
|
21
|
+
default:
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export default reducer;
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { FetchSlide } from '../../actions/api/fetch-slide';
|
|
5
|
-
import {
|
|
5
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
6
6
|
import { SlideUIAnimations } from '../../types/slides';
|
|
7
7
|
export declare type UISlide = {
|
|
8
8
|
validateButton: boolean;
|
|
@@ -12,5 +12,5 @@ export declare type UISlide = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare type UISlideState = Record<string, UISlide>;
|
|
14
14
|
export declare const initialState: UISlideState;
|
|
15
|
-
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection |
|
|
15
|
+
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlideAction) => UISlideState;
|
|
16
16
|
export default reducer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type
|
|
2
|
+
import { type SlideIndexes } from '../../common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
4
|
import type { AnswerUI } from '../../types/slides';
|
|
5
5
|
declare const ICON_VALUES: {
|
|
@@ -15,7 +15,6 @@ declare type StepItem = {
|
|
|
15
15
|
};
|
|
16
16
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
17
17
|
export declare type ReviewSlide = {
|
|
18
|
-
hidden: boolean;
|
|
19
18
|
position: number;
|
|
20
19
|
loading: boolean;
|
|
21
20
|
showCorrectionPopin?: boolean;
|
package/es/views/slides/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import concat from 'lodash/fp/concat';
|
|
2
1
|
import findLast from 'lodash/fp/findLast';
|
|
3
2
|
import get from 'lodash/fp/get';
|
|
4
3
|
import getOr from 'lodash/fp/getOr';
|
|
5
4
|
import last from 'lodash/fp/last';
|
|
6
5
|
import reduce from 'lodash/fp/reduce';
|
|
7
6
|
import set from 'lodash/fp/set';
|
|
8
|
-
import slice from 'lodash/fp/slice';
|
|
9
7
|
import toInteger from 'lodash/fp/toInteger';
|
|
10
8
|
import join from 'lodash/fp/join';
|
|
9
|
+
import { getProgressionSlidesRefs } from '../../common';
|
|
11
10
|
import { postAnswer } from '../../actions/api/post-answer';
|
|
12
11
|
import { nextSlide } from '../../actions/ui/next-slide';
|
|
13
12
|
import { mapApiSlideToUi } from './map-api-slide-to-ui';
|
|
@@ -16,40 +15,29 @@ const ICON_VALUES = {
|
|
|
16
15
|
wrong: 'wrong',
|
|
17
16
|
'no-answer': 'no-answer'
|
|
18
17
|
};
|
|
18
|
+
// TODO replace this, position no more needed
|
|
19
19
|
export const initialState = {
|
|
20
20
|
'0': {
|
|
21
|
-
hidden: false,
|
|
22
21
|
position: 0,
|
|
23
22
|
loading: true
|
|
24
23
|
},
|
|
25
24
|
'1': {
|
|
26
|
-
hidden: false,
|
|
27
25
|
position: 1,
|
|
28
26
|
loading: true
|
|
29
27
|
},
|
|
30
28
|
'2': {
|
|
31
|
-
hidden: false,
|
|
32
29
|
position: 2,
|
|
33
30
|
loading: true
|
|
34
31
|
},
|
|
35
32
|
'3': {
|
|
36
|
-
hidden: false,
|
|
37
33
|
position: 3,
|
|
38
34
|
loading: true
|
|
39
35
|
},
|
|
40
36
|
'4': {
|
|
41
|
-
hidden: false,
|
|
42
37
|
position: 4,
|
|
43
38
|
loading: true
|
|
44
39
|
}
|
|
45
40
|
};
|
|
46
|
-
const getProgressionSlidesRefs = (progression) => {
|
|
47
|
-
if (progression.state.step.current < 5) {
|
|
48
|
-
const slideRef = progression.state.nextContent.ref;
|
|
49
|
-
return concat(progression.state.slides, [slideRef]);
|
|
50
|
-
}
|
|
51
|
-
return slice(0, 5, progression.state.slides);
|
|
52
|
-
};
|
|
53
41
|
const buildStackSlides = (state, dispatch) => {
|
|
54
42
|
const currentSlideRef = state.ui.currentSlideRef;
|
|
55
43
|
const progression = state.data.progression;
|
|
@@ -57,23 +45,27 @@ const buildStackSlides = (state, dispatch) => {
|
|
|
57
45
|
return initialState;
|
|
58
46
|
const slideRefs = getProgressionSlidesRefs(progression);
|
|
59
47
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
60
|
-
const stack = reduce.convert({ cap: false })((acc, uiSlide,
|
|
61
|
-
const
|
|
48
|
+
const stack = reduce.convert({ cap: false })((acc, uiSlide, _index) => {
|
|
49
|
+
const index = toInteger(_index);
|
|
50
|
+
const positions = state.ui.positions;
|
|
51
|
+
const position = positions[index];
|
|
52
|
+
const slideRef = slideRefs[index];
|
|
62
53
|
if (!slideRef)
|
|
63
|
-
return set(index, uiSlide, acc);
|
|
54
|
+
return set(index, { ...uiSlide, position }, acc);
|
|
64
55
|
const slideFromAPI = get(slideRef, state.data.slides);
|
|
65
56
|
if (!slideFromAPI)
|
|
66
|
-
return set(index, uiSlide, acc);
|
|
57
|
+
return set(index, { ...uiSlide, position }, acc);
|
|
67
58
|
const answers = getOr([], ['ui', 'answers', slideRef], state);
|
|
68
59
|
const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
69
|
-
const
|
|
70
|
-
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
60
|
+
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
71
61
|
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
62
|
+
const slideUI = get(['ui', 'slide', slideRef], state);
|
|
63
|
+
const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
|
|
64
|
+
const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
|
|
65
|
+
const animationType = slideUI.animationType;
|
|
75
66
|
const updatedUiSlide = {
|
|
76
67
|
...uiSlide,
|
|
68
|
+
position,
|
|
77
69
|
showCorrectionPopin,
|
|
78
70
|
animateCorrectionPopin,
|
|
79
71
|
loading: false,
|
|
@@ -5,10 +5,12 @@ declare type NextSlidePayload = {
|
|
|
5
5
|
currentSlideRef: string;
|
|
6
6
|
nextSlideRef: string;
|
|
7
7
|
animationType: string;
|
|
8
|
+
totalCorrectAnswers: number;
|
|
9
|
+
answeredSlides: string[];
|
|
8
10
|
};
|
|
9
|
-
export declare type
|
|
11
|
+
export declare type NextSlideAction = {
|
|
10
12
|
type: typeof NEXT_SLIDE;
|
|
11
13
|
payload: NextSlidePayload;
|
|
12
14
|
};
|
|
13
|
-
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) =>
|
|
15
|
+
export declare const nextSlide: (dispatch: Dispatch, getState: () => StoreState) => NextSlideAction;
|
|
14
16
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import filter from 'lodash/fp/filter';
|
|
1
2
|
import get from 'lodash/fp/get';
|
|
2
|
-
import getOr from 'lodash/fp/getOr';
|
|
3
3
|
export var NEXT_SLIDE = '@@slide/NEXT_SLIDE';
|
|
4
4
|
export var nextSlide = function (dispatch, getState) {
|
|
5
5
|
var state = getState();
|
|
6
|
+
var progression = state.data.progression;
|
|
7
|
+
var _a = progression.state, isCorrect = _a.isCorrect, allAnswers = _a.allAnswers, slides = _a.slides;
|
|
8
|
+
var correctAnswers = filter(function (answer) { return answer.isCorrect; }, allAnswers);
|
|
6
9
|
var payload = {
|
|
7
10
|
currentSlideRef: get(['ui', 'currentSlideRef'], state),
|
|
8
11
|
nextSlideRef: get(['state', 'nextContent', 'ref'], state.data.progression),
|
|
9
|
-
animationType:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
animationType: isCorrect ? 'unstack' : 'restack',
|
|
13
|
+
totalCorrectAnswers: correctAnswers.length,
|
|
14
|
+
answeredSlides: slides
|
|
12
15
|
};
|
|
13
16
|
var action = {
|
|
14
17
|
type: NEXT_SLIDE,
|
|
@@ -12,10 +12,9 @@ export declare type Slide = {
|
|
|
12
12
|
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
13
13
|
};
|
|
14
14
|
export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
|
|
15
|
-
export declare type
|
|
15
|
+
export declare type SetCurrentSlideAction = {
|
|
16
16
|
type: typeof SET_CURRENT_SLIDE;
|
|
17
17
|
payload: SlideFromAPI;
|
|
18
18
|
};
|
|
19
|
-
export declare const setCurrentSlide: (payload: SlideFromAPI) =>
|
|
20
|
-
export declare type UISlidesAction = SetCurrentSlide;
|
|
19
|
+
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlideAction;
|
|
21
20
|
export {};
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProgressionFromAPI } from '../types/common';
|
|
1
2
|
export declare const VIEWS: {
|
|
2
3
|
readonly skills: 'skills';
|
|
3
4
|
readonly onboarding: 'onboarding';
|
|
@@ -5,3 +6,4 @@ export declare const VIEWS: {
|
|
|
5
6
|
};
|
|
6
7
|
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
7
8
|
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
9
|
+
export declare const getProgressionSlidesRefs: (progression: ProgressionFromAPI) => string[];
|
package/lib/common/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import concat from 'lodash/fp/concat';
|
|
2
|
+
import slice from 'lodash/fp/slice';
|
|
1
3
|
export var VIEWS = {
|
|
2
4
|
skills: 'skills',
|
|
3
5
|
onboarding: 'onboarding',
|
|
4
6
|
slides: 'slides'
|
|
5
7
|
};
|
|
6
8
|
export var slideIndexes = ['0', '1', '2', '3', '4'];
|
|
9
|
+
export var getProgressionSlidesRefs = function (progression) {
|
|
10
|
+
if (progression.state.step.current < 5) {
|
|
11
|
+
var slideRef = progression.state.nextContent.ref;
|
|
12
|
+
return concat(progression.state.slides, [slideRef]);
|
|
13
|
+
}
|
|
14
|
+
return slice(0, 5, progression.state.slides);
|
|
15
|
+
};
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
18
|
navigation: import("./ui/navigation").NavigationState;
|
|
19
19
|
answers: import("./ui/answers").UIAnswerState;
|
|
20
20
|
slide: import("./ui/slide").UISlideState;
|
|
21
|
+
positions: import("./ui/positions").UIPositionState;
|
|
21
22
|
}>;
|
|
22
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").
|
|
23
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | 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").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
23
24
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
-
import {
|
|
2
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
3
|
export declare type UISlideAnswer = string[];
|
|
4
4
|
export declare type UIAnswerState = Record<string, UISlideAnswer>;
|
|
5
5
|
export declare const initialState: UIAnswerState;
|
|
6
|
-
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction |
|
|
6
|
+
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlideAction) => UIAnswerState;
|
|
7
7
|
export default reducer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
2
|
+
import { SetCurrentSlideAction } from '../../actions/ui/slides';
|
|
2
3
|
export declare type CurrentSlideRefState = string;
|
|
3
|
-
declare const reducer: (state: string | undefined, action:
|
|
4
|
+
declare const reducer: (state: string | undefined, action: SetCurrentSlideAction | NextSlideAction) => CurrentSlideRefState;
|
|
4
5
|
export default reducer;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
1
2
|
import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
|
|
2
3
|
var reducer = function (
|
|
3
4
|
// eslint-disable-next-line default-param-last
|
|
4
5
|
state, action) {
|
|
5
6
|
if (state === void 0) { state = ''; }
|
|
6
7
|
switch (action.type) {
|
|
8
|
+
case NEXT_SLIDE:
|
|
9
|
+
return action.payload.nextSlideRef;
|
|
7
10
|
case SET_CURRENT_SLIDE: {
|
|
8
11
|
return action.payload._id;
|
|
9
12
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
3
|
import { UIAnswerState } from './answers';
|
|
4
|
+
import { UIPositionState } from './positions';
|
|
4
5
|
import { UISlideState } from './slide';
|
|
5
6
|
export declare type UIState = {
|
|
6
7
|
currentSlideRef: CurrentSlideRefState;
|
|
7
8
|
navigation: NavigationState;
|
|
8
9
|
answers: UIAnswerState;
|
|
9
10
|
slide: UISlideState;
|
|
11
|
+
positions: UIPositionState;
|
|
10
12
|
};
|
|
11
13
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
12
14
|
currentSlideRef: string;
|
|
13
15
|
navigation: NavigationState;
|
|
14
16
|
answers: UIAnswerState;
|
|
15
17
|
slide: UISlideState;
|
|
16
|
-
|
|
18
|
+
positions: UIPositionState;
|
|
19
|
+
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
17
20
|
export default _default;
|
package/lib/reducers/ui/index.js
CHANGED
|
@@ -2,10 +2,12 @@ import { combineReducers } from 'redux';
|
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
4
|
import answers from './answers';
|
|
5
|
+
import positions from './positions';
|
|
5
6
|
import slide from './slide';
|
|
6
7
|
export default combineReducers({
|
|
7
8
|
currentSlideRef: currentSlideRef,
|
|
8
9
|
navigation: navigation,
|
|
9
10
|
answers: answers,
|
|
10
|
-
slide: slide
|
|
11
|
+
slide: slide,
|
|
12
|
+
positions: positions
|
|
11
13
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
2
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
3
|
+
export declare type UIPositionState = number[];
|
|
4
|
+
declare const reducer: (state: UIPositionState | undefined, action: NextSlideAction | ReceivedProgression) => UIPositionState;
|
|
5
|
+
export default reducer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import findIndex from 'lodash/fp/findIndex';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import set from 'lodash/fp/set';
|
|
4
|
+
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
5
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
6
|
+
var initialState = [0, 1, 2, 3, 4];
|
|
7
|
+
var reducer = function (
|
|
8
|
+
// eslint-disable-next-line default-param-last
|
|
9
|
+
state, action) {
|
|
10
|
+
if (state === void 0) { state = initialState; }
|
|
11
|
+
switch (action.type) {
|
|
12
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
13
|
+
return initialState;
|
|
14
|
+
}
|
|
15
|
+
case NEXT_SLIDE: {
|
|
16
|
+
var _a = action.payload, totalCorrectAnswers = _a.totalCorrectAnswers, answeredSlides = _a.answeredSlides, currentSlideRef_1 = _a.currentSlideRef, animationType = _a.animationType;
|
|
17
|
+
var nextCurrentSlidePosition = animationType === 'unstack' ? -1 : 4 - totalCorrectAnswers;
|
|
18
|
+
var currentSlideIndex = findIndex(function (ref) { return ref === currentSlideRef_1; }, answeredSlides);
|
|
19
|
+
var newState = map(function (position) { return (position === -1 ? position : position - 1); }, state);
|
|
20
|
+
return set(["".concat(currentSlideIndex)], nextCurrentSlidePosition)(newState);
|
|
21
|
+
}
|
|
22
|
+
default:
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default reducer;
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { FetchSlide } from '../../actions/api/fetch-slide';
|
|
5
|
-
import {
|
|
5
|
+
import { NextSlideAction } from '../../actions/ui/next-slide';
|
|
6
6
|
import { SlideUIAnimations } from '../../types/slides';
|
|
7
7
|
export declare type UISlide = {
|
|
8
8
|
validateButton: boolean;
|
|
@@ -12,5 +12,5 @@ export declare type UISlide = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare type UISlideState = Record<string, UISlide>;
|
|
14
14
|
export declare const initialState: UISlideState;
|
|
15
|
-
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection |
|
|
15
|
+
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlideAction) => UISlideState;
|
|
16
16
|
export default reducer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import type
|
|
2
|
+
import { type SlideIndexes } from '../../common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
4
|
import type { AnswerUI } from '../../types/slides';
|
|
5
5
|
declare const ICON_VALUES: {
|
|
@@ -15,7 +15,6 @@ declare type StepItem = {
|
|
|
15
15
|
};
|
|
16
16
|
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
17
17
|
export declare type ReviewSlide = {
|
|
18
|
-
hidden: boolean;
|
|
19
18
|
position: number;
|
|
20
19
|
loading: boolean;
|
|
21
20
|
showCorrectionPopin?: boolean;
|