@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
@@ -0,0 +1,84 @@
1
+ export var correctionPopinProps = {
2
+ klf: {
3
+ label: 'Key learning factor',
4
+ tooltip: 'Some tooltip info.',
5
+ onClick: function () {
6
+ console.log('klf onClick');
7
+ }
8
+ },
9
+ information: {
10
+ label: 'Key learning factor',
11
+ message: 'info msg'
12
+ },
13
+ next: {
14
+ label: 'Next',
15
+ ariaLabel: 'Next'
16
+ },
17
+ successLabel: 'CORRECT ANSWER',
18
+ failureLabel: 'WRONG ANSWER'
19
+ };
20
+ var confettiAnimationProps = {
21
+ 'aria-label': 'aria lottie',
22
+ 'data-name': 'default-lottie',
23
+ className: undefined,
24
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/confetti.json',
25
+ loop: undefined,
26
+ autoplay: true,
27
+ rendererSettings: {
28
+ hideOnTransparent: false,
29
+ animationClassName: ''
30
+ },
31
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/conffeti_congrats.svg',
32
+ animationControl: undefined
33
+ };
34
+ var starAnimationProps = {
35
+ 'aria-label': 'Review Card Congrats Container',
36
+ 'data-name': 'card-star',
37
+ animationLottie: {
38
+ 'aria-label': 'aria lottie',
39
+ 'data-name': 'default-lottie',
40
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/star.json',
41
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/stars_icon_congrats.svg'
42
+ },
43
+ iconAriaLabel: 'Image without information',
44
+ cardType: 'card-star',
45
+ reviewCardTitle: 'You have won',
46
+ reviewCardValue: '100',
47
+ timerAnimation: 200
48
+ };
49
+ var rankAnimationProps = {
50
+ 'aria-label': 'Review Card Congrats Container',
51
+ 'data-name': 'card-rank',
52
+ animationLottie: {
53
+ 'aria-label': 'aria lottie',
54
+ 'data-name': 'default-lottie',
55
+ animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
56
+ ie11ImageBackup: 'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg'
57
+ },
58
+ cardType: 'card-rank',
59
+ iconAriaLabel: 'Image without information',
60
+ reviewCardTitle: 'You are now',
61
+ reviewCardValue: '14',
62
+ rankSuffix: 'th',
63
+ timerAnimation: 200
64
+ };
65
+ export var congratsProps = {
66
+ 'aria-label': 'Review Congratulations',
67
+ 'data-name': 'review-congrats',
68
+ animationLottie: confettiAnimationProps,
69
+ title: 'Congratulations!',
70
+ cardCongratsStar: starAnimationProps,
71
+ cardCongratsRank: rankAnimationProps,
72
+ buttonRevising: {
73
+ 'aria-label': 'Continue revising button',
74
+ label: 'Continue revising',
75
+ onClick: function () { return console.log('Continue revising'); },
76
+ type: 'tertiary'
77
+ },
78
+ buttonRevisingSkill: {
79
+ label: 'Revise another skill',
80
+ 'aria-label': 'Revise another skill button',
81
+ onClick: function () { return console.log('Revise another skill'); },
82
+ type: 'primary'
83
+ }
84
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import cssRegister from '@coorpacademy/css-modules-require-hook';
2
+ cssRegister();
package/lib/index.d.ts CHANGED
@@ -1,17 +1,10 @@
1
- /// <reference types="react" />
2
- declare const AppRevision: ({ options }: Props) => JSX.Element;
1
+ import type { AppOptions } from './types/common';
2
+ declare const AppReview: ({ options }: {
3
+ options: AppOptions;
4
+ }) => JSX.Element;
3
5
  declare global {
4
6
  interface Window {
5
7
  __REDUX_DEVTOOLS_EXTENSION__?: boolean;
6
8
  }
7
9
  }
8
- declare type Props = {
9
- options: AppOptions;
10
- };
11
- export declare type AppOptions = {
12
- token: string;
13
- theme?: any;
14
- translations?: any;
15
- };
16
- export default AppRevision;
17
- //# sourceMappingURL=index.d.ts.map
10
+ export default AppReview;
package/lib/index.js CHANGED
@@ -1,14 +1,3 @@
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
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,39 +36,87 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
36
  };
