@coorpacademy/app-review 0.5.2 → 0.5.4-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/es/actions/api/fetch-rank.js +5 -1
  2. package/es/actions/ui/quit-popin.d.ts +8 -0
  3. package/es/actions/ui/quit-popin.js +8 -0
  4. package/es/reducers/data/rank.d.ts +4 -3
  5. package/es/reducers/data/rank.js +9 -18
  6. package/es/reducers/index.d.ts +7 -1
  7. package/es/reducers/ui/index.d.ts +11 -1
  8. package/es/reducers/ui/index.js +5 -1
  9. package/es/reducers/ui/navigation.js +0 -1
  10. package/es/reducers/ui/positions.js +3 -1
  11. package/es/reducers/ui/quit-popin.d.ts +4 -0
  12. package/es/reducers/ui/quit-popin.js +16 -0
  13. package/es/reducers/ui/show-congrats.d.ts +5 -0
  14. package/es/reducers/ui/show-congrats.js +20 -0
  15. package/es/reducers/ui/slide.js +4 -1
  16. package/es/views/slides/index.d.ts +18 -0
  17. package/es/views/slides/index.js +30 -2
  18. package/lib/actions/api/fetch-rank.js +7 -1
  19. package/lib/actions/ui/quit-popin.d.ts +8 -0
  20. package/lib/actions/ui/quit-popin.js +8 -0
  21. package/lib/reducers/data/rank.d.ts +4 -3
  22. package/lib/reducers/data/rank.js +9 -18
  23. package/lib/reducers/index.d.ts +7 -1
  24. package/lib/reducers/ui/index.d.ts +11 -1
  25. package/lib/reducers/ui/index.js +5 -1
  26. package/lib/reducers/ui/navigation.js +0 -1
  27. package/lib/reducers/ui/positions.js +3 -1
  28. package/lib/reducers/ui/quit-popin.d.ts +4 -0
  29. package/lib/reducers/ui/quit-popin.js +17 -0
  30. package/lib/reducers/ui/show-congrats.d.ts +5 -0
  31. package/lib/reducers/ui/show-congrats.js +21 -0
  32. package/lib/reducers/ui/slide.js +4 -1
  33. package/lib/views/slides/index.d.ts +18 -0
  34. package/lib/views/slides/index.js +32 -2
  35. package/package.json +5 -5
  36. package/src/actions/api/fetch-rank.ts +8 -1
  37. package/src/actions/api/test/fetch-correction.test.ts +4 -2
  38. package/src/actions/api/test/fetch-rank.test.ts +17 -8
  39. package/src/actions/api/test/fetch-skills.test.ts +4 -2
  40. package/src/actions/api/test/fetch-slide.test.ts +4 -2
  41. package/src/actions/api/test/post-answer.test.ts +9 -10
  42. package/src/actions/api/test/post-progression.test.ts +4 -2
  43. package/src/actions/data/test/token.test.ts +4 -2
  44. package/src/actions/ui/quit-popin.ts +10 -0
  45. package/src/actions/ui/test/answers.test.ts +4 -2
  46. package/src/actions/ui/test/next-slide.test.ts +5 -2
  47. package/src/actions/ui/test/quit-popin.test.ts +39 -0
  48. package/src/actions/ui/test/slides.test.ts +4 -2
  49. package/src/reducers/data/rank.ts +15 -31
  50. package/src/reducers/data/test/rank.test.ts +33 -52
  51. package/src/reducers/ui/index.ts +7 -1
  52. package/src/reducers/ui/navigation.ts +0 -2
  53. package/src/reducers/ui/positions.ts +3 -1
  54. package/src/reducers/ui/quit-popin.ts +22 -0
  55. package/src/reducers/ui/show-congrats.ts +26 -0
  56. package/src/reducers/ui/slide.ts +4 -2
  57. package/src/reducers/ui/test/positions.test.ts +14 -0
  58. package/src/reducers/ui/test/quit-popin.test.ts +24 -0
  59. package/src/reducers/ui/test/show-congrats.test.ts +40 -0
  60. package/src/reducers/ui/test/slide.test.ts +21 -0
  61. package/src/views/skills/test/skills.test.ts +8 -4
  62. package/src/views/slides/index.ts +52 -3
  63. package/src/views/slides/test/header.on-click.test.ts +46 -0
  64. package/src/views/slides/test/index.test.ts +76 -22
  65. package/src/views/slides/test/on-quit-popin.on-click.test.ts +65 -0
  66. package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
  67. package/src/views/slides/test/slide.next-slide.on-click.test.ts +107 -2
  68. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -2
  69. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +4 -2
  70. package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -2
  71. package/src/views/slides/test/slide.slider.on-change.test.ts +4 -2
  72. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +4 -2
  73. package/src/views/slides/test/slide.template.on-change.test.ts +4 -2
