@coorpacademy/app-review 0.1.13 → 0.1.15

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 (174) hide show
  1. package/es/actions/api/fetch-slide.d.ts +3 -3
  2. package/es/actions/api/fetch-slide.js +22 -2
  3. package/es/actions/api/post-progression.js +1 -2
  4. package/es/actions/index.d.ts +1 -10
  5. package/es/actions/ui/is-fetching.js +0 -2
  6. package/es/actions/ui/slides.d.ts +26 -0
  7. package/es/actions/ui/slides.js +9 -0
  8. package/es/common/index.d.ts +3 -1
  9. package/es/common/index.js +3 -1
  10. package/es/fixtures/qcm-slide.d.ts +2 -2
  11. package/es/fixtures/temp-fixture.d.ts +2 -2
  12. package/es/helpers/map-api-slide-to-ui.d.ts +4 -1
  13. package/es/helpers/map-api-slide-to-ui.js +33 -15
  14. package/es/helpers/test/fixtures/free-text.d.ts +2 -3
  15. package/es/helpers/test/fixtures/free-text.js +10 -4
  16. package/es/helpers/test/fixtures/qcm-drag.d.ts +2 -3
  17. package/es/helpers/test/fixtures/qcm-drag.js +38 -32
  18. package/es/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
  19. package/es/helpers/test/fixtures/qcm-graphic.js +20 -14
  20. package/es/helpers/test/fixtures/qcm.d.ts +2 -3
  21. package/es/helpers/test/fixtures/qcm.js +32 -26
  22. package/es/helpers/test/fixtures/select-template.d.ts +2 -3
  23. package/es/helpers/test/fixtures/select-template.js +38 -32
  24. package/es/helpers/test/fixtures/slider.d.ts +2 -3
  25. package/es/helpers/test/fixtures/slider.js +13 -7
  26. package/es/helpers/test/fixtures/text-template.d.ts +2 -3
  27. package/es/helpers/test/fixtures/text-template.js +16 -10
  28. package/es/index.js +14 -78
  29. package/es/reducers/data/index.d.ts +1 -1
  30. package/es/reducers/data/progression.d.ts +3 -16
  31. package/es/reducers/data/progression.js +3 -22
  32. package/es/reducers/data/slides.d.ts +5 -6
  33. package/es/reducers/data/slides.js +4 -107
  34. package/es/reducers/index.d.ts +3 -4
  35. package/es/reducers/ui/current-slide-ref.d.ts +4 -0
  36. package/es/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
  37. package/es/reducers/ui/index.d.ts +7 -10
  38. package/es/reducers/ui/index.js +4 -6
  39. package/es/reducers/ui/slides.d.ts +9 -0
  40. package/es/reducers/ui/slides.js +42 -0
  41. package/es/services/test/post-progression.test.js +6 -4
  42. package/es/test/util/services.mock.js +17 -5
  43. package/es/types/common.d.ts +40 -23
  44. package/es/types/common.js +0 -5
  45. package/es/types/slides.d.ts +0 -4
  46. package/es/types/views/slides.d.ts +41 -27
  47. package/es/types/views/slides.js +5 -0
  48. package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
  49. package/es/views/skills/index.js +25 -0
  50. package/es/views/slides/index.d.ts +3 -0
  51. package/es/views/slides/index.js +85 -0
  52. package/lib/actions/api/fetch-slide.d.ts +3 -3
  53. package/lib/actions/api/fetch-slide.js +20 -2
  54. package/lib/actions/api/post-progression.js +1 -2
  55. package/lib/actions/index.d.ts +1 -10
  56. package/lib/actions/ui/is-fetching.js +0 -2
  57. package/lib/actions/ui/slides.d.ts +26 -0
  58. package/lib/actions/ui/slides.js +9 -0
  59. package/lib/common/index.d.ts +3 -1
  60. package/lib/common/index.js +3 -1
  61. package/lib/fixtures/qcm-slide.d.ts +2 -2
  62. package/lib/fixtures/temp-fixture.d.ts +2 -2
  63. package/lib/helpers/map-api-slide-to-ui.d.ts +4 -1
  64. package/lib/helpers/map-api-slide-to-ui.js +34 -14
  65. package/lib/helpers/test/fixtures/free-text.d.ts +2 -3
  66. package/lib/helpers/test/fixtures/free-text.js +10 -4
  67. package/lib/helpers/test/fixtures/qcm-drag.d.ts +2 -3
  68. package/lib/helpers/test/fixtures/qcm-drag.js +38 -32
  69. package/lib/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
  70. package/lib/helpers/test/fixtures/qcm-graphic.js +20 -14
  71. package/lib/helpers/test/fixtures/qcm.d.ts +2 -3
  72. package/lib/helpers/test/fixtures/qcm.js +32 -26
  73. package/lib/helpers/test/fixtures/select-template.d.ts +2 -3
  74. package/lib/helpers/test/fixtures/select-template.js +38 -32
  75. package/lib/helpers/test/fixtures/slider.d.ts +2 -3
  76. package/lib/helpers/test/fixtures/slider.js +13 -7
  77. package/lib/helpers/test/fixtures/text-template.d.ts +2 -3
  78. package/lib/helpers/test/fixtures/text-template.js +16 -10
  79. package/lib/index.js +14 -78
  80. package/lib/reducers/data/index.d.ts +1 -1
  81. package/lib/reducers/data/progression.d.ts +3 -16
  82. package/lib/reducers/data/progression.js +3 -22
  83. package/lib/reducers/data/slides.d.ts +5 -6
  84. package/lib/reducers/data/slides.js +4 -113
  85. package/lib/reducers/index.d.ts +3 -4
  86. package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
  87. package/lib/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
  88. package/lib/reducers/ui/index.d.ts +7 -10
  89. package/lib/reducers/ui/index.js +4 -6
  90. package/lib/reducers/ui/slides.d.ts +9 -0
  91. package/lib/reducers/ui/slides.js +43 -0
  92. package/lib/services/test/post-progression.test.js +6 -4
  93. package/lib/test/util/services.mock.js +17 -5
  94. package/lib/types/common.d.ts +40 -23
  95. package/lib/types/common.js +0 -5
  96. package/lib/types/slides.d.ts +0 -4
  97. package/lib/types/views/slides.d.ts +41 -27
  98. package/lib/types/views/slides.js +5 -0
  99. package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
  100. package/lib/views/skills/index.js +25 -0
  101. package/lib/views/slides/index.d.ts +3 -0
  102. package/lib/views/slides/index.js +89 -0
  103. package/package.json +3 -3
  104. package/src/actions/api/fetch-slide.ts +26 -5
  105. package/src/actions/api/post-progression.ts +1 -2
  106. package/src/actions/index.ts +1 -10
  107. package/src/actions/ui/is-fetching.ts +0 -6
  108. package/src/actions/ui/slides.ts +35 -0
  109. package/src/common/index.ts +7 -1
  110. package/src/fixtures/qcm-slide.ts +2 -2
  111. package/src/fixtures/temp-fixture.ts +2 -2
  112. package/src/helpers/map-api-slide-to-ui.ts +43 -17
  113. package/src/helpers/test/fixtures/free-text.ts +12 -7
  114. package/src/helpers/test/fixtures/qcm-drag.ts +40 -35
  115. package/src/helpers/test/fixtures/qcm-graphic.ts +22 -17
  116. package/src/helpers/test/fixtures/qcm.ts +38 -32
  117. package/src/helpers/test/fixtures/select-template.ts +40 -35
  118. package/src/helpers/test/fixtures/slider.ts +15 -10
  119. package/src/helpers/test/fixtures/text-template.ts +18 -13
  120. package/src/helpers/test/map-api-slide-to-ui.test.ts +2 -11
  121. package/src/index.tsx +15 -84
  122. package/src/reducers/data/progression.ts +5 -40
  123. package/src/reducers/data/slides.ts +9 -126
  124. package/src/reducers/ui/current-slide-ref.ts +19 -0
  125. package/src/reducers/ui/index.ts +6 -9
  126. package/src/reducers/ui/slides.ts +58 -0
  127. package/src/services/test/post-progression.test.ts +6 -4
  128. package/src/test/util/services.mock.ts +17 -5
  129. package/src/types/common.ts +44 -27
  130. package/src/types/slides.ts +0 -5
  131. package/src/types/views/slides.ts +52 -27
  132. package/src/views/skills/index.ts +56 -0
  133. package/src/views/slides/index.ts +92 -0
  134. package/es/actions/data/slides.d.ts +0 -37
  135. package/es/actions/data/slides.js +0 -16
  136. package/es/actions/ui/finished-slides.d.ts +0 -10
  137. package/es/actions/ui/finished-slides.js +0 -8
  138. package/es/actions/ui/review-status.d.ts +0 -7
  139. package/es/actions/ui/review-status.js +0 -7
  140. package/es/actions/ui/step-items.d.ts +0 -24
  141. package/es/actions/ui/step-items.js +0 -11
  142. package/es/reducers/ui/finished-slides.d.ts +0 -7
  143. package/es/reducers/ui/finished-slides.js +0 -33
  144. package/es/reducers/ui/review-status.d.ts +0 -4
  145. package/es/reducers/ui/step-items.d.ts +0 -14
  146. package/es/reducers/ui/step-items.js +0 -74
  147. package/es/types/ui-progression.d.ts +0 -10
  148. package/es/types/ui-progression.js +0 -1
  149. package/es/types/views/skills.js +0 -1
  150. package/lib/actions/data/slides.d.ts +0 -37
  151. package/lib/actions/data/slides.js +0 -16
  152. package/lib/actions/ui/finished-slides.d.ts +0 -10
  153. package/lib/actions/ui/finished-slides.js +0 -8
  154. package/lib/actions/ui/review-status.d.ts +0 -7
  155. package/lib/actions/ui/review-status.js +0 -7
  156. package/lib/actions/ui/step-items.d.ts +0 -24
  157. package/lib/actions/ui/step-items.js +0 -11
  158. package/lib/reducers/ui/finished-slides.d.ts +0 -7
  159. package/lib/reducers/ui/finished-slides.js +0 -45
  160. package/lib/reducers/ui/review-status.d.ts +0 -4
  161. package/lib/reducers/ui/step-items.d.ts +0 -14
  162. package/lib/reducers/ui/step-items.js +0 -86
  163. package/lib/types/ui-progression.d.ts +0 -10
  164. package/lib/types/ui-progression.js +0 -1
  165. package/lib/types/views/skills.js +0 -1
  166. package/src/actions/data/slides.ts +0 -65
  167. package/src/actions/ui/finished-slides.ts +0 -21
  168. package/src/actions/ui/review-status.ts +0 -19
  169. package/src/actions/ui/step-items.ts +0 -45
  170. package/src/reducers/ui/finished-slides.ts +0 -52
  171. package/src/reducers/ui/review-status.ts +0 -19
  172. package/src/reducers/ui/step-items.ts +0 -116
  173. package/src/types/ui-progression.ts +0 -25
  174. package/src/types/views/skills.ts +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -40,7 +40,7 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@coorpacademy/components": "10.22.7",
