@coorpacademy/app-review 0.5.4 → 0.5.6-alpha.10

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 (256) hide show
  1. package/es/locales/en/review.json +14 -0
  2. package/es/sandbox/index.d.ts +9 -0
  3. package/es/sandbox/index.js +56 -0
  4. package/es/{index.js → src/index.js} +6 -5
  5. package/es/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
  6. package/es/src/services/fetch-slides-to-review-by-skill-ref.js +8 -0
  7. package/es/{services → src/services}/index.js +2 -0
  8. package/es/{test → src/test}/index.test.js +3 -1
  9. package/{lib → es/src}/test/util/services.mock.d.ts +1 -0
  10. package/es/{test → src/test}/util/services.mock.js +20 -1
  11. package/{lib → es/src}/types/common.d.ts +10 -2
  12. package/{lib → es/src}/views/slides/index.d.ts +2 -1
  13. package/es/{views → src/views}/slides/index.js +20 -18
  14. package/lib/locales/en/review.json +14 -0
  15. package/lib/sandbox/index.d.ts +9 -0
  16. package/lib/sandbox/index.js +67 -0
  17. package/lib/{index.js → src/index.js} +6 -6
  18. package/lib/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
  19. package/lib/src/services/fetch-slides-to-review-by-skill-ref.js +52 -0
  20. package/lib/{services → src/services}/index.js +2 -0
  21. package/lib/{test → src/test}/index.test.js +3 -1
  22. package/{es → lib/src}/test/util/services.mock.d.ts +1 -0
  23. package/lib/{test → src/test}/util/services.mock.js +20 -1
  24. package/{es → lib/src}/types/common.d.ts +10 -2
  25. package/{es → lib/src}/views/slides/index.d.ts +2 -1
  26. package/lib/{views → src/views}/slides/index.js +20 -18
  27. package/locales/en/review.json +14 -0
  28. package/package.json +9 -6
  29. package/src/index.tsx +7 -7
  30. package/src/services/fetch-slides-to-review-by-skill-ref.ts +18 -0
  31. package/src/services/index.ts +2 -0
  32. package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +51 -0
  33. package/src/test/index.test.tsx +3 -1
  34. package/src/test/util/services.mock.ts +24 -2
  35. package/src/types/common.ts +16 -2
  36. package/src/types/globals.d.ts +1 -0
  37. package/src/views/slides/index.ts +43 -19
  38. package/src/views/slides/test/header.on-click.test.ts +10 -3
  39. package/src/views/slides/test/index.test.ts +58 -55
  40. package/src/views/slides/test/on-quit-popin.on-click.test.ts +12 -3
  41. package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
  42. package/src/views/slides/test/slide.next-slide.on-click.test.ts +6 -3
  43. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +3 -2
  44. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +3 -2
  45. package/src/views/slides/test/slide.qcm.on-click.test.ts +3 -2
  46. package/src/views/slides/test/slide.slider.on-change.test.ts +3 -2
  47. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +3 -2
  48. package/src/views/slides/test/slide.template.on-change.test.ts +5 -4
  49. /package/es/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
  50. /package/es/{actions → src/actions}/api/fetch-correction.js +0 -0
  51. /package/es/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
  52. /package/es/{actions → src/actions}/api/fetch-rank.js +0 -0
  53. /package/es/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
  54. /package/es/{actions → src/actions}/api/fetch-skills.js +0 -0
  55. /package/es/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
  56. /package/es/{actions → src/actions}/api/fetch-slide.js +0 -0
  57. /package/es/{actions → src/actions}/api/post-answer.d.ts +0 -0
  58. /package/es/{actions → src/actions}/api/post-answer.js +0 -0
  59. /package/es/{actions → src/actions}/api/post-progression.d.ts +0 -0
  60. /package/es/{actions → src/actions}/api/post-progression.js +0 -0
  61. /package/es/{actions → src/actions}/data/token.d.ts +0 -0
  62. /package/es/{actions → src/actions}/data/token.js +0 -0
  63. /package/es/{actions → src/actions}/index.d.ts +0 -0
  64. /package/es/{actions → src/actions}/index.js +0 -0
  65. /package/es/{actions → src/actions}/test/create-test-store.d.ts +0 -0
  66. /package/es/{actions → src/actions}/test/create-test-store.js +0 -0
  67. /package/es/{actions → src/actions}/ui/answers.d.ts +0 -0
  68. /package/es/{actions → src/actions}/ui/answers.js +0 -0
  69. /package/es/{actions → src/actions}/ui/navigation.d.ts +0 -0
  70. /package/es/{actions → src/actions}/ui/navigation.js +0 -0
  71. /package/es/{actions → src/actions}/ui/next-slide.d.ts +0 -0
  72. /package/es/{actions → src/actions}/ui/next-slide.js +0 -0
  73. /package/es/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
  74. /package/es/{actions → src/actions}/ui/quit-popin.js +0 -0
  75. /package/es/{actions → src/actions}/ui/slides.d.ts +0 -0
  76. /package/es/{actions → src/actions}/ui/slides.js +0 -0
  77. /package/es/{common → src/common}/index.d.ts +0 -0
  78. /package/es/{common → src/common}/index.js +0 -0
  79. /package/es/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
  80. /package/es/{configure-store.js → src/configure-store.js} +0 -0
  81. /package/es/{helpers → src/helpers}/css-register.d.ts +0 -0
  82. /package/es/{helpers → src/helpers}/css-register.js +0 -0
  83. /package/es/{index.d.ts → src/index.d.ts} +0 -0
  84. /package/es/{reducers → src/reducers}/data/corrections.d.ts +0 -0
  85. /package/es/{reducers → src/reducers}/data/corrections.js +0 -0
  86. /package/es/{reducers → src/reducers}/data/index.d.ts +0 -0
  87. /package/es/{reducers → src/reducers}/data/index.js +0 -0
  88. /package/es/{reducers → src/reducers}/data/progression.d.ts +0 -0
  89. /package/es/{reducers → src/reducers}/data/progression.js +0 -0
  90. /package/es/{reducers → src/reducers}/data/rank.d.ts +0 -0
  91. /package/es/{reducers → src/reducers}/data/rank.js +0 -0
  92. /package/es/{reducers → src/reducers}/data/skills.d.ts +0 -0
  93. /package/es/{reducers → src/reducers}/data/skills.js +0 -0
  94. /package/es/{reducers → src/reducers}/data/slides.d.ts +0 -0
  95. /package/es/{reducers → src/reducers}/data/slides.js +0 -0
  96. /package/es/{reducers → src/reducers}/data/token.d.ts +0 -0
  97. /package/es/{reducers → src/reducers}/data/token.js +0 -0
  98. /package/es/{reducers → src/reducers}/index.d.ts +0 -0
  99. /package/es/{reducers → src/reducers}/index.js +0 -0
  100. /package/es/{reducers → src/reducers}/ui/answers.d.ts +0 -0
  101. /package/es/{reducers → src/reducers}/ui/answers.js +0 -0
  102. /package/es/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
  103. /package/es/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
  104. /package/es/{reducers → src/reducers}/ui/index.d.ts +0 -0
  105. /package/es/{reducers → src/reducers}/ui/index.js +0 -0
  106. /package/es/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
  107. /package/es/{reducers → src/reducers}/ui/navigation.js +0 -0
  108. /package/es/{reducers → src/reducers}/ui/positions.d.ts +0 -0
  109. /package/es/{reducers → src/reducers}/ui/positions.js +0 -0
  110. /package/es/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
  111. /package/es/{reducers → src/reducers}/ui/quit-popin.js +0 -0
  112. /package/es/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
  113. /package/es/{reducers → src/reducers}/ui/show-congrats.js +0 -0
  114. /package/es/{reducers → src/reducers}/ui/slide.d.ts +0 -0
  115. /package/es/{reducers → src/reducers}/ui/slide.js +0 -0
  116. /package/es/{services → src/services}/fetch-correction.d.ts +0 -0
  117. /package/es/{services → src/services}/fetch-correction.js +0 -0
  118. /package/es/{services → src/services}/fetch-rank.d.ts +0 -0
  119. /package/es/{services → src/services}/fetch-rank.js +0 -0
  120. /package/es/{services → src/services}/fetch-skills.d.ts +0 -0
  121. /package/es/{services → src/services}/fetch-skills.js +0 -0
  122. /package/es/{services → src/services}/fetch-slide.d.ts +0 -0
  123. /package/es/{services → src/services}/fetch-slide.js +0 -0
  124. /package/es/{services → src/services}/index.d.ts +0 -0
  125. /package/es/{services → src/services}/post-answer.d.ts +0 -0
  126. /package/es/{services → src/services}/post-answer.js +0 -0
  127. /package/es/{services → src/services}/post-progression.d.ts +0 -0
  128. /package/es/{services → src/services}/post-progression.js +0 -0
  129. /package/es/{services → src/services}/tools/fetch-responses.d.ts +0 -0
  130. /package/es/{services → src/services}/tools/fetch-responses.js +0 -0
  131. /package/es/{services → src/services}/tools/sleep.d.ts +0 -0
  132. /package/es/{services → src/services}/tools/sleep.js +0 -0
  133. /package/es/{test → src/test}/index.test.d.ts +0 -0
  134. /package/es/{types → src/types}/common.js +0 -0
  135. /package/es/{types → src/types}/slides.d.ts +0 -0
  136. /package/es/{types → src/types}/slides.js +0 -0
  137. /package/es/{views → src/views}/skills/index.d.ts +0 -0
  138. /package/es/{views → src/views}/skills/index.js +0 -0
  139. /package/es/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
  140. /package/es/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
  141. /package/es/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
  142. /package/es/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
  143. /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
  144. /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
  145. /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
  146. /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
  147. /package/es/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
  148. /package/es/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
  149. /package/es/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
  150. /package/es/{views → src/views}/slides/test/fixtures/slider.js +0 -0
  151. /package/es/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
  152. /package/es/{views → src/views}/slides/test/fixtures/template.js +0 -0
  153. /package/lib/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
  154. /package/lib/{actions → src/actions}/api/fetch-correction.js +0 -0
  155. /package/lib/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
  156. /package/lib/{actions → src/actions}/api/fetch-rank.js +0 -0
  157. /package/lib/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
  158. /package/lib/{actions → src/actions}/api/fetch-skills.js +0 -0
  159. /package/lib/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
  160. /package/lib/{actions → src/actions}/api/fetch-slide.js +0 -0
  161. /package/lib/{actions → src/actions}/api/post-answer.d.ts +0 -0
  162. /package/lib/{actions → src/actions}/api/post-answer.js +0 -0
  163. /package/lib/{actions → src/actions}/api/post-progression.d.ts +0 -0
  164. /package/lib/{actions → src/actions}/api/post-progression.js +0 -0
  165. /package/lib/{actions → src/actions}/data/token.d.ts +0 -0
  166. /package/lib/{actions → src/actions}/data/token.js +0 -0
  167. /package/lib/{actions → src/actions}/index.d.ts +0 -0
  168. /package/lib/{actions → src/actions}/index.js +0 -0
  169. /package/lib/{actions → src/actions}/test/create-test-store.d.ts +0 -0
  170. /package/lib/{actions → src/actions}/test/create-test-store.js +0 -0
  171. /package/lib/{actions → src/actions}/ui/answers.d.ts +0 -0
  172. /package/lib/{actions → src/actions}/ui/answers.js +0 -0
  173. /package/lib/{actions → src/actions}/ui/navigation.d.ts +0 -0
  174. /package/lib/{actions → src/actions}/ui/navigation.js +0 -0
  175. /package/lib/{actions → src/actions}/ui/next-slide.d.ts +0 -0
  176. /package/lib/{actions → src/actions}/ui/next-slide.js +0 -0
  177. /package/lib/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
  178. /package/lib/{actions → src/actions}/ui/quit-popin.js +0 -0
  179. /package/lib/{actions → src/actions}/ui/slides.d.ts +0 -0
  180. /package/lib/{actions → src/actions}/ui/slides.js +0 -0
  181. /package/lib/{common → src/common}/index.d.ts +0 -0
  182. /package/lib/{common → src/common}/index.js +0 -0
  183. /package/lib/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
  184. /package/lib/{configure-store.js → src/configure-store.js} +0 -0
  185. /package/lib/{helpers → src/helpers}/css-register.d.ts +0 -0
  186. /package/lib/{helpers → src/helpers}/css-register.js +0 -0
  187. /package/lib/{index.d.ts → src/index.d.ts} +0 -0
  188. /package/lib/{reducers → src/reducers}/data/corrections.d.ts +0 -0
  189. /package/lib/{reducers → src/reducers}/data/corrections.js +0 -0
  190. /package/lib/{reducers → src/reducers}/data/index.d.ts +0 -0
  191. /package/lib/{reducers → src/reducers}/data/index.js +0 -0
  192. /package/lib/{reducers → src/reducers}/data/progression.d.ts +0 -0
  193. /package/lib/{reducers → src/reducers}/data/progression.js +0 -0
  194. /package/lib/{reducers → src/reducers}/data/rank.d.ts +0 -0
  195. /package/lib/{reducers → src/reducers}/data/rank.js +0 -0
  196. /package/lib/{reducers → src/reducers}/data/skills.d.ts +0 -0
  197. /package/lib/{reducers → src/reducers}/data/skills.js +0 -0
  198. /package/lib/{reducers → src/reducers}/data/slides.d.ts +0 -0
  199. /package/lib/{reducers → src/reducers}/data/slides.js +0 -0
  200. /package/lib/{reducers → src/reducers}/data/token.d.ts +0 -0
  201. /package/lib/{reducers → src/reducers}/data/token.js +0 -0
  202. /package/lib/{reducers → src/reducers}/index.d.ts +0 -0
  203. /package/lib/{reducers → src/reducers}/index.js +0 -0
  204. /package/lib/{reducers → src/reducers}/ui/answers.d.ts +0 -0
  205. /package/lib/{reducers → src/reducers}/ui/answers.js +0 -0
  206. /package/lib/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
  207. /package/lib/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
  208. /package/lib/{reducers → src/reducers}/ui/index.d.ts +0 -0
  209. /package/lib/{reducers → src/reducers}/ui/index.js +0 -0
  210. /package/lib/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
  211. /package/lib/{reducers → src/reducers}/ui/navigation.js +0 -0
  212. /package/lib/{reducers → src/reducers}/ui/positions.d.ts +0 -0
  213. /package/lib/{reducers → src/reducers}/ui/positions.js +0 -0
  214. /package/lib/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
  215. /package/lib/{reducers → src/reducers}/ui/quit-popin.js +0 -0
  216. /package/lib/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
  217. /package/lib/{reducers → src/reducers}/ui/show-congrats.js +0 -0
  218. /package/lib/{reducers → src/reducers}/ui/slide.d.ts +0 -0
  219. /package/lib/{reducers → src/reducers}/ui/slide.js +0 -0
  220. /package/lib/{services → src/services}/fetch-correction.d.ts +0 -0
  221. /package/lib/{services → src/services}/fetch-correction.js +0 -0
  222. /package/lib/{services → src/services}/fetch-rank.d.ts +0 -0
  223. /package/lib/{services → src/services}/fetch-rank.js +0 -0
  224. /package/lib/{services → src/services}/fetch-skills.d.ts +0 -0
  225. /package/lib/{services → src/services}/fetch-skills.js +0 -0
  226. /package/lib/{services → src/services}/fetch-slide.d.ts +0 -0
  227. /package/lib/{services → src/services}/fetch-slide.js +0 -0
  228. /package/lib/{services → src/services}/index.d.ts +0 -0
  229. /package/lib/{services → src/services}/post-answer.d.ts +0 -0
  230. /package/lib/{services → src/services}/post-answer.js +0 -0
  231. /package/lib/{services → src/services}/post-progression.d.ts +0 -0
  232. /package/lib/{services → src/services}/post-progression.js +0 -0
  233. /package/lib/{services → src/services}/tools/fetch-responses.d.ts +0 -0
  234. /package/lib/{services → src/services}/tools/fetch-responses.js +0 -0
  235. /package/lib/{services → src/services}/tools/sleep.d.ts +0 -0
  236. /package/lib/{services → src/services}/tools/sleep.js +0 -0
  237. /package/lib/{test → src/test}/index.test.d.ts +0 -0
  238. /package/lib/{types → src/types}/common.js +0 -0
  239. /package/lib/{types → src/types}/slides.d.ts +0 -0
  240. /package/lib/{types → src/types}/slides.js +0 -0
  241. /package/lib/{views → src/views}/skills/index.d.ts +0 -0
  242. /package/lib/{views → src/views}/skills/index.js +0 -0
  243. /package/lib/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
  244. /package/lib/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
  245. /package/lib/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
  246. /package/lib/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
  247. /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
  248. /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
  249. /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
  250. /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
  251. /package/lib/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
  252. /package/lib/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
  253. /package/lib/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
  254. /package/lib/{views → src/views}/slides/test/fixtures/slider.js +0 -0
  255. /package/lib/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
  256. /package/lib/{views → src/views}/slides/test/fixtures/template.js +0 -0