@@ -6,6 +6,10 @@ export const RANK_FETCH_START_FAILURE = '@@rank/FETCH_START_FAILURE';
6
6
  export const RANK_FETCH_END_REQUEST = '@@rank/FETCH_END_REQUEST';
7
7
  export const RANK_FETCH_END_SUCCESS = '@@rank/FETCH_END_SUCCESS';
8
8
  export const RANK_FETCH_END_FAILURE = '@@rank/FETCH_END_FAILURE';
9
+ const bailout = (path) => (state) => {
10
+ const value = get(path, state);
11
+ return !Number.isNaN(value);
12
+ };
9
13
  export const fetchRank = (dispatch, getState, services, types, path) => {
10
14
  const action = buildTask({
11
15
  types,
@@ -14,7 +18,7 @@ export const fetchRank = (dispatch, getState, services, types, path) => {
14
18
  const token = get(['data', 'token'], state);
15
19
  return services.fetchRank(token);
16
20
  },
17
- bailout: path ? (state) => !!get(path, state) : undefined
21
+ bailout: path ? bailout(path) : undefined
18
22
  });
19
23
  return dispatch(action);
20
24
  };
@@ -0,0 +1,8 @@
1
+ export declare const OPEN_POPIN: "@@ui/OPEN_POPIN";
2
+ export declare const CLOSE_POPIN: "@@ui/CLOSE_POPIN";
3
+ export declare const openQuitPopin: {
4
+ type: "@@ui/OPEN_POPIN";
5
+ };
6
+ export declare const closeQuitPopin: {
7
+ type: "@@ui/CLOSE_POPIN";
8
+ };
@@ -0,0 +1,8 @@
1
+ export const OPEN_POPIN = '@@ui/OPEN_POPIN';
2
+ export const CLOSE_POPIN = '@@ui/CLOSE_POPIN';
3
+ export const openQuitPopin = {
4
+ type: OPEN_POPIN
5
+ };
6
+ export const closeQuitPopin = {
7
+ type: CLOSE_POPIN
8
+ };
@@ -1,7 +1,8 @@
1
+ import { type ReceivedProgression } from '../../actions/api/post-progression';
1
2
  import { RankAction } from '../../actions/api/fetch-rank';
2
3
  export declare type RankState = {
3
- start?: number | null;
4
- end?: number | null;
4
+ start: number;
5
+ end: number;
5
6
  };
6
- declare const reducer: (state: RankState | undefined, action: RankAction) => RankState;
7
+ declare const reducer: (state: RankState | undefined, action: RankAction | ReceivedProgression) => RankState;
7
8
  export default reducer;