48
37
  import React, { useEffect, useState } from 'react';
49
38
  import { connect, Provider } from 'react-redux';
50
- import AppReviewRootView from '@coorpacademy/components/es/template/app-review/root-view/root-view';
39
+ import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
51
40
  import configureStore from './configure-store';
52
41
  import { navigateTo, navigateBack, startApp } from './actions/navigation';
42
+ import { updateSlidesOnNext, updateSlidesOnValidation } from './actions/slides';
53
43
  import { getCurrentViewName } from './reducers/navigation';
44
+ import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
45
+ import { updateFinishedSlides } from './actions/finished-slides';
46
+ import { updateReviewStatus } from './actions/review-status';
47
+ import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/step-items';
48
+ import { validateSlide } from './actions/data/validate-slide';
54
49
  // -----------------------------------------------------------------------------
55
- var mapStateToProps = function (state, ownProps) {
56
- return __assign(__assign({}, ownProps), { viewName: getCurrentViewName(state) });
50
+ var mapDispatchToProps = {
51
+ navigateTo: navigateTo,
52
+ navigateBack: navigateBack,
53
+ validateSlide: validateSlide,
54
+ updateSlidesOnValidation: updateSlidesOnValidation,
55
+ updateSlidesOnNext: updateSlidesOnNext,
56
+ updateReviewStatus: updateReviewStatus,
57
+ updateStepItemsOnValidation: updateStepItemsOnValidation,
58
+ updateStepItemsOnNext: updateStepItemsOnNext,
59
+ updateFinishedSlides: updateFinishedSlides
57
60
  };
58
- var mapDispatchToProps = { navigateTo: navigateTo, navigateBack: navigateBack };
59
- var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewRootView);
61
+ var mapStateToProps = function (state) {
62
+ return {
63
+ viewName: getCurrentViewName(state),
64
+ slides: {
65
+ headerProps: {
66
+ mode: '__revision_mode',
67
+ skillName: '__agility',
68
+ onQuitClick: function () {
69
+ // eslint-disable-next-line no-console
70
+ console.log('onQuitClick');
71
+ },
72
+ 'aria-label': 'aria-header-wrapper',
73
+ closeButtonAriaLabel: 'aria-close-button'
74
+ },
75
+ slides: state.ui.slides,
76
+ validate: {
77
+ label: '__validate'
78
+ },
79
+ finishedSlides: state.ui.finishedSlides,
80
+ stepItems: state.ui.stepItems,
81
+ reviewStatus: state.ui.reviewStatus,
82
+ correctionPopinProps: correctionPopinProps,
83
+ congratsProps: congratsProps,
84
+ slideValidationResult: state.data.slideValidationResult
85
+ }
86
+ };
87
+ };
88
+ // Props = StaticProps && Dispatchers
89
+ var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
60
90
  // -----------------------------------------------------------------------------
61
- var AppRevision = function (_a) {
91
+ var AppReview = function (_a) {
62
92
  var options = _a.options;
63
93
  var _b = useState(null), store = _b[0], setStore = _b[1];
94
+ var _c = useState(false), appStarted = _c[0], setAppStarted = _c[1];
64
95
  useEffect(function () {
65
- var _configure = function () { return __awaiter(void 0, void 0, void 0, function () {
66
- var store;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
69
- case 0: return [4 /*yield*/, configureStore()];
70
- case 1:
71
- store = _a.sent();
72
- store.dispatch(startApp(options));
73
- setStore(store);
74
- return [2 /*return*/];
75
- }
76
- });
77
- }); };
78
- _configure();
79
- }, []);
80
- if (!store)
96
+ if (store) {
97
+ store.dispatch(startApp(options));
98
+ setAppStarted(true);
99
+ }
100
+ else {
101
+ var _configure = function () { return __awaiter(void 0, void 0, void 0, function () {
102
+ var _store;
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0: return [4 /*yield*/, configureStore()];
106
+ case 1:
107
+ _store = _a.sent();
108
+ setStore(_store);
109
+ return [2 /*return*/];
110
+ }
111
+ });
112
+ }); };
113
+ _configure();
114
+ }
115
+ }, [options, store]);
116
+ if (!store || !appStarted)
81
117
  return null;
