@coorpacademy/app-review 0.0.21-alpha.4 → 0.1.1

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 (260) hide show
  1. package/es/actions/courses.d.ts +2 -3
  2. package/es/actions/data/is-fetching.d.ts +5 -0
  3. package/es/actions/data/is-fetching.js +4 -0
  4. package/es/actions/data/validate-slide.d.ts +5 -0
  5. package/es/actions/data/validate-slide.js +6 -0
  6. package/es/actions/finished-slides.d.ts +7 -0
  7. package/es/actions/finished-slides.js +7 -0
  8. package/es/actions/index.d.ts +2 -5
  9. package/es/actions/index.js +1 -3
  10. package/es/actions/navigation.d.ts +5 -6
  11. package/es/actions/review-status.d.ts +7 -0
  12. package/es/actions/review-status.js +7 -0
  13. package/es/actions/slides.d.ts +20 -0
  14. package/es/actions/slides.js +17 -0
  15. package/es/actions/step-items.d.ts +14 -0
  16. package/es/actions/step-items.js +12 -0
  17. package/es/actions/token.d.ts +0 -1
  18. package/es/common/index.d.ts +8 -0
  19. package/es/common/index.js +8 -0
  20. package/es/configure-store.d.ts +3 -12
  21. package/es/configure-store.js +5 -7
  22. package/es/fixtures/qcm-slide.d.ts +2 -0
  23. package/es/fixtures/qcm-slide.js +29 -0
  24. package/es/fixtures/temp-fixture.d.ts +3 -0
  25. package/es/fixtures/temp-fixture.js +84 -0
  26. package/es/helpers/css-register.d.ts +1 -0
  27. package/es/helpers/css-register.js +2 -0
  28. package/es/index.d.ts +5 -12
  29. package/es/index.js +62 -14
  30. package/es/index.test.d.ts +1 -0
  31. package/es/index.test.js +52 -0
  32. package/es/middlewares/on-start-app.d.ts +1 -2
  33. package/es/middlewares/on-start-app.js +20 -9
  34. package/es/reducers/courses.d.ts +2 -3
  35. package/es/reducers/courses.js +2 -1
  36. package/es/reducers/data.d.ts +7 -0
  37. package/es/reducers/data.js +76 -0
  38. package/es/reducers/finished-slides.d.ts +6 -0
  39. package/es/reducers/finished-slides.js +32 -0
  40. package/es/reducers/index.d.ts +11 -6
  41. package/es/reducers/index.js +14 -4
  42. package/es/reducers/navigation.d.ts +4 -3
  43. package/es/reducers/navigation.js +4 -1
  44. package/es/reducers/review-status.d.ts +5 -0
  45. package/es/reducers/review-status.js +15 -0
  46. package/es/reducers/slides.d.ts +6 -0
  47. package/es/reducers/slides.js +112 -0
  48. package/es/reducers/step-items.d.ts +6 -0
  49. package/es/reducers/step-items.js +75 -0
  50. package/es/reducers/token.d.ts +5 -7
  51. package/es/reducers/token.js +4 -12
  52. package/es/services/fetch-demo.d.ts +0 -1
  53. package/es/services/fetch-demo.test.d.ts +0 -1
  54. package/es/services/fetch-responses.d.ts +6 -7
  55. package/es/services/fetch-responses.js +2 -2
  56. package/es/services/fetch.mocks.d.ts +3 -4
  57. package/es/services/fetch.mocks.js +3 -3
  58. package/es/types/common.d.ts +7 -0
  59. package/es/types/common.js +1 -0
  60. package/es/types/data/index.d.ts +14 -0
  61. package/es/types/data/index.js +1 -0
  62. package/es/types/dispatchers.d.ts +17 -0
  63. package/es/types/dispatchers.js +1 -0
  64. package/es/types/finished-slides.d.ts +9 -0
  65. package/es/types/finished-slides.js +1 -0
  66. package/es/types/review-status.d.ts +1 -0
  67. package/es/types/review-status.js +1 -0
  68. package/es/types/slides.d.ts +87 -0
  69. package/es/types/slides.js +1 -0
  70. package/es/types/states.d.ts +6 -0
  71. package/es/types/states.js +1 -0
  72. package/es/types/step-items.d.ts +26 -0
  73. package/es/types/step-items.js +5 -0
  74. package/es/types/store-state.d.ts +12 -0
  75. package/es/types/store-state.js +1 -0
  76. package/es/types/utils.d.ts +3 -0
  77. package/es/types/utils.js +1 -0
  78. package/es/types/views.d.ts +64 -0
  79. package/es/types/views.js +1 -0
  80. package/lib/actions/courses.d.ts +2 -3
  81. package/lib/actions/data/is-fetching.d.ts +5 -0
  82. package/lib/actions/data/is-fetching.js +4 -0
  83. package/lib/actions/data/validate-slide.d.ts +5 -0
  84. package/lib/actions/data/validate-slide.js +6 -0
  85. package/lib/actions/finished-slides.d.ts +7 -0
  86. package/lib/actions/finished-slides.js +7 -0
  87. package/lib/actions/index.d.ts +2 -5
  88. package/lib/actions/index.js +1 -3
  89. package/lib/actions/navigation.d.ts +5 -6
  90. package/lib/actions/review-status.d.ts +7 -0
  91. package/lib/actions/review-status.js +7 -0
  92. package/lib/actions/slides.d.ts +20 -0
  93. package/lib/actions/slides.js +17 -0
  94. package/lib/actions/step-items.d.ts +14 -0
  95. package/lib/actions/step-items.js +12 -0
  96. package/lib/actions/token.d.ts +0 -1
  97. package/lib/common/index.d.ts +8 -0
  98. package/lib/common/index.js +8 -0
  99. package/lib/configure-store.d.ts +3 -12
  100. package/lib/configure-store.js +10 -59
  101. package/lib/fixtures/qcm-slide.d.ts +2 -0
  102. package/lib/fixtures/qcm-slide.js +29 -0
  103. package/lib/fixtures/temp-fixture.d.ts +3 -0
  104. package/lib/fixtures/temp-fixture.js +84 -0
  105. package/lib/helpers/css-register.d.ts +1 -0
  106. package/lib/helpers/css-register.js +2 -0
  107. package/lib/index.d.ts +5 -12
  108. package/lib/index.js +71 -34
  109. package/lib/index.test.d.ts +1 -0
  110. package/lib/index.test.js +160 -0
  111. package/lib/middlewares/on-start-app.d.ts +1 -2
  112. package/lib/middlewares/on-start-app.js +29 -16
  113. package/lib/reducers/courses.d.ts +2 -3
  114. package/lib/reducers/courses.js +2 -1
  115. package/lib/reducers/data.d.ts +7 -0
  116. package/lib/reducers/data.js +77 -0
  117. package/lib/reducers/finished-slides.d.ts +6 -0
  118. package/lib/reducers/finished-slides.js +44 -0
  119. package/lib/reducers/index.d.ts +11 -6
  120. package/lib/reducers/index.js +14 -4
  121. package/lib/reducers/navigation.d.ts +4 -3
  122. package/lib/reducers/navigation.js +6 -1
  123. package/lib/reducers/review-status.d.ts +5 -0
  124. package/lib/reducers/review-status.js +16 -0
  125. package/lib/reducers/slides.d.ts +6 -0
  126. package/lib/reducers/slides.js +119 -0
  127. package/lib/reducers/step-items.d.ts +6 -0
  128. package/lib/reducers/step-items.js +87 -0
  129. package/lib/reducers/token.d.ts +5 -7
  130. package/lib/reducers/token.js +4 -13
  131. package/lib/services/fetch-demo.d.ts +0 -1
  132. package/lib/services/fetch-demo.js +25 -23
  133. package/lib/services/fetch-demo.test.d.ts +0 -1
  134. package/lib/services/fetch-responses.d.ts +6 -7
  135. package/lib/services/fetch-responses.js +2 -2
  136. package/lib/services/fetch.mocks.d.ts +3 -4
  137. package/lib/services/fetch.mocks.js +28 -16
  138. package/lib/types/common.d.ts +7 -0
  139. package/lib/types/common.js +1 -0
  140. package/lib/types/data/index.d.ts +14 -0
  141. package/lib/types/data/index.js +1 -0
  142. package/lib/types/dispatchers.d.ts +17 -0
  143. package/lib/types/dispatchers.js +1 -0
  144. package/lib/types/finished-slides.d.ts +9 -0
  145. package/lib/types/finished-slides.js +1 -0
  146. package/lib/types/review-status.d.ts +1 -0
  147. package/lib/types/review-status.js +1 -0
  148. package/lib/types/slides.d.ts +87 -0
  149. package/lib/types/slides.js +1 -0
  150. package/lib/types/states.d.ts +6 -0
  151. package/lib/types/states.js +1 -0
  152. package/lib/types/step-items.d.ts +26 -0
  153. package/lib/types/step-items.js +5 -0
  154. package/lib/types/store-state.d.ts +12 -0
  155. package/lib/types/store-state.js +1 -0
  156. package/lib/types/utils.d.ts +3 -0
  157. package/lib/types/utils.js +1 -0
  158. package/lib/types/views.d.ts +64 -0
  159. package/lib/types/views.js +1 -0
  160. package/package.json +21 -7
  161. package/src/actions/courses.ts +2 -2
  162. package/src/actions/data/is-fetching.ts +12 -0
  163. package/src/actions/data/validate-slide.ts +15 -0
  164. package/src/actions/finished-slides.ts +21 -0
  165. package/src/actions/index.ts +8 -5
  166. package/src/actions/navigation.ts +6 -5
  167. package/src/actions/review-status.ts +19 -0
  168. package/src/actions/slides.ts +45 -0
  169. package/src/actions/step-items.ts +39 -0
  170. package/src/common/index.ts +14 -0
  171. package/src/configure-store.ts +14 -22
  172. package/src/fixtures/qcm-slide.ts +31 -0
  173. package/src/fixtures/temp-fixture.ts +94 -0
  174. package/src/helpers/css-modules-require-hook.d.ts +4 -0
  175. package/src/helpers/css-register.ts +3 -0
  176. package/src/index.test.tsx +82 -0
  177. package/src/index.tsx +75 -22
  178. package/src/middlewares/on-start-app.ts +35 -20
  179. package/src/reducers/courses.ts +3 -2
  180. package/src/reducers/data.ts +88 -0
  181. package/src/reducers/finished-slides.ts +48 -0
  182. package/src/reducers/index.ts +14 -4
  183. package/src/reducers/navigation.ts +7 -3
  184. package/src/reducers/review-status.ts +23 -0
  185. package/src/reducers/slides.ts +136 -0
  186. package/src/reducers/step-items.ts +112 -0
  187. package/src/reducers/token.ts +6 -15
  188. package/src/services/fetch-demo.ts +17 -15
  189. package/src/services/fetch-responses.ts +7 -7
  190. package/src/services/fetch.mocks.ts +29 -14
  191. package/src/types/common.ts +8 -0
  192. package/src/types/data/index.ts +16 -0
  193. package/src/types/dispatchers.ts +18 -0
  194. package/src/types/finished-slides.ts +9 -0
  195. package/src/types/globals.d.ts +6 -0
  196. package/src/types/review-status.ts +1 -0
  197. package/src/types/slides.ts +107 -0
  198. package/src/types/states.ts +6 -0
  199. package/src/types/step-items.ts +31 -0
  200. package/src/types/store-state.ts +20 -0
  201. package/src/types/utils.ts +4 -0
  202. package/src/types/views.tsx +69 -0
  203. package/es/actions/courses.d.ts.map +0 -1
  204. package/es/actions/index.d.ts.map +0 -1
  205. package/es/actions/navigation.d.ts.map +0 -1
  206. package/es/actions/token.d.ts.map +0 -1
  207. package/es/components/__tmp-backup-vues-mobile/revision-home.d.ts +0 -10
  208. package/es/components/__tmp-backup-vues-mobile/revision-home.d.ts.map +0 -1
  209. package/es/components/__tmp-backup-vues-mobile/revision-home.js +0 -83
  210. package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
  211. package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts.map +0 -1
  212. package/es/components/__tmp-backup-vues-mobile/revision-home.stories.js +0 -14
  213. package/es/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts +0 -4
  214. package/es/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts.map +0 -1
  215. package/es/components/__tmp-backup-vues-mobile/revision-onboarding.js +0 -57
  216. package/es/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts +0 -19
  217. package/es/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts.map +0 -1
  218. package/es/components/__tmp-backup-vues-mobile/revision-quizzer.js +0 -120
  219. package/es/configure-store.d.ts.map +0 -1
  220. package/es/index.d.ts.map +0 -1
  221. package/es/middlewares/on-start-app.d.ts.map +0 -1
  222. package/es/reducers/courses.d.ts.map +0 -1
  223. package/es/reducers/index.d.ts.map +0 -1
  224. package/es/reducers/navigation.d.ts.map +0 -1
  225. package/es/reducers/token.d.ts.map +0 -1
  226. package/es/services/fetch-demo.d.ts.map +0 -1
  227. package/es/services/fetch-demo.test.d.ts.map +0 -1
  228. package/es/services/fetch-responses.d.ts.map +0 -1
  229. package/es/services/fetch.mocks.d.ts.map +0 -1
  230. package/lib/actions/courses.d.ts.map +0 -1
  231. package/lib/actions/index.d.ts.map +0 -1
  232. package/lib/actions/navigation.d.ts.map +0 -1
  233. package/lib/actions/token.d.ts.map +0 -1
  234. package/lib/components/__tmp-backup-vues-mobile/revision-home.d.ts +0 -10
  235. package/lib/components/__tmp-backup-vues-mobile/revision-home.d.ts.map +0 -1
  236. package/lib/components/__tmp-backup-vues-mobile/revision-home.js +0 -98
  237. package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
  238. package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts.map +0 -1
  239. package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.js +0 -14
  240. package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts +0 -4
  241. package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts.map +0 -1
  242. package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.js +0 -60
  243. package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts +0 -19
  244. package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts.map +0 -1
  245. package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.js +0 -128
  246. package/lib/configure-store.d.ts.map +0 -1
  247. package/lib/index.d.ts.map +0 -1
  248. package/lib/middlewares/on-start-app.d.ts.map +0 -1
  249. package/lib/reducers/courses.d.ts.map +0 -1
  250. package/lib/reducers/index.d.ts.map +0 -1
  251. package/lib/reducers/navigation.d.ts.map +0 -1
  252. package/lib/reducers/token.d.ts.map +0 -1
  253. package/lib/services/fetch-demo.d.ts.map +0 -1
  254. package/lib/services/fetch-demo.test.d.ts.map +0 -1
  255. package/lib/services/fetch-responses.d.ts.map +0 -1
  256. package/lib/services/fetch.mocks.d.ts.map +0 -1
  257. package/src/components/__tmp-backup-vues-mobile/revision-home.stories.tsx +0 -16
  258. package/src/components/__tmp-backup-vues-mobile/revision-home.tsx +0 -125
  259. package/src/components/__tmp-backup-vues-mobile/revision-onboarding.tsx +0 -84
  260. package/src/components/__tmp-backup-vues-mobile/revision-quizzer.tsx +0 -176