@@ -1,34 +1,25 @@
1
- import { get, isNull, isUndefined, pipe, set, unset, update } from 'lodash/fp';
2
- import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../actions/api/fetch-rank';
3
- const initialState = {};
1
+ import set from 'lodash/fp/set';
2
+ import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
3
+ import { RANK_FETCH_START_SUCCESS, RANK_FETCH_END_SUCCESS } from '../../actions/api/fetch-rank';
4
+ const initialState = {
5
+ start: Number.NaN,
6
+ end: Number.NaN
7
+ };
4
8
  const reducer = (
5
9
  // eslint-disable-next-line default-param-last
6
10
  state = initialState, action) => {
7
11
  switch (action.type) {
8
- case RANK_FETCH_START_REQUEST: {
9
- return update('start', (startRank) => (isUndefined(startRank) ? null : startRank), state);
12
+ case POST_PROGRESSION_SUCCESS: {
13
+ return initialState;
10
14
  }
11
15
  case RANK_FETCH_START_SUCCESS: {
12
16
  const { payload } = action;
13
17
  return set('start', payload.rank, state);
14
18
  }
15
- case RANK_FETCH_START_FAILURE: {
16
- if (pipe(get('start'), isNull)(state))
17
- return unset('start', state);
18
- return state;
19
- }
20
- case RANK_FETCH_END_REQUEST: {
21
- return update('end', (endRank) => (isUndefined(endRank) ? null : endRank), state);
22
- }
23
19
  case RANK_FETCH_END_SUCCESS: {
24
20
  const { payload } = action;
25
21
  return set('end', payload.rank, state);
26
22
  }
27
- case RANK_FETCH_END_FAILURE: {
28
- if (pipe(get('end'), isNull)(state))
29
- return unset('end', state);
30
- return state;
31
- }
32
23
  default:
33
24
  return state;
34
25
  }
@@ -19,6 +19,12 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
19
  answers: import("./ui/answers").UIAnswerState;
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
+ showQuitPopin: boolean;
23
+ showCongrats: boolean;
22
24
  }>;
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>;
25
+ }>, 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 | {
26
+ type: "@@ui/OPEN_POPIN";
27
+ } | {
28
+ type: "@@ui/CLOSE_POPIN";
29
+ }>;
24
30
  export default _default;
@@ -3,12 +3,16 @@ import { NavigationState } from './navigation';
3
3
  import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
+ import { type ShowQuitPopinState } from './quit-popin';
7
+ import { UIShowCongratsState } from './show-congrats';
6
8
  export declare type UIState = {
7
9
  currentSlideRef: CurrentSlideRefState;
8
10
  navigation: NavigationState;
9
11
  answers: UIAnswerState;
10
12
  slide: UISlideState;
11
13
  positions: UIPositionState;
14
+ showQuitPopin: ShowQuitPopinState;
15
+ showCongrats: UIShowCongratsState;
12
16
  };
13
17
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
14
18
  currentSlideRef: string;
@@ -16,5 +20,11 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
20
  answers: UIAnswerState;
17
21
  slide: UISlideState;
18
22
  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>;
23
+ showQuitPopin: boolean;
24
+ showCongrats: boolean;
25
+ }>, 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 | {
26
+ type: "@@ui/OPEN_POPIN";
27
+ } | {
28
+ type: "@@ui/CLOSE_POPIN";
29
+ }>;
20
30
  export default _default;
@@ -4,10 +4,14 @@ import navigation from './navigation';
4
4
  import answers from './answers';
5
5
  import positions from './positions';
6
6
  import slide from './slide';
7
+ import showQuitPopin from './quit-popin';
8
+ import showCongrats from './show-congrats';
7
9
  export default combineReducers({
8
10
  currentSlideRef,
9
11
  navigation,
10
12
  answers,
11
13
  slide,
12
- positions
14
+ positions,
15
+ showQuitPopin,
16
+ showCongrats
13
17
  });
@@ -15,5 +15,4 @@ state = [], action) => {
15
15
  return state;
16
16
  }
17
17
  };
18
- // -----------------------------------------------------------------------------
19
18
  export default reducer;
@@ -12,7 +12,9 @@ state = initialState, action) => {
12
12
  return initialState;
13
13
  }
