@coorpacademy/app-review 0.1.7 → 0.1.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 (200) hide show
  1. package/es/actions/api/fetch-skills.d.ts +10 -0
  2. package/es/actions/api/fetch-skills.js +8 -0
  3. package/es/actions/api/fetch-slide.d.ts +10 -0
  4. package/es/actions/api/fetch-slide.js +8 -0
  5. package/es/actions/api/post-progression.d.ts +10 -0
  6. package/es/actions/api/post-progression.js +15 -0
  7. package/es/actions/data/slides.d.ts +3 -24
  8. package/es/actions/data/slides.js +0 -11
  9. package/es/actions/index.d.ts +5 -4
  10. package/es/actions/ui/navigation.d.ts +0 -1
  11. package/es/actions/ui/navigation.js +0 -4
  12. package/es/actions/ui/step-items.d.ts +2 -8
  13. package/es/actions/ui/step-items.js +0 -6
  14. package/es/configure-store.d.ts +3 -26
  15. package/es/configure-store.js +4 -5
  16. package/es/fixtures/qcm-slide.d.ts +2 -2
  17. package/es/index.js +38 -19
  18. package/es/reducers/data/index.d.ts +16 -5
  19. package/es/reducers/data/progression.d.ts +1 -2
  20. package/es/reducers/data/progression.js +4 -7
  21. package/es/reducers/data/skills.d.ts +4 -5
  22. package/es/reducers/data/skills.js +3 -6
  23. package/es/reducers/data/slides.d.ts +2 -1
  24. package/es/reducers/data/slides.js +3 -3
  25. package/es/reducers/data/token.d.ts +0 -1
  26. package/es/reducers/data/token.js +1 -5
  27. package/es/reducers/index.d.ts +9 -3
  28. package/es/reducers/ui/finished-slides.d.ts +0 -1
  29. package/es/reducers/ui/finished-slides.js +1 -3
  30. package/es/reducers/ui/index.d.ts +14 -4
  31. package/es/reducers/ui/navigation.d.ts +0 -1
  32. package/es/reducers/ui/navigation.js +1 -3
  33. package/es/reducers/ui/review-status.d.ts +0 -1
  34. package/es/reducers/ui/review-status.js +1 -4
  35. package/es/reducers/ui/step-items.d.ts +5 -5
  36. package/es/reducers/ui/step-items.js +0 -1
  37. package/es/services/fetch-skills.d.ts +2 -8
  38. package/es/services/fetch-skills.js +2 -14
  39. package/es/services/fetch-slide.d.ts +2 -8
  40. package/es/services/fetch-slide.js +9 -24
  41. package/es/services/index.d.ts +2 -0
  42. package/es/services/index.js +8 -0
  43. package/es/services/post-progression.d.ts +2 -8
  44. package/es/services/post-progression.js +2 -14
  45. package/es/services/test/fetch-skills.test.js +29 -0
  46. package/es/services/test/post-progression.test.js +35 -0
  47. package/es/{index.test.js → test/index.test.js} +15 -4
  48. package/es/test/util/services.mock.d.ts +2 -0
  49. package/es/test/util/services.mock.js +68 -0
  50. package/es/types/common.d.ts +58 -0
  51. package/es/types/common.js +5 -0
  52. package/es/types/slides.d.ts +1 -1
  53. package/es/types/views/slides.d.ts +1 -1
  54. package/lib/actions/api/fetch-skills.d.ts +10 -0
  55. package/lib/actions/api/fetch-skills.js +13 -0
  56. package/lib/actions/api/fetch-slide.d.ts +10 -0
  57. package/lib/actions/api/fetch-slide.js +13 -0
  58. package/lib/actions/api/post-progression.d.ts +10 -0
  59. package/lib/actions/api/post-progression.js +18 -0
  60. package/lib/actions/data/slides.d.ts +3 -24
  61. package/lib/actions/data/slides.js +0 -11
  62. package/lib/actions/index.d.ts +5 -4
  63. package/lib/actions/ui/navigation.d.ts +0 -1
  64. package/lib/actions/ui/navigation.js +0 -4
  65. package/lib/actions/ui/step-items.d.ts +2 -8
  66. package/lib/actions/ui/step-items.js +0 -6
  67. package/lib/configure-store.d.ts +3 -26
  68. package/lib/configure-store.js +4 -5
  69. package/lib/fixtures/qcm-slide.d.ts +2 -2
  70. package/lib/index.js +38 -63
  71. package/lib/reducers/data/index.d.ts +16 -5
  72. package/lib/reducers/data/progression.d.ts +1 -2
  73. package/lib/reducers/data/progression.js +4 -7
  74. package/lib/reducers/data/skills.d.ts +4 -5
  75. package/lib/reducers/data/skills.js +3 -6
  76. package/lib/reducers/data/slides.d.ts +2 -1
  77. package/lib/reducers/data/slides.js +3 -3
  78. package/lib/reducers/data/token.d.ts +0 -1
  79. package/lib/reducers/data/token.js +1 -5
  80. package/lib/reducers/index.d.ts +9 -3
  81. package/lib/reducers/ui/finished-slides.d.ts +0 -1
  82. package/lib/reducers/ui/finished-slides.js +1 -3
  83. package/lib/reducers/ui/index.d.ts +14 -4
  84. package/lib/reducers/ui/navigation.d.ts +0 -1
  85. package/lib/reducers/ui/navigation.js +1 -3
  86. package/lib/reducers/ui/review-status.d.ts +0 -1
  87. package/lib/reducers/ui/review-status.js +1 -4
  88. package/lib/reducers/ui/step-items.d.ts +5 -5
  89. package/lib/reducers/ui/step-items.js +0 -1
  90. package/lib/services/fetch-skills.d.ts +2 -8
  91. package/lib/services/fetch-skills.js +3 -15
  92. package/lib/services/fetch-slide.d.ts +2 -8
  93. package/lib/services/fetch-slide.js +18 -25
  94. package/lib/services/index.d.ts +2 -0
  95. package/lib/services/index.js +8 -0
  96. package/lib/services/post-progression.d.ts +2 -8
  97. package/lib/services/post-progression.js +3 -15
  98. package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
  99. package/lib/services/{post-progression.test.js → test/post-progression.test.js} +28 -23
  100. package/lib/{index.test.js → test/index.test.js} +20 -10
  101. package/lib/test/util/services.mock.d.ts +2 -0
  102. package/lib/test/util/services.mock.js +68 -0
  103. package/lib/types/common.d.ts +58 -0
  104. package/lib/types/common.js +5 -0
  105. package/lib/types/slides.d.ts +1 -1
  106. package/lib/types/views/slides.d.ts +1 -1
  107. package/package.json +5 -3
  108. package/src/actions/api/fetch-skills.ts +20 -0
  109. package/src/actions/api/fetch-slide.ts +20 -0
  110. package/src/actions/api/post-progression.ts +26 -0
  111. package/src/actions/data/slides.ts +3 -35
  112. package/src/actions/index.ts +5 -11
  113. package/src/actions/ui/navigation.ts +0 -5
  114. package/src/actions/ui/step-items.ts +2 -14
  115. package/src/configure-store.ts +6 -37
  116. package/src/fixtures/qcm-slide.ts +2 -2
  117. package/src/index.tsx +43 -19
  118. package/src/reducers/data/index.ts +12 -4
  119. package/src/reducers/data/progression.ts +5 -15
  120. package/src/reducers/data/skills.ts +5 -10
  121. package/src/reducers/data/slides.ts +4 -8
  122. package/src/reducers/data/token.ts +1 -11
  123. package/src/reducers/index.ts +7 -2
  124. package/src/reducers/ui/finished-slides.ts +1 -7
  125. package/src/reducers/ui/index.ts +11 -4
  126. package/src/reducers/ui/navigation.ts +1 -6
  127. package/src/reducers/ui/review-status.ts +1 -8
  128. package/src/reducers/ui/step-items.ts +5 -14
  129. package/src/services/fetch-skills.ts +4 -29
  130. package/src/services/fetch-slide.ts +10 -38
  131. package/src/services/index.ts +10 -0
  132. package/src/services/post-progression.ts +6 -28
  133. package/src/services/test/fetch-skills.test.ts +39 -0
  134. package/src/services/test/post-progression.test.ts +45 -0
  135. package/src/{index.test.tsx → test/index.test.tsx} +13 -5
  136. package/src/test/util/services.mock.ts +70 -0
  137. package/src/types/common.ts +70 -0
  138. package/src/types/globals.d.ts +1 -0
  139. package/src/types/slides.ts +1 -1
  140. package/src/types/views/slides.ts +1 -1
  141. package/es/actions/data/progression.d.ts +0 -30
  142. package/es/actions/data/progression.js +0 -12
  143. package/es/actions/data/skills.d.ts +0 -13
  144. package/es/actions/data/skills.js +0 -10
  145. package/es/middlewares/on-receive-progression.d.ts +0 -6
  146. package/es/middlewares/on-receive-progression.js +0 -22
  147. package/es/middlewares/on-receive-progression.test.d.ts +0 -1
  148. package/es/middlewares/on-receive-progression.test.js +0 -43
  149. package/es/middlewares/on-start-app.d.ts +0 -5
  150. package/es/middlewares/on-start-app.js +0 -37
  151. package/es/middlewares/on-start-app.test.d.ts +0 -1
  152. package/es/middlewares/on-start-app.test.js +0 -53
  153. package/es/services/fetch-skills.mock.d.ts +0 -3
  154. package/es/services/fetch-skills.mock.js +0 -17
  155. package/es/services/fetch-skills.test.js +0 -22
  156. package/es/services/post-progression.mock.d.ts +0 -5
  157. package/es/services/post-progression.mock.js +0 -31
  158. package/es/services/post-progression.test.js +0 -30
  159. package/es/services/tools/fetch.mocks.d.ts +0 -8
  160. package/es/services/tools/fetch.mocks.js +0 -13
  161. package/es/types/skills.d.ts +0 -7
  162. package/es/types/skills.js +0 -1
  163. package/lib/actions/data/progression.d.ts +0 -30
  164. package/lib/actions/data/progression.js +0 -12
  165. package/lib/actions/data/skills.d.ts +0 -13
  166. package/lib/actions/data/skills.js +0 -10
  167. package/lib/middlewares/on-receive-progression.d.ts +0 -6
  168. package/lib/middlewares/on-receive-progression.js +0 -27
  169. package/lib/middlewares/on-receive-progression.test.d.ts +0 -1
  170. package/lib/middlewares/on-receive-progression.test.js +0 -88
  171. package/lib/middlewares/on-start-app.d.ts +0 -5
  172. package/lib/middlewares/on-start-app.js +0 -42
  173. package/lib/middlewares/on-start-app.test.d.ts +0 -1
  174. package/lib/middlewares/on-start-app.test.js +0 -98
  175. package/lib/services/fetch-skills.mock.d.ts +0 -3
  176. package/lib/services/fetch-skills.mock.js +0 -17
  177. package/lib/services/post-progression.mock.d.ts +0 -5
  178. package/lib/services/post-progression.mock.js +0 -31
  179. package/lib/services/tools/fetch.mocks.d.ts +0 -8
  180. package/lib/services/tools/fetch.mocks.js +0 -35
  181. package/lib/types/skills.d.ts +0 -7
  182. package/lib/types/skills.js +0 -1
  183. package/src/actions/data/progression.ts +0 -50
  184. package/src/actions/data/skills.ts +0 -24
  185. package/src/middlewares/on-receive-progression.test.ts +0 -60
  186. package/src/middlewares/on-receive-progression.ts +0 -42
  187. package/src/middlewares/on-start-app.test.ts +0 -68
  188. package/src/middlewares/on-start-app.ts +0 -50
  189. package/src/services/fetch-skills.mock.ts +0 -21
  190. package/src/services/fetch-skills.test.ts +0 -32
  191. package/src/services/post-progression.mock.ts +0 -35
  192. package/src/services/post-progression.test.ts +0 -41
  193. package/src/services/tools/fetch.mocks.ts +0 -41
  194. package/src/types/skills.ts +0 -8
  195. /package/es/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
  196. /package/es/services/{post-progression.test.d.ts → test/post-progression.test.d.ts} +0 -0
  197. /package/es/{index.test.d.ts → test/index.test.d.ts} +0 -0
  198. /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
  199. /package/lib/services/{post-progression.test.d.ts → test/post-progression.test.d.ts} +0 -0
  200. /package/lib/{index.test.d.ts → test/index.test.d.ts} +0 -0