@@ -1,10 +1,20 @@
1
1
  import { combineReducers } from 'redux';
2
+ import data from './data';
2
3
  import courses from './courses';
4
+ import finishedSlides from './finished-slides';
3
5
  import navigation from './navigation';
4
- import token from './token';
5
- var rootReducer = combineReducers({
6
+ import reviewStatus from './review-status';
7
+ import slides from './slides';
8
+ import stepItems from './step-items';
9
+ var ui = combineReducers({
6
10
  courses: courses,
11
+ finishedSlides: finishedSlides,
7
12
  navigation: navigation,
8
- token: token
13
+ reviewStatus: reviewStatus,
14
+ slides: slides,
15
+ stepItems: stepItems
16
+ });
17
+ export default combineReducers({
18
+ ui: ui,
19
+ data: data
9
20
  });
10
- export default rootReducer;
@@ -1,7 +1,8 @@
1
+ import { ViewPath } from '../actions/navigation';
1
2
  import type { NavigateTo, NavigateBack } from '../actions/navigation';
2
- export declare type State = Array<string>;
3
+ import { StoreState } from '../types/store-state';
4
+ import { NavigationState as State } from '../types/states';
3
5
  export declare const initialState: State;
4
6
  declare const reducer: (state: State, action: NavigateTo | NavigateBack) => State;
5
- export declare const getCurrentViewName: (appState: any) => any;
7
+ export declare const getCurrentViewName: (appState: StoreState) => ViewPath;
6
8
  export default reducer;
7
- //# sourceMappingURL=navigation.d.ts.map
@@ -8,8 +8,11 @@ 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/navigation';
11
+ // -----------------------------------------------------------------------------
12
+ // export type State = Array<string>;
11
13
  export var initialState = ['home'];
12
14
  // -----------------------------------------------------------------------------
15
+ // eslint-disable-next-line default-param-last
13
16
  var reducer = function (state, action) {
14
17
  if (state === void 0) { state = initialState; }
15
18
  switch (action.type) {
@@ -26,6 +29,8 @@ var reducer = function (state, action) {
26
29
  }
27
30
  };
28
31
  // -----------------------------------------------------------------------------
29
- export var getCurrentViewName = function (appState) { return appState.navigation[appState.navigation.length - 1]; };
32
+ export var getCurrentViewName = function (appState) {
33
+ return appState.ui.navigation[appState.ui.navigation.length - 1];
34
+ };
30
35
  // -----------------------------------------------------------------------------
31
36
  export default reducer;
@@ -0,0 +1,5 @@
1
+ import { UpdateReviewStatus } from '../actions/review-status';
2
+ export declare type State = 'finished' | 'ongoing';
3
+ export declare const initialState: State;
4
+ declare const reducer: (state: State, action: UpdateReviewStatus) => State;
5
+ export default reducer;
@@ -0,0 +1,16 @@
1
+ import { UPDATE_REVIEW_STATUS } from '../actions/review-status';
2
+ export var initialState = 'ongoing';
3
+ // -----------------------------------------------------------------------------
4
+ // eslint-disable-next-line default-param-last
5
+ var reducer = function (state, action) {
6
+ if (state === void 0) { state = initialState; }
7
+ switch (action.type) {
8
+ case UPDATE_REVIEW_STATUS: {
9
+ return action.payload;
10
+ }
11
+ default:
12
+ return state;
13
+ }
14
+ };
15
+ // -----------------------------------------------------------------------------
16
+ export default reducer;
@@ -0,0 +1,6 @@
1
+ import { SlidesAction } from '../actions/slides';
2
+ import { Slides } from '../types/slides';
3
+ export declare type State = Slides;
4
+ export declare const initialState: State;
5
+ declare const reducer: (state: State, action: SlidesAction) => State;
6
+ export default reducer;
@@ -0,0 +1,119 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import map from 'lodash/fp/map';
13
+ import { STORE_FIRST_SLIDE, UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../actions/slides';
14
+ import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
15
+ var getInitialState = function () {
16
+ var state = {
17
+ slideNumbers: slideNumbers
18
+ };
19
+ // eslint-disable-next-line fp/no-loops
20
+ for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
21
+ state[index] = { hidden: false, position: index };
22
+ }
23
+ return state;
24
+ };
25
+ export var initialState = getInitialState();
26
+ // -----------------------------------------------------------------------------
27
+ var setFirstSlide = function (state, slide) {
28
+ var _state = {
29
+ slideNumbers: slideNumbers
30
+ };
31
+ // eslint-disable-next-line lodash-fp/no-unused-result
32
+ map(function (index) {
33
+ var previousValue = state[index];
34
+ // Only update the 1st one
35
+ var content = index === 0 ? __assign(__assign({}, previousValue), slide) : __assign({}, previousValue);
36
+ _state[index] = __assign({}, content);
37
+ }, state.slideNumbers);
38
+ return _state;
39
+ };
40
+ // ||-------> Handles the updates of a given slide on validation,
41
+ // & then updates de remaining slides if this given change should impact their content
42
+ var stateUpdateOnValidation = function (state, payload) {
43
+ var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides, nextSlide = payload.nextSlide;
44
+ var _state = {
45
+ slideNumbers: slideNumbers
46
+ };
47
+ // eslint-disable-next-line lodash-fp/no-unused-result
48
+ map(function (index) {
49
+ var previousValue = state[index];
50
+ // the current slide
51
+ if (index === slideNumber) {
52
+ // only one slide remaining, presets the next value
53
+ if (numberOfFinishedSlides === HIGHEST_INDEX) {
54
+ _state[index] = __assign(__assign({}, previousValue), { nextSlide: nextSlide, position: newSlideContent.position, validationResult: newSlideContent.validationResult });
55
+ }
56
+ else
57
+ _state[slideNumber] = __assign(__assign({}, previousValue), newSlideContent);
58
+ }
59
+ else {
60
+ // updates the rest of the slides here
61
+ var hidden = previousValue.hidden, position = previousValue.position;
62
+ _state[index] = __assign(__assign({}, nextSlide), { endReview: newSlideContent.endReview, hidden: hidden, position: position });
63
+ }
64
+ }, state.slideNumbers);
65
+ return _state;
66
+ };
67
+ // ||-------> Handles the updates of a given slide on correction popin's next click,
68
+ // & then updates de remaining slides (updates position to trigger animations)
69
+ var stateUpdateOnNext = function (state, payload) {
70
+ var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides;
71
+ var _state = {
72
+ slideNumbers: slideNumbers
73
+ };
74
+ // eslint-disable-next-line lodash-fp/no-unused-result
75
+ map(function (index) {
76
+ var previousValue = state[index];
77
+ // the current slide
78
+ if (index === slideNumber) {
79
+ // when there is only one slide remaining, updates the slide value
80
+ if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextSlide) {
81
+ _state[index] = __assign(__assign({}, previousValue.nextSlide), { position: previousValue.position });
82
+ }
83
+ else
84
+ _state[slideNumber] = newSlideContent;
85
+ }
86
+ else {
87
+ // updates the rest of the slides here
88
+ var hidden = previousValue.hidden, position = previousValue.position, answerUI = previousValue.answerUI, questionText = previousValue.questionText;
89
+ _state[index] = {
90
+ hidden: hidden,
91
+ position: position - 1,
92
+ answerUI: answerUI,
93
+ questionText: questionText,
94
+ endReview: newSlideContent.endReview
95
+ };
96
+ }
97
+ }, state.slideNumbers);
98
+ return _state;
99
+ };
100
+ // -----------------------------------------------------------------------------
101
+ // eslint-disable-next-line default-param-last
102
+ var reducer = function (state, action) {
103
+ if (state === void 0) { state = initialState; }
104
+ switch (action.type) {
105
+ case STORE_FIRST_SLIDE: {
106
+ return setFirstSlide(state, action.payload);
107
+ }
108
+ case UPDATE_SLIDES_ON_VALIDATION: {
109
+ return stateUpdateOnValidation(state, action.payload);
110
+ }
111
+ case UPDATE_SLIDES_ON_NEXT: {
112
+ return stateUpdateOnNext(state, action.payload);
113
+ }
114
+ default:
115
+ return state;
116
+ }
117
+ };
118
+ // -----------------------------------------------------------------------------
119
+ export default reducer;
@@ -0,0 +1,6 @@
1
+ import { StepItemsAction } from '../actions/step-items';
2
+ import { StepItems } from '../types/step-items';
3
+ export declare type State = StepItems;
4
+ export declare const initialState: State;
5
+ declare const reducer: (state: State, action: StepItemsAction) => State;
6
+ export default reducer;
@@ -0,0 +1,87 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import isNil from 'lodash/fp/isNil';
13
+ import get from 'lodash/fp/get';
14
+ import has from 'lodash/fp/has';
15
+ 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';
18
+ var getInitialState = function () {
19
+ var state = {
20
+ slideNumbers: slideNumbers
21
+ };
22
+ // eslint-disable-next-line fp/no-loops
23
+ for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
24
+ var current = index === 0;
25
+ state[index] = { current: current, value: "".concat(index + 1), icon: null };
26
+ }
27
+ return state;
28
+ };
29
+ export var initialState = getInitialState();
30
+ // -----------------------------------------------------------------------------
31
+ // ||-------> aux function, finds the next consecutive index
32
+ // to loop from 0 to HIGHEST_INDEX (4) & again to 0
33
+ var getNextIndex = function (currentIndex) {
34
+ return currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
35
+ };
36
+ // ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
37
+ // they have to be skipped)
38
+ var calculateNextStepIndex = function (currentStepNumber, finishedSlides, lastVisitedIndex) {
39
+ if (lastVisitedIndex === void 0) { lastVisitedIndex = null; }
40
+ // only one slide remaining, the step should stay on the same number
41
+ if (lastVisitedIndex === currentStepNumber) {
42
+ return currentStepNumber;
43
+ }
44
+ var indexToVisit = getNextIndex(isNil(lastVisitedIndex) ? currentStepNumber : lastVisitedIndex);
45
+ // if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
46
+ return has(indexToVisit, finishedSlides)
47
+ ? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
48
+ : indexToVisit;
49
+ };
50
+ var recalculateStepItemsState = function (state, stepNumber, stepItemToUpdateProps) {
51
+ var nextIndex = get('nextIndex', stepItemToUpdateProps);
52
+ var _state = {
53
+ slideNumbers: slideNumbers
54
+ };
55
+ // eslint-disable-next-line lodash-fp/no-unused-result
56
+ map(function (index) {
57
+ var previousValue = state[index];
58
+ if (stepNumber === index)
59
+ _state[stepNumber] = __assign(__assign({}, previousValue), stepItemToUpdateProps);
60
+ /* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
61
+ _state[index] = __assign(__assign({}, previousValue), { current: true });
62
+ }
63
+ else
64
+ _state[index] = previousValue;
65
+ }, state.slideNumbers);
66
+ return _state;
67
+ };
68
+ // -----------------------------------------------------------------------------
69
+ // eslint-disable-next-line default-param-last
70
+ var reducer = function (state, action) {
71
+ if (state === void 0) { state = initialState; }
72
+ switch (action.type) {
73
+ case UPDATE_STEP_ITEMS_ON_VALIDATION: {
74
+ var _a = action.payload, stepNumber = _a.stepNumber, icon = _a.icon;
75
+ return recalculateStepItemsState(state, stepNumber, { icon: icon });
76
+ }
77
+ case UPDATE_STEP_ITEMS_ON_NEXT: {
78
+ var _b = action.payload, stepNumber = _b.stepNumber, finishedSlides = _b.finishedSlides, current = _b.current;
79
+ var nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : null;
80
+ return recalculateStepItemsState(state, stepNumber, { current: current, nextIndex: nextIndex });
81
+ }
82
+ default:
83
+ return state;
84
+ }
85
+ };
86
+ // -----------------------------------------------------------------------------
87
+ export default reducer;
@@ -1,7 +1,5 @@
1
- import { StoreToken } from '../actions';
2
- export declare type State = string;
3
- export declare const initialState: State;
4
- declare const reducer: (state: State, action: StoreToken) => State;
5
- export declare const getToken: (appState: any) => any;
6
- export default reducer;
7
- //# sourceMappingURL=token.d.ts.map
1
+ import { StoreState } from '../types/store-state';
2
+ import { DataState } from '../types/data';
3
+ export declare const initialState: DataState['token'];
4
+ export declare const setToken: (token: string, state: DataState) => DataState;
5
+ export declare const getToken: (appState: StoreState) => StoreState['data']['token'];
@@ -1,17 +1,8 @@
1
- import { STORE_TOKEN } from '../actions';
1
+ import set from 'lodash/fp/set';
2
+ // -----------------------------------------------------------------------------
2
3
  export var initialState = null;
3
4
  // -----------------------------------------------------------------------------
4
- var reducer = function (state, action) {
5
- if (state === void 0) { state = initialState; }
6
- switch (action.type) {
7
- case STORE_TOKEN: {
8
- return action.payload;
9
- }
10
- default:
11
- return state;
12
- }
13
- };
5
+ export var setToken = function (token, state) { return set('token', token, state); };
14
6
  // -----------------------------------------------------------------------------
15
- export var getToken = function (appState) { return appState.token; };
7
+ export var getToken = function (appState) { return appState.data.token; };
16
8
  // -----------------------------------------------------------------------------
17
- export default reducer;
@@ -9,4 +9,3 @@ export declare type CatalogHits = {
9
9
  export { fetchCourse };
10
10
  declare const _default: (token: any, language: any, universalRef: any) => Promise<Course>;
11
11
  export default _default;
12
- //# sourceMappingURL=fetch-demo.d.ts.map
@@ -46,29 +46,31 @@ var buildUrlQueryParams = function (params) {
46
46
  .join('&');
47
47
  };
48
48
  // -----------------------------------------------------------------------------
49
- var fetchCourse = function (fetch) { return function (token, language, universalRef) { return __awaiter(void 0, void 0, void 0, function () {
50
- var jwt, query, response, hits;
51
- return __generator(this, function (_a) {
52
- switch (_a.label) {
53
- case 0:
54
- jwt = decode(token);
55
- query = {
56
- type: 'course',
57
- universalRef: universalRef,
58
- lang: language
59
- };
60
- return [4 /*yield*/, fetch("".concat(jwt.host, "/api/v2/contents?").concat(buildUrlQueryParams(query)), {
61
- headers: { authorization: token }
62
- })];
63
- case 1:
64
- response = _a.sent();
65
- return [4 /*yield*/, toJSON(response)];
66
- case 2:
67
- hits = (_a.sent()).hits;
68
- return [2 /*return*/, hits === null || hits === void 0 ? void 0 : hits[0]];
69
- }
70
- });
71
- }); }; };
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
+ }); };
73
+ };
72
74
  // -----------------------------------------------------------------------------
