@coorpacademy/app-review 0.1.3 → 0.1.4

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 (266) hide show
  1. package/es/actions/data/skills.d.ts +13 -0
  2. package/es/actions/data/skills.js +10 -0
  3. package/es/actions/data/slides.d.ts +54 -0
  4. package/es/actions/{slides.js → data/slides.js} +5 -0
  5. package/es/actions/index.d.ts +19 -5
  6. package/es/actions/ui/finished-slides.d.ts +10 -0
  7. package/es/actions/{finished-slides.js → ui/finished-slides.js} +1 -0
  8. package/es/actions/ui/is-fetching.d.ts +10 -0
  9. package/es/actions/ui/is-fetching.js +6 -0
  10. package/{lib/actions → es/actions/ui}/navigation.d.ts +2 -2
  11. package/es/actions/ui/review-status.d.ts +7 -0
  12. package/{lib/actions → es/actions/ui}/step-items.d.ts +17 -1
  13. package/es/actions/{step-items.js → ui/step-items.js} +5 -0
  14. package/es/common/index.d.ts +1 -1
  15. package/es/common/index.js +1 -1
  16. package/es/configure-store.d.ts +34 -4
  17. package/es/configure-store.js +1 -2
  18. package/es/fixtures/qcm-slide.js +7 -3
  19. package/es/fixtures/temp-fixture.d.ts +1 -1
  20. package/es/index.js +54 -36
  21. package/es/index.test.js +1 -1
  22. package/es/middlewares/on-start-app.d.ts +2 -3
  23. package/es/middlewares/on-start-app.js +18 -17
  24. package/es/reducers/data/index.d.ts +7 -0
  25. package/es/reducers/data/index.js +11 -0
  26. package/es/reducers/data/progression.d.ts +14 -0
  27. package/es/reducers/data/progression.js +78 -0
  28. package/es/reducers/data/skills.d.ts +6 -0
  29. package/es/reducers/{courses.js → data/skills.js} +3 -4
  30. package/es/reducers/data/slides.d.ts +8 -0
  31. package/es/reducers/{slides.js → data/slides.js} +4 -3
  32. package/es/reducers/data/token.d.ts +5 -0
  33. package/es/reducers/data/token.js +15 -0
  34. package/es/reducers/index.d.ts +11 -8
  35. package/es/reducers/index.js +3 -16
  36. package/es/reducers/ui/finished-slides.d.ts +8 -0
  37. package/es/reducers/{finished-slides.js → ui/finished-slides.js} +9 -6
  38. package/es/reducers/ui/index.d.ts +7 -0
  39. package/es/reducers/ui/index.js +11 -0
  40. package/es/reducers/ui/navigation.d.ts +5 -0
  41. package/es/reducers/{navigation.js → ui/navigation.js} +4 -7
  42. package/es/reducers/ui/review-status.d.ts +5 -0
  43. package/es/reducers/{review-status.js → ui/review-status.js} +3 -2
  44. package/es/reducers/ui/step-items.d.ts +14 -0
  45. package/es/reducers/{step-items.js → ui/step-items.js} +7 -7
  46. package/es/services/fetch-skills.d.ts +8 -0
  47. package/es/services/fetch-skills.js +23 -0
  48. package/es/services/fetch-skills.mock.d.ts +3 -0
  49. package/es/services/fetch-skills.mock.js +17 -0
  50. package/es/services/fetch-skills.test.js +22 -0
  51. package/es/services/tools/fetch-responses.d.ts +7 -0
  52. package/es/services/tools/fetch.mocks.d.ts +8 -0
  53. package/es/services/{fetch.mocks.js → tools/fetch.mocks.js} +1 -0
  54. package/es/types/common.d.ts +12 -0
  55. package/es/types/skills.d.ts +7 -0
  56. package/es/types/slides.d.ts +3 -21
  57. package/es/types/views/skills.d.ts +24 -0
  58. package/{lib/types/views.d.ts → es/types/views/slides.d.ts} +7 -11
  59. package/lib/actions/data/skills.d.ts +13 -0
  60. package/lib/actions/data/skills.js +10 -0
  61. package/lib/actions/data/slides.d.ts +54 -0
  62. package/lib/actions/{slides.js → data/slides.js} +5 -0
  63. package/lib/actions/index.d.ts +19 -5
  64. package/lib/actions/ui/finished-slides.d.ts +10 -0
  65. package/lib/actions/{finished-slides.js → ui/finished-slides.js} +1 -0
  66. package/lib/actions/ui/is-fetching.d.ts +10 -0
  67. package/lib/actions/ui/is-fetching.js +6 -0
  68. package/{es/actions → lib/actions/ui}/navigation.d.ts +2 -2
  69. package/lib/actions/ui/review-status.d.ts +7 -0
  70. package/{es/actions → lib/actions/ui}/step-items.d.ts +17 -1
  71. package/lib/actions/{step-items.js → ui/step-items.js} +5 -0
  72. package/lib/common/index.d.ts +1 -1
  73. package/lib/common/index.js +1 -1
  74. package/lib/configure-store.d.ts +34 -4
  75. package/lib/configure-store.js +1 -2
  76. package/lib/fixtures/qcm-slide.js +7 -3
  77. package/lib/fixtures/temp-fixture.d.ts +1 -1
  78. package/lib/index.js +57 -37
  79. package/lib/index.test.js +1 -1
  80. package/lib/middlewares/on-start-app.d.ts +2 -3
  81. package/lib/middlewares/on-start-app.js +18 -17
  82. package/lib/reducers/data/index.d.ts +7 -0
  83. package/lib/reducers/data/index.js +11 -0
  84. package/lib/reducers/data/progression.d.ts +14 -0
  85. package/lib/reducers/data/progression.js +79 -0
  86. package/lib/reducers/data/skills.d.ts +6 -0
  87. package/lib/reducers/data/skills.js +15 -0
  88. package/lib/reducers/data/slides.d.ts +8 -0
  89. package/lib/reducers/{slides.js → data/slides.js} +4 -3
  90. package/lib/reducers/data/token.d.ts +5 -0
  91. package/lib/reducers/data/token.js +16 -0
  92. package/lib/reducers/index.d.ts +11 -8
  93. package/lib/reducers/index.js +3 -16
  94. package/lib/reducers/ui/finished-slides.d.ts +8 -0
  95. package/lib/reducers/{finished-slides.js → ui/finished-slides.js} +9 -6
  96. package/lib/reducers/ui/index.d.ts +7 -0
  97. package/lib/reducers/ui/index.js +11 -0
  98. package/lib/reducers/ui/navigation.d.ts +5 -0
  99. package/lib/reducers/{courses.js → ui/navigation.js} +9 -3
  100. package/lib/reducers/ui/review-status.d.ts +5 -0
  101. package/lib/reducers/{review-status.js → ui/review-status.js} +3 -2
  102. package/lib/reducers/ui/step-items.d.ts +14 -0
  103. package/lib/reducers/{step-items.js → ui/step-items.js} +7 -7
  104. package/lib/services/fetch-skills.d.ts +8 -0
  105. package/lib/services/{fetch-demo.js → fetch-skills.js} +28 -35
  106. package/lib/services/fetch-skills.mock.d.ts +3 -0
  107. package/lib/services/fetch-skills.mock.js +17 -0
  108. package/lib/services/{fetch-demo.test.js → fetch-skills.test.js} +31 -12
  109. package/lib/services/tools/fetch-responses.d.ts +7 -0
  110. package/lib/services/tools/fetch.mocks.d.ts +8 -0
  111. package/lib/services/{fetch.mocks.js → tools/fetch.mocks.js} +1 -0
  112. package/lib/types/common.d.ts +12 -0
  113. package/lib/types/skills.d.ts +7 -0
  114. package/lib/types/slides.d.ts +3 -21
  115. package/lib/types/views/skills.d.ts +24 -0
  116. package/{es/types/views.d.ts → lib/types/views/slides.d.ts} +7 -11
  117. package/package.json +3 -3
  118. package/src/actions/data/skills.ts +24 -0
  119. package/src/actions/data/slides.ts +89 -0
  120. package/src/actions/index.ts +27 -5
  121. package/src/actions/{finished-slides.ts → ui/finished-slides.ts} +5 -5
  122. package/src/actions/ui/is-fetching.ts +19 -0
  123. package/src/actions/{navigation.ts → ui/navigation.ts} +2 -2
  124. package/src/actions/{review-status.ts → ui/review-status.ts} +4 -4
  125. package/src/actions/{step-items.ts → ui/step-items.ts} +22 -4
  126. package/src/common/index.ts +2 -2
  127. package/src/configure-store.ts +40 -8
  128. package/src/fixtures/qcm-slide.ts +7 -3
  129. package/src/fixtures/temp-fixture.ts +1 -1
  130. package/src/index.test.tsx +1 -1
  131. package/src/index.tsx +69 -44
  132. package/src/middlewares/on-start-app.ts +23 -26
  133. package/src/reducers/data/index.ts +13 -0
  134. package/src/reducers/data/progression.ts +106 -0
  135. package/src/reducers/data/skills.ts +21 -0
  136. package/src/reducers/{slides.ts → data/slides.ts} +24 -21
  137. package/src/reducers/{review-status.ts → data/token.ts} +8 -6
  138. package/src/reducers/index.ts +3 -17
  139. package/src/reducers/{finished-slides.ts → ui/finished-slides.ts} +24 -14
  140. package/src/reducers/ui/index.ts +13 -0
  141. package/src/reducers/ui/navigation.ts +36 -0
  142. package/src/reducers/ui/review-status.ts +26 -0
  143. package/src/reducers/{step-items.ts → ui/step-items.ts} +34 -21
  144. package/src/services/fetch-skills.mock.ts +21 -0
  145. package/src/services/fetch-skills.test.ts +32 -0
  146. package/src/services/fetch-skills.ts +40 -0
  147. package/src/services/{fetch-responses.ts → tools/fetch-responses.ts} +3 -16
  148. package/src/services/{fetch.mocks.ts → tools/fetch.mocks.ts} +10 -10
  149. package/src/types/common.ts +15 -0
  150. package/src/types/globals.d.ts +2 -0
  151. package/src/types/skills.ts +8 -0
  152. package/src/types/slides.ts +3 -26
  153. package/src/types/views/skills.ts +27 -0
  154. package/src/types/{views.tsx → views/slides.ts} +7 -11
  155. package/es/actions/courses.d.ts +0 -6
  156. package/es/actions/courses.js +0 -5
  157. package/es/actions/data/is-fetching.d.ts +0 -5
  158. package/es/actions/data/is-fetching.js +0 -4
  159. package/es/actions/data/validate-slide.d.ts +0 -5
  160. package/es/actions/data/validate-slide.js +0 -6
  161. package/es/actions/finished-slides.d.ts +0 -7
  162. package/es/actions/review-status.d.ts +0 -7
  163. package/es/actions/slides.d.ts +0 -20
  164. package/es/reducers/courses.d.ts +0 -5
  165. package/es/reducers/data.d.ts +0 -7
  166. package/es/reducers/data.js +0 -76
  167. package/es/reducers/finished-slides.d.ts +0 -6
  168. package/es/reducers/navigation.d.ts +0 -8
  169. package/es/reducers/review-status.d.ts +0 -5
  170. package/es/reducers/slides.d.ts +0 -6
  171. package/es/reducers/step-items.d.ts +0 -6
  172. package/es/reducers/token.d.ts +0 -5
  173. package/es/reducers/token.js +0 -8
  174. package/es/services/fetch-demo.d.ts +0 -11
  175. package/es/services/fetch-demo.js +0 -26
  176. package/es/services/fetch-demo.test.js +0 -12
  177. package/es/services/fetch-responses.d.ts +0 -19
  178. package/es/services/fetch.mocks.d.ts +0 -9
  179. package/es/types/data/index.d.ts +0 -14
  180. package/es/types/dispatchers.d.ts +0 -17
  181. package/es/types/finished-slides.d.ts +0 -9
  182. package/es/types/review-status.d.ts +0 -1
  183. package/es/types/states.d.ts +0 -6
  184. package/es/types/step-items.d.ts +0 -26
  185. package/es/types/step-items.js +0 -5
  186. package/es/types/store-state.d.ts +0 -12
  187. package/es/types/utils.d.ts +0 -3
  188. package/es/types/views.js +0 -1
  189. package/lib/actions/courses.d.ts +0 -6
  190. package/lib/actions/courses.js +0 -5
  191. package/lib/actions/data/is-fetching.d.ts +0 -5
  192. package/lib/actions/data/is-fetching.js +0 -4
  193. package/lib/actions/data/validate-slide.d.ts +0 -5
  194. package/lib/actions/data/validate-slide.js +0 -6
  195. package/lib/actions/finished-slides.d.ts +0 -7
  196. package/lib/actions/review-status.d.ts +0 -7
  197. package/lib/actions/slides.d.ts +0 -20
  198. package/lib/reducers/courses.d.ts +0 -5
  199. package/lib/reducers/data.d.ts +0 -7
  200. package/lib/reducers/data.js +0 -77
  201. package/lib/reducers/finished-slides.d.ts +0 -6
  202. package/lib/reducers/navigation.d.ts +0 -8
  203. package/lib/reducers/navigation.js +0 -36
  204. package/lib/reducers/review-status.d.ts +0 -5
  205. package/lib/reducers/slides.d.ts +0 -6
  206. package/lib/reducers/step-items.d.ts +0 -6
  207. package/lib/reducers/token.d.ts +0 -5
  208. package/lib/reducers/token.js +0 -8
  209. package/lib/services/fetch-demo.d.ts +0 -11
  210. package/lib/services/fetch-demo.test.d.ts +0 -1
  211. package/lib/services/fetch-responses.d.ts +0 -19
  212. package/lib/services/fetch.mocks.d.ts +0 -9
  213. package/lib/types/data/index.d.ts +0 -14
  214. package/lib/types/data/index.js +0 -1
  215. package/lib/types/dispatchers.d.ts +0 -17
  216. package/lib/types/dispatchers.js +0 -1
  217. package/lib/types/finished-slides.d.ts +0 -9
  218. package/lib/types/finished-slides.js +0 -1
  219. package/lib/types/review-status.d.ts +0 -1
  220. package/lib/types/review-status.js +0 -1
  221. package/lib/types/states.d.ts +0 -6
  222. package/lib/types/states.js +0 -1
  223. package/lib/types/step-items.d.ts +0 -26
  224. package/lib/types/step-items.js +0 -5
  225. package/lib/types/store-state.d.ts +0 -12
  226. package/lib/types/store-state.js +0 -1
  227. package/lib/types/utils.d.ts +0 -3
  228. package/lib/types/utils.js +0 -1
  229. package/lib/types/views.js +0 -1
  230. package/src/actions/courses.ts +0 -11
  231. package/src/actions/data/is-fetching.ts +0 -12
  232. package/src/actions/data/validate-slide.ts +0 -15
  233. package/src/actions/slides.ts +0 -45
  234. package/src/reducers/courses.ts +0 -23
  235. package/src/reducers/data.ts +0 -88
  236. package/src/reducers/navigation.ts +0 -36
  237. package/src/reducers/token.ts +0 -17
  238. package/src/services/fetch-demo.test.ts +0 -16
  239. package/src/services/fetch-demo.ts +0 -57
  240. package/src/types/data/index.ts +0 -16
  241. package/src/types/dispatchers.ts +0 -18
  242. package/src/types/finished-slides.ts +0 -9
  243. package/src/types/review-status.ts +0 -1
  244. package/src/types/states.ts +0 -6
  245. package/src/types/step-items.ts +0 -31
  246. package/src/types/store-state.ts +0 -20
  247. package/src/types/utils.ts +0 -4
  248. /package/es/actions/{token.d.ts → data/token.d.ts} +0 -0
  249. /package/es/actions/{token.js → data/token.js} +0 -0
  250. /package/es/actions/{navigation.js → ui/navigation.js} +0 -0
  251. /package/es/actions/{review-status.js → ui/review-status.js} +0 -0
  252. /package/es/services/{fetch-demo.test.d.ts → fetch-skills.test.d.ts} +0 -0
  253. /package/es/services/{fetch-responses.js → tools/fetch-responses.js} +0 -0
  254. /package/es/types/{data/index.js → skills.js} +0 -0
  255. /package/es/types/{dispatchers.js → views/skills.js} +0 -0
  256. /package/es/types/{finished-slides.js → views/slides.js} +0 -0
  257. /package/lib/actions/{token.d.ts → data/token.d.ts} +0 -0
  258. /package/lib/actions/{token.js → data/token.js} +0 -0
  259. /package/lib/actions/{navigation.js → ui/navigation.js} +0 -0
  260. /package/lib/actions/{review-status.js → ui/review-status.js} +0 -0
  261. /package/{es/types/review-status.js → lib/services/fetch-skills.test.d.ts} +0 -0
  262. /package/lib/services/{fetch-responses.js → tools/fetch-responses.js} +0 -0
  263. /package/{es/types/states.js → lib/types/skills.js} +0 -0
  264. /package/{es/types/store-state.js → lib/types/views/skills.js} +0 -0
  265. /package/{es/types/utils.js → lib/types/views/slides.js} +0 -0
  266. /package/src/actions/{token.ts → data/token.ts} +0 -0