14
14
  case NEXT_SLIDE: {
15
- const { totalCorrectAnswers, answeredSlides, currentSlideRef, animationType } = action.payload;
15
+ const { totalCorrectAnswers, answeredSlides, currentSlideRef, animationType, nextSlideRef } = action.payload;
16
+ if (nextSlideRef === 'successExitNode')
17
+ return state;
16
18
  const nextCurrentSlidePosition = animationType === 'unstack' ? -1 : 4 - totalCorrectAnswers;
17
19
  const currentSlideIndex = findIndex(ref => ref === currentSlideRef, answeredSlides);
18
20
  const newState = map(position => (position === -1 ? position : position - 1), state);
@@ -0,0 +1,4 @@
1
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
2
+ export declare type ShowQuitPopinState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: typeof openQuitPopin | typeof closeQuitPopin) => ShowQuitPopinState;
4
+ export default reducer;
@@ -0,0 +1,16 @@
1
+ import { CLOSE_POPIN, OPEN_POPIN } from '../../actions/ui/quit-popin';
2
+ const reducer = (
3
+ // eslint-disable-next-line default-param-last
4
+ state = false, action) => {
5
+ switch (action.type) {
6
+ case OPEN_POPIN: {
7
+ return true;
8
+ }
9
+ case CLOSE_POPIN: {
10
+ return false;
11
+ }
12
+ default:
13
+ return state;
14
+ }
15
+ };
16
+ export default reducer;
@@ -0,0 +1,5 @@
1
+ import { NextSlideAction } from '../../actions/ui/next-slide';
2
+ import { ReceivedProgression } from '../../actions/api/post-progression';
3
+ export declare type UIShowCongratsState = boolean;
4
+ declare const reducer: (state: boolean | undefined, action: NextSlideAction | ReceivedProgression) => UIShowCongratsState;
5
+ export default reducer;
@@ -0,0 +1,20 @@
1
+ import { NEXT_SLIDE } from '../../actions/ui/next-slide';
2
+ import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
3
+ const reducer = (
4
+ // eslint-disable-next-line default-param-last
5
+ state = false, action) => {
6
+ switch (action.type) {
7
+ case POST_PROGRESSION_SUCCESS: {
8
+ return false;
9
+ }
10
+ case NEXT_SLIDE: {
11
+ const { nextSlideRef } = action.payload;
12
+ if (nextSlideRef === 'successExitNode')
13
+ return true;
14
+ return false;
15
+ }
16
+ default:
17
+ return state;
18
+ }
19
+ };
20
+ export default reducer;
@@ -35,7 +35,10 @@ state = initialState, action) => {
35
35
  return pipe(set([action.meta.slideRef, 'animateCorrectionPopin'], true), set([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
36
36
  }
37
37
  case NEXT_SLIDE: {
38
- return pipe(set([action.payload.currentSlideRef, 'animateCorrectionPopin'], false), set([action.payload.currentSlideRef, 'animationType'], action.payload.animationType))(state);
38
+ const { currentSlideRef, nextSlideRef } = action.payload;
39
+ if (nextSlideRef === 'successExitNode')
40
+ return state;
41
+ return pipe(set([currentSlideRef, 'animateCorrectionPopin'], false), set([currentSlideRef, 'animationType'], action.payload.animationType))(state);
39
42
  }
40
43
  default:
41
44
  return state;
@@ -40,6 +40,15 @@ declare type CorrectionPopinNext = {
40
40
  ariaLabel: string;
41
41
  onClick: Function;
42
42
  };
43
+ declare type QuitPopinButton = {
44
+ label: string;
45
+ type: string;
46
+ customStyle?: {
47
+ color: string;
48
+ };
49
+ handleOnclick: Function;
50
+ ariaLabel: string;
51
+ };
43
52
  export declare type CorrectionPopinProps = {
44
53
  klf?: CorrectionPopinKlf;
45
54
  information: CorrectionPopinInformation;
@@ -47,6 +56,14 @@ export declare type CorrectionPopinProps = {
47
56
  resultLabel: string;
48
57
  type: 'right' | 'wrong';
49
58
  };
59
+ export declare type QuitPopinProps = {
60
+ content: string;
61
+ icon: string;
62
+ mode: string;
63
+ descriptionText: string;
64
+ firstButton: QuitPopinButton;
65
+ secondButton: QuitPopinButton;
66
+ };
50
67
  export declare type SlidesViewProps = {
51
68
  header: {
52
69
  mode: string;
@@ -87,6 +104,7 @@ export declare type SlidesViewProps = {
87
104
  type: string;
88
105
  };
89
106
  };
107
+ quitPopin?: QuitPopinProps;
90
108
  };
91
109
  export declare const initialState: SlidesStack;
92
110
  export declare const buildStepItems: (state: StoreState) => StepItem[];
@@ -6,6 +6,7 @@ import reduce from 'lodash/fp/reduce';
6
6
  import set from 'lodash/fp/set';
7
7
  import toInteger from 'lodash/fp/toInteger';
8
8
  import join from 'lodash/fp/join';
9
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
9
10
  import { getProgressionSlidesRefs } from '../../common';
10
11
  import { postAnswer } from '../../actions/api/post-answer';
11
12
  import { nextSlide } from '../../actions/ui/next-slide';
@@ -168,16 +169,42 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) =>
168
169
  type: isCorrect ? 'right' : 'wrong'
169
170
  };
170
171
  };
172
+ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
173
+ return {
174
+ content: `Tu t'en vas déjà ?`,
175
+ icon: `MoonRocket`,
176
+ mode: 'alert',
177
+ descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
178
+ firstButton: {
179
+ label: 'Arrêter ma session',
180
+ type: 'tertiary',
181
+ customStyle: {
182
+ color: '#ED3436'
183
+ },
184
+ handleOnclick: onQuitClick,
185
+ ariaLabel: 'Stop session'
186
+ },
187
+ secondButton: {
188
+ label: `Continuer d'apprendre`,
189
+ type: 'primary',
190
+ handleOnclick: () => {
191
+ dispatch(closeQuitPopin);
192
+ },
193
+ ariaLabel: 'Continue review'
194
+ }
195
+ };
196
+ };
171
197
  export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