73
75
  export { fetchCourse };
74
76
  export default fetchCourse(crossFetch);
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=fetch-demo.test.d.ts.map
@@ -1,4 +1,4 @@
1
- export declare type Response = {
1
+ export declare type _Response = {
2
2
  ok: boolean;
3
3
  status: number;
4
4
  statusText: string;
@@ -9,12 +9,11 @@ export declare type Fetch = (url?: string, options?: {
9
9
  headers: {
10
10
  authorization: string;
11
11
  };
12
- }) => Promise<Response>;
12
+ }) => Promise<_Response>;
13
13
  export declare class ResponseError extends Error {
14
14
  statusCode: number;
15
- constructor(status: number, statusText: string, body?: string);
15
+ constructor(statusCode: number, statusText: string, body?: string);
16
16
  }
17
- export declare const toJSON: (response: Response) => Promise<unknown>;
18
- export declare const toText: (response: Response) => Promise<string>;
19
- export declare const toVoid: (response: Response) => Promise<void>;
20
- //# sourceMappingURL=fetch-responses.d.ts.map
17
+ export declare const toJSON: (response: _Response) => Promise<unknown>;
18
+ export declare const toText: (response: _Response) => Promise<string>;
19
+ export declare const toVoid: (response: _Response) => Promise<void>;
@@ -51,11 +51,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
51
51
  };