82
118
  return (React.createElement(Provider, { store: store },
83
119
  React.createElement(App, null)));
84
120
  };
85
- export default AppRevision;
121
+ // -----------------------------------------------------------------------------
122
+ export default AppReview;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,160 @@
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
+ import browserEnv from 'browser-env';
38
+ import test from 'ava';
39
+ import React from 'react';
40
+ import { render, fireEvent, act } from '@testing-library/react';
41
+ import { slide } from './fixtures/qcm-slide';
42
+ import AppReview from '.';
43
+ browserEnv({ pretendToBeVisual: true });
44
+ var elementExists = function (foundElements) {
45
+ return foundElements && foundElements[0];
46
+ };
47
+ var sleep = function (msToSleep) {
48
+ return new Promise(function (resolve) {
49
+ setTimeout(resolve, msToSleep);
50
+ });
51
+ };
52
+ var waitForChanges = function (msToWait) {
53
+ if (msToWait === void 0) { msToWait = 3000; }
54
+ return __awaiter(void 0, void 0, void 0, function () {
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0: return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0: return [4 /*yield*/, sleep(msToWait)];
61
+ case 1:
62
+ _a.sent(); // wait *just* a little longer than the timeout in the component
63
+ return [2 /*return*/];
64
+ }
65
+ });
66
+ }); })];
67
+ case 1:
68
+ _a.sent();
69
+ return [2 /*return*/];
70
+ }
71
+ });
72
+ });
73
+ };
74
+ var LIMIT = 5;
75
+ var clickAllSlides = function (t, container, accumulator) {
76
+ if (accumulator === void 0) { accumulator = 0; }
77
+ return __awaiter(void 0, void 0, void 0, function () {
78
+ var validateButton, nextButton;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0:
82
+ if (accumulator === LIMIT)
83
+ return [2 /*return*/];
84
+ if (!(accumulator === 4)) return [3 /*break*/, 2];
85
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
86
+ return __generator(this, function (_a) {
87
+ switch (_a.label) {
88
+ case 0: return [4 /*yield*/, sleep(1000)];
89
+ case 1:
90
+ _a.sent();
91
+ return [2 /*return*/];
92
+ }
93
+ });
94
+ }); })];
95
+ case 1:
96
+ _a.sent();
97
+ _a.label = 2;
98
+ case 2:
99
+ validateButton = container.querySelectorAll("[data-name=\"slide-validate-button-".concat(accumulator, "\"]"));
100
+ t.truthy(elementExists(validateButton));
101
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0: return [4 /*yield*/, fireEvent.click(validateButton[0])];
105
+ case 1:
106
+ _a.sent();
107
+ return [2 /*return*/];
108
+ }
109
+ });
110
+ }); })];
111
+ case 3:
112
+ _a.sent();
113
+ nextButton = container.querySelectorAll("[data-name=\"next-question-button-".concat(accumulator, "\"]"));
114
+ t.truthy(elementExists(nextButton));
115
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, fireEvent.click(nextButton[0])];
119
+ case 1:
120
+ _a.sent();
121
+ return [2 /*return*/];
122
+ }
123
+ });
124
+ }); })];
125
+ case 4:
126
+ _a.sent();
127
+ return [4 /*yield*/, clickAllSlides(t, container, accumulator + 1)];
128
+ case 5:
129
+ _a.sent();
130
+ return [2 /*return*/];
131
+ }
132
+ });
133
+ });
134
+ };
135
+ var appOptions = {
136
+ token: process.env.API_TEST_TOKEN || '',
137
+ slide: slide
138
+ };
139
+ test('should validate all the slides (all correct scenario)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
140
+ var container, wrapper, stackedSlidesContainer;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0:
144
+ t.plan(13);
145
+ container = render(React.createElement(AppReview, { options: appOptions, key: 0 })).container;
146
+ return [4 /*yield*/, waitForChanges(1000)];
147
+ case 1:
148
+ _a.sent();
149
+ wrapper = container.querySelector('[data-name="slides-revision-container"]');
150
+ t.truthy(wrapper);
151
+ stackedSlidesContainer = wrapper.querySelector('[data-name="stacked-slides-container"]');
152
+ t.truthy(stackedSlidesContainer);
153
+ return [4 /*yield*/, clickAllSlides(t, container)];
154
+ case 2:
155
+ _a.sent();
156
+ t.pass();
157
+ return [2 /*return*/];
158
+ }
159
+ });
160
+ }); });
@@ -1,7 +1,6 @@
1
1
  import type { Middleware } from 'redux';