172
198
  const currentSlideRef = get(['ui', 'currentSlideRef'], state);
173
199
  const correction = get(['data', 'corrections', currentSlideRef], state);
174
200
  const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
175
201
  const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
202
+ const showQuitPopin = get(['ui', 'showQuitPopin'], state);
176
203
  return {
177
204
  header: {
178
205
  mode: '__revision_mode',
179
206
  skillName: '__agility',
180
- onQuitClick,
207
+ onQuitClick: () => dispatch(openQuitPopin),
181
208
  'aria-label': 'aria-header-wrapper',
182
209
  closeButtonAriaLabel: 'aria-close-button',
183
210
  steps: buildStepItems(state)
@@ -194,6 +221,7 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
194
221
  correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
195
222
  endReview: false
196
223
  },
197
- congrats: undefined
224
+ congrats: undefined,
225
+ quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
198
226
  };
199
227
  };
@@ -6,6 +6,12 @@ export var RANK_FETCH_START_FAILURE = '@@rank/FETCH_START_FAILURE';
6
6
  export var RANK_FETCH_END_REQUEST = '@@rank/FETCH_END_REQUEST';
7
7
  export var RANK_FETCH_END_SUCCESS = '@@rank/FETCH_END_SUCCESS';
8
8
  export var RANK_FETCH_END_FAILURE = '@@rank/FETCH_END_FAILURE';