52
52
  var ResponseError = /** @class */ (function (_super) {
53
53
  __extends(ResponseError, _super);
54
- function ResponseError(status, statusText, body) {
54
+ function ResponseError(statusCode, statusText, body) {
55
55
  if (body === void 0) { body = ''; }
56
56
  var _this = _super.call(this, "".concat(statusText, " ").concat(body).trim()) || this;
57
57
  _this.name = 'ResponseError';
58
- _this.statusCode = status;
58
+ _this.statusCode = statusCode;
59
59
  return _this;
60
60
  }
61
61
  return ResponseError;
@@ -1,10 +1,9 @@
1
- import { Response } from './fetch-responses';
2
- export declare const toResponse: (status: number, statusText: string, body: string) => Promise<Response>;
3
- declare type FetchFunction = () => Promise<Response>;
1
+ import { _Response } from './fetch-responses';
2
+ export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<_Response>;
3
+ declare type FetchFunction = () => Promise<_Response>;
4
4
  export declare const okJSONResponse: (body: unknown) => FetchFunction;
5
5
  export declare const internalServerErrorJSONResponse: (body: unknown) => FetchFunction;
6
6
  export declare const notFoundJSONResponse: (body: unknown) => FetchFunction;
7
7
  export declare const okTextResponse: (body: string) => FetchFunction;
8
8
  export declare const internalServerErrorTextResponse: (body: string) => FetchFunction;
9
9
  export {};
10
- //# sourceMappingURL=fetch.mocks.d.ts.map
@@ -1,22 +1,34 @@
1
- export var toResponse = function (status, statusText, body) {
1
+ export var toResponse = function (statusCode, statusText, body) {
2
2
  return Promise.resolve({
3
- ok: status < 400,
4
- status: status,
3
+ ok: statusCode < 400,
4
+ status: statusCode,
5
5
  statusText: statusText,
6
6
  json: function () { return Promise.resolve(body).then(JSON.parse); },
7
7
  text: function () { return Promise.resolve(body); }
8
8
  });
9
9
  };
10
- export var okJSONResponse = function (body) { return function () {
11
- return toResponse(200, 'OK', JSON.stringify(body));
12
- }; };
13
- export var internalServerErrorJSONResponse = function (body) { return function () {
14
- return toResponse(500, 'InternalServerError', JSON.stringify(body));
15
- }; };
16
- export var notFoundJSONResponse = function (body) { return function () {
17
- return toResponse(404, 'Not Found', JSON.stringify(body));
18
- }; };
19
- export var okTextResponse = function (body) { return function () { return toResponse(200, 'OK', body); }; };
20
- export var internalServerErrorTextResponse = function (body) { return function () {
21
- return toResponse(500, 'InternalServerError', body);
22
- }; };
10
+ export var okJSONResponse = function (body) {
11
+ return function () {
12
+ return toResponse(200, 'OK', JSON.stringify(body));
13
+ };
14
+ };
15
+ export var internalServerErrorJSONResponse = function (body) {
16
+ return function () {
17
+ return toResponse(500, 'InternalServerError', JSON.stringify(body));
18
+ };
19
+ };
20
+ export var notFoundJSONResponse = function (body) {
21
+ return function () {
22
+ return toResponse(404, 'Not Found', JSON.stringify(body));
23
+ };
24
+ };
25
+ export var okTextResponse = function (body) {
26
+ return function () {
27
+ return toResponse(200, 'OK', body);
28
+ };
29
+ };
30
+ export var internalServerErrorTextResponse = function (body) {
31
+ return function () {
32
+ return toResponse(500, 'InternalServerError', body);
33
+ };
34
+ };
@@ -0,0 +1,7 @@
1
+ import { Slide } from './slides';
2
+ export declare type AppOptions = {
3
+ token: string;
4
+ theme?: unknown;
5
+ translations?: unknown;
6
+ slide?: Slide;
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { AnswerUI } from '../slides';
2
+ export declare type DataState = {
3
+ isFetching?: boolean;
4
+ slideValidationResult?: {
5
+ slideNumber: number;
6
+ result: 'success' | 'failure';
7
+ exitNode?: 'successExitNode' | 'failExitNode';
8
+ nextSlide: {
9
+ questionText?: string;
10
+ answerUI?: AnswerUI;
11
+ };
12
+ };
13
+ token?: string;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { validateSlide } from '../actions/data/validate-slide';
2
+ import { updateFinishedSlides } from '../actions/finished-slides';
3
+ import { navigateBack, navigateTo } from '../actions/navigation';
4
+ import { updateReviewStatus } from '../actions/review-status';
5
+ import { updateSlidesOnValidation, updateSlidesOnNext } from '../actions/slides';
6
+ import { updateStepItemsOnValidation, updateStepItemsOnNext } from '../actions/step-items';
7
+ export declare type Dispatchers = {
8
+ navigateTo: typeof navigateTo;
9
+ navigateBack: typeof navigateBack;
10
+ validateSlide: typeof validateSlide;
11
+ updateSlidesOnValidation: typeof updateSlidesOnValidation;
12
+ updateSlidesOnNext: typeof updateSlidesOnNext;
13
+ updateReviewStatus: typeof updateReviewStatus;
14
+ updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
15
+ updateStepItemsOnNext: typeof updateStepItemsOnNext;
16
+ updateFinishedSlides: typeof updateFinishedSlides;
17
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { SlideNumber } from './slides';
2
+ export declare type FinishedSlides = {
3
+ slideNumbers: SlideNumber[];
4
+ [key: SlideNumber]: true;
5
+ };
6
+ export declare type UpdateFinishedSlidesPayload = {
7
+ slideNumber: SlideNumber;
8
+ value: true;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare type UpdateReviewStatusPayload = 'finished';
@@ -0,0 +1 @@
1
+ export {};