2
2
  import { Dispatch } from 'redux';
3
3
  import { Action } from '../actions';
4
- import { StoreState } from '../configure-store';
4
+ import { StoreState } from '../types/store-state';
5
5
  declare const onStartApp: Middleware<{}, StoreState, Dispatch<Action>>;
6
6
  export default onStartApp;
7
- //# sourceMappingURL=on-start-app.d.ts.map
@@ -1,20 +1,33 @@
1
- import { receivedCourse, START_APP, storeToken } from '../actions';
2
- import fetchCourse from '../services/fetch-demo';
1
+ // import fetchCourse from '../services/fetch-demo';
2
+ import { VIEWS } from '../common';
3
+ import { navigateTo, START_APP } from '../actions/navigation';
4
+ import { storeToken } from '../actions/token';
5
+ import { storeFirstSlide } from '../actions/slides';
3
6
  var onStartApp = function (_a) {
4
7
  var dispatch = _a.dispatch;
5
- return function (next) { return function (action) {
6
- if (action.type === START_APP) {
7
- var token = action.payload.token;
8
- dispatch(storeToken(token));
9
- // --------------
10
- // demo service
11
- var language = 'fr';
12
- var universalRef = 'dis_xxx15';
13
- fetchCourse(token, language, universalRef).then(function (course) {
14
- dispatch(receivedCourse(course));
15
- });
16
- }
17
- return next(action);
18
- }; };
8
+ return function (next) {
9
+ return function (action) {
10
+ if (action.type === START_APP) {
11
+ // eslint-disable-next-line no-warning-comments
12
+ // TODO: fetchProgression + fetchSlide à partir de la progression passée dans les options de l'app
13
+ var slide = action.payload.slide;
14
+ if (slide) {
15
+ var token = action.payload.token;
16
+ dispatch(storeToken(token));
17
+ dispatch(storeFirstSlide(slide));
18
+ }
19
+ var initialView = slide ? VIEWS.slides : VIEWS.onboarding;
20
+ dispatch(navigateTo(initialView));
21
+ // --------------
22
+ // demo service
23
+ // const language = 'fr';
24
+ // const universalRef = 'dis_xxx15';
25
+ // fetchCourse(token, language, universalRef).then(course => {
26
+ // dispatch(receivedCourse(course));
27
+ // });
28
+ }
29
+ return next(action);
30
+ };
31
+ };
19
32
  };
20
33
  export default onStartApp;
@@ -1,6 +1,5 @@
1
- import { ReceivedCourse } from '../actions';
2
- export declare type State = Array<any>;
1
+ import { ReceivedCourse } from '../actions/courses';
2
+ export declare type State = Array<unknown>;
3
3
  export declare const initialState: State;
4
4
  declare const reducer: (state: State, action: ReceivedCourse) => State;
5
5
  export default reducer;
6
- //# sourceMappingURL=courses.d.ts.map
@@ -7,9 +7,10 @@ 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';
10
+ import { RECEIVED_COURSE } from '../actions/courses';
11
11
  export var initialState = [];
12
12
  // -----------------------------------------------------------------------------