9
+ var bailout = function (path) {
10
+ return function (state) {
11
+ var value = get(path, state);
12
+ return !Number.isNaN(value);
13
+ };
14
+ };
9
15
  export var fetchRank = function (dispatch, getState, services, types, path) {
10
16
  var action = buildTask({
11
17
  types: types,
@@ -14,7 +20,7 @@ export var fetchRank = function (dispatch, getState, services, types, path) {
14
20
  var token = get(['data', 'token'], state);
15
21
  return services.fetchRank(token);
16
22
  },
17
- bailout: path ? function (state) { return !!get(path, state); } : undefined
23
+ bailout: path ? bailout(path) : undefined
18
24
  });
19
25
  return dispatch(action);
20
26
  };
@@ -0,0 +1,8 @@
1
+ export declare const OPEN_POPIN: "@@ui/OPEN_POPIN";
2
+ export declare const CLOSE_POPIN: "@@ui/CLOSE_POPIN";
3
+ export declare const openQuitPopin: {
4
+ type: "@@ui/OPEN_POPIN";
5
+ };
6
+ export declare const closeQuitPopin: {
7
+ type: "@@ui/CLOSE_POPIN";
8
+ };
@@ -0,0 +1,8 @@
1
+ export var OPEN_POPIN = '@@ui/OPEN_POPIN';
2
+ export var CLOSE_POPIN = '@@ui/CLOSE_POPIN';
3
+ export var openQuitPopin = {
4
+ type: OPEN_POPIN
5
+ };
6
+ export var closeQuitPopin = {
7
+ type: CLOSE_POPIN
8
+ };
@@ -1,7 +1,8 @@
1
+ import { type ReceivedProgression } from '../../actions/api/post-progression';
1
2
  import { RankAction } from '../../actions/api/fetch-rank';
2
3
  export declare type RankState = {
3
- start?: number | null;
4
- end?: number | null;
4
+ start: number;
5
+ end: number;
5
6
  };
6
- declare const reducer: (state: RankState | undefined, action: RankAction) => RankState;
7
+ declare const reducer: (state: RankState | undefined, action: RankAction | ReceivedProgression) => RankState;
7
8
  export default reducer;
@@ -1,35 +1,26 @@
1
- import { get, isNull, isUndefined, pipe, set, unset, update } from 'lodash/fp';
2
- import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../actions/api/fetch-rank';
3
- var initialState = {};
1
+ import set from 'lodash/fp/set';
2
+ import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
3
+ import { RANK_FETCH_START_SUCCESS, RANK_FETCH_END_SUCCESS } from '../../actions/api/fetch-rank';
4
+ var initialState = {
5
+ start: Number.NaN,
6
+ end: Number.NaN
7
+ };
4
8
  var reducer = function (
5
9
  // eslint-disable-next-line default-param-last
6
10
  state, action) {
7
11
  if (state === void 0) { state = initialState; }
8
12
  switch (action.type) {
9
- case RANK_FETCH_START_REQUEST: {
10
- return update('start', function (startRank) { return (isUndefined(startRank) ? null : startRank); }, state);
13
+ case POST_PROGRESSION_SUCCESS: {
14
+ return initialState;
11
15
  }
12
16
  case RANK_FETCH_START_SUCCESS: {
13
17
  var payload = action.payload;
14
18
  return set('start', payload.rank, state);
15
19
  }
16
- case RANK_FETCH_START_FAILURE: {
17
- if (pipe(get('start'), isNull)(state))
18
- return unset('start', state);
19
- return state;
20
- }
21
- case RANK_FETCH_END_REQUEST: {
22
- return update('end', function (endRank) { return (isUndefined(endRank) ? null : endRank); }, state);
23
- }
24
20
  case RANK_FETCH_END_SUCCESS: {
25
21
  var payload = action.payload;
26
22
  return set('end', payload.rank, state);
27
23
  }
28
- case RANK_FETCH_END_FAILURE: {
29
- if (pipe(get('end'), isNull)(state))
30
- return unset('end', state);
31
- return state;
32
- }
33
24
  default:
34
25
  return state;
35
26
  }
@@ -19,6 +19,12 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
19
  answers: import("./ui/answers").UIAnswerState;
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
+ showQuitPopin: boolean;
23
+ showCongrats: boolean;
22
24
  }>;
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>;
25
+ }>, 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 | {
26
+ type: "@@ui/OPEN_POPIN";
27
+ } | {
28
+ type: "@@ui/CLOSE_POPIN";
29
+ }>;
24
30
  export default _default;