@@ -1,12 +1,15 @@
1
1
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
+ data: import("redux").CombinedState<{
3
+ progression: import("./data/progression").ProgressionState;
4
+ skills: import("../types/skills").Skills;
5
+ slides: import("./data/slides").SlidesState;
6
+ token: import("./data/token").TokenState;
7
+ }>;
2
8
  ui: import("redux").CombinedState<{
3
- courses: import("./courses").State;
4
- finishedSlides: import("../types/finished-slides").FinishedSlides;
5
- navigation: import("../types/states").NavigationState;
6
- reviewStatus: import("./review-status").State;
7
- slides: import("../types/slides").Slides;
8
- stepItems: import("../types/step-items").StepItems;
9
+ finishedSlides: import("./ui/finished-slides").FinishedSlidesState;
10
+ navigation: import("./ui/navigation").NavigationState;
11
+ reviewStatus: import("./ui/review-status").ReviewStatusState;
12
+ stepItems: import("./ui/step-items").StepItems;
9
13
  }>;
10
- data: import("../types/data").DataState;
11
- }>, import("redux").AnyAction>;
14
+ }>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/data/skills").ReceivedSkills | import("../actions/data/token").StoreToken | import("../actions/ui/finished-slides").UpdateFinishedSlides | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/review-status").UpdateReviewStatus | import("../actions/ui/step-items").StepItemsAction>;
12
15
  export default _default;
