@coorpacademy/app-review 0.5.7-alpha.0 → 0.6.1-alpha.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.
Files changed (227) hide show
  1. package/es/actions/api/fetch-correction.d.ts +2 -2
  2. package/es/actions/api/fetch-rank.d.ts +3 -3
  3. package/es/actions/api/fetch-skills.d.ts +2 -2
  4. package/es/actions/api/fetch-slide.d.ts +2 -2
  5. package/es/actions/api/post-answer.d.ts +2 -2
  6. package/es/actions/api/post-progression.d.ts +2 -2
  7. package/es/actions/ui/navigation.d.ts +11 -10
  8. package/es/actions/ui/navigation.js +23 -7
  9. package/es/common/index.d.ts +0 -5
  10. package/es/common/index.js +0 -5
  11. package/es/configure-store.js +5 -1
  12. package/es/index.js +3 -3
  13. package/es/reducers/index.d.ts +1 -1
  14. package/es/reducers/ui/index.d.ts +1 -1
  15. package/es/reducers/ui/navigation.d.ts +2 -2
  16. package/es/reducers/ui/navigation.js +1 -1
  17. package/es/types/common.d.ts +7 -4
  18. package/es/views/skills/index.d.ts +1 -3
  19. package/es/views/skills/index.js +0 -2
  20. package/es/views/slides/index.d.ts +4 -112
  21. package/es/views/slides/index.js +6 -4
  22. package/lib/actions/api/fetch-correction.d.ts +2 -2
  23. package/lib/actions/api/fetch-correction.js +22 -16
  24. package/lib/actions/api/fetch-rank.d.ts +3 -3
  25. package/lib/actions/api/fetch-rank.js +33 -28
  26. package/lib/actions/api/fetch-skills.d.ts +2 -2
  27. package/lib/actions/api/fetch-skills.js +18 -12
  28. package/lib/actions/api/fetch-slide.d.ts +2 -2
  29. package/lib/actions/api/fetch-slide.js +35 -78
  30. package/lib/actions/api/post-answer.d.ts +2 -2
  31. package/lib/actions/api/post-answer.js +40 -89
  32. package/lib/actions/api/post-progression.d.ts +2 -2
  33. package/lib/actions/api/post-progression.js +24 -69
  34. package/lib/actions/data/token.js +8 -4
  35. package/lib/actions/ui/answers.js +45 -49
  36. package/lib/actions/ui/navigation.d.ts +11 -10
  37. package/lib/actions/ui/navigation.js +31 -10
  38. package/lib/actions/ui/next-slide.js +21 -14
  39. package/lib/actions/ui/quit-popin.js +9 -6
  40. package/lib/actions/ui/slides.js +9 -5
  41. package/lib/common/index.d.ts +0 -5
  42. package/lib/common/index.js +13 -11
  43. package/lib/configure-store.js +20 -10
  44. package/lib/helpers/css-register.js +7 -2
  45. package/lib/index.js +73 -58
  46. package/lib/reducers/data/corrections.js +18 -14
  47. package/lib/reducers/data/index.js +13 -8
  48. package/lib/reducers/data/progression.js +10 -9
  49. package/lib/reducers/data/rank.js +19 -15
  50. package/lib/reducers/data/skills.js +6 -5
  51. package/lib/reducers/data/slides.js +17 -12
  52. package/lib/reducers/data/token.js +6 -5
  53. package/lib/reducers/index.d.ts +1 -1
  54. package/lib/reducers/index.js +11 -6
  55. package/lib/reducers/ui/answers.js +19 -17
  56. package/lib/reducers/ui/current-slide-ref.js +9 -8
  57. package/lib/reducers/ui/index.d.ts +1 -1
  58. package/lib/reducers/ui/index.js +21 -16
  59. package/lib/reducers/ui/navigation.d.ts +2 -2
  60. package/lib/reducers/ui/navigation.js +10 -18
  61. package/lib/reducers/ui/positions.js +21 -17
  62. package/lib/reducers/ui/quit-popin.js +8 -7
  63. package/lib/reducers/ui/show-congrats.js +10 -9
  64. package/lib/reducers/ui/slide.js +36 -31
  65. package/lib/services/fetch-correction.js +19 -56
  66. package/lib/services/fetch-rank.js +15 -52
  67. package/lib/services/fetch-skills.js +15 -52
  68. package/lib/services/fetch-slide.js +15 -52
  69. package/lib/services/fetch-slides-to-review-by-skill-ref.js +13 -50
  70. package/lib/services/index.js +20 -16
  71. package/lib/services/post-answer.js +25 -62
  72. package/lib/services/post-progression.js +25 -62
  73. package/lib/services/tools/fetch-responses.js +36 -108
  74. package/lib/services/tools/sleep.js +7 -5
  75. package/lib/types/common.d.ts +7 -4
  76. package/lib/types/common.js +2 -1
  77. package/lib/types/slides.js +2 -1
  78. package/lib/views/skills/index.d.ts +1 -3
  79. package/lib/views/skills/index.js +8 -6
  80. package/lib/views/slides/index.d.ts +4 -112
  81. package/lib/views/slides/index.js +153 -141
  82. package/lib/views/slides/map-api-slide-to-ui.js +123 -134
  83. package/package.json +5 -13
  84. package/es/actions/index.d.ts +0 -5
  85. package/es/actions/index.js +0 -1
  86. package/es/actions/test/create-test-store.d.ts +0 -5
  87. package/es/actions/test/create-test-store.js +0 -16
  88. package/es/test/index.test.d.ts +0 -1
  89. package/es/test/index.test.js +0 -66
  90. package/es/test/util/services.mock.d.ts +0 -7
  91. package/es/test/util/services.mock.js +0 -444
  92. package/es/views/slides/test/fixtures/free-text.d.ts +0 -4
  93. package/es/views/slides/test/fixtures/free-text.js +0 -38
  94. package/es/views/slides/test/fixtures/qcm-drag.d.ts +0 -4
  95. package/es/views/slides/test/fixtures/qcm-drag.js +0 -108
  96. package/es/views/slides/test/fixtures/qcm-graphic.d.ts +0 -4
  97. package/es/views/slides/test/fixtures/qcm-graphic.js +0 -252
  98. package/es/views/slides/test/fixtures/qcm.d.ts +0 -4
  99. package/es/views/slides/test/fixtures/qcm.js +0 -109
  100. package/es/views/slides/test/fixtures/slider.d.ts +0 -4
  101. package/es/views/slides/test/fixtures/slider.js +0 -37
  102. package/es/views/slides/test/fixtures/template.d.ts +0 -4
  103. package/es/views/slides/test/fixtures/template.js +0 -170
  104. package/lib/actions/index.d.ts +0 -5
  105. package/lib/actions/index.js +0 -1
  106. package/lib/actions/test/create-test-store.d.ts +0 -5
  107. package/lib/actions/test/create-test-store.js +0 -18
  108. package/lib/test/index.test.d.ts +0 -1
  109. package/lib/test/index.test.js +0 -170
  110. package/lib/test/util/services.mock.d.ts +0 -7
  111. package/lib/test/util/services.mock.js +0 -448
  112. package/lib/views/slides/test/fixtures/free-text.d.ts +0 -4
  113. package/lib/views/slides/test/fixtures/free-text.js +0 -38
  114. package/lib/views/slides/test/fixtures/qcm-drag.d.ts +0 -4
  115. package/lib/views/slides/test/fixtures/qcm-drag.js +0 -108
  116. package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +0 -4
  117. package/lib/views/slides/test/fixtures/qcm-graphic.js +0 -252
  118. package/lib/views/slides/test/fixtures/qcm.d.ts +0 -4
  119. package/lib/views/slides/test/fixtures/qcm.js +0 -109
  120. package/lib/views/slides/test/fixtures/slider.d.ts +0 -4
  121. package/lib/views/slides/test/fixtures/slider.js +0 -37
  122. package/lib/views/slides/test/fixtures/template.d.ts +0 -4
  123. package/lib/views/slides/test/fixtures/template.js +0 -170
  124. package/src/actions/api/fetch-correction.ts +0 -39
  125. package/src/actions/api/fetch-rank.ts +0 -91
  126. package/src/actions/api/fetch-skills.ts +0 -31
  127. package/src/actions/api/fetch-slide.ts +0 -50
  128. package/src/actions/api/post-answer.ts +0 -55
  129. package/src/actions/api/post-progression.ts +0 -33
  130. package/src/actions/api/test/fetch-correction.test.ts +0 -119
  131. package/src/actions/api/test/fetch-rank.test.ts +0 -138
  132. package/src/actions/api/test/fetch-skills.test.ts +0 -78
  133. package/src/actions/api/test/fetch-slide.test.ts +0 -85
  134. package/src/actions/api/test/post-answer.test.ts +0 -262
  135. package/src/actions/api/test/post-progression.test.ts +0 -127
  136. package/src/actions/data/test/token.test.ts +0 -32
  137. package/src/actions/data/token.ts +0 -11
  138. package/src/actions/index.ts +0 -6
  139. package/src/actions/test/create-test-store.ts +0 -25
  140. package/src/actions/ui/answers.ts +0 -77
  141. package/src/actions/ui/navigation.ts +0 -30
  142. package/src/actions/ui/next-slide.ts +0 -44
  143. package/src/actions/ui/quit-popin.ts +0 -10
  144. package/src/actions/ui/slides.ts +0 -26
  145. package/src/actions/ui/test/answers.test.ts +0 -174
  146. package/src/actions/ui/test/next-slide.test.ts +0 -87
  147. package/src/actions/ui/test/quit-popin.test.ts +0 -39
  148. package/src/actions/ui/test/slides.test.ts +0 -33
  149. package/src/common/index.ts +0 -25
  150. package/src/common/test/get-progression-slide-ref.test.ts +0 -35
  151. package/src/configure-store.ts +0 -22
  152. package/src/helpers/css-modules-require-hook.d.ts +0 -4
  153. package/src/helpers/css-register.ts +0 -3
  154. package/src/index.tsx +0 -105
  155. package/src/reducers/data/corrections.ts +0 -36
  156. package/src/reducers/data/index.ts +0 -19
  157. package/src/reducers/data/progression.ts +0 -23
  158. package/src/reducers/data/rank.ts +0 -44
  159. package/src/reducers/data/skills.ts +0 -16
  160. package/src/reducers/data/slides.ts +0 -31
  161. package/src/reducers/data/test/corrections.test.ts +0 -36
  162. package/src/reducers/data/test/progression.test.ts +0 -28
  163. package/src/reducers/data/test/rank.test.ts +0 -59
  164. package/src/reducers/data/test/skills.test.ts +0 -14
  165. package/src/reducers/data/test/slides.test.ts +0 -27
  166. package/src/reducers/data/test/token.test.ts +0 -13
  167. package/src/reducers/data/token.ts +0 -15
  168. package/src/reducers/index.ts +0 -14
  169. package/src/reducers/ui/answers.ts +0 -41
  170. package/src/reducers/ui/current-slide-ref.ts +0 -22
  171. package/src/reducers/ui/index.ts +0 -29
  172. package/src/reducers/ui/navigation.ts +0 -29
  173. package/src/reducers/ui/positions.ts +0 -34
  174. package/src/reducers/ui/quit-popin.ts +0 -22
  175. package/src/reducers/ui/show-congrats.ts +0 -26
  176. package/src/reducers/ui/slide.ts +0 -87
  177. package/src/reducers/ui/test/answers.test.ts +0 -105
  178. package/src/reducers/ui/test/current-slide-ref.test.ts +0 -14
  179. package/src/reducers/ui/test/navigation.test.ts +0 -19
  180. package/src/reducers/ui/test/positions.test.ts +0 -82
  181. package/src/reducers/ui/test/quit-popin.test.ts +0 -24
  182. package/src/reducers/ui/test/show-congrats.test.ts +0 -40
  183. package/src/reducers/ui/test/slide.test.ts +0 -110
  184. package/src/services/fetch-correction.ts +0 -26
  185. package/src/services/fetch-rank.ts +0 -14
  186. package/src/services/fetch-skills.ts +0 -14
  187. package/src/services/fetch-slide.ts +0 -14
  188. package/src/services/fetch-slides-to-review-by-skill-ref.ts +0 -18
  189. package/src/services/index.ts +0 -18
  190. package/src/services/post-answer.ts +0 -28
  191. package/src/services/post-progression.ts +0 -28
  192. package/src/services/test/fetch-correction.test.ts +0 -55
  193. package/src/services/test/fetch-rank.test.ts +0 -34
  194. package/src/services/test/fetch-skills.test.ts +0 -39
  195. package/src/services/test/fetch-slide.test.ts +0 -30
  196. package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +0 -51
  197. package/src/services/test/post-answer.test.ts +0 -100
  198. package/src/services/test/post-progression.test.ts +0 -66
  199. package/src/services/tools/fetch-responses.ts +0 -40
  200. package/src/services/tools/sleep.ts +0 -4
  201. package/src/test/index.test.tsx +0 -99
  202. package/src/test/util/services.mock.ts +0 -465
  203. package/src/types/common.ts +0 -203
  204. package/src/types/globals.d.ts +0 -4
  205. package/src/types/slides.ts +0 -98
  206. package/src/views/skills/index.ts +0 -52
  207. package/src/views/skills/test/skills.test.ts +0 -108
  208. package/src/views/slides/index.ts +0 -510
  209. package/src/views/slides/map-api-slide-to-ui.ts +0 -287
  210. package/src/views/slides/test/fixtures/free-text.ts +0 -44
  211. package/src/views/slides/test/fixtures/qcm-drag.ts +0 -112
  212. package/src/views/slides/test/fixtures/qcm-graphic.ts +0 -264
  213. package/src/views/slides/test/fixtures/qcm.ts +0 -120
  214. package/src/views/slides/test/fixtures/slider.ts +0 -43
  215. package/src/views/slides/test/fixtures/template.ts +0 -177
  216. package/src/views/slides/test/header.on-click.test.ts +0 -46
  217. package/src/views/slides/test/index.test.ts +0 -1500
  218. package/src/views/slides/test/map-api-slide-to-ui.test.ts +0 -52
  219. package/src/views/slides/test/on-quit-popin.on-click.test.ts +0 -65
  220. package/src/views/slides/test/slide.free-text.on-change.test.ts +0 -117
  221. package/src/views/slides/test/slide.next-slide.on-click.test.ts +0 -176
  222. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +0 -90
  223. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +0 -90
  224. package/src/views/slides/test/slide.qcm.on-click.test.ts +0 -92
  225. package/src/views/slides/test/slide.slider.on-change.test.ts +0 -92
  226. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +0 -91
  227. package/src/views/slides/test/slide.template.on-change.test.ts +0 -126
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { CorrectionFromAPI, Options } from '../../types/common';
3
+ import type { CorrectionFromAPI, ThunkOptions } from '../../types/common';
4
4
  export declare const CORRECTION_FETCH_REQUEST: "@@correction/FETCH_REQUEST";
