@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,125 +1,16 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import map from 'lodash/fp/map';
13
- import { UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../../actions/data/slides';
14
- import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
15
- import { slide as qcmSlide } from '../../fixtures/qcm-slide';
1
+ import set from 'lodash/fp/set';
16
2
  import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
17
- var getInitialState = function () {
18
- var state = {
19
- slideNumbers: slideNumbers
20
- };
21
- // eslint-disable-next-line fp/no-loops
22
- for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
23
- state[index] = { hidden: false, position: index };
24
- }
25
- return state;
26
- };
27
- export var initialState = getInitialState();
28
- // -----------------------------------------------------------------------------
29
- var setFirstSlide = function (state, slide) {
30
- var _state = {
31
- slideNumbers: slideNumbers
32
- };
33
- // eslint-disable-next-line lodash-fp/no-unused-result
34
- map(function (index) {
35
- var previousValue = state[index];
36
- // Only update the 1st one
37
- var content = index === 0 ? __assign(__assign({}, previousValue), slide) : __assign({}, previousValue);
38
- _state[index] = __assign({}, content);
39
- }, state.slideNumbers);
40
- return _state;
41
- };
42
- // ||-------> Handles the updates of a given slide on validation,
43
- // & then updates de remaining slides if this given change should impact their content
44
- var stateUpdateOnValidation = function (state, payload) {
45
- var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides, nextContent = payload.nextContent;
46
- var _state = {
47
- slideNumbers: slideNumbers
48
- };
49
- // eslint-disable-next-line lodash-fp/no-unused-result
50
- map(function (index) {
51
- var previousValue = state[index];
52
- // the current slide
53
- if (index === slideNumber) {
54
- // only one slide remaining, presets the next value
55
- if (numberOfFinishedSlides === HIGHEST_INDEX) {
56
- _state[index] = __assign(__assign({}, previousValue), { nextContent: nextContent, position: newSlideContent.position, isCorrect: newSlideContent.isCorrect });
57
- }
58
- else
59
- _state[slideNumber] = __assign(__assign({}, previousValue), newSlideContent);
60
- }
61
- else {
62
- // updates the rest of the slides here
63
- var hidden = previousValue.hidden, position = previousValue.position;
64
- _state[index] = __assign(__assign({}, nextContent), { endReview: newSlideContent.endReview, hidden: hidden, position: position });
65
- }
66
- }, state.slideNumbers);
67
- return _state;
68
- };
69
- // ||-------> Handles the updates of a given slide on correction popin's next click,
70
- // & then updates de remaining slides (updates position to trigger animations)
71
- var stateUpdateOnNext = function (state, payload) {
72
- var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides;
73
- var _state = {
74
- slideNumbers: slideNumbers
75
- };
76
- // eslint-disable-next-line lodash-fp/no-unused-result
77
- map(function (index) {
78
- var previousValue = state[index];
79
- // the current slide
80
- if (index === slideNumber) {
81
- // when there is only one slide remaining, updates the slide value
82
- if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextContent) {
83
- _state[index] = __assign(__assign({}, previousValue.nextContent), { position: previousValue.position });
84
- }
85
- else
86
- _state[slideNumber] = newSlideContent;
87
- }
88
- else {
89
- // updates the rest of the slides here
90
- var hidden = previousValue.hidden, position = previousValue.position, answerUI = previousValue.answerUI, questionText = previousValue.questionText;
91
- _state[index] = {
92
- hidden: hidden,
93
- position: position - 1,
94
- answerUI: answerUI,
95
- questionText: questionText,
96
- endReview: newSlideContent.endReview
97
- };
98
- }
99
- }, state.slideNumbers);
100
- return _state;
101
- };
102
- // -----------------------------------------------------------------------------
3
+ export var initialState = {};
103
4
  // eslint-disable-next-line default-param-last
104
5
  var reducer = function (state, action) {
105
6
  if (state === void 0) { state = initialState; }
106
7
  switch (action.type) {
107
8
  case SLIDE_FETCH_SUCCESS: {
108
- // TODO: An intermediate slide transform is needed here (or in fetchSlide)
109
- // const apiSlide = action.payload;
110
- // apiSlide adapt to uiSlide
111
- var uiSlide = qcmSlide;
112
- return setFirstSlide(state, uiSlide);
113
- }
114
- case UPDATE_SLIDES_ON_VALIDATION: {
115
- return stateUpdateOnValidation(state, action.payload);
116
- }
117
- case UPDATE_SLIDES_ON_NEXT: {
118
- return stateUpdateOnNext(state, action.payload);
9
+ var slide = action.payload;
10
+ return set(slide.id, slide, state);
119
11
  }
120
12
  default:
121
13
  return state;
122
14
  }
123
15
  };
124
- // -----------------------------------------------------------------------------
125
16
  export default reducer;
@@ -12,10 +12,9 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
12
12
  token: import("./data/token").TokenState;
13
13
  }>;