13
+ // eslint-disable-next-line default-param-last
13
14
  var reducer = function (state, action) {
14
15
  if (state === void 0) { state = initialState; }
15
16
  switch (action.type) {
@@ -0,0 +1,7 @@
1
+ import { StoreToken } from '../actions/token';
2
+ import { IsFetching } from '../actions/data/is-fetching';
3
+ import { ValidateSlide } from '../actions/data/validate-slide';
4
+ import { DataState } from '../types/data';
5
+ declare type ApiActions = IsFetching | ValidateSlide | StoreToken;
6
+ declare const data: (state: DataState, action: ApiActions) => DataState;
7
+ export default data;
@@ -0,0 +1,77 @@
1
+ import getOr from 'lodash/fp/getOr';
2
+ import noop from 'lodash/fp/noop';
3
+ import set from 'lodash/fp/set';
4
+ import { STORE_TOKEN } from '../actions/token';
5
+ import { IS_FETCHING_TRUE } from '../actions/data/is-fetching';
6
+ import { VALIDATE_SLIDE } from '../actions/data/validate-slide';
7
+ import { setToken } from './token';
8
+ var defaultState = {
9
+ isFetching: true,
10
+ slideValidationResult: null,
11
+ token: null
12
+ };
13
+ // eslint-disable-next-line default-param-last
14
+ var data = function (state, action) {
15
+ if (state === void 0) { state = defaultState; }
16
+ switch (action.type) {
17
+ case STORE_TOKEN: {
18
+ return setToken(action.payload, state);
19
+ }
20
+ case VALIDATE_SLIDE: {
21
+ var previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
22
+ // hard coded for now
23
+ return set('slideValidationResult', {
24
+ slideNumber: previousSlideNumber + 1,
25
+ result: 'success',
26
+ // exitNode
27
+ nextSlide: {
28
+ questionText: 'Test',
29
+ answerUI: {
30
+ model: {
31
+ answers: [
32
+ {
33
+ title: 'There is no need for a password',
34
+ onClick: noop,
35
+ selected: false
36
+ },
37
+ {
38
+ title: 'Lorem ipsum',
39
+ onClick: noop,
40
+ selected: false
41
+ },
42
+ {
43
+ title: 'Lorem',
44
+ onClick: noop,
45
+ selected: true,
46
+ order: 1
47
+ },
48
+ {
49
+ title: 'You need to have a password',
50
+ onClick: noop,
51
+ selected: false
52
+ },
53
+ {
54
+ title: 'Pouet',
55
+ onClick: noop,
56
+ selected: true,
57
+ order: 0
58
+ }
59
+ ],
60
+ type: 'qcmDrag'
61
+ },
62
+ help: 'Help text will appear here'
63
+ }
64
+ }
65
+ }, state);
66
+ }
67
+ case IS_FETCHING_TRUE: {
68
+ return set('isFetching', true, state);
69
+ }
70
+ // case VALIDATE_SLIDE_FAILURE: {
71
+ // return set('entities.isFetching', false, state);
72
+ // }
73
+ default:
74
+ return state;
75
+ }
76
+ };
77
+ export default data;
@@ -0,0 +1,6 @@
1
+ import { UpdateFinishedSlides } from '../actions/finished-slides';
2
+ import { FinishedSlides } from '../types/finished-slides';
3
+ export declare type State = FinishedSlides;
4
+ export declare const initialState: State;
5
+ declare const reducer: (state: State, action: UpdateFinishedSlides) => State;
6
+ export default reducer;
@@ -0,0 +1,44 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
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
+ });
18
+ export var initialState = {
19
+ slideNumbers: slideNumbers
20
+ };
21
+ // -----------------------------------------------------------------------------
22
+ // eslint-disable-next-line default-param-last
23
+ var reducer = function (state, action) {
24
+ if (state === void 0) { state = initialState; }
25
+ switch (action.type) {
26
+ case UPDATE_FINISHED_SLIDES: {
27
+ var _slideNumbers = state.slideNumbers, rest = __rest(state, ["slideNumbers"]);
28
+ var _a = action.payload, slideNumber = _a.slideNumber, value = _a.value;
29
+ var _state_1 = {
30
+ slideNumbers: _slideNumbers
31
+ };
32
+ _forEach(function (finishedSlide, index) {
33
+ var previousValue = finishedSlide;
34
+ _state_1[index] = previousValue;
35
+ }, rest);
36
+ _state_1[slideNumber] = value;
37
+ return _state_1;
38
+ }
39
+ default:
40
+ return state;
41
+ }
42
+ };
43
+ // -----------------------------------------------------------------------------
44
+ export default reducer;
@@ -1,7 +1,12 @@
1
- declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
2
- courses: import("./courses").State;
3
- navigation: import("./navigation").State;
4
- token: string;
1
+ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
+ 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
+ }>;
10
+ data: import("../types/data").DataState;
5
11
  }>, import("redux").AnyAction>;
6
- export default rootReducer;
7
- //# sourceMappingURL=index.d.ts.map
12
+ export default _default;