43
+ "@coorpacademy/components": "10.22.9",
44
44
  "@coorpacademy/redux-task": "^1.1.5",
45
45
  "cross-fetch": "^3.1.5",
46
46
  "jwt-decode": "^3.1.2",
@@ -77,5 +77,5 @@
77
77
  "ts-node": "^10.8.1",
78
78
  "typescript": "^4.7.4"
79
79
  },
80
- "gitHead": "0581f6b96f948da672c274c4d233bc853981f4cc"
80
+ "gitHead": "0f66b53a129b22c69cb3db1f3ae3993903cd8df3"
81
81
  }
@@ -1,8 +1,12 @@
1
1
  import type {AnyAction} from 'redux';
2
2
  import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
3
3
  import buildTask from '@coorpacademy/redux-task';
4
+ import get from 'lodash/fp/get';
5
+ import has from 'lodash/fp/has';
6
+ import isEmpty from 'lodash/fp/isEmpty';
4
7
  import type {StoreState} from '../../reducers';
5
- import {Options, SlideFromAPI} from '../../types/common';
8
+ import type {Options, ProgressionFromAPI, SlideFromAPI} from '../../types/common';
9
+ import {setCurrentSlide} from '../ui/slides';
6
10
 
7
11
  export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST' as const;
8
12
  export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS' as const;