@@ -8,7 +8,3 @@ export var navigateTo = function (newPath) { return ({
8
8
  export var navigateBack = function () { return ({
9
9
  type: NAVIGATE_BACK
10
10
  }); };
11
- export var startApp = function (options) { return ({
12
- type: START_APP,
13
- payload: options
14
- }); };
@@ -1,19 +1,13 @@
1
- import { FinishedSlidesState } from '../../reducers/ui/finished-slides';
1
+ import { FinishedSlides, IconValue } from '../../types/common';
2
2
  export declare const UPDATE_STEP_ITEMS_ON_VALIDATION = "@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION";
3
3
  export declare const UPDATE_STEP_ITEMS_ON_NEXT = "@@step-items/UPDATE_STEP_ITEMS_ON_NEXT";
4
- declare const ICON_VALUES: {
5
- readonly right: "right";
6
- readonly wrong: "wrong";
7
- readonly 'no-answer': "no-answer";
8
- };
9
- export declare type IconValue = keyof typeof ICON_VALUES;
10
4
  declare type UpdateStepItemsOnValidationClickPayload = {
11
5
  stepNumber: number;
12
6
  icon: IconValue;
13
7
  };
14
8
  declare type UpdateStepItemsOnNextClickPayload = {
15
9
  stepNumber: number;
16
- finishedSlides: FinishedSlidesState;
10
+ finishedSlides: FinishedSlides;
17
11
  current: boolean;
18
12
  };
19
13
  export declare type UpdateStepItemsOnValidation = {
@@ -1,11 +1,5 @@
1
- // -----------------------------------------------------------------------------
2
1
  export var UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
3
2
  export var UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
4
- var ICON_VALUES = {
5
- right: 'right',
6
- wrong: 'wrong',
7
- 'no-answer': 'no-answer'
8
- };
9
3
  // -----------------------------------------------------------------------------
10
4
  export var updateStepItemsOnValidation = function (payload) { return ({
11
5
  type: UPDATE_STEP_ITEMS_ON_VALIDATION,
@@ -1,27 +1,4 @@
1
1
  import { AnyAction, Store } from 'redux';
2
- import { SkillsState } from './reducers/data/skills';
3
- import { SlidesState } from './reducers/data/slides';
4
- import { TokenState } from './reducers/data/token';
5
- import { NavigationState } from './reducers/ui/navigation';
6
- import { ReviewStatusState } from './reducers/ui/review-status';
7
- import { StepItemsState } from './reducers/ui/step-items';
8
- import { FinishedSlidesState } from './reducers/ui/finished-slides';
9
- import { ProgressionState } from './reducers/data/progression';
10
- declare type DataState = {
11
- isFetching?: boolean;
12
- progression?: ProgressionState;
13
- skills: SkillsState;
14
- slides: SlidesState;
15
- token?: TokenState;
16
- };
17
- export declare type StoreState = {
18
- ui: {
19
- navigation: NavigationState;
20
- stepItems: StepItemsState;
21
- finishedSlides: FinishedSlidesState;
22
- reviewStatus: ReviewStatusState;
23
- };
24
- data: DataState;
25
- };
26
- export default function configureStore(): Store<StoreState, AnyAction>;
27
- export {};
2
+ import { StoreState } from './reducers';
3
+ import { AppOptions } from './types/common';
4
+ export default function configureStore(options: AppOptions): Store<StoreState, AnyAction>;
@@ -1,10 +1,8 @@
1
1
  import { applyMiddleware, compose, createStore } from 'redux';
2
2
  import thunk from 'redux-thunk';
3
3
  import rootReducer from './reducers';
4
- import onStartApp from './middlewares/on-start-app';
5
- import onReceiveProgression from './middlewares/on-receive-progression';
6
- // -----------------------------------------------------------------------------
7
- export default function configureStore() {
4
+ import { getServices } from './services';
5
+ export default function configureStore(options) {
8
6
  var _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
9
7
  ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
10
8
  name: 'app-review',
@@ -12,7 +10,8 @@ export default function configureStore() {
12
10
  traceLimit: 25
13
11
  })
14
12
  : compose;
15
- var enhancer = _compose(applyMiddleware(thunk, onStartApp, onReceiveProgression));
13
+ var thunkMiddleware = thunk.withExtraArgument({ services: options.services || getServices() });
14
+ var enhancer = _compose(applyMiddleware(thunkMiddleware));
16
15
  var store = createStore(rootReducer, undefined, enhancer);
17
16
  return store;
18
17
  }
@@ -1,2 +1,2 @@
1
- import { Slide } from '../types/slides';
2
- export declare const slide: Slide;
1
+ import { UISlide } from '../types/slides';
2
+ export declare const slide: UISlide;
package/lib/index.js CHANGED
@@ -1,39 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
1
  import React, { useEffect, useState } from 'react';
38
2
  import { connect, Provider } from 'react-redux';
39
3
  import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
@@ -41,10 +5,14 @@ import { TemplateContext } from '@coorpacademy/components/es/template/app-review
41
5
  import configureStore from './configure-store';
42
6
  import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
43
7
  import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
44
- import { navigateTo, navigateBack, startApp } from './actions/ui/navigation';
8
+ import { navigateTo, navigateBack } from './actions/ui/navigation';
9
+ import { storeToken } from './actions/data/token';
45
10
  import { updateFinishedSlides } from './actions/ui/finished-slides';
46
11
  import { updateReviewStatus } from './actions/ui/review-status';
47
12
  import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui/step-items';
13
+ import { fetchSkills } from './actions/api/fetch-skills';
14
+ import { postProgression } from './actions/api/post-progression';
15
+ import { VIEWS } from './common';
48
16
  // -----------------------------------------------------------------------------
49
17
  var mapDispatchToProps = {
50
18
  navigateTo: navigateTo,
@@ -115,40 +83,47 @@ var mapStateToSlidesProps = function (state) {
115
83
  };
116
84
  };
117
85
  // -----------------------------------------------------------------------------
118
- var mapStateToProps = function (state) { return ({
119
- viewName: getCurrentViewName(state),
120
- slides: mapStateToSlidesProps(state),
121
- skills: mapStateToSkillsProps(state)
122
- }); };
86
+ var mapStateToProps = function (state) {
87
+ return {
88
+ viewName: getCurrentViewName(state),
89
+ slides: mapStateToSlidesProps(state),
90
+ skills: mapStateToSkillsProps(state)
91
+ };
92
+ };
123
93
  // Props = StaticProps && Dispatchers
124
94
  var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
125
95
  // -----------------------------------------------------------------------------
126
96
  var AppReview = function (_a) {
127
97
  var options = _a.options;
128
98
  var _b = useState(null), store = _b[0], setStore = _b[1];
129
- var _c = useState(false), appStarted = _c[0], setAppStarted = _c[1];
130
99
  useEffect(function () {
131
- if (store) {
132
- store.dispatch(startApp(options));
133
- setAppStarted(true);
134
- }
135
- else {
136
- var _configure = function () { return __awaiter(void 0, void 0, void 0, function () {
137
- var newStore;
138
- return __generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0: return [4 /*yield*/, configureStore()];
141
- case 1:
142
- newStore = _a.sent();
143
- setStore(newStore);
144
- return [2 /*return*/];
145
- }
146
- });
147
- }); };
148
- _configure();
149
- }
100
+ if (store)
101
+ return;
102
+ var newStore = configureStore(options);
103
+ setStore(newStore);
104
+ }, [options, store]);
105
+ useEffect(function () {
106
+ if (store === null)
107
+ return;
108
+ var skillRef = options.skillRef;
109
+ var initialView = skillRef ? VIEWS.slides : VIEWS.skills;
110
+ store.dispatch(navigateTo(initialView));
111
+ }, [options, store]);
112
+ useEffect(function () {
113
+ if (store === null)
114
+ return;
115
+ var token = options.token;
116
+ store.dispatch(storeToken(token));
117
+ }, [options, store]);
118
+ useEffect(function () {
119
+ if (store === null)
120
+ return;
121
+ var skillRef = options.skillRef, token = options.token;
122
+ skillRef
123
+ ? store.dispatch(postProgression(skillRef, token))
124
+ : store.dispatch(fetchSkills(token));
150
125
  }, [options, store]);
151
- if (!store || !appStarted)
126
+ if (!store)
152
127
  return null;
153
128
  var values = options.templateContext;
154
129
  return (React.createElement(Provider, { store: store },
@@ -1,7 +1,18 @@
1
+ import { ProgressionState } from './progression';
2
+ import { SkillsState } from './skills';
3
+ import { SlidesState } from './slides';
4
+ import { TokenState } from './token';
5
+ export declare type DataState = {
6
+ isFetching?: boolean;
7
+ progression?: ProgressionState;
8
+ skills: SkillsState;
9
+ slides: SlidesState;
10
+ token?: TokenState;
11
+ };
1
12
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
- progression: import("./progression").ProgressionState;
3
- skills: import("../../types/skills").Skills;
4
- slides: import("./slides").SlidesState;
5
- token: import("./token").TokenState;
6
- }>, import("../../actions/data/progression").ReceiveProgression | import("../../actions/data/slides").ValidateSlide | import("../../actions/data/slides").SlidesAction | import("../../actions/data/skills").ReceivedSkills | import("../../actions/data/token").StoreToken>;
13
+ progression: ProgressionState;
14
+ skills: SkillsState;
15
+ slides: SlidesState;
16
+ token: TokenState;
17
+ }>, import("../../actions/data/slides").ValidateSlide | import("../../actions/data/slides").SlidesAction | import("../../actions/api/post-progression").ReceiveProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("../../actions/data/token").StoreToken>;
7
18
  export default _default;
@@ -1,5 +1,5 @@
1
- import { ReceiveProgression } from '../../actions/data/progression';
2
1
  import { ValidateSlide } from '../../actions/data/slides';
2
+ import { ReceiveProgression } from '../../actions/api/post-progression';
3
3
  export declare type ProgressionState = {
4
4
  _id?: string;
5
5
  state: {
@@ -15,6 +15,5 @@ export declare type ProgressionState = {
15
15
  };
16
16
  slideNumber?: number;
17
17
  } | null;
18
- export declare const initialState: ProgressionState;
19
18
  declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
20
19
  export default reducer;
@@ -1,13 +1,10 @@
1
1
  import { getOr } from 'lodash/fp';
2
- import { RECEIVE_PROGRESSION } from '../../actions/data/progression';
3
2
  import { VALIDATE_SLIDE } from '../../actions/data/slides';
4
- // -----------------------------------------------------------------------------
5
- export var initialState = null;
6
- // -----------------------------------------------------------------------------
3
+ import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
7
4
  var reducer = function (
8
5
  // eslint-disable-next-line default-param-last
9
6
  state, action) {
10
- if (state === void 0) { state = initialState; }
7
+ if (state === void 0) { state = null; }
11
8
  switch (action.type) {
12
9
  case VALIDATE_SLIDE: {
13
10
  var previousSlideNumber = getOr(-1, 'slideNumber', state);
@@ -30,8 +27,8 @@ state, action) {
30
27
  }
31
28
  };
32
29
  }
33
- case RECEIVE_PROGRESSION: {
34
- var progression = action.payload.progression;
30
+ case POST_PROGRESSION_SUCCESS: {
31
+ var progression = action.payload;
35
32
  return progression;
36
33
  }
37
34
  default:
@@ -1,6 +1,5 @@
1
- import { ReceivedSkills } from '../../actions/data/skills';
2
- import { Skills } from '../../types/skills';
3
- export declare type SkillsState = Skills;
4
- export declare const initialState: SkillsState;
5
- declare const reducer: (state: Skills | undefined, action: ReceivedSkills) => Skills;
1
+ import { Skill } from '../../types/common';
2
+ import { ReceivedSkills } from '../../actions/api/fetch-skills';
3
+ export declare type SkillsState = Skill[];
4
+ declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
6
5
  export default reducer;
@@ -1,15 +1,12 @@
1
- import { RECEIVED_SKILLS } from '../../actions/data/skills';
2
- export var initialState = [];
3
- // -----------------------------------------------------------------------------
1
+ import { SKILLS_FETCH_SUCCESS } from '../../actions/api/fetch-skills';
4
2
  // eslint-disable-next-line default-param-last
5
3
  var reducer = function (state, action) {
6
- if (state === void 0) { state = initialState; }
4
+ if (state === void 0) { state = []; }
7
5
  switch (action.type) {
8
- case RECEIVED_SKILLS:
6
+ case SKILLS_FETCH_SUCCESS:
9
7
  return action.payload;
10
8
  default:
11
9
  return state;
12
10
  }
13
11
  };
14
- // -----------------------------------------------------------------------------
15
12
  export default reducer;
@@ -1,4 +1,5 @@
1
- import { Slide, SlidesAction } from '../../actions/data/slides';
1
+ import { SlidesAction } from '../../actions/data/slides';
2
+ import { Slide } from '../../types/common';
2
3
  export declare type SlidesState = {
3
4
  slideNumbers: number[];
4
5
  [key: number]: Slide;
@@ -10,10 +10,10 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import map from 'lodash/fp/map';
13
- import { STORE_FIRST_SLIDE, UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../../actions/data/slides';
13
+ import { UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../../actions/data/slides';
14
14
  import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
15
15
  import { slide as qcmSlide } from '../../fixtures/qcm-slide';
16
- // -----------------------------------------------------------------------------
16
+ import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
17
17
  var getInitialState = function () {
18
18
  var state = {
19
19
  slideNumbers: slideNumbers
@@ -104,7 +104,7 @@ var stateUpdateOnNext = function (state, payload) {
104
104
  var reducer = function (state, action) {
105
105
  if (state === void 0) { state = initialState; }
106
106
  switch (action.type) {
107
- case STORE_FIRST_SLIDE: {
107
+ case SLIDE_FETCH_SUCCESS: {
108
108
  // TODO: An intermediate slide transform is needed here (or in fetchSlide)
109
109
  // const apiSlide = action.payload;
110
110
  // apiSlide adapt to uiSlide
@@ -1,5 +1,4 @@
1
1
  import { StoreToken } from '../../actions/data/token';
2
2
  export declare type TokenState = string | null;
3
- export declare const initialState: TokenState;
4
3
  declare const reducer: (state: TokenState | undefined, action: StoreToken) => TokenState;
5
4
  export default reducer;
@@ -1,10 +1,7 @@
1
1
  import { STORE_TOKEN } from '../../actions/data/token';
2
- // -----------------------------------------------------------------------------
3
- export var initialState = null;
4
- // -----------------------------------------------------------------------------
5
2
  // eslint-disable-next-line default-param-last
6
3
  var reducer = function (state, action) {
7
- if (state === void 0) { state = initialState; }
4
+ if (state === void 0) { state = null; }
8
5
  switch (action.type) {
9
6
  case STORE_TOKEN:
10
7
  return action.payload;
@@ -12,5 +9,4 @@ var reducer = function (state, action) {
12
9
  return state;
13
10
  }
14
11
  };
15
- // -----------------------------------------------------------------------------
16
12
  export default reducer;
@@ -1,7 +1,13 @@
1
+ import { DataState } from './data';
2
+ import { UIState } from './ui';
3
+ export declare type StoreState = {
4
+ ui: UIState;
5
+ data: DataState;
6
+ };
1
7
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
8
  data: import("redux").CombinedState<{
3
9
  progression: import("./data/progression").ProgressionState;
4
- skills: import("../types/skills").Skills;
10
+ skills: import("./data/skills").SkillsState;
5
11
  slides: import("./data/slides").SlidesState;
6
12
  token: import("./data/token").TokenState;
7
13
  }>;
@@ -9,7 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
9
15
  finishedSlides: import("./ui/finished-slides").FinishedSlidesState;
10
16
  navigation: import("./ui/navigation").NavigationState;
11
17
  reviewStatus: import("./ui/review-status").ReviewStatusState;
12
- stepItems: import("./ui/step-items").StepItems;
18
+ stepItems: import("./ui/step-items").StepItemsState;
13
19
  }>;
14
- }>, import("../actions/data/progression").ReceiveProgression | 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>;
20
+ }>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-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>;
15
21
  export default _default;
@@ -3,6 +3,5 @@ export declare type FinishedSlidesState = {
3
3
  slideNumbers: number[];
4
4
  [key: number]: true;
5
5
  };
6
- export declare const initialState: FinishedSlidesState;
7
6
  declare const reducer: (state: FinishedSlidesState | undefined, action: UpdateFinishedSlides) => FinishedSlidesState;
8
7
  export default reducer;
@@ -12,11 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import forEach from 'lodash/fp/forEach';
13
13
  import { UPDATE_FINISHED_SLIDES } from '../../actions/ui/finished-slides';
14
14
  import { slideNumbers } from '../../common';
15
- // -----------------------------------------------------------------------------
16
- export var initialState = {
15
+ var initialState = {
17
16
  slideNumbers: slideNumbers
18
17
  };
19
- // -----------------------------------------------------------------------------
20
18
  var _forEach = forEach.convert({
21
19
  cap: false
22
20
  });
@@ -1,7 +1,17 @@
1
+ import { FinishedSlidesState } from './finished-slides';
2
+ import { NavigationState } from './navigation';
3
+ import { ReviewStatusState } from './review-status';
4
+ import { StepItemsState } from './step-items';
5
+ export declare type UIState = {
6
+ navigation: NavigationState;
7
+ stepItems: StepItemsState;
8
+ finishedSlides: FinishedSlidesState;
9
+ reviewStatus: ReviewStatusState;
10
+ };
1
11
  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;
12
+ finishedSlides: FinishedSlidesState;
13
+ navigation: NavigationState;
14
+ reviewStatus: ReviewStatusState;
15
+ stepItems: StepItemsState;
6
16
  }>, 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
17
  export default _default;
@@ -1,5 +1,4 @@
1
1
  import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
2
2
  export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides'>;
3
- export declare const initialState: NavigationState;
4
3
  declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
5
4
  export default reducer;
@@ -8,12 +8,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
10
  import { NAVIGATE_BACK, NAVIGATE_TO } from '../../actions/ui/navigation';
11
- export var initialState = [];
12
- // -----------------------------------------------------------------------------
13
11
  var reducer = function (
14
12
  // eslint-disable-next-line default-param-last
15
13
  state, action) {
16
- if (state === void 0) { state = initialState; }
14
+ if (state === void 0) { state = []; }
17
15
  switch (action.type) {
18
16
  case NAVIGATE_TO: {
19
17
  return __spreadArray(__spreadArray([], state, true), [action.payload], false);
@@ -1,5 +1,4 @@
1
1
  import { UpdateReviewStatus } from '../../actions/ui/review-status';
2
2
  export declare type ReviewStatusState = 'finished' | 'ongoing';
3
- export declare const initialState: ReviewStatusState;
4
3
  declare const reducer: (state: ReviewStatusState | undefined, action: UpdateReviewStatus) => ReviewStatusState;
5
4
  export default reducer;
@@ -1,10 +1,8 @@
1
1
  import { UPDATE_REVIEW_STATUS } from '../../actions/ui/review-status';
2
- export var initialState = 'ongoing';
3
- // -----------------------------------------------------------------------------
4
2
  var reducer = function (
5
3
  // eslint-disable-next-line default-param-last
6
4
  state, action) {
7
- if (state === void 0) { state = initialState; }
5
+ if (state === void 0) { state = 'ongoing'; }
8
6
  switch (action.type) {
9
7
  case UPDATE_REVIEW_STATUS: {
10
8
  return action.payload;
@@ -13,5 +11,4 @@ state, action) {
13
11
  return state;
14
12
  }
15
13
  };
16
- // -----------------------------------------------------------------------------
17
14
  export default reducer;
@@ -1,14 +1,14 @@
1
- import { IconValue, StepItemsAction } from '../../actions/ui/step-items';
2
- declare type StepItem = {
1
+ import { IconValue } from '../../types/common';
2
+ import { StepItemsAction } from '../../actions/ui/step-items';
3
+ export declare type StepItem = {
3
4
  current: boolean;
4
5
  icon: IconValue;
5
6
  value: string;
6
7
  };
7
- export declare type StepItems = {
8
+ export declare type StepItemsState = {
8
9
  slideNumbers: number[];
9
10
  [key: number]: StepItem;
10
11
  };
11
- export declare type StepItemsState = StepItems;
12
12
  export declare const initialState: StepItemsState;
13
- declare const reducer: (state: StepItems | undefined, action: StepItemsAction) => StepItemsState;
13
+ declare const reducer: (state: StepItemsState | undefined, action: StepItemsAction) => StepItemsState;
14
14
  export default reducer;
@@ -14,7 +14,6 @@ import has from 'lodash/fp/has';
14
14
  import map from 'lodash/fp/map';
15
15
  import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../../actions/ui/step-items';
16
16
  import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
17
- // -----------------------------------------------------------------------------
18
17
  var getInitialState = function () {
19
18
  var state = {
20
19
  slideNumbers: slideNumbers
@@ -1,8 +1,2 @@
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;
1
+ import { Skill } from '../types/common';
2
+ export declare const fetchSkills: (token: string) => Promise<Skill[]>;
@@ -37,15 +37,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  import crossFetch from 'cross-fetch';
38
38
  import decode from 'jwt-decode';
39
39
  import { toJSON } from './tools/fetch-responses';
40
- import mockFetchSkills from './fetch-skills.mock';
41
- // -----------------------------------------------------------------------------
42
- var fetchSkills = function (fetch) { return function (token) { return __awaiter(void 0, void 0, void 0, function () {
40
+ export var fetchSkills = function (token) { return __awaiter(void 0, void 0, void 0, function () {
43
41
  var _a, userId, host, response;
44
42
  return __generator(this, function (_b) {
45
43
  switch (_b.label) {
46
44
  case 0:
47
45
  _a = decode(token), userId = _a.user, host = _a.host;
48
- return [4 /*yield*/, fetch("".concat(host, "/api/v2/skills/review/user/").concat(userId), {
46
+ return [4 /*yield*/, crossFetch("".concat(host, "/api/v2/skills/review/user/").concat(userId), {
49
47
  headers: { authorization: token }
50
48
  })];
51
49
  case 1:
@@ -53,14 +51,4 @@ var fetchSkills = function (fetch) { return function (token) { return __awaiter(
53
51
  return [2 /*return*/, toJSON(response)];
54
52
  }
55
53
  });
56
- }); }; };
57
- // -----------------------------------------------------------------------------
58
- var createFetchSkills = function () {
59
- if (process.env.SERVICES !== 'mocks') {
60
- return fetchSkills(crossFetch);
61
- }
62
- return fetchSkills(mockFetchSkills);
63
- };
64
- // -----------------------------------------------------------------------------
65
- export { fetchSkills };
66
- export default createFetchSkills();
54
+ }); };
@@ -1,8 +1,2 @@
1
- import crossFetch from 'cross-fetch';
2
- import { SlideFromAPI } from '../actions/data/slides';
3
- declare type FetchSlide = (slideRef: string, token: string) => Promise<SlideFromAPI>;
4
- declare type FetchSlideBuilder = (fetch: typeof crossFetch) => FetchSlide;
5
- declare const fetchSlide: FetchSlideBuilder;
6
- export { fetchSlide };
7
- declare const _default: FetchSlide;
8
- export default _default;
1
+ import { SlideFromAPI } from '../types/common';
2
+ export declare const fetchSlide: (slideRef: string, token: string) => Promise<SlideFromAPI | void>;