@@ -1,20 +1,7 @@
1
1
  import { combineReducers } from 'redux';
2
2
  import data from './data';
3
- import courses from './courses';
4
- import finishedSlides from './finished-slides';
5
- import navigation from './navigation';
6
- import reviewStatus from './review-status';
7
- import slides from './slides';
8
- import stepItems from './step-items';
9
- var ui = combineReducers({
10
- courses: courses,
11
- finishedSlides: finishedSlides,
12
- navigation: navigation,
13
- reviewStatus: reviewStatus,
14
- slides: slides,
15
- stepItems: stepItems
16
- });
3
+ import ui from './ui';
17
4
  export default combineReducers({
18
- ui: ui,
19
- data: data
5
+ data: data,
6
+ ui: ui
20
7
  });
@@ -0,0 +1,8 @@
1
+ import { UpdateFinishedSlides } from '../../actions/ui/finished-slides';
2
+ export declare type FinishedSlidesState = {
3
+ slideNumbers: number[];
4
+ [key: number]: true;
5
+ };
6
+ export declare const initialState: FinishedSlidesState;
7
+ declare const reducer: (state: FinishedSlidesState | undefined, action: UpdateFinishedSlides) => FinishedSlidesState;
8
+ export default reducer;
@@ -10,17 +10,20 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import forEach from 'lodash/fp/forEach';
13
- import { UPDATE_FINISHED_SLIDES } from '../actions/finished-slides';
14
- import { slideNumbers } from '../common';
15
- var _forEach = forEach.convert({
16
- cap: false
17
- });
13
+ import { UPDATE_FINISHED_SLIDES } from '../../actions/ui/finished-slides';
14
+ import { slideNumbers } from '../../common';
15
+ // -----------------------------------------------------------------------------
18
16
  export var initialState = {
19
17
  slideNumbers: slideNumbers
20
18
  };