@@ -13,12 +17,29 @@ export interface ReceivedSlide extends AnyAction {
13
17
  payload: SlideFromAPI;
14
18
  }
15
19
 
16
- export type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
20
+ export type FetchSlideAction = ThunkAction<Promise<SlideFromAPI>, StoreState, Options, AnyAction>;
17
21
  type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
18
22
 
19
- export const fetchSlide = (slideRef: string, token: string): FetchSlideAction =>
23
+ export const fetchSlide = (
24
+ progressionFromAPI: ProgressionFromAPI,
25
+ token: string
26
+ ): FetchSlideAction =>
20
27
  buildTask({
21
28
  types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
22
- task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) =>
23
- services.fetchSlide(slideRef, token)
29
+ bailout: (state: StoreState): boolean => {
30
+ const {ref: slideRef} = get('state.nextContent', progressionFromAPI);
31
+ return has(`data.slide.${slideRef}`, state);
32
+ },
33
+ task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
34
+ const {ref: slideRef} = get('state.nextContent', progressionFromAPI);
35
+ return services.fetchSlide(slideRef, token).then((slideFromAPI: SlideFromAPI | void) => {
36
+ if (!slideFromAPI) throw new Error('Slide not found');
37
+ const state = getState();
38
+ const slides = get('data.progression.state.slides', state);
39
+ if (isEmpty(slides)) {
40
+ dispatch(setCurrentSlide(slideFromAPI));
41
+ }
42
+ return slideFromAPI;
43
+ });
44
+ }
24
45
  });