5
5
  export declare const CORRECTION_FETCH_SUCCESS: "@@correction/FETCH_SUCCESS";
6
6
  export declare const CORRECTION_FETCH_FAILURE: "@@correction/FETCH_FAILURE";
@@ -17,4 +17,4 @@ export declare type ReceivedCorrection = {
17
17
  slideRef: string;
18
18
  };
19
19
  };
20
- export declare const fetchCorrection: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => ReceivedCorrection;
20
+ export declare const fetchCorrection: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => ReceivedCorrection;
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { Rank, Services, Options } from '../../types/common';
3
+ import type { Rank, Services, ThunkOptions } from '../../types/common';
4
4
  export declare const RANK_FETCH_START_REQUEST: "@@rank/FETCH_START_REQUEST";
5
5
  export declare const RANK_FETCH_START_SUCCESS: "@@rank/FETCH_START_SUCCESS";
6
6
  export declare const RANK_FETCH_START_FAILURE: "@@rank/FETCH_START_FAILURE";
@@ -27,6 +27,6 @@ export declare type RankAction = RankRequestAction | RankSuccessAction | RankFai
27
27
  declare type RankStart = [RankFetchStartRequestType, RankFetchStartSuccessType, RankFetchStartFailureType];
28
28
  declare type RankEnd = [RankFetchEndRequestType, RankFetchEndSuccessType, RankFetchEndFailureType];