@@ -3,12 +3,16 @@ import { NavigationState } from './navigation';
3
3
  import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
+ import { type ShowQuitPopinState } from './quit-popin';
7
+ import { UIShowCongratsState } from './show-congrats';
6
8
  export declare type UIState = {
7
9
  currentSlideRef: CurrentSlideRefState;
8
10
  navigation: NavigationState;
9
11
  answers: UIAnswerState;
10
12
  slide: UISlideState;
11
13
  positions: UIPositionState;
14
+ showQuitPopin: ShowQuitPopinState;
15
+ showCongrats: UIShowCongratsState;
12
16
  };
13
17
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
14
18
  currentSlideRef: string;
@@ -16,5 +20,11 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
20
  answers: UIAnswerState;
17
21
  slide: UISlideState;
18
22
  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>;
23
+ showQuitPopin: boolean;
24
+ showCongrats: boolean;
25
+ }>, 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 | {
26
+ type: "@@ui/OPEN_POPIN";
27
+ } | {
28
+ type: "@@ui/CLOSE_POPIN";
29
+ }>;
20
30
  export default _default;
@@ -4,10 +4,14 @@ import navigation from './navigation';
4
4
  import answers from './answers';
5
5
  import positions from './positions';
6
6
  import slide from './slide';
7
+ import showQuitPopin from './quit-popin';
8
+ import showCongrats from './show-congrats';
7
9
  export default combineReducers({
8
10
  currentSlideRef: currentSlideRef,
9
11
  navigation: navigation,
10
12
  answers: answers,
11
13
  slide: slide,
12
- positions: positions
14
+ positions: positions,
15
+ showQuitPopin: showQuitPopin,
16
+ showCongrats: showCongrats
13
17
  });
@@ -25,5 +25,4 @@ state, action) {
25
25
  return state;
26
26
  }
27
27
  };
28
- // -----------------------------------------------------------------------------
29
28
  export default reducer;
@@ -13,7 +13,9 @@ state, action) {
13
13
  return initialState;
14
14
  }