@@ -28,8 +28,7 @@ export const postProgression = (skillRef: string, token: string): PostProgressio
28
28
  types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
29
29
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
30
30
  return services.postProgression(skillRef, token).then((progression: ProgressionFromAPI) => {
31
- const {ref} = progression.state.nextContent;
32
- dispatch(fetchSlide(ref, token));
31
+ dispatch(fetchSlide(progression, token));
33
32
  return progression;
34
33
  });
35
34
  }
@@ -1,13 +1,10 @@
1
- import {updateSlidesOnValidation, updateSlidesOnNext, validateSlide} from './data/slides';
2
1
  import {StoreToken} from './data/token';
3
2
 
4
- import {updateFinishedSlides} from './ui/finished-slides';
5
3
  import {navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp} from './ui/navigation';
6
- import {updateReviewStatus} from './ui/review-status';
7
- import {updateStepItemsOnValidation, updateStepItemsOnNext} from './ui/step-items';
8
4
  import {ReceivedSlide} from './api/fetch-slide';
9
5
  import {ReceiveProgression} from './api/post-progression';
10
6
  import {ReceivedSkills} from './api/fetch-skills';
7
+ import {validateSlide} from './ui/slides';
11
8
 
12
9
  export type Action =
13
10
  | NavigateBack
@@ -22,10 +19,4 @@ export type Dispatchers = {
22
19
  navigateTo: typeof navigateTo;
23
20
  navigateBack: typeof navigateBack;
24
21
  validateSlide: typeof validateSlide;
25
- updateSlidesOnValidation: typeof updateSlidesOnValidation;
26
- updateSlidesOnNext: typeof updateSlidesOnNext;
27
- updateReviewStatus: typeof updateReviewStatus;
28
- updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
29
- updateStepItemsOnNext: typeof updateStepItemsOnNext;
30
- updateFinishedSlides: typeof updateFinishedSlides;
31
22
  };
@@ -1,10 +1,6 @@
1
- // -----------------------------------------------------------------------------
2
-
3
1
  export const START_FETCHING = '@@ui/START_FETCHING';
4
2
  export const STOP_FETCHING = '@@ui/STOP_FETCHING';
5
3
 
6
- // -----------------------------------------------------------------------------
7
-
8
4
  export type StartFetching = {
9
5
  type: typeof START_FETCHING;
10
6
  };
@@ -13,7 +9,5 @@ export type StopFetching = {
13
9
  type: typeof STOP_FETCHING;
14
10
  };
15
11
 
16
- // -----------------------------------------------------------------------------
17
-
18
12
  export const startFetching = (): StartFetching => ({type: START_FETCHING});
19
13
  export const stopFetching = (): StopFetching => ({type: STOP_FETCHING});