14
14
  ui: import("redux").CombinedState<{
15
- finishedSlides: import("./ui/finished-slides").FinishedSlidesState;
15
+ currentSlideRef: string;
16
16
  navigation: import("./ui/navigation").NavigationState;
17
- reviewStatus: import("./ui/review-status").ReviewStatusState;
18
- stepItems: import("./ui/step-items").StepItemsState;
17
+ slides: import("./ui/slides").UISlidesState;
19
18
  }>;
20
- }>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("../actions/data/token").StoreToken | import("../actions/ui/finished-slides").UpdateFinishedSlides | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/review-status").UpdateReviewStatus | import("../actions/ui/step-items").StepItemsAction>;
19
+ }>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack>;
21
20
  export default _default;
@@ -0,0 +1,4 @@
1
+ import { UISlidesAction } from '../../actions/ui/slides';
2
+ export declare type CurrentSlideRefState = string;
3
+ declare const reducer: (state: string | undefined, action: UISlidesAction) => CurrentSlideRefState;
4
+ export default reducer;
@@ -1,11 +1,11 @@
1
- import { UPDATE_REVIEW_STATUS } from '../../actions/ui/review-status';
1
+ import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
2
2
  var reducer = function (
3
3
  // eslint-disable-next-line default-param-last
4
4
  state, action) {
5
- if (state === void 0) { state = 'ongoing'; }
5
+ if (state === void 0) { state = ''; }
6
6
  switch (action.type) {
7
- case UPDATE_REVIEW_STATUS: {
8
- return action.payload;
7
+ case SET_CURRENT_SLIDE: {
8
+ return action.payload.id;
9
9
  }
10
10
  default:
11
11
  return state;
@@ -1,17 +1,14 @@
1
- import { FinishedSlidesState } from './finished-slides';
1
+ import { CurrentSlideRefState } from './current-slide-ref';
2
2
  import { NavigationState } from './navigation';
3
- import { ReviewStatusState } from './review-status';
4
- import { StepItemsState } from './step-items';
3
+ import { UISlidesState } from './slides';
5
4
  export declare type UIState = {
5
+ currentSlideRef: CurrentSlideRefState;
6
6
  navigation: NavigationState;
7
- stepItems: StepItemsState;
8
- finishedSlides: FinishedSlidesState;
9
- reviewStatus: ReviewStatusState;
7
+ slides: UISlidesState;
10
8
  };
11
9
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
12
- finishedSlides: FinishedSlidesState;
10
+ currentSlideRef: string;
13
11
  navigation: NavigationState;
14
- reviewStatus: ReviewStatusState;
15
- stepItems: StepItemsState;
16
- }>, import("../../actions/ui/finished-slides").UpdateFinishedSlides | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/review-status").UpdateReviewStatus | import("../../actions/ui/step-items").StepItemsAction>;
12
+ slides: UISlidesState;
13
+ }>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack>;
17
14
  export default _default;
@@ -1,11 +1,9 @@
1
1
  import { combineReducers } from 'redux';
2
- import finishedSlides from './finished-slides';
2
+ import currentSlideRef from './current-slide-ref';
3
3
  import navigation from './navigation';
4
- import reviewStatus from './review-status';
5
- import stepItems from './step-items';
4
+ import slides from './slides';
6
5
  export default combineReducers({
7
- finishedSlides: finishedSlides,
6
+ currentSlideRef: currentSlideRef,
8
7
  navigation: navigation,
9
- reviewStatus: reviewStatus,
10
- stepItems: stepItems
8
+ slides: slides
11
9
  });
@@ -0,0 +1,9 @@
1
+ import type { UISlide } from '../../types/common';
2
+ import { SlideIndexes } from '../../common';
3
+ import { UISlidesAction } from '../../actions/ui/slides';
4
+ export declare type UISlidesState = {
5
+ [key in SlideIndexes]: UISlide;
6
+ };
7
+ export declare const initialState: UISlidesState;
8
+ declare const reducer: (state: UISlidesState | undefined, action: UISlidesAction) => UISlidesState;
9
+ export default reducer;
@@ -0,0 +1,43 @@
1
+ import pipe from 'lodash/fp/pipe';
2
+ import set from 'lodash/fp/set';
3
+ import { mapApiSlideToUi } from '../../helpers/map-api-slide-to-ui';
4
+ import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
5
+ export var initialState = {
6
+ '0': {
7
+ hidden: false,
8
+ position: 0
9
+ },
10
+ '1': {
11
+ hidden: false,
12
+ position: 1
13
+ },
14
+ '2': {
15
+ hidden: false,
16
+ position: 2
17
+ },
18
+ '3': {
19
+ hidden: false,
20
+ position: 3
21
+ },
22
+ '4': {
23
+ hidden: false,
24
+ position: 4
25
+ }
26
+ };
27
+ var setFirstSlide = function (state, slideFromAPI) {
28
+ var _a = mapApiSlideToUi({ translate: function (text) { return text; } })(slideFromAPI), questionText = _a.questionText, answerUI = _a.answerUI;
29
+ return pipe(set(['0', 'questionText'], questionText), set(['0', 'answerUI'], answerUI), set(['0', 'parentContentTitle'], 'Parent Title') // TODO parentContentTitle + translate
30
+ )(state);
31
+ };
32
+ // eslint-disable-next-line default-param-last
33
+ var reducer = function (state, action) {
34
+ if (state === void 0) { state = initialState; }
35
+ switch (action.type) {
36
+ case SET_CURRENT_SLIDE: {
37
+ return setFirstSlide(state, action.payload);
38
+ }
39
+ default:
40
+ return state;
41
+ }
42
+ };
43
+ export default reducer;
@@ -41,15 +41,17 @@ var skillRef = '_skill-ref';
41
41
  var result = {
42
42
  _id: '123456123456',
43
43
  state: {
44
+ allAnswers: [],
44
45
  isCorrect: true,
45
- step: {
46
- current: 1
47
- },
48
46
  nextContent: {
49
47
  type: 'slide',
50
48
  ref: 'sli_NJ3m5KtWh'
51
49
  },
52
- pendingSlides: []
50
+ pendingSlides: [],
51
+ slides: [],
52
+ step: {
53
+ current: 1
54
+ }
53
55
  }
54
56
  };
55
57
  test.before(function () {
@@ -18,12 +18,15 @@ export var services = {
18
18
  slidesToReview: 2,
19
19
  name: 'skill-test',
20
20
  custom: false
21
+ // TODO parentContentTitle
21
22
  },
22
23
  {
23
24
  skillRef: '_skill-ref-2',
24
25
  slidesToReview: 2,
25
26
  name: 'skill-test-2',
26
- custom: true
27
+ custom: true,
28
+ parentContentTitle: 'parentContentTitle 2'
29
+ // TODO parentContentTitle
27
30
  }
28
31
  ]);
29
32
  },