29
29
  export declare const fetchRank: (dispatch: Dispatch, getState: () => StoreState, services: Services, types: RankStart | RankEnd, path?: string) => RankAction;
30
- export declare const fetchStartRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
31
- export declare const fetchEndRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
30
+ export declare const fetchStartRank: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => RankAction;
31
+ export declare const fetchEndRank: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => RankAction;
32
32
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { Options, Skill } from '../../types/common';
3
+ import type { ThunkOptions, Skill } from '../../types/common';
4
4
  export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
5
5
  export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
6
6
  export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
@@ -8,4 +8,4 @@ export declare type ReceivedSkills = {
8
8
  type: typeof SKILLS_FETCH_SUCCESS;
9
9
  payload: Skill[];
10
10
  };
11
- export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => ReceivedSkills;
11
+ export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => ReceivedSkills;
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { Options, SlideFromAPI } from '../../types/common';
3
+ import type { ThunkOptions, SlideFromAPI } from '../../types/common';
4
4
  export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
5
5
  export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
6
6
  export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
@@ -17,4 +17,4 @@ export declare type ReceivedSlide = {
17
17
  slideRef: string;
18
18
  };
19
19
  };
20
- export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
20
+ export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { Dispatch } from 'redux';
2
- import type { Options, ProgressionFromAPI } from '../../types/common';
2
+ import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
3
3
  import type { StoreState } from '../../reducers';