@@ -0,0 +1,35 @@
1
+ import {SlideFromAPI} from '../../types/common';
2
+ import {AnswerUI} from '../../types/slides';
3
+
4
+ type SlideUIAnimations = 'unstack' | 'restack';
5
+
6
+ export type Slide = {
7
+ questionText?: string;
8
+ answerUI?: AnswerUI;
9
+ hidden?: boolean;
10
+ position: number;
11
+ animationType?: SlideUIAnimations;
12
+ isCorrect?: boolean;
13
+ endReview?: boolean;
14
+ nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
15
+ };
16
+
17
+ export const SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE' as const;
18
+ export type SetCurrentSlide = {
19
+ type: typeof SET_CURRENT_SLIDE;
20
+ payload: SlideFromAPI;
21
+ };
22
+ export const setCurrentSlide = (payload: SlideFromAPI): SetCurrentSlide => ({
23
+ type: SET_CURRENT_SLIDE,
24
+ payload
25
+ });
26
+
27
+ export const VALIDATE_SLIDE = '@@slide/VALIDATE';
28
+ export type ValidateSlide = {
29
+ type: typeof VALIDATE_SLIDE;
30
+ };
31
+ export const validateSlide = (): ValidateSlide => ({
32
+ type: VALIDATE_SLIDE
33
+ });
34
+
35
+ export type UISlidesAction = SetCurrentSlide;
@@ -1,3 +1,5 @@
1
+ import _toString from 'lodash/fp/toString';
2
+
1
3
  export const TOTAL_SLIDES_STACK = 5;
2
4
  export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
3
5
 
@@ -11,4 +13,8 @@ export const VIEWS: {
11
13
  slides: 'slides'
12
14
  };
13
15
 
14
- export const slideNumbers: number[] = [0, 1, 2, 3, 4];
16
+ export const slideIndexes = ['0', '1', '2', '3', '4'] as const;
17
+
18
+ export type SlideIndexes = typeof slideIndexes[number];
19
+
20
+ export const indexToString = (index: number): SlideIndexes => _toString(index) as SlideIndexes;
@@ -1,7 +1,7 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {UISlide} from '../types/slides';
2
+ import {UISlide} from '../types/common';
3
3
 
4
- export const slide: UISlide = {
4
+ export const slide: Pick<UISlide, 'questionText' | 'answerUI'> = {
5
5
  questionText: 'QCM',
6
6
  answerUI: {
7
7
  help: '__help',
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
- import {SlidesViewProps} from '../types/views/slides';
2
+ import {SlidesViewProps, CorrectionPopinProps} from '../types/views/slides';
3
3
 
4
- export const correctionPopinProps: SlidesViewProps['correctionPopinProps'] = {
4
+ export const correctionPopinProps: CorrectionPopinProps = {
5
5
  klf: {
6
6
  label: 'Key learning factor',
7
7
  tooltip: 'Some tooltip info.',
@@ -8,7 +8,6 @@ import {
8
8
  indexOf,
9
9
  isEmpty,
10
10
  map,
11
- noop,
12
11
  pipe,
13
12
  rangeStep,
14
13
  size,
@@ -48,7 +47,8 @@ const qcmProps = (question: QcmQuestion): Qcm => {
48
47
  title: choice.label,
49
48
  selected: includes(choice.label, answers),
50
49
  // TODO: EDIT_CHOICES
51
- onClick: noop,
50
+ // eslint-disable-next-line no-console
51
+ onClick: () => console.log('TODO: on choice click'),
52
52
  ariaLabel: choice.label
53
53
  }),
54
54
  // TODO: EDIT_CHOICES -> getChoices
@@ -58,7 +58,6 @@ const qcmProps = (question: QcmQuestion): Qcm => {
58
58
  };
59
59
 
60
60
  const qcmDragProps = (question: QcmDragQuestion): QcmDrag => {
61
- // mock the answers
62
61
  // TODO: EDIT_CHOICES -> getAnswerValues
63
62
  const answers: string[] = [];
64
63
  return {
@@ -70,7 +69,8 @@ const qcmDragProps = (question: QcmDragQuestion): QcmDrag => {
70
69
  selected: indexInAnswer !== -1,
71
70
  order: indexInAnswer,
72
71
  // TODO: EDIT_CHOICES
73
- onClick: noop
72
+ // eslint-disable-next-line no-console
73
+ onClick: () => console.log('TODO: on choice click')
74
74
  };
75
75
  // TODO: EDIT_CHOICES -> getChoices
76
76
  }, question.content.choices)
@@ -89,7 +89,8 @@ const qcmGraphicProps = (question: QcmGraphicQuestion): QcmGraphic => {
89
89
  image: get('media.src.0.url', choice),
90
90
  selected: includes(choice.label, answers),
91
91
  // TODO: EDIT_CHOICES
92
- onClick: noop
92
+ // eslint-disable-next-line no-console
93
+ onClick: () => console.log('TODO: on choice click')
93
94
  }),
94
95
  // TODO: EDIT_CHOICES -> getChoices
95
96
  question.content.choices
@@ -109,7 +110,8 @@ const templateTextProps =
109
110
  placeholder: translate('Type here'),
110
111
  value: get(index, answers),
111
112
  // TODO: EDIT_CHOICES
112
- onChange: noop
113
+ // eslint-disable-next-line no-console
114
+ onChange: () => console.log('TODO: on choice change')
113
115
  };
114
116
  };
115
117
 
@@ -141,7 +143,8 @@ const templateSelectProps = (uiUtils: UiUtils) => {
141
143
  type: 'select',
142
144
  name: getOr('', 'name', choice),
143
145
  // TODO: EDIT_CHOICES
144
- onChange: noop,
146
+ // eslint-disable-next-line no-console
147
+ onChange: () => console.log('TODO: on choice change'),
145
148
  options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
146
149
  };
147
150
  };
@@ -177,7 +180,8 @@ const basicProps = (uiUtils: UiUtils): (() => FreeText) => {
177
180
  placeholder: translate('Type here'),
178
181
  value: head(answers),
179
182
  // TODO: EDIT_CHOICES
180
- onChange: noop
183
+ // eslint-disable-next-line no-console
184
+ onChange: () => console.log('TODO: on choice change')
181
185
  };
182
186
  };
183
187
  };
