@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
@@ -1,4 +1,5 @@
1
- import { UISlide } from './slides';
1
+ import { SlideIndexes } from '../common';
2
+ import { AnswerUI } from './slides';
2
3
  declare type TemplateContextValues = {
3
4
  brandTheme?: unknown;
4
5
  theme?: unknown;
@@ -68,21 +69,33 @@ export declare type SlideFromAPI = {
68
69
  tips?: string;
69
70
  clue?: string;
70
71
  hasClue?: boolean;
71
- id?: string;
72
+ id: string;
73
+ };
74
+ declare type ProgressionAnswerItem = {
75
+ isCorrect: boolean;
76
+ slideRef: string;
77
+ answer: string[];
78
+ };
79
+ export declare type ProgressionState = {
80
+ allAnswers: ProgressionAnswerItem[];
81
+ content?: {
82
+ ref: string;
83
+ type: string;
84
+ };
85
+ isCorrect: boolean;
86
+ nextContent: {
87
+ type: 'success' | 'slide';
88
+ ref: 'successExitNode' | string;
89
+ };
90
+ pendingSlides: string[];
91
+ slides: string[];
92
+ step: {
93
+ current: number;
94
+ };
72
95
  };
73
96
  export declare type ProgressionFromAPI = {
74
97
  _id: string;
75
- state: {
76
- isCorrect: boolean;
77
- step: {
78
- current: number;
79
- };
80
- nextContent: {
81
- type: 'success' | 'slide';
82
- ref: 'successExitNode' | string;
83
- };
84
- pendingSlides: [];
85
- };
98
+ state: ProgressionState;
86
99
  };
87
100
  export declare type Skill = {
88
101
  skillRef: string;
@@ -116,23 +129,27 @@ export declare type JWT = {
116
129
  host: string;
117
130
  };
118
131
  declare type SlideUIAnimations = 'unstack' | 'restack';
119
- export declare type Slide = UISlide & {
132
+ export declare type NextUISlide = {
133
+ questionText?: string;
134
+ answerUI?: AnswerUI;
120
135
  hidden?: boolean;
121
- position: number;
136
+ position?: number;
122
137
  animationType?: SlideUIAnimations;
123
138
  isCorrect?: boolean;
124
139
  endReview?: boolean;
125
- nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
126
140
  };
127
- declare const ICON_VALUES: {
128
- readonly right: "right";
129
- readonly wrong: "wrong";
130
- readonly 'no-answer': "no-answer";
141
+ export declare type UISlide = {
142
+ questionText?: string;
143
+ answerUI?: AnswerUI;
144
+ hidden?: boolean;
145
+ position: number;
146
+ animationType?: SlideUIAnimations;
147
+ isCorrect?: boolean;
148
+ endReview?: boolean;
149
+ nextContent?: NextUISlide;
131
150
  };
132
- export declare type IconValue = keyof typeof ICON_VALUES;
133
151
  export declare type FinishedSlides = {
134
- slideNumbers: number[];
135
- [key: number]: true;
152
+ [key in SlideIndexes]?: true;
136
153
  };
137
154
  export declare type WithRequired<T, K extends keyof T> = T & {
138
155
  [P in K]-?: T[P];
@@ -1,6 +1 @@
1
- const ICON_VALUES = {
2
- right: 'right',
3
- wrong: 'wrong',
4
- 'no-answer': 'no-answer'
5
- };
6
1
  export {};
@@ -74,7 +74,3 @@ export declare type AnswerUI = {
74
74
  help: string;
75
75
  };
76
76
  export declare type SlideUIAnimations = 'unstack' | 'restack';
77
- export declare type UISlide = {
78
- questionText?: string;
79
- answerUI?: AnswerUI;
80
- };
@@ -1,20 +1,53 @@
1
1
  import type { StoreState } from '../../reducers';
2
2
  import { Dispatchers } from '../../actions';
3
+ declare const ICON_VALUES: {
4
+ readonly right: "right";
5
+ readonly wrong: "wrong";
6
+ readonly 'no-answer': "no-answer";
7
+ };
8
+ declare type IconValue = keyof typeof ICON_VALUES;
9
+ declare type StepItem = {
10
+ current: boolean;
11
+ icon: IconValue;
12
+ value: string;
13
+ };
14
+ declare type CorrectionPopinProps = {
15
+ klf: {
16
+ label: string;
17
+ onClick: Function;
18
+ tooltip: string;
19
+ };
20
+ information: {
21
+ label: string;
22
+ message: string;
23
+ };
24
+ next: {
25
+ label: string;
26
+ ariaLabel: string;
27
+ };
28
+ successLabel: string;
29
+ failureLabel: string;
30
+ };
3
31
  declare type SlidesViewStaticProps = {
4
- slides: StoreState['data']['slides'];
5
- headerProps: {
32
+ header: {
6
33
  mode: string;
7
34
  skillName: string;
8
35
  onQuitClick: Function;
9
36
  'aria-label'?: string;
10
37
  closeButtonAriaLabel: string;
38
+ steps: StepItem[];
11
39
  };
12
- finishedSlides: StoreState['ui']['finishedSlides'];
13
- stepItems: StoreState['ui']['stepItems'];
14
- reviewStatus: StoreState['ui']['reviewStatus'];
15
- validate: {
16
- label: string;
40
+ stack: {
41
+ slides: StoreState['ui']['slides'];
42
+ validateButton: {
43
+ label: string;
44
+ disabled: boolean;
45
+ onClick: Function;
46
+ };
47
+ correctionPopinProps?: CorrectionPopinProps;
48
+ endReview: boolean;
17
49
  };
50
+ reviewBackgroundAriaLabel?: string;
18
51
  congratsProps?: {
19
52
  'aria-label'?: string;
20
53
  'data-name'?: string;
@@ -35,26 +68,7 @@ declare type SlidesViewStaticProps = {
35
68
  type: string;
36
69
  };
37
70
  };
38
- correctionPopinProps?: {
39
- klf: {
40
- label: string;
41
- onClick: Function;
42
- tooltip: string;
43
- };
44
- information: {
45
- label: string;
46
- message: string;
47
- };
48
- next: {
49
- label: string;
50
- ariaLabel: string;
51
- };
52
- successLabel: string;
53
- failureLabel: string;
54
- };
55
- reviewBackgroundAriaLabel?: string;
56
- progression: StoreState['data']['progression'];
57
71
  };
58
72
  declare type SlidesViewDispatcherProps = Omit<Dispatchers, 'navigateTo' | 'navigateBack'>;
59
73
  declare type SlidesViewProps = SlidesViewStaticProps & SlidesViewDispatcherProps;
60
- export { SlidesViewStaticProps, SlidesViewDispatcherProps, SlidesViewProps };
74
+ export { CorrectionPopinProps, IconValue, SlidesViewStaticProps, SlidesViewDispatcherProps, SlidesViewProps, StepItem };
@@ -1 +1,6 @@
1
+ const ICON_VALUES = {
2
+ right: 'right',
3
+ wrong: 'wrong',
4
+ 'no-answer': 'no-answer'
5
+ };
1
6
  export {};
@@ -1,3 +1,4 @@
1
+ import { StoreState } from '../../reducers';
1
2
  declare type SkillCard = {
2
3
  'aria-label': string;
3
4
  skillTitle: string;
@@ -22,3 +23,4 @@ declare type SkillsProps = NoSkillsProps & {
22
23
  listSkills: SkillCard[];
23
24
  };
24
25
  export { SkillsProps };
26
+ export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps | null;
@@ -0,0 +1,25 @@
1
+ export const mapStateToSkillsProps = (state) => {
2
+ if (!state.data.skills) {
3
+ return null;
4
+ }
5
+ return {
6
+ title: '@todo title',
7
+ titleNoSkills: '@todo titleNoSkills',
8
+ textNoSkills: '@todo textNoSkills',
9
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel',
10
+ isLoading: false,
11
+ isLoadingAriaLabel: '@todo loading',
12
+ listSkills: state.data.skills.map(skill => ({
13
+ 'aria-label': '',
14
+ isCustom: skill.custom,
15
+ skillTitle: skill.name,
16
+ skillAriaLabel: '@todo skill aria label',
17
+ buttonLabel: '@todo button',
18
+ buttonAriaLabel: '@todo button aria label',
19
+ reviseLabel: '@todo revise',
20
+ reviseAriaLabel: '@todo revise aria label',
21
+ // eslint-disable-next-line no-console
22
+ onClick: () => console.log('@todo plug dispatcher select skill')
23
+ }))
24
+ };
25
+ };
@@ -0,0 +1,3 @@
1
+ import { StoreState } from '../../reducers';
2
+ import { SlidesViewStaticProps } from '../../types/views/slides';
3
+ export declare const mapStateToSlidesProps: (state: StoreState) => SlidesViewStaticProps | null;
@@ -0,0 +1,85 @@
1
+ import isEmpty from 'lodash/fp/isEmpty';
2
+ const buildStepItemps = (state) => {
3
+ const { progression } = state.data;
4
+ const { currentSlideRef } = state.ui;
5
+ if (!progression)
6
+ return [];
7
+ const defaultProps = [
8
+ {
9
+ icon: 'no-answer',
10
+ current: true,
11
+ value: '1'
12
+ },
13
+ {
14
+ icon: 'no-answer',
15
+ current: false,
16
+ value: '2'
17
+ },
18
+ {
19
+ icon: 'no-answer',
20
+ current: false,
21
+ value: '3'
22
+ },
23
+ {
24
+ icon: 'no-answer',
25
+ current: false,
26
+ value: '4'
27
+ },
28
+ {
29
+ icon: 'no-answer',
30
+ current: false,
31
+ value: '5'
32
+ }
33
+ ];
34
+ const allAnswers = progression.state.allAnswers;
35
+ const step = progression.state.step;
36
+ if (isEmpty(allAnswers))
37
+ return defaultProps;
38
+ const steps = defaultProps.map((stepItem, index) => {
39
+ const givenAnswer = allAnswers[index];
40
+ if (!givenAnswer) {
41
+ return {
42
+ ...stepItem,
43
+ current: step.current === index + 1
44
+ };
45
+ }
46
+ return {
47
+ ...stepItem,
48
+ icon: givenAnswer.isCorrect ? 'right' : 'wrong',
49
+ current: givenAnswer.slideRef === currentSlideRef
50
+ };
51
+ });
52
+ return steps;
53
+ };
54
+ export const mapStateToSlidesProps = (state) => {
55
+ if (!state.data.slides) {
56
+ return null;
57
+ }
58
+ return {
59
+ header: {
60
+ mode: '__revision_mode',
61
+ skillName: '__agility',
62
+ onQuitClick: () => {
63
+ // eslint-disable-next-line no-console
64
+ console.log('onQuitClick');
65
+ },
66
+ 'aria-label': 'aria-header-wrapper',
67
+ closeButtonAriaLabel: 'aria-close-button',
68
+ steps: buildStepItemps(state)
69
+ },
70
+ stack: {
71
+ slides: state.ui.slides,
72
+ validateButton: {
73
+ label: '__validate',
74
+ disabled: true,
75
+ onClick: () => {
76
+ // eslint-disable-next-line no-console
77
+ console.log('TODO: validate question');
78
+ }
79
+ },
80
+ correctionPopinProps: undefined,
81
+ endReview: false
82
+ },
83
+ congratsProps: undefined
84
+ };
85
+ };
@@ -1,7 +1,7 @@
1
1
  import type { AnyAction } from 'redux';
2
2
  import type { ThunkAction } from 'redux-thunk';
3
3
  import type { StoreState } from '../../reducers';
4
- import { Options, SlideFromAPI } from '../../types/common';
4
+ import type { Options, ProgressionFromAPI, SlideFromAPI } from '../../types/common';
5
5
  export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
6
6
  export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
7
7
  export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
@@ -9,5 +9,5 @@ export interface ReceivedSlide extends AnyAction {
9
9
  type: typeof SLIDE_FETCH_SUCCESS;
10
10
  payload: SlideFromAPI;
11
11
  }
12
- export declare type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
- export declare const fetchSlide: (slideRef: string, token: string) => FetchSlideAction;
12
+ export declare type FetchSlideAction = ThunkAction<Promise<SlideFromAPI>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSlide: (progressionFromAPI: ProgressionFromAPI, token: string) => FetchSlideAction;
@@ -1,13 +1,31 @@
1
1
  import buildTask from '@coorpacademy/redux-task';
2
+ import get from 'lodash/fp/get';
3
+ import has from 'lodash/fp/has';
4
+ import isEmpty from 'lodash/fp/isEmpty';
5
+ import { setCurrentSlide } from '../ui/slides';
2
6
  export var SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
3
7
  export var SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
4
8
  export var SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
5
- export var fetchSlide = function (slideRef, token) {
9
+ export var fetchSlide = function (progressionFromAPI, token) {
6
10
  return buildTask({
7
11
  types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
12
+ bailout: function (state) {
13
+ var slideRef = get('state.nextContent', progressionFromAPI).ref;
14
+ return has("data.slide.".concat(slideRef), state);
15
+ },
8
16
  task: function (dispatch, getState, _a) {
9
17
  var services = _a.services;
10
- return services.fetchSlide(slideRef, token);
18
+ var slideRef = get('state.nextContent', progressionFromAPI).ref;
19
+ return services.fetchSlide(slideRef, token).then(function (slideFromAPI) {
20
+ if (!slideFromAPI)
21
+ throw new Error('Slide not found');
22
+ var state = getState();
23
+ var slides = get('data.progression.state.slides', state);
24
+ if (isEmpty(slides)) {
25
+ dispatch(setCurrentSlide(slideFromAPI));
26
+ }
27
+ return slideFromAPI;
28
+ });
11
29
  }
12
30
  });
13
31
  };
@@ -9,8 +9,7 @@ export var postProgression = function (skillRef, token) {
9
9
  task: function (dispatch, getState, _a) {
10
10
  var services = _a.services;
11
11
  return services.postProgression(skillRef, token).then(function (progression) {
12
- var ref = progression.state.nextContent.ref;
13
- dispatch(fetchSlide(ref, token));
12
+ dispatch(fetchSlide(progression, token));
14
13
  return progression;
15
14
  });
16
15
  }
@@ -1,21 +1,12 @@
1
- import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
2
1
  import { StoreToken } from './data/token';
3
- import { updateFinishedSlides } from './ui/finished-slides';
4
2
  import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
5
- import { updateReviewStatus } from './ui/review-status';
6
- import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
7
3
  import { ReceivedSlide } from './api/fetch-slide';
8
4
  import { ReceiveProgression } from './api/post-progression';
9
5
  import { ReceivedSkills } from './api/fetch-skills';
6
+ import { validateSlide } from './ui/slides';
10
7
  export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
11
8
  export declare type Dispatchers = {
12
9
  navigateTo: typeof navigateTo;
13
10
  navigateBack: typeof navigateBack;
14
11
  validateSlide: typeof validateSlide;
15
- updateSlidesOnValidation: typeof updateSlidesOnValidation;
16
- updateSlidesOnNext: typeof updateSlidesOnNext;
17
- updateReviewStatus: typeof updateReviewStatus;
18
- updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
19
- updateStepItemsOnNext: typeof updateStepItemsOnNext;
20
- updateFinishedSlides: typeof updateFinishedSlides;
21
12
  };
@@ -1,6 +1,4 @@
1
- // -----------------------------------------------------------------------------
2
1
  export var START_FETCHING = '@@ui/START_FETCHING';
3
2
  export var STOP_FETCHING = '@@ui/STOP_FETCHING';
4
- // -----------------------------------------------------------------------------
5
3
  export var startFetching = function () { return ({ type: START_FETCHING }); };
6
4
  export var stopFetching = function () { return ({ type: STOP_FETCHING }); };
@@ -0,0 +1,26 @@
1
+ import { SlideFromAPI } from '../../types/common';
2
+ import { AnswerUI } from '../../types/slides';
3
+ declare type SlideUIAnimations = 'unstack' | 'restack';
4
+ export declare type Slide = {
5
+ questionText?: string;
6
+ answerUI?: AnswerUI;
7
+ hidden?: boolean;
8
+ position: number;
9
+ animationType?: SlideUIAnimations;
10
+ isCorrect?: boolean;
11
+ endReview?: boolean;
12
+ nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
13
+ };
14
+ export declare const SET_CURRENT_SLIDE: "@@slide/SET_CURRENT_SLIDE";
15
+ export declare type SetCurrentSlide = {
16
+ type: typeof SET_CURRENT_SLIDE;
17
+ payload: SlideFromAPI;
18
+ };
19
+ export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlide;
20
+ export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
21
+ export declare type ValidateSlide = {
22
+ type: typeof VALIDATE_SLIDE;
23
+ };
24
+ export declare const validateSlide: () => ValidateSlide;
25
+ export declare type UISlidesAction = SetCurrentSlide;
26
+ export {};
@@ -0,0 +1,9 @@
1
+ export var SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE';
2
+ export var setCurrentSlide = function (payload) { return ({
3
+ type: SET_CURRENT_SLIDE,
4
+ payload: payload
5
+ }); };
6
+ export var VALIDATE_SLIDE = '@@slide/VALIDATE';
7
+ export var validateSlide = function () { return ({
8
+ type: VALIDATE_SLIDE
9
+ }); };
@@ -5,4 +5,6 @@ export declare const VIEWS: {
5
5
  readonly onboarding: 'onboarding';
6
6
  readonly slides: 'slides';
7
7
  };
8
- export declare const slideNumbers: number[];
8
+ export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
9
+ export declare type SlideIndexes = typeof slideIndexes[number];
10
+ export declare const indexToString: (index: number) => SlideIndexes;
@@ -1,3 +1,4 @@
1
+ import _toString from 'lodash/fp/toString';
1
2
  export var TOTAL_SLIDES_STACK = 5;
2
3
  export var HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
3
4
  export var VIEWS = {
@@ -5,4 +6,5 @@ export var VIEWS = {
5
6
  onboarding: 'onboarding',
6
7
  slides: 'slides'
7
8
  };
8
- export var slideNumbers = [0, 1, 2, 3, 4];
9
+ export var slideIndexes = ['0', '1', '2', '3', '4'];
10
+ export var indexToString = function (index) { return _toString(index); };
@@ -1,2 +1,2 @@
1
- import { UISlide } from '../types/slides';
2
- export declare const slide: UISlide;
1
+ import { UISlide } from '../types/common';
2
+ export declare const slide: Pick<UISlide, 'questionText' | 'answerUI'>;
@@ -1,3 +1,3 @@
1
- import { SlidesViewProps } from '../types/views/slides';
2
- export declare const correctionPopinProps: SlidesViewProps['correctionPopinProps'];
1
+ import { SlidesViewProps, CorrectionPopinProps } from '../types/views/slides';
2
+ export declare const correctionPopinProps: CorrectionPopinProps;
3
3
  export declare const congratsProps: SlidesViewProps['congratsProps'];
@@ -4,5 +4,8 @@ declare type UiUtils = {
4
4
  translate: (text: string) => string;
5
5
  };
6
6
  export declare const getQuestionType: (slide: SlideFromAPI) => SlideFromAPI['question']['type'];
7
- export declare const mapApiSlideToUi: (uiUtils: UiUtils) => (slide: SlideFromAPI) => AnswerUI['model'] | void;
7
+ export declare const mapApiSlideToUi: (uiUtils: UiUtils) => (slide: SlideFromAPI) => {
8
+ questionText: string;
9
+ answerUI: AnswerUI;
10
+ };
8
11
  export {};
@@ -1,4 +1,4 @@
1
- import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, noop, pipe, rangeStep, size, toInteger } from 'lodash/fp';
1
+ import { concat, divide, get, getOr, head, includes, indexOf, isEmpty, map, pipe, rangeStep, size, toInteger } from 'lodash/fp';
2
2
  var qcmProps = function (question) {
3
3
  // TODO: EDIT_CHOICES -> getAnswerValues
4
4
  var answers = [];
@@ -8,7 +8,8 @@ var qcmProps = function (question) {
8
8
  title: choice.label,
9
9
  selected: includes(choice.label, answers),
10
10
  // TODO: EDIT_CHOICES
11
- onClick: noop,
11
+ // eslint-disable-next-line no-console
12
+ onClick: function () { return console.log('TODO: on choice click'); },
12
13
  ariaLabel: choice.label
13
14
  }); },
14
15
  // TODO: EDIT_CHOICES -> getChoices
@@ -16,7 +17,6 @@ var qcmProps = function (question) {
16
17
  };
17
18
  };
18
19
  var qcmDragProps = function (question) {
19
- // mock the answers
20
20
  // TODO: EDIT_CHOICES -> getAnswerValues
21
21
  var answers = [];
22
22
  return {
@@ -28,7 +28,8 @@ var qcmDragProps = function (question) {
28
28
  selected: indexInAnswer !== -1,
29
29
  order: indexInAnswer,
30
30
  // TODO: EDIT_CHOICES
31
- onClick: noop
31
+ // eslint-disable-next-line no-console
32
+ onClick: function () { return console.log('TODO: on choice click'); }
32
33
  };
33
34
  // TODO: EDIT_CHOICES -> getChoices
34
35
  }, question.content.choices)
@@ -45,7 +46,8 @@ var qcmGraphicProps = function (question) {
45
46
  image: get('media.src.0.url', choice),
46
47
  selected: includes(choice.label, answers),
47
48
  // TODO: EDIT_CHOICES
48
- onClick: noop
49
+ // eslint-disable-next-line no-console
50
+ onClick: function () { return console.log('TODO: on choice click'); }
49
51
  }); },
50
52
  // TODO: EDIT_CHOICES -> getChoices
51
53
  question.content.choices)
@@ -62,7 +64,8 @@ var templateTextProps = function (uiUtils) {
62
64
  placeholder: translate('Type here'),
63
65
  value: get(index, answers),
64
66
  // TODO: EDIT_CHOICES
65
- onChange: noop
67
+ // eslint-disable-next-line no-console
68
+ onChange: function () { return console.log('TODO: on choice change'); }
66
69
  };
67
70
  };
68
71
  };
@@ -92,7 +95,8 @@ var templateSelectProps = function (uiUtils) {
92
95
  type: 'select',
93
96
  name: getOr('', 'name', choice),
94
97
  // TODO: EDIT_CHOICES
95
- onChange: noop,
98
+ // eslint-disable-next-line no-console
99
+ onChange: function () { return console.log('TODO: on choice change'); },
96
100
  options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
97
101
  };
98
102
  };
@@ -124,13 +128,14 @@ var basicProps = function (uiUtils) {
124
128
  placeholder: translate('Type here'),
125
129
  value: head(answers),
126
130
  // TODO: EDIT_CHOICES
127
- onChange: noop
131
+ // eslint-disable-next-line no-console
132
+ onChange: function () { return console.log('TODO: on choice change'); }
128
133
  };
129
134
  };
130
135
  };