4
4
  export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
5
5
  export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
@@ -17,4 +17,4 @@ export declare type PostAnswerSuccessAction = {
17
17
  };
18
18
  payload: ProgressionFromAPI;
19
19
  };
20
- export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
20
+ export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { Dispatch } from 'redux';
2
- import type { Options, ProgressionFromAPI } from '../../types/common';
2
+ import type { ThunkOptions, ProgressionFromAPI } from '../../types/common';
3
3
  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";
@@ -8,4 +8,4 @@ export declare type ReceivedProgression = {
8
8
  type: typeof POST_PROGRESSION_SUCCESS;
9
9
  payload: ProgressionFromAPI;
10
10
  };
11
- export declare const postProgression: (skillRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
11
+ export declare const postProgression: (skillRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => Promise<void>;
@@ -1,18 +1,19 @@
1
- import { AppOptions } from '../../types/common';
2
- export declare const NAVIGATE_TO = "@@navigation/NAVIGATE_TO";
3
- export declare const NAVIGATE_BACK = "@@navigation/NAVIGATE_BACK";
4
- export declare const START_APP = "@@navigation/START_APP";
5
- export declare type ViewPath = 'skills' | 'onboarding' | 'slides' | 'loader';
6
- export declare type NavigateTo = {
1
+ import { Dispatch } from 'redux';
2
+ import type { StoreState } from '../../reducers';
3
+ import { ThunkOptions, AppOptions, ViewName } from '../../types/common';
4
+ export declare type NavigateToAction = {
7
5
  type: '@@navigation/NAVIGATE_TO';
8
- payload: ViewPath;
6
+ payload: ViewName;
9
7
  };
10
- export declare type NavigateBack = {
8
+ export declare type NavigateBackAction = {
11
9
  type: '@@navigation/NAVIGATE_BACK';
12
10
  };
13
11
  export declare type StartApp = {
14
12
  type: '@@navigation/START_APP';
15
13
  payload: AppOptions;
16
14
  };
17
- export declare const navigateTo: (newPath: ViewPath) => NavigateTo;
18
- export declare const navigateBack: () => NavigateBack;
15
+ export declare const NAVIGATE_TO = "@@navigation/NAVIGATE_TO";
16
+ export declare const NAVIGATE_BACK = "@@navigation/NAVIGATE_BACK";
17
+ export declare const START_APP = "@@navigation/START_APP";
18
+ export declare const navigateTo: (newViewName: ViewName) => (dispatch: Dispatch, getState: () => StoreState, { callbackOnViewChanged }: ThunkOptions) => Promise<NavigateToAction>;
19
+ export declare const navigateBack: (dispatch: Dispatch, getState: () => StoreState, { callbackOnViewChanged }: ThunkOptions) => Promise<NavigateBackAction>;
@@ -1,10 +1,26 @@
1
1
  export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
2
2
  export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
3
3
  export const START_APP = '@@navigation/START_APP';
4
- export const navigateTo = (newPath) => ({
5
- type: NAVIGATE_TO,
6
- payload: newPath
7
- });
8
- export const navigateBack = () => ({
9
- type: NAVIGATE_BACK
10
- });
4
+ export const navigateTo = (newViewName) => async (dispatch, getState, { callbackOnViewChanged }) => {
5
+ const action = {
6
+ type: NAVIGATE_TO,
7
+ payload: newViewName
8
+ };
9
+ const res = await dispatch(action);
10
+ if (callbackOnViewChanged) {
11
+ callbackOnViewChanged(newViewName);
12
+ }
13
+ return res;
14
+ };
15
+ export const navigateBack = async (dispatch, getState, { callbackOnViewChanged }) => {
16
+ const action = {
17
+ type: NAVIGATE_BACK
18
+ };
19
+ const res = await dispatch(action);
20
+ if (callbackOnViewChanged) {
21
+ const storeState = getState();
22
+ const viewName = storeState.ui.navigation[storeState.ui.navigation.length - 1];
23
+ callbackOnViewChanged(viewName);
24
+ }
25
+ return res;
26
+ };
@@ -1,9 +1,4 @@
1
1
  import type { ProgressionFromAPI } from '../types/common';
2
- export declare const VIEWS: {
3
- readonly skills: 'skills';
4
- readonly onboarding: 'onboarding';
5
- readonly slides: 'slides';
6
- };
7
2
  export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
8
3
  export declare type SlideIndexes = typeof slideIndexes[number];
9
4
  export declare const getProgressionSlidesRefs: (progression: ProgressionFromAPI) => string[];
@@ -1,10 +1,5 @@
1
1
  import concat from 'lodash/fp/concat';
2
2
  import slice from 'lodash/fp/slice';
3
- export const VIEWS = {
4
- skills: 'skills',
5
- onboarding: 'onboarding',
6
- slides: 'slides'
7
- };
8
3
  export const slideIndexes = ['0', '1', '2', '3', '4'];
9
4
  export const getProgressionSlidesRefs = (progression) => {
10
5
  if (progression.state.step.current <= 5) {
@@ -10,7 +10,11 @@ export default function configureStore(options) {
10
10
  traceLimit: 25
11
11
  })
12
12
  : compose;
13
- const thunkMiddleware = thunk.withExtraArgument({ services: options.services || getServices() });
13
+ const thunkOptions = {
14
+ services: options.services || getServices(),
15
+ callbackOnViewChanged: options.callbackOnViewChanged
16
+ };
17
+ const thunkMiddleware = thunk.withExtraArgument(thunkOptions);
14
18
  const enhancer = _compose(applyMiddleware(thunkMiddleware));
15
19
  const store = createStore(rootReducer, undefined, enhancer);
16
20
  return store;
package/es/index.js CHANGED
@@ -4,16 +4,16 @@ import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
4
4
  import isEmpty from 'lodash/fp/isEmpty';
5
5
  import get from 'lodash/fp/get';
6
6
  import configureStore from './configure-store';
7
- import { navigateTo } from './actions/ui/navigation';
7
+ import { navigateBack, navigateTo } from './actions/ui/navigation';
8
8
  import { storeToken } from './actions/data/token';
9
9
  import { fetchSkills } from './actions/api/fetch-skills';
10
10
  import { postProgression } from './actions/api/post-progression';
11
- import { VIEWS } from './common';
12
11
  import { mapStateToSlidesProps } from './views/slides';
13
12
  import { mapStateToSkillsProps } from './views/skills';
14
13
  const ConnectedApp = ({ onQuitClick }) => {
15
14
  const dispatch = useDispatch();
16
15
  const props = {
16
+ navigateBack: () => dispatch(navigateBack),
17
17
  viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
18
18
  slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
19
19
  skills: useSelector((state) => mapStateToSkillsProps(state)),
@@ -62,7 +62,7 @@ const AppReview = ({ options }) => {
62
62
  store.dispatch(navigateTo('loader')); // use loader while posting progression
63
63
  return;
64
64
  }
65
- const initialView = skillRef ? VIEWS.slides : VIEWS.skills;
65
+ const initialView = skillRef ? 'slides' : 'skills';
66
66
  store.dispatch(navigateTo(initialView));
67
67
  }, [isProgressionCreated, options, store]);
68
68
  if (!store)
@@ -22,7 +22,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
22
22
  showQuitPopin: boolean;
23
23
  showCongrats: boolean;
24
24
  }>;
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 | {
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").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
26
26
  type: "@@ui/OPEN_POPIN";
27
27
  } | {
28
28
  type: "@@ui/CLOSE_POPIN";
@@ -22,7 +22,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
22
22
  positions: UIPositionState;
23
23
  showQuitPopin: boolean;
24
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 | {
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").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
26
26
  type: "@@ui/OPEN_POPIN";
27
27
  } | {
28
28
  type: "@@ui/CLOSE_POPIN";
@@ -1,4 +1,4 @@
1
- import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
1
+ import { NavigateToAction, NavigateBackAction } from '../../actions/ui/navigation';
2
2
  export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides' | 'loader'>;
3
- declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
3
+ declare const reducer: (state: NavigationState | undefined, action: NavigateToAction | NavigateBackAction) => NavigationState;
4
4
  export default reducer;
@@ -1,4 +1,4 @@
1
- import { NAVIGATE_BACK, NAVIGATE_TO } from '../../actions/ui/navigation';
1
+ import { NAVIGATE_TO, NAVIGATE_BACK } from '../../actions/ui/navigation';
2
2
  const reducer = (
3
3
  // eslint-disable-next-line default-param-last
4
4
  state = [], action) => {
@@ -1,3 +1,4 @@
1
+ export declare type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
1
2
  export declare type ChoiceFromAPI = {
2
3
  _id: string;
3
4
  id?: string;
@@ -136,15 +137,17 @@ export declare type Services = {
136
137
  fetchRank(token: string): Promise<Rank>;
137
138
  fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
138
139
  };
139
- export declare type Options = {
140
- services: Services;
141
- };
142
140
  export declare type AppOptions = {
143
141
  token: string;
144
142
  skillRef?: string;
145
143
  services: Services;
146
- onQuitClick: Function;
144
+ onQuitClick: () => void;
147
145
  url: string;
146
+ callbackOnViewChanged?: (viewName: ViewName) => void;
147
+ };
148
+ export declare type ThunkOptions = {
149
+ callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
150
+ services: Services;
148
151
  };
149
152
  export declare type JWT = {
150
153
  exp: number;
@@ -8,11 +8,9 @@ declare type SkillCard = {
8
8
  reviseLabel: string;
9
9
  reviseAriaLabel: string;
10
10
  isCustom: boolean;
11
- onClick: Function;
11
+ onClick: () => void;
12
12
  };
13
13
  declare type NoSkillsProps = {
14
- titleNoSkills: string;
15
- textNoSkills: string;
16
14
  iconSkillAriaLabel: string;
17
15
  };
18
16
  declare type SkillsProps = NoSkillsProps & {
@@ -1,8 +1,6 @@
1
1
  export const mapStateToSkillsProps = (state) => {
2
2
  return {
3
3
  title: '@todo title',
4
- titleNoSkills: '@todo titleNoSkills',
5
- textNoSkills: '@todo textNoSkills',
6
4
  iconSkillAriaLabel: '@todo iconSkillAriaLabel',
7
5
  isLoading: false,
8
6
  isLoadingAriaLabel: '@todo loading',
@@ -1,5 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
- import { type SlideIndexes } from '../../common';
2
+ import { ReviewPlayerProps } from '@coorpacademy/components/es/template/app-review/player/prop-types';
3
+ import { SlideProps } from '@coorpacademy/components/es/organism/review-slide/prop-types';
3
4
  import type { StoreState } from '../../reducers';
4
5
  import type { AnswerUI } from '../../types/slides';
5
6
  declare const ICON_VALUES: {
@@ -25,118 +26,9 @@ export declare type ReviewSlide = {
25
26
  animationType?: SlideUIAnimations;
26
27
  };
27
28
  declare type SlidesStack = {
28
- [key in SlideIndexes]: ReviewSlide;
29
- };
30
- declare type CorrectionPopinInformation = {
31
- label: string;
32
- message: string;
33
- };
34
- declare type CorrectionPopinKlf = {
35
- label: string;
36
- tooltip: string;
37
- };
38
- declare type CorrectionPopinNext = {
39
- label: string;
40
- ariaLabel: string;
41
- onClick: Function;
42
- };
43
- declare type QuitPopinButton = {
44
- label: string;
45
- type: string;
46
- customStyle?: {
47
- color: string;
48
- };
49
- handleOnclick: Function;
50
- ariaLabel: string;
51
- };
52
- export declare type CorrectionPopinProps = {
53
- klf?: CorrectionPopinKlf;
54
- information: CorrectionPopinInformation;
55
- next: CorrectionPopinNext;
56
- resultLabel: string;
57
- type: 'right' | 'wrong';
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
- };
67
- export declare type SlidesViewProps = {
68
- header: {
69
- mode: string;
70
- skillName: string;
71
- onQuitClick: Function;
72
- 'aria-label'?: string;
73
- closeButtonAriaLabel: string;
74
- steps: StepItem[];
75
- };
76
- stack: {
77
- slides: SlidesStack;
78
- validateButton: {
79
- label: string;
80
- disabled: boolean;
81
- onClick: Function;
82
- };
83
- correctionPopinProps?: CorrectionPopinProps;
84
- endReview: boolean;
85
- };
86
- reviewBackgroundAriaLabel?: string;
87
- congrats?: CongratsProps;
88
- quitPopin?: QuitPopinProps;
89
- };
90
- declare type LottieAnimationProps = {
91
- 'aria-label': string;
92
- 'data-name'?: string;
93
- animationSrc: string;
94
- loop?: boolean;
95
- rendererSettings?: {
96
- hideOnTransparent?: boolean;
97
- className?: string;
98
- };
99
- height?: number;
100
- width?: number;
101
- className?: number;
102
- ie11ImageBackup: string;
103
- backupImageClassName?: string;
104
- autoplay?: boolean;
105
- animationControl?: 'play' | 'pause' | 'stop' | 'loading';
106
- };
107
- export declare type CongratsCardProps = {
108
- 'aria-label': string;
109
- 'data-name': string;
110
- animationLottie: LottieAnimationProps;
111
- iconAriaLabel: string;
112
- className?: string;
113
- cardType: string;
114
- reviewCardTitle: string;
115
- reviewCardValue: string;
116
- rankSuffix?: string;
117
- timerAnimation: number;
118
- };
119
- export declare type CongratsProps = {
120
- 'aria-label': string;
121
- 'data-name': 'review-congrats';
122
- animationLottie: LottieAnimationProps;
123
- title: string;
124
- cardCongratsStar: CongratsCardProps;
125
- cardCongratsRank?: CongratsCardProps;
126
- buttonRevising?: {
127
- 'aria-label': string;
128
- label: string;
129
- onClick: Function;
130
- type: string;
131
- };
132
- buttonRevisingSkill?: {
133
- label: string;
134
- 'aria-label': string;
135
- onClick: Function;
136
- type: string;
137
- };
29
+ [key: string]: SlideProps;
138
30
  };
139
31
  export declare const initialState: SlidesStack;
140
32
  export declare const buildStepItems: (state: StoreState) => StepItem[];
141
- export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: Function) => SlidesViewProps;
33
+ export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: () => void) => ReviewPlayerProps;
142
34
  export {};
@@ -180,7 +180,7 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) =>
180
180
  message: isCorrect ? klf : join(',', correctAnswer)
181
181
  },
182
182
  next: {
183
- ariaLabel: '_correctionNextAriaLabel',
183
+ 'aria-label': '_correctionNextAriaLabel',
184
184
  label: '_correctionNextLabel',
185
185
  onClick: () => {
186
186
  dispatch(nextSlide);
@@ -202,7 +202,7 @@ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
202
202
  color: '#ED3436'
203
203
  },
204
204
  handleOnclick: onQuitClick,
205
- ariaLabel: 'Stop session'
205
+ 'aria-label': 'Stop session'
206
206
  },
207
207
  secondButton: {
208
208
  label: `Continuer d'apprendre`,
@@ -210,7 +210,7 @@ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
210
210
  handleOnclick: () => {
211
211
  dispatch(closeQuitPopin);
212
212
  },
213
- ariaLabel: 'Continue review'
213
+ 'aria-label': 'Continue review'
214
214
  }
215
215
  };
216
216
  };
@@ -288,6 +288,7 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
288
288
  const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
289
289
  const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
290
290
  const showQuitPopin = get(['ui', 'showQuitPopin'], state);
291
+ const showCongrats = get(['ui', 'showCongrats'], state);
291
292
  return {
292
293
  header: {
293
294
  mode: '__revision_mode',
@@ -295,7 +296,8 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
295
296
  onQuitClick: () => dispatch(openQuitPopin),
296
297
  'aria-label': 'aria-header-wrapper',
297
298
  closeButtonAriaLabel: 'aria-close-button',
298
- steps: buildStepItems(state)
299
+ steps: buildStepItems(state),
300
+ hiddenSteps: showCongrats
299
301
  },
300
302
  stack: {
301
303
  slides: buildStackSlides(state, dispatch),
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { CorrectionFromAPI, Options } from '../../types/common';
3
+ import type { CorrectionFromAPI, ThunkOptions } from '../../types/common';
4
4
  export declare const CORRECTION_FETCH_REQUEST: "@@correction/FETCH_REQUEST";
5
5
  export declare const CORRECTION_FETCH_SUCCESS: "@@correction/FETCH_SUCCESS";
6
6
  export declare const CORRECTION_FETCH_FAILURE: "@@correction/FETCH_FAILURE";
@@ -17,4 +17,4 @@ export declare type ReceivedCorrection = {
17
17
  slideRef: string;
18
18
  };
19
19
  };
20
- export declare const fetchCorrection: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => ReceivedCorrection;
20
+ export declare const fetchCorrection: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => ReceivedCorrection;
@@ -1,19 +1,25 @@
1
- import buildTask from '@coorpacademy/redux-task';
2
- import get from 'lodash/fp/get';
3
- export var CORRECTION_FETCH_REQUEST = '@@correction/FETCH_REQUEST';
4
- export var CORRECTION_FETCH_SUCCESS = '@@correction/FETCH_SUCCESS';
5
- export var CORRECTION_FETCH_FAILURE = '@@correction/FETCH_FAILURE';
6
- export var fetchCorrection = function (dispatch, getState, _a) {
7
- var services = _a.services;
8
- var state = getState();
9
- var slideRef = get(['ui', 'currentSlideRef'], state);
10
- var token = get(['data', 'token'], state);
11
- var progressionId = get(['data', 'progression', '_id'], state);
12
- var answer = get(['ui', 'answers', slideRef], state);
13
- var action = buildTask({
14
- types: [CORRECTION_FETCH_REQUEST, CORRECTION_FETCH_SUCCESS, CORRECTION_FETCH_FAILURE],
15
- meta: { slideRef: slideRef },
16
- task: function () { return services.fetchCorrection(slideRef, token, progressionId, answer); }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchCorrection = exports.CORRECTION_FETCH_FAILURE = exports.CORRECTION_FETCH_SUCCESS = exports.CORRECTION_FETCH_REQUEST = void 0;
7
+ const redux_task_1 = __importDefault(require("@coorpacademy/redux-task"));
8
+ const get_1 = __importDefault(require("lodash/fp/get"));
9
+ exports.CORRECTION_FETCH_REQUEST = '@@correction/FETCH_REQUEST';
10
+ exports.CORRECTION_FETCH_SUCCESS = '@@correction/FETCH_SUCCESS';
11
+ exports.CORRECTION_FETCH_FAILURE = '@@correction/FETCH_FAILURE';
12
+ const fetchCorrection = (dispatch, getState, { services }) => {
13
+ const state = getState();
14
+ const slideRef = (0, get_1.default)(['ui', 'currentSlideRef'], state);
15
+ const token = (0, get_1.default)(['data', 'token'], state);
16
+ const progressionId = (0, get_1.default)(['data', 'progression', '_id'], state);
17
+ const answer = (0, get_1.default)(['ui', 'answers', slideRef], state);
18
+ const action = (0, redux_task_1.default)({
19
+ types: [exports.CORRECTION_FETCH_REQUEST, exports.CORRECTION_FETCH_SUCCESS, exports.CORRECTION_FETCH_FAILURE],
20
+ meta: { slideRef },
21
+ task: () => services.fetchCorrection(slideRef, token, progressionId, answer)
17
22
  });
18
23
  return dispatch(action);
19
24
  };
25
+ exports.fetchCorrection = fetchCorrection;
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import type { StoreState } from '../../reducers';
3
- import type { Rank, Services, Options } from '../../types/common';
3
+ import type { Rank, Services, ThunkOptions } from '../../types/common';
4
4
  export declare const RANK_FETCH_START_REQUEST: "@@rank/FETCH_START_REQUEST";
5
5
  export declare const RANK_FETCH_START_SUCCESS: "@@rank/FETCH_START_SUCCESS";
6
6
  export declare const RANK_FETCH_START_FAILURE: "@@rank/FETCH_START_FAILURE";
@@ -27,6 +27,6 @@ export declare type RankAction = RankRequestAction | RankSuccessAction | RankFai
27
27
  declare type RankStart = [RankFetchStartRequestType, RankFetchStartSuccessType, RankFetchStartFailureType];
28
28
  declare type RankEnd = [RankFetchEndRequestType, RankFetchEndSuccessType, RankFetchEndFailureType];
29
29
  export declare const fetchRank: (dispatch: Dispatch, getState: () => StoreState, services: Services, types: RankStart | RankEnd, path?: string) => RankAction;
30
- export declare const fetchStartRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
31
- export declare const fetchEndRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
30
+ export declare const fetchStartRank: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => RankAction;
31
+ export declare const fetchEndRank: (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => RankAction;
32
32
  export {};
@@ -1,38 +1,43 @@
1
- import buildTask from '@coorpacademy/redux-task';
2
- import get from 'lodash/fp/get';
3
- export var RANK_FETCH_START_REQUEST = '@@rank/FETCH_START_REQUEST';
4
- export var RANK_FETCH_START_SUCCESS = '@@rank/FETCH_START_SUCCESS';
5
- export var RANK_FETCH_START_FAILURE = '@@rank/FETCH_START_FAILURE';
6
- export var RANK_FETCH_END_REQUEST = '@@rank/FETCH_END_REQUEST';
7
- export var RANK_FETCH_END_SUCCESS = '@@rank/FETCH_END_SUCCESS';
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
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
4
  };
15
- export var fetchRank = function (dispatch, getState, services, types, path) {
16
- var action = buildTask({
17
- types: types,
18
- task: function () {
19
- var state = getState();
20
- var token = get(['data', 'token'], state);
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchEndRank = exports.fetchStartRank = exports.fetchRank = exports.RANK_FETCH_END_FAILURE = exports.RANK_FETCH_END_SUCCESS = exports.RANK_FETCH_END_REQUEST = exports.RANK_FETCH_START_FAILURE = exports.RANK_FETCH_START_SUCCESS = exports.RANK_FETCH_START_REQUEST = void 0;
7
+ const redux_task_1 = __importDefault(require("@coorpacademy/redux-task"));
8
+ const get_1 = __importDefault(require("lodash/fp/get"));
9
+ exports.RANK_FETCH_START_REQUEST = '@@rank/FETCH_START_REQUEST';
10
+ exports.RANK_FETCH_START_SUCCESS = '@@rank/FETCH_START_SUCCESS';
11
+ exports.RANK_FETCH_START_FAILURE = '@@rank/FETCH_START_FAILURE';
12
+ exports.RANK_FETCH_END_REQUEST = '@@rank/FETCH_END_REQUEST';
13
+ exports.RANK_FETCH_END_SUCCESS = '@@rank/FETCH_END_SUCCESS';
14
+ exports.RANK_FETCH_END_FAILURE = '@@rank/FETCH_END_FAILURE';
15
+ const bailout = (path) => (state) => {
16
+ const value = (0, get_1.default)(path, state);
17
+ return !Number.isNaN(value);
18
+ };
19
+ const fetchRank = (dispatch, getState, services, types, path) => {
20
+ const action = (0, redux_task_1.default)({
21
+ types,
22
+ task: () => {
23
+ const state = getState();
24
+ const token = (0, get_1.default)(['data', 'token'], state);
21
25
  return services.fetchRank(token);
22
26
  },
23
27
  bailout: path ? bailout(path) : undefined
24
28
  });
25
29
  return dispatch(action);
26
30
  };
27
- export var fetchStartRank = function (dispatch, getState, _a) {
28
- var services = _a.services;
29
- return fetchRank(dispatch, getState, services, [RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE], 'data.rank.start');
31
+ exports.fetchRank = fetchRank;
32
+ const fetchStartRank = (dispatch, getState, { services }) => {
33
+ return (0, exports.fetchRank)(dispatch, getState, services, [exports.RANK_FETCH_START_REQUEST, exports.RANK_FETCH_START_SUCCESS, exports.RANK_FETCH_START_FAILURE], 'data.rank.start');
30
34
  };
31
- export var fetchEndRank = function (dispatch, getState, _a) {
32
- var services = _a.services;
33
- return fetchRank(dispatch, getState, services, [
34
- RANK_FETCH_END_REQUEST,
35
- RANK_FETCH_END_SUCCESS,
36
- RANK_FETCH_END_FAILURE
35
+ exports.fetchStartRank = fetchStartRank;
36
+ const fetchEndRank = (dispatch, getState, { services }) => {
37
+ return (0, exports.fetchRank)(dispatch, getState, services, [
38
+ exports.RANK_FETCH_END_REQUEST,
39
+ exports.RANK_FETCH_END_SUCCESS,
40
+ exports.RANK_FETCH_END_FAILURE
37
41
  ]);
38
42
  };
43
+ exports.fetchEndRank = fetchEndRank;