21
19
  // -----------------------------------------------------------------------------
20
+ var _forEach = forEach.convert({
21
+ cap: false
22
+ });
23
+ // -----------------------------------------------------------------------------
24
+ var reducer = function (
22
25
  // eslint-disable-next-line default-param-last
23
- var reducer = function (state, action) {
26
+ state, action) {
24
27
  if (state === void 0) { state = initialState; }
25
28
  switch (action.type) {
26
29
  case UPDATE_FINISHED_SLIDES: {
@@ -0,0 +1,7 @@
1
+ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
+ finishedSlides: import("./finished-slides").FinishedSlidesState;
3
+ navigation: import("./navigation").NavigationState;
4
+ reviewStatus: import("./review-status").ReviewStatusState;
5
+ stepItems: import("./step-items").StepItems;
6
+ }>, import("../../actions/ui/finished-slides").UpdateFinishedSlides | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/review-status").UpdateReviewStatus | import("../../actions/ui/step-items").StepItemsAction>;
7
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { combineReducers } from 'redux';
2
+ import finishedSlides from './finished-slides';
3
+ import navigation from './navigation';
4
+ import reviewStatus from './review-status';
5
+ import stepItems from './step-items';
6
+ export default combineReducers({
7
+ finishedSlides: finishedSlides,
8
+ navigation: navigation,
9
+ reviewStatus: reviewStatus,
10
+ stepItems: stepItems
11
+ });
@@ -0,0 +1,5 @@
1
+ import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
2
+ export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides'>;
3
+ export declare const initialState: NavigationState;
4
+ declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
5
+ export default reducer;
@@ -7,16 +7,22 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
- import { RECEIVED_COURSE } from '../actions/courses';
10
+ import { NAVIGATE_BACK, NAVIGATE_TO } from '../../actions/ui/navigation';
11
11
  export var initialState = [];
12
12
  // -----------------------------------------------------------------------------
13
+ var reducer = function (
13
14
  // eslint-disable-next-line default-param-last
14
- var reducer = function (state, action) {
15
+ state, action) {
15
16
  if (state === void 0) { state = initialState; }
16
17
  switch (action.type) {
17
- case RECEIVED_COURSE: {
18
+ case NAVIGATE_TO: {
18
19
  return __spreadArray(__spreadArray([], state, true), [action.payload], false);
19
20
  }
21
+ case NAVIGATE_BACK: {
22
+ var newState = __spreadArray([], state, true);
23
+ newState.pop();
24
+ return newState;
25
+ }
20
26
  default:
21
27
  return state;
22
28
  }
@@ -0,0 +1,5 @@
1
+ import { UpdateReviewStatus } from '../../actions/ui/review-status';
2
+ export declare type ReviewStatusState = 'finished' | 'ongoing';
3
+ export declare const initialState: ReviewStatusState;
4
+ declare const reducer: (state: ReviewStatusState | undefined, action: UpdateReviewStatus) => ReviewStatusState;
5
+ export default reducer;
@@ -1,8 +1,9 @@
1
- import { UPDATE_REVIEW_STATUS } from '../actions/review-status';
1
+ import { UPDATE_REVIEW_STATUS } from '../../actions/ui/review-status';
2
2
  export var initialState = 'ongoing';
3
3
  // -----------------------------------------------------------------------------
4
+ var reducer = function (
4
5
  // eslint-disable-next-line default-param-last
5
- var reducer = function (state, action) {
6
+ state, action) {
6
7
  if (state === void 0) { state = initialState; }
7
8
  switch (action.type) {
8
9
  case UPDATE_REVIEW_STATUS: {
@@ -0,0 +1,14 @@
1
+ import { IconValue, StepItemsAction } from '../../actions/ui/step-items';
2
+ declare type StepItem = {
3
+ current: boolean;
4
+ icon: IconValue;
5
+ value: string;
6
+ };
7
+ export declare type StepItems = {
8
+ slideNumbers: number[];
9
+ [key: number]: StepItem;
10
+ };
11
+ export declare type StepItemsState = StepItems;
12
+ export declare const initialState: StepItemsState;
13
+ declare const reducer: (state: StepItems | undefined, action: StepItemsAction) => StepItemsState;
14
+ export default reducer;
@@ -9,12 +9,12 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import isNil from 'lodash/fp/isNil';
13
12
  import get from 'lodash/fp/get';
14
13
  import has from 'lodash/fp/has';
15
14
  import map from 'lodash/fp/map';
16
- import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../actions/step-items';
17
- import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
15
+ import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../../actions/ui/step-items';
16
+ import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
17
+ // -----------------------------------------------------------------------------
18
18
  var getInitialState = function () {
19
19
  var state = {
20
20
  slideNumbers: slideNumbers
@@ -22,7 +22,7 @@ var getInitialState = function () {
22
22
  // eslint-disable-next-line fp/no-loops
23
23
  for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
24
24
  var current = index === 0;
25
- state[index] = { current: current, value: "".concat(index + 1), icon: null };
25
+ state[index] = { current: current, value: "".concat(index + 1), icon: 'no-answer' };
26
26
  }
27
27
  return state;
28
28
  };
@@ -36,12 +36,12 @@ var getNextIndex = function (currentIndex) {
36
36
  // ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
37
37
  // they have to be skipped)
38
38
  var calculateNextStepIndex = function (currentStepNumber, finishedSlides, lastVisitedIndex) {
39
- if (lastVisitedIndex === void 0) { lastVisitedIndex = null; }
39
+ if (lastVisitedIndex === void 0) { lastVisitedIndex = -1; }
40
40
  // only one slide remaining, the step should stay on the same number
41
41
  if (lastVisitedIndex === currentStepNumber) {
42
42
  return currentStepNumber;
43
43
  }
44
- var indexToVisit = getNextIndex(isNil(lastVisitedIndex) ? currentStepNumber : lastVisitedIndex);
44
+ var indexToVisit = getNextIndex(lastVisitedIndex === -1 ? currentStepNumber : lastVisitedIndex);
45
45
  // if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
46
46
  return has(indexToVisit, finishedSlides)
47
47
  ? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
@@ -76,7 +76,7 @@ var reducer = function (state, action) {
76
76
  }
77
77
  case UPDATE_STEP_ITEMS_ON_NEXT: {
78
78
  var _b = action.payload, stepNumber = _b.stepNumber, finishedSlides = _b.finishedSlides, current = _b.current;
79
- var nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : null;
79
+ var nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : -1;
80
80
  return recalculateStepItemsState(state, stepNumber, { current: current, nextIndex: nextIndex });
81
81
  }
82
82
  default:
@@ -0,0 +1,8 @@
1
+ import crossFetch from 'cross-fetch';
2
+ import { Skills } from '../types/skills';
3
+ declare type FetchSkills = (token: string) => Promise<Skills>;
4
+ declare type CreateFetchSkills = (fetch: typeof crossFetch) => FetchSkills;
5
+ declare const fetchSkills: CreateFetchSkills;
6
+ export { fetchSkills };
7
+ declare const _default: FetchSkills;
8
+ export default _default;
@@ -36,41 +36,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  };
37
37
  import crossFetch from 'cross-fetch';
38
38
  import decode from 'jwt-decode';
39
- import { toJSON } from './fetch-responses';
40
- var buildUrlQueryParams = function (params) {
41
- return Object.keys(params)
42
- .map(function (key) {
43
- var value = params[key].toString();
44
- return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
45
- })
46
- .join('&');
47
- };
39
+ import { toJSON } from './tools/fetch-responses';
40
+ import mockFetchSkills from './fetch-skills.mock';
48
41
  // -----------------------------------------------------------------------------
49
- var fetchCourse = function (fetch) {
50
- return function (token, language, universalRef) { return __awaiter(void 0, void 0, void 0, function () {
51
- var jwt, query, response, hits;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- jwt = decode(token);
56
- query = {
57
- type: 'course',
58
- universalRef: universalRef,
59
- lang: language
60
- };
61
- return [4 /*yield*/, fetch("".concat(jwt.host, "/api/v2/contents?").concat(buildUrlQueryParams(query)), {
62
- headers: { authorization: token }
63
- })];
64
- case 1:
65
- response = _a.sent();
66
- return [4 /*yield*/, toJSON(response)];
67
- case 2:
68
- hits = (_a.sent()).hits;
69
- return [2 /*return*/, hits === null || hits === void 0 ? void 0 : hits[0]];
70
- }
71
- });
72
- }); };
42
+ var fetchSkills = function (fetch) { return function (token) { return __awaiter(void 0, void 0, void 0, function () {
43
+ var _a, userId, host, response, skills;
44
+ return __generator(this, function (_b) {
45
+ switch (_b.label) {
46
+ case 0:
47
+ _a = decode(token), userId = _a.user, host = _a.host;
48
+ return [4 /*yield*/, fetch("".concat(host, "/api/v2/skills/review/user/").concat(userId), {
49
+ headers: { authorization: token }
50
+ })];
51
+ case 1:
52
+ response = _b.sent();
53
+ return [4 /*yield*/, toJSON(response)];
54
+ case 2:
55
+ skills = (_b.sent());
56
+ return [2 /*return*/, skills];
57
+ }
58
+ });
59
+ }); }; };
60
+ // -----------------------------------------------------------------------------
61
+ var createFetchSkills = function () {
62
+ if (process.env.SERVICES !== 'mocks') {
63
+ return fetchSkills(crossFetch);
64
+ }
65
+ return fetchSkills(mockFetchSkills);
73
66
  };
74
67
  // -----------------------------------------------------------------------------
75
- export { fetchCourse };
76
- export default fetchCourse(crossFetch);
68
+ export { fetchSkills };
69
+ export default createFetchSkills();
@@ -0,0 +1,3 @@
1
+ import crossFetch from 'cross-fetch';
2
+ declare const mockFetchSkills: typeof crossFetch;
3
+ export default mockFetchSkills;
@@ -0,0 +1,17 @@
1
+ import { okJSONResponse } from './tools/fetch.mocks';
2
+ var result = [
3
+ {
4
+ skillRef: '_skill-ref',
5
+ slidesToReview: 2,
6
+ name: 'skill-test',
7
+ custom: false
8
+ },
9
+ {
10
+ skillRef: '_skill-ref-2',
11
+ slidesToReview: 2,
12
+ name: 'skill-test-2',
13
+ custom: true
14
+ }
15
+ ];
16
+ var mockFetchSkills = okJSONResponse(result);
17
+ export default mockFetchSkills;
@@ -35,22 +35,41 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import test from 'ava';
38
- import { fetchCourse as _fetchCourse } from './fetch-demo';
39
- import { okJSONResponse } from './fetch.mocks';
40
- test('should fetch a demo course', function (t) { return __awaiter(void 0, void 0, void 0, function () {
41
- var token, language, universalRef, result, fetchCourse, course;
38
+ import { fetchSkills } from './fetch-skills';
39
+ import { okJSONResponse, token } from './tools/fetch.mocks';
40
+ test('should fetch skills with success', function (t) { return __awaiter(void 0, void 0, void 0, function () {
41
+ var result, mockedFetchSkills, skills;
42
42
  return __generator(this, function (_a) {
43
43
  switch (_a.label) {
44
44
  case 0:
45
- token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
46
- language = 'fr';
47
- universalRef = 'bar';
48
- result = { hits: [{ title: 'Digital IQ test' }] };
49
- fetchCourse = _fetchCourse(okJSONResponse(result));
50
- return [4 /*yield*/, fetchCourse(token, language, universalRef)];
45
+ result = [
46
+ {
47
+ slidesToReview: 1,
48
+ name: 'skill-test',
49
+ custom: false,
50
+ skillRef: '_skill-ref'
51
+ }
52
+ ];
53
+ mockedFetchSkills = fetchSkills(okJSONResponse(result));
54
+ return [4 /*yield*/, mockedFetchSkills(token)];
51
55
  case 1:
52
- course = _a.sent();
53
- t.is(course.title, 'Digital IQ test');
56
+ skills = _a.sent();
57
+ t.deepEqual(result, skills);
58
+ return [2 /*return*/];
59
+ }
60
+ });
61
+ }); });
62
+ test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
63
+ var badToken, mockedFetchSkills, error;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ badToken = 'token is not a jwt';
68
+ mockedFetchSkills = fetchSkills(okJSONResponse([]));
69
+ return [4 /*yield*/, t.throwsAsync(function () { return mockedFetchSkills(badToken); })];
70
+ case 1:
71
+ error = _a.sent();
72
+ t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
54
73
  return [2 /*return*/];
55
74
  }
56
75
  });
@@ -0,0 +1,7 @@
1
+ export declare class ResponseError extends Error {
2
+ statusCode: number;
3
+ constructor(statusCode: number, statusText: string, body?: string);
4
+ }
5
+ export declare const toJSON: (response: Response) => Promise<unknown>;
6
+ export declare const toText: (response: Response) => Promise<string>;
7
+ export declare const toVoid: (response: Response) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import crossFetch from 'cross-fetch';
2
+ export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<Response>;
3
+ export declare const okJSONResponse: (body: unknown) => typeof crossFetch;
4
+ export declare const internalServerErrorJSONResponse: (body: unknown) => typeof crossFetch;
5
+ export declare const notFoundJSONResponse: (body: unknown) => typeof crossFetch;
6
+ export declare const okTextResponse: (body: string) => typeof crossFetch;
7
+ export declare const internalServerErrorTextResponse: (body: string) => typeof crossFetch;
8
+ export declare const token: string;
@@ -32,3 +32,4 @@ export var internalServerErrorTextResponse = function (body) {
32
32
  return toResponse(500, 'InternalServerError', body);
33
33
  };
34
34
  };
35
+ export var token = process.env.API_TEST_TOKEN || 'no-API_TEST_TOKEN';
@@ -5,3 +5,15 @@ export declare type AppOptions = {
5
5
  translations?: unknown;
6
6
  slide?: Slide;
7
7
  };
8
+ export declare type JWT = {
9
+ exp: number;
10
+ iat: number;
11
+ grants: unknown;
12
+ iss: string;
13
+ user: string;
14
+ usage: string;
15
+ host: string;
16
+ };
17
+ export declare type WithRequired<T, K extends keyof T> = T & {
18
+ [P in K]-?: T[P];
19
+ };
@@ -0,0 +1,7 @@
1
+ export declare type Skill = {
2
+ skillRef: string;
3
+ slidesToReview: number;
4
+ custom: boolean;
5
+ name: string;
6
+ };
7
+ export declare type Skills = Skill[];
@@ -1,14 +1,14 @@
1
- import { WithRequired } from './utils';
2
1
  export declare type Choice = {
3
2
  order?: number;
4
3
  selected: boolean;
5
4
  title: string;
6
5
  help: string;
6
+ onClick: Function;
7
7
  };
8
8
  export declare type QcmDrag = {
9
9
  type: 'qcmDrag';
10
- choices: Choice[];
11
- help: string;
10
+ answers: Choice[];
11
+ help?: string;
12
12
  };
13
13
  export declare type Qcm = {
14
14
  type: 'qcm';
@@ -62,26 +62,8 @@ export declare type AnswerUI = {
62
62
  model: QcmDrag | Qcm | QcmGraphic | FreeText | DropDown | QuestionRange | Template;
63
63
  help: string;
64
64
  };
65
- export declare type SlideNumber = number;
66
65
  export declare type SlideUIAnimations = 'unstack' | 'restack';
67
66
  export declare type Slide = {
68
- hidden?: boolean;
69
- position?: number;
70
- animationType?: SlideUIAnimations;
71
- validationResult?: 'success' | 'failure';
72
- endReview?: boolean;
73
67
  questionText?: string;
74
68
  answerUI?: AnswerUI;
75
- nextSlide?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextSlide'>;
76
- };
77
- export declare type Slides = {
78
- slideNumbers: SlideNumber[];
79
- [key: SlideNumber]: Slide;
80
- };
81
- export declare type UpdateSlidesOnValidationPayload = {
82
- slideNumber: SlideNumber;
83
- newSlideContent: Slide;
84
- numberOfFinishedSlides: number;
85
- nextSlide: WithRequired<Slide['nextSlide'], 'answerUI' | 'questionText'>;
86
69
  };
87
- export declare type UpdateSlidesOnNextPayload = Omit<UpdateSlidesOnValidationPayload, 'nextSlide'>;
@@ -0,0 +1,24 @@
1
+ declare type SkillCard = {
2
+ 'aria-label': string;
3
+ skillTitle: string;
4
+ skillAriaLabel: string;
5
+ buttonLabel: string;
6
+ buttonAriaLabel: string;
7
+ reviseLabel: string;
8
+ reviseAriaLabel: string;
9
+ isCustom: boolean;
10
+ onClick: Function;
11
+ };
12
+ declare type NoSkillsProps = {
13
+ titleNoSkills: string;
14
+ textNoSkills: string;
15
+ iconSkillAriaLabel: string;
16
+ };
17
+ declare type SkillsProps = NoSkillsProps & {
18
+ 'aria-label'?: string;
19
+ title: string;
20
+ isLoading?: boolean;
21
+ isLoadingAriaLabel: string;
22
+ listSkills: SkillCard[];
23
+ };
24
+ export { SkillsProps };
@@ -1,11 +1,7 @@
1
- import { State as ReviewStatus } from '../reducers/review-status';
2
- import { DataState } from './data';
3
- import { Dispatchers } from './dispatchers';
4
- import { FinishedSlides } from './finished-slides';
5
- import { Slides } from './slides';
6
- import { StepItems } from './step-items';
1
+ import { Dispatchers } from '../../actions';
2
+ import { StoreState } from '../../configure-store';
7
3
  declare type SlidesViewStaticProps = {
8
- slides: Slides;
4
+ slides: StoreState['data']['slides'];
9
5
  headerProps: {
10
6
  mode: string;
11
7
  skillName: string;
@@ -13,9 +9,9 @@ declare type SlidesViewStaticProps = {
13
9
  'aria-label'?: string;
14
10
  closeButtonAriaLabel: string;
15
11
  };
16
- finishedSlides: FinishedSlides;
17
- stepItems: StepItems;
18
- reviewStatus: ReviewStatus;
12
+ finishedSlides: StoreState['ui']['finishedSlides'];
13
+ stepItems: StoreState['ui']['stepItems'];
14
+ reviewStatus: StoreState['ui']['reviewStatus'];
19
15
  validate: {
20
16
  label: string;
21
17
  };
@@ -57,7 +53,7 @@ declare type SlidesViewStaticProps = {
57
53
  failureLabel: string;
58
54
  };
59
55
  reviewBackgroundAriaLabel?: string;
60
- slideValidationResult: DataState['slideValidationResult'];
56
+ progression: StoreState['data']['progression'];
61
57
  };
62
58
  declare type SlidesViewDispatcherProps = Omit<Dispatchers, 'navigateTo' | 'navigateBack'>;
63
59
  declare type SlidesViewProps = SlidesViewStaticProps & SlidesViewDispatcherProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -40,7 +40,7 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@coorpacademy/components": "10.21.2",
43
+ "@coorpacademy/components": "10.21.3",
44
44
  "cross-fetch": "^3.1.5",
45
45
  "jwt-decode": "^3.1.2",
46
46
  "react-redux": "^8.0.1",
@@ -76,5 +76,5 @@
76
76
  "ts-node": "^10.8.1",
77
77
  "typescript": "^4.7.4"
78
78
  },
79
- "gitHead": "d45f65336f89f149396b5b466c74318fe742dfe1"
79
+ "gitHead": "e56c49d3c4ba099a60afb29e6cec578e33f8c39e"
80
80
  }
@@ -0,0 +1,24 @@
1
+ import {Skills} from '../../types/skills';
2
+
3
+ export const RECEIVED_SKILLS = '@@data/skills/RECEIVED_SKILLS';
4
+ export const ERROR_FETCHING_SKILLS = '@@data/skills/ERROR_FETCHING_SKILLS';
5
+
6
+ export type ReceivedSkills = {
7
+ type: '@@data/skills/RECEIVED_SKILLS';
8
+ payload: Skills;
9
+ };
10
+
11
+ export type ErrorFetchingSkills = {
12
+ type: '@@data/skills/ERROR_FETCHING_SKILLS';
13
+ payload: Error;
14
+ };
15
+
16
+ export const receivedSkills = (skills: Skills): ReceivedSkills => ({
17
+ type: RECEIVED_SKILLS,
18
+ payload: skills
19
+ });
20
+
21
+ export const errorFetchingSkills = (error: Error): ErrorFetchingSkills => ({
22
+ type: ERROR_FETCHING_SKILLS,
23
+ payload: error
24
+ });