@@ -1,4 +1,5 @@
1
1
  import type { Dispatch } from 'redux';
2
+ import type { ConnectedOptions } from '../../types/common';
2
3
  import { type SlideIndexes } from '../../common';
3
4
  import type { StoreState } from '../../reducers';
4
5
  import type { AnswerUI } from '../../types/slides';
@@ -138,5 +139,5 @@ export declare type CongratsProps = {
138
139
  };
139
140
  export declare const initialState: SlidesStack;
140
141
  export declare const buildStepItems: (state: StoreState) => StepItem[];
141
- export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: Function) => SlidesViewProps;
142
+ export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, options: ConnectedOptions) => SlidesViewProps;
142
143
  export {};
@@ -161,22 +161,22 @@ export var buildStepItems = function (state) {
161
161
  return steps;
162
162
  };
163
163
  var getCorrectionPopinProps = function (dispatch) {
164
- return function (isCorrect, correctAnswer, klf) {
164
+ return function (isCorrect, correctAnswer, klf, translate) {
165
165
  return {
166
166
  klf: isCorrect
167
167
  ? undefined
168
168
  : {
169
- label: '_klf',
169
+ label: translate('KLF'),
170
170
  tooltip: klf
171
171
  },
172
- resultLabel: isCorrect ? '_right' : '_wrong',
172
+ resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
173
173
  information: {
174
- label: isCorrect ? '_klf' : '_correctAnswer',
174
+ label: isCorrect ? translate('KLF') : translate('Correct Answer'),
175
175
  message: isCorrect ? klf : join(',', correctAnswer)
176
176
  },
177
177
  next: {
178
- ariaLabel: '_correctionNextAriaLabel',
179
- label: '_correctionNextLabel',
178
+ ariaLabel: translate('Next Question'),
179
+ label: translate('Next Question'),
180
180
  onClick: function () {
181
181
  dispatch(nextSlide);
182
182
  }
@@ -212,7 +212,7 @@ var buildQuitPopinProps = function (dispatch) {
212
212
  };
213
213
  };
214
214
  };
215
- var buildRankCard = function (rank) {
215
+ var buildRankCard = function (rank, translate) {
216
216
  return {
217
217
  'aria-label': 'Review Card Congrats Container',
218
218
  'data-name': 'card-rank',
@@ -227,13 +227,13 @@ var buildRankCard = function (rank) {
227
227
  cardType: 'card-rank',
228
228
  iconAriaLabel: 'Image without information',
229
229
  className: undefined,
230
- reviewCardTitle: 'You are now',
230
+ reviewCardTitle: translate('You are now'),
231
231
  reviewCardValue: "".concat(rank),
232
232
  rankSuffix: 'th',
233
233
  timerAnimation: 200
234
234
  };
235
235
  };
236
- var buildCongratsProps = function (state) {
236
+ var buildCongratsProps = function (state, translate) {
237
237
  if (!state.ui.showCongrats)
238
238
  return;
239
239
  var progression = state.data.progression;
@@ -256,18 +256,18 @@ var buildCongratsProps = function (state) {
256
256
  iconAriaLabel: 'Image without information',
257
257
  className: undefined,
258
258
  cardType: 'card-star',
259
- reviewCardTitle: 'You have won',
259
+ reviewCardTitle: translate('You have won'),
260
260
  reviewCardValue: "".concat(stars),
261
261
  timerAnimation: 200
262
262
  };
263
263
  var _a = state.data.rank, start = _a.start, end = _a.end;
264
264
  var newRank = start - end;
265
- var cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
265
+ var cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
266
266
  return {
267
267
  'aria-label': 'Review Congratulations',
268
268
  'data-name': 'review-congrats',
269
269
  animationLottie: confettiAnimation,
270
- title: 'Congratulations!',
270
+ title: translate('Congratulations!'),
271
271
  cardCongratsStar: cardCongratsStar,
272
272
  cardCongratsRank: cardCongratsRank,
273
273
  buttonRevising: undefined,
@@ -279,7 +279,8 @@ var isEndOfProgression = function (progression) {
279
279
  return false;
280
280
  return progression.state.nextContent.ref === 'successExitNode';
281
281
  };
282
- export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
282
+ export var mapStateToSlidesProps = function (state, dispatch, options) {
283
+ var translate = options.translate, onQuitClick = options.onQuitClick;
283
284
  var currentSlideRef = getCurrentSlideRef(state);
284
285
  var endReview = isEndOfProgression(state.data.progression);
285
286
  var correction = get(['data', 'corrections', currentSlideRef], state);
@@ -288,8 +289,8 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
288
289
  var showQuitPopin = get(['ui', 'showQuitPopin'], state);
289
290
  return {
290
291
  header: {
291
- mode: '__revision_mode',
292
- skillName: '__agility',
292
+ mode: translate('Review Title'),
293
+ skillName: translate('Content Parent Title'),
293
294
  onQuitClick: function () { return dispatch(openQuitPopin); },
294
295
  'aria-label': 'aria-header-wrapper',
295
296
  closeButtonAriaLabel: 'aria-close-button',
@@ -298,16 +299,17 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
298
299
  stack: {
299
300
  slides: buildStackSlides(state, dispatch),
300
301
  validateButton: {
301
- label: '__validate',
302
+ label: translate('Validate'),
302
303
  disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
303
304
  onClick: function () {
304
305
  dispatch(postAnswer);
305
306
  }
306
307
  },
307
- correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
308
+ correctionPopinProps: correction &&
309
+ getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, options.translate),
308
310
  endReview: endReview && state.ui.showCongrats
309
311
  },
310
- congrats: buildCongratsProps(state),
312
+ congrats: buildCongratsProps(state, options.translate),
311
313
  quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
312
314
  };
313
315
  };
@@ -0,0 +1,14 @@
1
+ {
2
+ "Review Title": "Review Mode",
3
+ "Content Parent Title": "From `{{contentTitle}}` `{{contentType}}`",
4
+ "Validate": "Validate",
5
+ "Next Question": "Next Question",
6
+ "KLF": "Key Learning Factor",
7
+ "Correct Answer": "Correct Answer",
8
+ "Wrong Answer": "Wrong Answer",
9
+ "You have won": "You have won",
10
+ "You are now": "You are now",
11
+ "Revise another skill": "Revise another skill",
12
+ "Continue reviewing": "Continue reviewing",
13
+ "Congratulations!": "Congratulations!"
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.5.4",
3
+ "version": "0.5.6-alpha.10+0092fc5b2",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -30,6 +30,7 @@
30
30
  "lib",
31
31
  "es",
32
32
  "src",
33
+ "locales",
33
34
  "readme.md"
34
35
  ],
35
36
  "main": "./es/index.js",
@@ -39,11 +40,13 @@
39
40
  "commonjs": "./lib/index.js",
40
41
  "types": "./es/index.d.ts"
41
42
  },
42
- "./package.json": "./package.json"
43
+ "./package.json": "./package.json",
44
+ "./locales/en/review": "./locales/en/review.json"
43
45
  },
44
46
  "dependencies": {
45
- "@coorpacademy/components": "10.24.3",
47
+ "@coorpacademy/components": "10.24.4",
46
48
  "@coorpacademy/redux-task": "1.1.6",
49
+ "@coorpacademy/translate": "6.1.5",
47
50
  "cross-fetch": "^3.1.5",
48
51
  "jwt-decode": "^3.1.2",
49
52
  "react-redux": "^7.2.9",
@@ -55,9 +58,9 @@
55
58
  "react": "^17.0.2"
56
59
  },
57
60
  "devDependencies": {
58
- "@coorpacademy/css-modules-require-hook": "2.1.5",
61
+ "@coorpacademy/css-modules-require-hook": "3.0.0",
59
62
  "@coorpacademy/eslint-plugin-coorpacademy": "^11.0.0",
60
- "@coorpacademy/webpack-config": "11.0.0",
63
+ "@coorpacademy/webpack-config": "12.0.0",
61
64
  "@testing-library/react": "^12.1.5",
62
65
  "@types/lodash": "^4.14.182",
63
66
  "@typescript-eslint/eslint-plugin": "^5.28.0",
@@ -77,5 +80,5 @@
77
80
  "webpack-cli": "^4.10.0",
78
81
  "webpack-dev-server": "^4.11.1"
79
82
  },
80
- "gitHead": "9e64ba973f7219fca6b39876f2e64d423356c721"
83
+ "gitHead": "0092fc5b24aa99b5e3ffdd2ee48501bcfb5427d6"
81
84
  }
package/src/index.tsx CHANGED
@@ -8,7 +8,7 @@ import isEmpty from 'lodash/fp/isEmpty';
8
8
  import get from 'lodash/fp/get';
9
9
  import configureStore from './configure-store';
10
10
 
11
- import type {AppOptions} from './types/common';
11
+ import type {AppOptions, ConnectedOptions} from './types/common';
12
12
  import type {StoreState} from './reducers';
13
13
 
14
14
  import {navigateTo, ViewPath} from './actions/ui/navigation';
@@ -19,15 +19,15 @@ import {VIEWS} from './common';
19
19
  import {mapStateToSlidesProps} from './views/slides';
20
20
  import {mapStateToSkillsProps} from './views/skills';
21
21
 
22
- const ConnectedApp = ({onQuitClick}: {onQuitClick: Function}): JSX.Element => {
22
+ const ConnectedApp = (options: ConnectedOptions): JSX.Element => {
23
23
  const dispatch = useDispatch();
24
-
25
24
  const props = {
26
25
  viewName: useSelector(
27
26
  (state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
28
27
  ),
29
- slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
30
- skills: useSelector((state: StoreState) => mapStateToSkillsProps(state))
28
+ slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch, options)),
29
+ skills: useSelector((state: StoreState) => mapStateToSkillsProps(state)),
30
+ onboarding: {}
31
31
  };
32
32
  return <AppReviewTemplate {...props} />;
33
33
  };
@@ -36,7 +36,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
36
36
  const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
37
37
  const [isProgressionCreated, setIsProgressionCreated] = useState(false);
38
38
 
39
- const onQuitClick = options.onQuitClick;
39
+ const {translate, onQuitClick} = options;
40
40
 
41
41
  useEffect(() => {
42
42
  if (store) return;
@@ -89,7 +89,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
89
89
 
90
90
  return (
91
91
  <Provider store={store}>
92
- <ConnectedApp onQuitClick={onQuitClick} />
92
+ <ConnectedApp onQuitClick={onQuitClick} translate={translate} />
93
93
  </Provider>
94
94
  );
95
95
  };
@@ -0,0 +1,18 @@
1
+ import crossFetch from 'cross-fetch';
2
+ import decode from 'jwt-decode';
3
+
4
+ import {JWT, SlideIdFromAPI} from '../types/common';
5
+ import {toJSON} from './tools/fetch-responses';
6
+
7
+ export const fetchSlidesToReviewBySkillRef = async (
8
+ url: string,
9
+ token: string,
10
+ skillRef: string
11
+ ): Promise<SlideIdFromAPI[]> => {
12
+ const {user: userId}: JWT = decode(token);
13
+ const response = await crossFetch(
14
+ `${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`
15
+ );
16
+
17
+ return toJSON<SlideIdFromAPI[]>(response);
18
+ };
@@ -3,6 +3,7 @@ import {fetchCorrection} from './fetch-correction';
3
3
  import {fetchRank} from './fetch-rank';
4
4
  import {fetchSkills} from './fetch-skills';
5
5
  import {fetchSlide} from './fetch-slide';
6
+ import {fetchSlidesToReviewBySkillRef} from './fetch-slides-to-review-by-skill-ref';
6
7
  import {postAnswer} from './post-answer';
7
8
  import {postProgression} from './post-progression';
8
9
 
@@ -11,6 +12,7 @@ export const getServices = (): Services => ({
11
12
  fetchRank,
12
13
  fetchSkills,
13
14
  fetchSlide,
15
+ fetchSlidesToReviewBySkillRef,
14
16
  postAnswer,
15
17
  postProgression
16
18
  });
@@ -0,0 +1,51 @@
1
+ import test from 'ava';
2
+ import nock from 'nock';
3
+ import {fetchSlidesToReviewBySkillRef} from '../fetch-slides-to-review-by-skill-ref';
4
+ import {SlideIdFromAPI} from '../../types/common';
5
+
6
+ const url = process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006';
7
+
8
+ const result: SlideIdFromAPI[] = [
9
+ {
10
+ slideId: 'sli_6'
11
+ },
12
+ {
13
+ slideId: 'sli_7'
14
+ },
15
+ {
16
+ slideId: 'sli_8'
17
+ },
18
+ {
19
+ slideId: 'sli_9'
20
+ },
21
+ {
22
+ slideId: 'sli_10'
23
+ }
24
+ ];
25
+
26
+ test.before(() => {
27
+ nock(url)
28
+ .get('/api/v1/review/users/592d830b240b923f00bffba6/skills/_skill-ref/slide?limit=5&offset=0')
29
+ .reply(200, result);
30
+ });
31
+
32
+ test.after(() => {
33
+ nock.cleanAll();
34
+ });
35
+
36
+ test('should fetch slides id with success', async t => {
37
+ const token = process.env.API_TEST_TOKEN || '';
38
+ const slidesId = await fetchSlidesToReviewBySkillRef(url, token, '_skill-ref');
39
+ t.deepEqual(result, slidesId);
40
+ });
41
+
42
+ test('should reject if a bad token is passed', async t => {
43
+ const badToken = 'token is not a jwt';
44
+ const error = await t.throwsAsync(() =>
45
+ fetchSlidesToReviewBySkillRef(url, badToken, '_skill-ref')
46
+ );
47
+ t.is(
48
+ error?.message,
49
+ "Invalid token specified: Cannot read properties of undefined (reading 'replace')"
50
+ );
51
+ });
@@ -61,7 +61,9 @@ const appOptions: AppOptions = {
61
61
  token: process.env.API_TEST_TOKEN || '',
62
62
  skillRef: 'skill_NJC0jFKoH',
63
63
  services,
64
- onQuitClick: identity
64
+ onQuitClick: identity,
65
+ translate: key => key,
66
+ url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
65
67
  };
66
68
 
67
69
  test('should show the loader while the app is fetching the data', async t => {
@@ -11,7 +11,8 @@ import {
11
11
  ReviewContent,
12
12
  ReviewEngine,
13
13
  Services,
14
- SlideFromAPI
14
+ SlideFromAPI,
15
+ SlideIdFromAPI
15
16
  } from '../../types/common';
16
17
 
17
18
  const content: ReviewContent = {
@@ -432,6 +433,24 @@ export const getChoicesCorrection = (ref: string, wrongChoice = false): Correcti
432
433
  }
433
434
  };
434
435
 
436
+ const fetchSlidesToReviewBySkillRefResponse: SlideIdFromAPI[] = [
437
+ {
438
+ slideId: freeTextSlide._id
439
+ },
440
+ {
441
+ slideId: templateSlide._id
442
+ },
443
+ {
444
+ slideId: qcmDragSlide._id
445
+ },
446
+ {
447
+ slideId: qcmGraphicSlide._id
448
+ },
449
+ {
450
+ slideId: qcmSlide._id
451
+ }
452
+ ];
453
+
435
454
  export const services: Services = {
436
455
  fetchSkills: () => Promise.resolve(fetchSkillsResponse),
437
456
  fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, _id: ref}),
@@ -441,5 +460,8 @@ export const services: Services = {
441
460
  return Promise.resolve(get(currentSlide, postAnswerResponses));
442
461
  },
443
462
  fetchCorrection: ref => Promise.resolve(getChoicesCorrection(ref)),
444
- fetchRank: () => Promise.resolve(fetchRankResponse)
463
+ fetchRank: () => Promise.resolve(fetchRankResponse),
464
+ fetchSlidesToReviewBySkillRef: () => Promise.resolve(fetchSlidesToReviewBySkillRefResponse)
445
465
  };
466
+
467
+ export const translate = (key: string): string => `___${key}`;
@@ -82,6 +82,10 @@ export type SlideFromAPI = {
82
82
  };
83
83
  };
84
84
 
85
+ export type SlideIdFromAPI = {
86
+ slideId: string;
87
+ };
88
+
85
89
  export type Rank = {
86
90
  rank: number;
87
91
  };
@@ -164,17 +168,27 @@ export type Services = {
164
168
  answer: string[]
165
169
  ): Promise<CorrectionFromAPI | void>;
166
170
  fetchRank(token: string): Promise<Rank>;
171
+ fetchSlidesToReviewBySkillRef(
172
+ url: string,
173
+ token: string,
174
+ skillRef: string
175
+ ): Promise<SlideIdFromAPI[]>;
167
176
  };
168
177
 
169
178
  export type Options = {
170
179
  services: Services;
171
180
  };
172
181
 
173
- export type AppOptions = {
182
+ export type ConnectedOptions = {
183
+ translate: (key: string, data?: unknown) => string;
184
+ onQuitClick: Function;
185
+ };
186
+
187
+ export type AppOptions = ConnectedOptions & {
174
188
  token: string;
175
189
  skillRef?: string;
176
190
  services: Services;
177
- onQuitClick: Function;
191
+ url: string;
178
192
  };
179
193
 
180
194
  export type JWT = {
@@ -2,3 +2,4 @@ declare module '*.css';
2
2
  declare module 'browser-env';
3
3
  declare module '@coorpacademy/components/es/*';
4
4
  declare module '@coorpacademy/redux-task';
5
+ declare module '@coorpacademy/translate';
@@ -8,7 +8,12 @@ import toInteger from 'lodash/fp/toInteger';
8
8
  import type {Dispatch} from 'redux';
9
9
  import join from 'lodash/fp/join';
10
10
  import {closeQuitPopin, openQuitPopin} from '../../actions/ui/quit-popin';
11
- import type {ProgressionAnswerItem, ProgressionFromAPI, SlideContent} from '../../types/common';
11
+ import type {
12
+ ConnectedOptions,
13
+ ProgressionAnswerItem,
14
+ ProgressionFromAPI,
15
+ SlideContent
16
+ } from '../../types/common';
12
17
  import {getProgressionSlidesRefs, type SlideIndexes} from '../../common';
13
18
  import type {StoreState} from '../../reducers';
14
19
  import type {AnswerUI} from '../../types/slides';
@@ -346,22 +351,27 @@ export const buildStepItems = (state: StoreState): StepItem[] => {
346
351
 
347
352
  const getCorrectionPopinProps =
348
353
  (dispatch: Dispatch) =>
349
- (isCorrect: boolean, correctAnswer: string[], klf: string): CorrectionPopinProps => {
354
+ (
355
+ isCorrect: boolean,
356
+ correctAnswer: string[],
357
+ klf: string,
358
+ translate: (key: string, data?: unknown) => string
359
+ ): CorrectionPopinProps => {
350
360
  return {
351
361
  klf: isCorrect
352
362
  ? undefined
353
363
  : {
354
- label: '_klf',
364
+ label: translate('KLF'),
355
365
  tooltip: klf
356
366
  },
357
- resultLabel: isCorrect ? '_right' : '_wrong',
367
+ resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
358
368
  information: {
359
- label: isCorrect ? '_klf' : '_correctAnswer',
369
+ label: isCorrect ? translate('KLF') : translate('Correct Answer'),
360
370
  message: isCorrect ? klf : join(',', correctAnswer)
361
371
  },
362
372
  next: {
363
- ariaLabel: '_correctionNextAriaLabel',
364
- label: '_correctionNextLabel',
373
+ ariaLabel: translate('Next Question'),
374
+ label: translate('Next Question'),
365
375
  onClick: (): void => {
366
376
  dispatch(nextSlide);
367
377
  }
@@ -398,7 +408,10 @@ const buildQuitPopinProps =
398
408
  };
399
409
  };
400
410
 
401
- const buildRankCard = (rank: number): CongratsCardProps => {
411
+ const buildRankCard = (
412
+ rank: number,
413
+ translate: (key: string, data?: unknown) => string
414
+ ): CongratsCardProps => {
402
415
  return {
403
416
  'aria-label': 'Review Card Congrats Container',
404
417
  'data-name': 'card-rank',
@@ -414,14 +427,17 @@ const buildRankCard = (rank: number): CongratsCardProps => {
414
427
  cardType: 'card-rank',
415
428
  iconAriaLabel: 'Image without information',
416
429
  className: undefined,
417
- reviewCardTitle: 'You are now',
430
+ reviewCardTitle: translate('You are now'),
418
431
  reviewCardValue: `${rank}`,
419
432
  rankSuffix: 'th',
420
433
  timerAnimation: 200
421
434
  };
422
435
  };
423
436
 
424
- const buildCongratsProps = (state: StoreState): CongratsProps | undefined => {
437
+ const buildCongratsProps = (
438
+ state: StoreState,
439
+ translate: (key: string, data?: unknown) => string
440
+ ): CongratsProps | undefined => {
425
441
  if (!state.ui.showCongrats) return;
426
442
 
427
443
  const progression = state.data.progression as ProgressionFromAPI;
@@ -445,20 +461,21 @@ const buildCongratsProps = (state: StoreState): CongratsProps | undefined => {
445
461
  iconAriaLabel: 'Image without information',
446
462
  className: undefined,
447
463
  cardType: 'card-star',
448
- reviewCardTitle: 'You have won',
464
+ reviewCardTitle: translate('You have won'),
449
465
  reviewCardValue: `${stars}`,
450
466
  timerAnimation: 200
451
467
  };
452
468
 
453
469
  const {start, end} = state.data.rank;
454
470
  const newRank = start - end;
455
- const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
471
+ const cardCongratsRank =
472
+ !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
456
473
 
457
474
  return {
458
475
  'aria-label': 'Review Congratulations',
459
476
  'data-name': 'review-congrats',
460
477
  animationLottie: confettiAnimation,
461
- title: 'Congratulations!',
478
+ title: translate('Congratulations!'),
462
479
  cardCongratsStar,
463
480
  cardCongratsRank,
464
481
  buttonRevising: undefined, // TODO make boutons and actions
@@ -474,8 +491,9 @@ const isEndOfProgression = (progression: ProgressionState): boolean => {
474
491
  export const mapStateToSlidesProps = (
475
492
  state: StoreState,
476
493
  dispatch: Dispatch,
477
- onQuitClick: Function
494
+ options: ConnectedOptions
478
495
  ): SlidesViewProps => {
496
+ const {translate, onQuitClick} = options;
479
497
  const currentSlideRef = getCurrentSlideRef(state);
480
498
  const endReview = isEndOfProgression(state.data.progression);
481
499
  const correction = get(['data', 'corrections', currentSlideRef], state);
@@ -484,8 +502,8 @@ export const mapStateToSlidesProps = (
484
502
  const showQuitPopin = get(['ui', 'showQuitPopin'], state);
485
503
  return {
486
504
  header: {
487
- mode: '__revision_mode',
488
- skillName: '__agility',
505
+ mode: translate('Review Title'),
506
+ skillName: translate('Content Parent Title'),
489
507
  onQuitClick: () => dispatch(openQuitPopin),
490
508
  'aria-label': 'aria-header-wrapper',
491
509
  closeButtonAriaLabel: 'aria-close-button',
@@ -494,17 +512,23 @@ export const mapStateToSlidesProps = (
494
512
  stack: {
495
513
  slides: buildStackSlides(state, dispatch),
496
514
  validateButton: {
497
- label: '__validate',
515
+ label: translate('Validate'),
498
516
  disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
499
517
  onClick: (): void => {
500
518
  dispatch(postAnswer);
501
519
  }
502
520
  },
503
521
  correctionPopinProps:
504
- correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
522
+ correction &&
523
+ getCorrectionPopinProps(dispatch)(
524
+ isCorrect,
525
+ correction.correctAnswer,
526
+ klf,
527
+ options.translate
528
+ ),
505
529
  endReview: endReview && state.ui.showCongrats
506
530
  },
507
- congrats: buildCongratsProps(state),
531
+ congrats: buildCongratsProps(state, options.translate),
508
532
  quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
509
533
  };
510
534
  };
@@ -1,7 +1,11 @@
1
1
  import test from 'ava';
2
2
  import identity from 'lodash/fp/identity';
3
3
  import {createTestStore} from '../../../actions/test/create-test-store';
4
- import {incorrectFreeTextPostAnswerResponse, services} from '../../../test/util/services.mock';
4
+ import {
5
+ incorrectFreeTextPostAnswerResponse,
6
+ services,
7
+ translate
8
+ } from '../../../test/util/services.mock';
5
9
  import {StoreState} from '../../../reducers';
6
10
  import {OPEN_POPIN} from '../../../actions/ui/quit-popin';
7
11
  import {mapStateToSlidesProps} from '..';
@@ -37,10 +41,13 @@ const state: StoreState = {
37
41
  test('should dispatch OPEN_POPIN action after a click on close button in header', async t => {
38
42
  const expectedAction = [{type: OPEN_POPIN}];
39
43
  const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
40
- const props = mapStateToSlidesProps(getState(), dispatch, identity);
44
+ const props = mapStateToSlidesProps(getState(), dispatch, {translate, onQuitClick: identity});
41
45
  t.is(props.quitPopin, undefined);
42
46
  await props.header.onQuitClick();
43
- const updatedProps = mapStateToSlidesProps(getState(), dispatch, identity);
47
+ const updatedProps = mapStateToSlidesProps(getState(), dispatch, {
48
+ translate,
49
+ onQuitClick: identity
50
+ });
44
51
  t.not(updatedProps.quitPopin, undefined);
45
52
  t.pass();
46
53
  });