@@ -187,7 +191,7 @@ const sliderProps = (question: SliderQuestion): QuestionRange => {
187
191
  getOr(1, 'content.step', question),
188
192
  getOr(Number.NaN, 'content.min', question),
189
193
  getOr(Number.NaN, 'content.max', question) + 1
190
- // Lodash doesn't infere the type very well here
194
+ // Lodash doesn't infer the type very well here
191
195
  ) as unknown as number[];
192
196
 
193
197
  // TODO: EDIT_CHOICES -> getAnswerValues
@@ -209,23 +213,26 @@ const sliderProps = (question: SliderQuestion): QuestionRange => {
209
213
  title: `${currentValue} ${question.content.unitLabel}`,
210
214
  value: sliderPosition,
211
215
  // TODO: EDIT_CHOICES
212
- onChange: noop
216
+ // eslint-disable-next-line no-console
217
+ onChange: () => console.log('TODO: on choice change')
213
218
  };
214
219
  };
215
220
 
216
221
  export const getQuestionType = (slide: SlideFromAPI): SlideFromAPI['question']['type'] =>
217
222
  slide.question.type;
218
223
 
219
- export const mapApiSlideToUi = (
220
- uiUtils: UiUtils
221
- ): ((slide: SlideFromAPI) => AnswerUI['model'] | void) => {
224
+ const getHelp =
225
+ (uiUtils: UiUtils) =>
226
+ (slide: SlideFromAPI): string => {
227
+ const {translate} = uiUtils;
228
+ return get('question.explanation', slide) || translate('Select something below');
229
+ };
230
+
231
+ const getAnswerUIModel = (uiUtils: UiUtils): ((slide: SlideFromAPI) => AnswerUI['model']) => {
222
232
  const basicProps_ = basicProps(uiUtils);
223
233
  const templateProps_ = templateProps(uiUtils);
224
234
 
225
- return (slide: SlideFromAPI): AnswerUI['model'] | void => {
226
- if (!slide) {
227
- return;
228
- }
235
+ return slide => {
229
236
  const type = getQuestionType(slide);
230
237
  switch (type) {
231
238
  case 'qcm':
@@ -251,3 +258,22 @@ export const mapApiSlideToUi = (
251
258
  }
252
259
  };
253
260
  };
261
+
262
+ export const mapApiSlideToUi = (
263
+ uiUtils: UiUtils
264
+ ): ((slide: SlideFromAPI) => {questionText: string; answerUI: AnswerUI}) => {
265
+ const getAnswerUIModel_ = getAnswerUIModel(uiUtils);
266
+ const getHelp_ = getHelp(uiUtils);
267
+
268
+ return slide => {
269
+ if (!slide) {
270
+ throw new Error('no slide was found');
271
+ }
272
+ const questionText = pipe<[SlideFromAPI], string, string>(
273
+ getOr('', 'question.header') as unknown as (_slide: SlideFromAPI) => string,
274
+ uiUtils.translate
275
+ )(slide);
276
+
277
+ return {questionText, answerUI: {model: getAnswerUIModel_(slide), help: getHelp_(slide)}};
278
+ };
279
+ };
@@ -1,6 +1,5 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {FreeText} from '../../../types/slides';
3
- import {SlideFromAPI} from '../../../types/common';
2
+ import {SlideFromAPI, UISlide} from '../../../types/common';
4
3
 
5
4
  export const freeTextSlide: SlideFromAPI = {
6
5
  id: 'sli_E1Pcl-XAYbi',
@@ -20,9 +19,15 @@ export const freeTextSlide: SlideFromAPI = {
20
19
  tips: 'sli_E1Pcl-XAYbi.tips'
21
20
  };
22
21
 
23
- export const freeTextUISlide: FreeText = {
24
- type: 'freeText',
25
- placeholder: 'Type here',
26
- value: undefined,
27
- onChange: noop
22
+ export const freeTextUISlide: Partial<UISlide> = {
23
+ answerUI: {
24
+ help: 'sli_E1Pcl-XAYbi.explanation',
25
+ model: {
26
+ type: 'freeText',
27
+ placeholder: 'Type here',
28
+ value: undefined,
29
+ onChange: noop
30
+ }
31
+ },
32
+ questionText: 'sli_E1Pcl-XAYbi.header'
28
33
  };
@@ -1,6 +1,5 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {QcmDrag} from '../../../types/slides';
3
- import {SlideFromAPI} from '../../../types/common';
2
+ import {SlideFromAPI, UISlide} from '../../../types/common';
4
3
 
5
4
  export const qcmDragSlide: SlideFromAPI = {
6
5
  id: 'sli_419IlQQnf',
@@ -73,38 +72,44 @@ export const qcmDragSlide: SlideFromAPI = {
73
72
  tips: 'sli_419IlQQnf.tips'
74
73
  };
75
74
 
76
- export const qcmDragUISlide: QcmDrag = {
77
- type: 'qcmDrag',
78
- answers: [
79
- {
80
- title: 'sli_419IlQQnf.choice_4kWwlQXhG',
81
- selected: false,
82
- order: -1,
83
- onClick: noop
84
- },
85
- {
86
- title: 'sli_419IlQQnf.choice_NJxbwgXm2G',
87
- selected: false,
88
- order: -1,
89
- onClick: noop
90
- },
91
- {
92
- title: 'sli_419IlQQnf.choice_41fwgQXnf',
93
- selected: false,
94
- order: -1,
95
- onClick: noop
96
- },
97
- {
98
- title: 'sli_419IlQQnf.choice_VJmweQ7nz',
99
- selected: false,
100
- order: -1,
101
- onClick: noop
102
- },
103
- {
104
- title: 'sli_419IlQQnf.choice_4kDDgXQhz',
105
- selected: false,
106
- order: -1,
107
- onClick: noop
75
+ export const qcmDragUISlide: Partial<UISlide> = {
76
+ questionText: 'sli_419IlQQnf.header',
77
+ answerUI: {
78
+ help: 'sli_419IlQQnf.explanation',
79
+ model: {
80
+ type: 'qcmDrag',
81
+ answers: [
82
+ {
83
+ title: 'sli_419IlQQnf.choice_4kWwlQXhG',
84
+ selected: false,
85
+ order: -1,
86
+ onClick: noop
87
+ },
88
+ {
89
+ title: 'sli_419IlQQnf.choice_NJxbwgXm2G',
90
+ selected: false,
91
+ order: -1,
92
+ onClick: noop
93
+ },
94
+ {
95
+ title: 'sli_419IlQQnf.choice_41fwgQXnf',
96
+ selected: false,
97
+ order: -1,
98
+ onClick: noop
99
+ },
100
+ {
101
+ title: 'sli_419IlQQnf.choice_VJmweQ7nz',
102
+ selected: false,
103
+ order: -1,
104
+ onClick: noop
105
+ },
106
+ {
107
+ title: 'sli_419IlQQnf.choice_4kDDgXQhz',
108
+ selected: false,
109
+ order: -1,
110
+ onClick: noop
111
+ }
112
+ ]
108
113
  }
109
- ]
114
+ }
110
115
  };
@@ -1,6 +1,5 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {QcmGraphic} from '../../../types/slides';
3
- import {SlideFromAPI} from '../../../types/common';
2
+ import {SlideFromAPI, UISlide} from '../../../types/common';
4
3
 
5
4
  export const qcmGraphicSlide: SlideFromAPI = {
6
5
  id: 'sli_41~RSVclH',
@@ -55,20 +54,26 @@ export const qcmGraphicSlide: SlideFromAPI = {
55
54
  tips: 'sli_41~RSVclH.tips'
56
55
  };
57
56
 
58
- export const qcmGraphicUISlide: QcmGraphic = {
59
- type: 'qcmGraphic',
60
- answers: [
61
- {
62
- title: 'sli_41~RSVclH.choice_V1gN0r4qgS',
63
- image: 'med_4JVRrE5gH.mediaUrl_VkBtUV9gB',
64
- selected: false,
65
- onClick: noop
66
- },
67
- {
68
- title: 'sli_41~RSVclH.choice_4JlLeLE5lS',
69
- image: 'med_Ek8gIEqxB.mediaUrl_EkcFUEclH',
70
- selected: false,
71
- onClick: noop
57
+ export const qcmGraphicUISlide: Partial<UISlide> = {
58
+ questionText: 'sli_41~RSVclH.header',
59
+ answerUI: {
60
+ help: 'sli_41~RSVclH.explanation',
61
+ model: {
62
+ type: 'qcmGraphic',
63
+ answers: [
64
+ {
65
+ title: 'sli_41~RSVclH.choice_V1gN0r4qgS',
66
+ image: 'med_4JVRrE5gH.mediaUrl_VkBtUV9gB',
67
+ selected: false,
68
+ onClick: noop
69
+ },
70
+ {
71
+ title: 'sli_41~RSVclH.choice_4JlLeLE5lS',
72
+ image: 'med_Ek8gIEqxB.mediaUrl_EkcFUEclH',
73
+ selected: false,
74
+ onClick: noop
75
+ }
76
+ ]
72
77
  }
73
- ]
78
+ }
74
79
  };
@@ -1,6 +1,5 @@
1
1
  import noop from 'lodash/fp/noop';
2
- import {Qcm} from '../../../types/slides';
3
- import {SlideFromAPI} from '../../../types/common';
2
+ import {SlideFromAPI, UISlide} from '../../../types/common';
4
3
 
5
4
  export const qcmSlide: SlideFromAPI = {
6
5
  question: {
@@ -74,35 +73,42 @@ export const qcmSlide: SlideFromAPI = {
74
73
  id: 'sli_N1XACJobn'
75
74
  };
76
75
 
77
- export const qcmUISlide: Qcm = {
78
- type: 'qcm',
79
- answers: [
80
- {
81
- title: 'Le créateur peut fixer un pourcentage pour chaque transaction future',
82
- selected: false,
83
- onClick: noop,
84
- ariaLabel: 'Le créateur peut fixer un pourcentage pour chaque transaction future'
85
- },
86
- {
87
- title:
88
- "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente",
89
- selected: false,
90
- onClick: noop,
91
- ariaLabel:
92
- "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente"
93
- },
94
- {
95
- title: "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT",
96
- selected: false,
97
- onClick: noop,
98
- ariaLabel:
99
- "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT"
100
- },
101
- {
102
- title: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission",
103
- selected: false,
104
- onClick: noop,
105
- ariaLabel: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission"
76
+ export const qcmUISlide: Partial<UISlide> = {
77
+ questionText: "Après la vente d'un NFT, son créateur peut-il toucher de l'argent ?",
78
+ answerUI: {
79
+ help: 'Sélectionnez la bonne réponse.',
80
+ model: {
81
+ type: 'qcm',
82
+ answers: [
83
+ {
84
+ title: 'Le créateur peut fixer un pourcentage pour chaque transaction future',
85
+ selected: false,
86
+ onClick: noop,
87
+ ariaLabel: 'Le créateur peut fixer un pourcentage pour chaque transaction future'
88
+ },
89
+ {
90
+ title:
91
+ "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente",
92
+ selected: false,
93
+ onClick: noop,
94
+ ariaLabel:
95
+ "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente"
96
+ },
97
+ {
98
+ title:
99
+ "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT",
100
+ selected: false,
101
+ onClick: noop,
102
+ ariaLabel:
103
+ "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT"
104
+ },
105
+ {
106
+ title: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission",
107
+ selected: false,
108
+ onClick: noop,
109
+ ariaLabel: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission"
110
+ }
111
+ ]
106
112
  }
107
- ]
113
+ }
108
114
  };