131
136
  var sliderProps = function (question) {
132
137
  var values = rangeStep(getOr(1, 'content.step', question), getOr(Number.NaN, 'content.min', question), getOr(Number.NaN, 'content.max', question) + 1
133
- // Lodash doesn't infere the type very well here
138
+ // Lodash doesn't infer the type very well here
134
139
  );
135
140
  // TODO: EDIT_CHOICES -> getAnswerValues
136
141
  var answers = [];
@@ -147,19 +152,23 @@ var sliderProps = function (question) {
147
152
  title: "".concat(currentValue, " ").concat(question.content.unitLabel),
148
153
  value: sliderPosition,
149
154
  // TODO: EDIT_CHOICES
150
- onChange: noop
155
+ // eslint-disable-next-line no-console
156
+ onChange: function () { return console.log('TODO: on choice change'); }
151
157
  };
152
158
  };
153
159
  export var getQuestionType = function (slide) {
154
160
  return slide.question.type;
155
161
  };
156
- export var mapApiSlideToUi = function (uiUtils) {
162
+ var getHelp = function (uiUtils) {
163
+ return function (slide) {
164
+ var translate = uiUtils.translate;
165
+ return get('question.explanation', slide) || translate('Select something below');
166
+ };
167
+ };
168
+ var getAnswerUIModel = function (uiUtils) {
157
169
  var basicProps_ = basicProps(uiUtils);
158
170
  var templateProps_ = templateProps(uiUtils);
159
171
  return function (slide) {
160
- if (!slide) {
161
- return;
162
- }
163
172
  var type = getQuestionType(slide);
164
173
  switch (type) {
165
174
  case 'qcm':
@@ -179,3 +188,14 @@ export var mapApiSlideToUi = function (uiUtils) {
179
188
  }
180
189
  };
181
190
  };
191
+ export var mapApiSlideToUi = function (uiUtils) {
192
+ var getAnswerUIModel_ = getAnswerUIModel(uiUtils);
193
+ var getHelp_ = getHelp(uiUtils);
194
+ return function (slide) {
195
+ if (!slide) {
196
+ throw new Error('no slide was found');
197
+ }
198
+ var questionText = pipe(getOr('', 'question.header'), uiUtils.translate)(slide);
199
+ return { questionText: questionText, answerUI: { model: getAnswerUIModel_(slide), help: getHelp_(slide) } };
200
+ };
201
+ };
@@ -1,4 +1,3 @@
1
- import { FreeText } from '../../../types/slides';
2
- import { SlideFromAPI } from '../../../types/common';
1
+ import { SlideFromAPI, UISlide } from '../../../types/common';
3
2
  export declare const freeTextSlide: SlideFromAPI;
4
- export declare const freeTextUISlide: FreeText;
3
+ export declare const freeTextUISlide: Partial<UISlide>;
@@ -17,8 +17,14 @@ export var freeTextSlide = {
17
17
  tips: 'sli_E1Pcl-XAYbi.tips'
18
18
  };
19
19
  export var freeTextUISlide = {
20
- type: 'freeText',
21
- placeholder: 'Type here',
22
- value: undefined,
23
- onChange: noop
20
+ answerUI: {
21
+ help: 'sli_E1Pcl-XAYbi.explanation',
22
+ model: {
23
+ type: 'freeText',
24
+ placeholder: 'Type here',
25
+ value: undefined,
26
+ onChange: noop
27
+ }
28
+ },
29
+ questionText: 'sli_E1Pcl-XAYbi.header'
24
30
  };