@@ -33,15 +36,24 @@ export var services = {
33
36
  postProgression: function () {
34
37
  return Promise.resolve({
35
38
  _id: '62b1d1087aa12f00253f40ee',
39
+ content: {
40
+ ref: '_skill-ref',
41
+ type: 'skill'
42
+ },
43
+ engine: {
44
+ ref: 'review'
45
+ },
36
46
  state: {
37
- pendingSlides: [],
38
- step: {
39
- current: 1
40
- },
47
+ allAnswers: [],
41
48
  isCorrect: true,
42
49
  nextContent: {
43
50
  ref: 'sli_N1XACJobn',
44
51
  type: 'slide'
52
+ },
53
+ pendingSlides: [],
54
+ slides: [],
55
+ step: {
56
+ current: 1
45
57
  }
46
58
  }
47
59
  });
@@ -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
- var 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
+ var 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 var mapStateToSkillsProps = function (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(function (skill) { return ({
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: function () { return 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,89 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import isEmpty from 'lodash/fp/isEmpty';
13
+ var buildStepItemps = function (state) {
14
+ var progression = state.data.progression;
15
+ var currentSlideRef = state.ui.currentSlideRef;
16
+ if (!progression)
17
+ return [];
18
+ var defaultProps = [
19
+ {
20
+ icon: 'no-answer',
21
+ current: true,
22
+ value: '1'
23
+ },
24
+ {
25
+ icon: 'no-answer',
26
+ current: false,
27
+ value: '2'
28
+ },
29
+ {
30
+ icon: 'no-answer',
31
+ current: false,
32
+ value: '3'
33
+ },
34
+ {
35
+ icon: 'no-answer',
36
+ current: false,
37
+ value: '4'
38
+ },
39
+ {
40
+ icon: 'no-answer',
41
+ current: false,
42
+ value: '5'
43
+ }
44
+ ];
45
+ var allAnswers = progression.state.allAnswers;
46
+ var step = progression.state.step;
47
+ if (isEmpty(allAnswers))
48
+ return defaultProps;
49
+ var steps = defaultProps.map(function (stepItem, index) {
50
+ var givenAnswer = allAnswers[index];
51
+ if (!givenAnswer) {
52
+ return __assign(__assign({}, stepItem), { current: step.current === index + 1 });
53
+ }
54
+ return __assign(__assign({}, stepItem), { icon: givenAnswer.isCorrect ? 'right' : 'wrong', current: givenAnswer.slideRef === currentSlideRef });
55
+ });
56
+ return steps;
57
+ };
58
+ export var mapStateToSlidesProps = function (state) {
59
+ if (!state.data.slides) {
60
+ return null;
61
+ }
62
+ return {
63
+ header: {
64
+ mode: '__revision_mode',
65
+ skillName: '__agility',
66
+ onQuitClick: function () {
67
+ // eslint-disable-next-line no-console
68
+ console.log('onQuitClick');
69
+ },
70
+ 'aria-label': 'aria-header-wrapper',
71
+ closeButtonAriaLabel: 'aria-close-button',
72
+ steps: buildStepItemps(state)
73
+ },
74
+ stack: {
75
+ slides: state.ui.slides,
76
+ validateButton: {
77
+ label: '__validate',
78
+ disabled: true,
79
+ onClick: function () {
80
+ // eslint-disable-next-line no-console
81
+ console.log('TODO: validate question');
82
+ }
83
+ },
84
+ correctionPopinProps: undefined,
85
+ endReview: false
86
+ },
87
+ congratsProps: undefined
88
+ };
89
+ };