15
15
  case NEXT_SLIDE: {
16
- var _a = action.payload, totalCorrectAnswers = _a.totalCorrectAnswers, answeredSlides = _a.answeredSlides, currentSlideRef_1 = _a.currentSlideRef, animationType = _a.animationType;
16
+ var _a = action.payload, totalCorrectAnswers = _a.totalCorrectAnswers, answeredSlides = _a.answeredSlides, currentSlideRef_1 = _a.currentSlideRef, animationType = _a.animationType, nextSlideRef = _a.nextSlideRef;
17
+ if (nextSlideRef === 'successExitNode')
18
+ return state;
17
19
  var nextCurrentSlidePosition = animationType === 'unstack' ? -1 : 4 - totalCorrectAnswers;
18
20
  var currentSlideIndex = findIndex(function (ref) { return ref === currentSlideRef_1; }, answeredSlides);
19
21
  var newState = map(function (position) { return (position === -1 ? position : position - 1); }, state);
@@ -0,0 +1,4 @@
1
+ import { closeQuitPopin, openQuitPopin } from '../../actions/ui/quit-popin';
2
+ export declare type ShowQuitPopinState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: typeof openQuitPopin | typeof closeQuitPopin) => ShowQuitPopinState;
4
+ export default reducer;
@@ -0,0 +1,17 @@
1
+ import { CLOSE_POPIN, OPEN_POPIN } from '../../actions/ui/quit-popin';
2
+ var reducer = function (
3
+ // eslint-disable-next-line default-param-last
4
+ state, action) {
5
+ if (state === void 0) { state = false; }
6
+ switch (action.type) {
7
+ case OPEN_POPIN: {
8
+ return true;
9
+ }
10
+ case CLOSE_POPIN: {
11
+ return false;
12
+ }
13
+ default:
14
+ return state;
15
+ }
16
+ };
17
+ export default reducer;
@@ -0,0 +1,5 @@
1
+ import { NextSlideAction } from '../../actions/ui/next-slide';
2
+ import { ReceivedProgression } from '../../actions/api/post-progression';
3
+ export declare type UIShowCongratsState = boolean;
4
+ declare const reducer: (state: boolean | undefined, action: NextSlideAction | ReceivedProgression) => UIShowCongratsState;
5
+ export default reducer;
@@ -0,0 +1,21 @@
1
+ import { NEXT_SLIDE } from '../../actions/ui/next-slide';
2
+ import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
3
+ var reducer = function (
4
+ // eslint-disable-next-line default-param-last
5
+ state, action) {
6
+ if (state === void 0) { state = false; }
7
+ switch (action.type) {
8
+ case POST_PROGRESSION_SUCCESS: {
9
+ return false;
10
+ }
11
+ case NEXT_SLIDE: {
12
+ var nextSlideRef = action.payload.nextSlideRef;
13
+ if (nextSlideRef === 'successExitNode')
14
+ return true;
15
+ return false;
16
+ }
17
+ default:
18
+ return state;
19
+ }
20
+ };
21
+ export default reducer;
@@ -36,7 +36,10 @@ state, action) {
36
36
  return pipe(set([action.meta.slideRef, 'animateCorrectionPopin'], true), set([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
37
37
  }
38
38
  case NEXT_SLIDE: {
39
- return pipe(set([action.payload.currentSlideRef, 'animateCorrectionPopin'], false), set([action.payload.currentSlideRef, 'animationType'], action.payload.animationType))(state);
39
+ var _a = action.payload, currentSlideRef = _a.currentSlideRef, nextSlideRef = _a.nextSlideRef;
40
+ if (nextSlideRef === 'successExitNode')
41
+ return state;
42
+ return pipe(set([currentSlideRef, 'animateCorrectionPopin'], false), set([currentSlideRef, 'animationType'], action.payload.animationType))(state);
40
43
  }
41
44
  default:
42
45
  return state;
@@ -40,6 +40,15 @@ declare type CorrectionPopinNext = {
40
40
  ariaLabel: string;
41
41
  onClick: Function;
42
42
  };
43
+ declare type QuitPopinButton = {
44
+ label: string;
45
+ type: string;
46
+ customStyle?: {
47
+ color: string;
48
+ };
49
+ handleOnclick: Function;
50
+ ariaLabel: string;
51
+ };
43
52
  export declare type CorrectionPopinProps = {
44
53
  klf?: CorrectionPopinKlf;
45
54
  information: CorrectionPopinInformation;
@@ -47,6 +56,14 @@ export declare type CorrectionPopinProps = {
47
56
  resultLabel: string;
48
57
  type: 'right' | 'wrong';
49
58
  };
59
+ export declare type QuitPopinProps = {
60
+ content: string;
61
+ icon: string;
62
+ mode: string;
63
+ descriptionText: string;
64
+ firstButton: QuitPopinButton;
65
+ secondButton: QuitPopinButton;
66
+ };
50
67
  export declare type SlidesViewProps = {
51
68
  header: {
52
69
  mode: string;
@@ -87,6 +104,7 @@ export declare type SlidesViewProps = {
87
104
  type: string;
88
105
  };
89
106
  };
107
+ quitPopin?: QuitPopinProps;
90
108
  };
91
109
  export declare const initialState: SlidesStack;
92
110
  export declare const buildStepItems: (state: StoreState) => StepItem[];