@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,116 +0,0 @@
1
- import get from 'lodash/fp/get';
2
- import has from 'lodash/fp/has';
3
- import map from 'lodash/fp/map';
4
- import {IconValue, FinishedSlides} from '../../types/common';
5
- import {
6
- StepItemsAction,
7
- UPDATE_STEP_ITEMS_ON_NEXT,
8
- UPDATE_STEP_ITEMS_ON_VALIDATION
9
- } from '../../actions/ui/step-items';
10
- import {HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK} from '../../common';
11
-
12
- export type StepItem = {
13
- current: boolean;
14
- icon: IconValue;
15
- value: string;
16
- };
17
-
18
- export type StepItemsState = {
19
- slideNumbers: number[];
20
- [key: number]: StepItem;
21
- };
22
-
23
- const getInitialState = (): StepItemsState => {
24
- const state: StepItemsState = {
25
- slideNumbers
26
- };
27
-
28
- // eslint-disable-next-line fp/no-loops
29
- for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
30
- const current = index === 0;
31
- state[index] = {current, value: `${index + 1}`, icon: 'no-answer'};
32
- }
33
- return state;
34
- };
35
-
36
- export const initialState: StepItemsState = getInitialState();
37
-
38
- // -----------------------------------------------------------------------------
39
-
40
- // ||-------> aux function, finds the next consecutive index
41
- // to loop from 0 to HIGHEST_INDEX (4) & again to 0
42
- const getNextIndex = (currentIndex: number): number =>
43
- currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
44
-
45
- // ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
46
- // they have to be skipped)
47
- const calculateNextStepIndex = (
48
- currentStepNumber: number,
49
- finishedSlides: FinishedSlides,
50
- lastVisitedIndex = -1
51
- ): number => {
52
- // only one slide remaining, the step should stay on the same number
53
- if (lastVisitedIndex === currentStepNumber) {
54
- return currentStepNumber;
55
- }
56
-
57
- const indexToVisit = getNextIndex(lastVisitedIndex === -1 ? currentStepNumber : lastVisitedIndex);
58
-
59
- // if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
60
- return has(indexToVisit, finishedSlides)
61
- ? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
62
- : indexToVisit;
63
- };
64
-
65
- type StepItemToUpdateProps =
66
- | Pick<StepItem, 'icon'>
67
- | (Pick<StepItem, 'current'> & {nextIndex: number});
68
-
69
- const recalculateStepItemsState = (
70
- state: StepItemsState,
71
- stepNumber: number,
72
- stepItemToUpdateProps: StepItemToUpdateProps
73
- ): StepItemsState => {
74
- const nextIndex: number = get('nextIndex', stepItemToUpdateProps);
75
- const _state: StepItemsState = {
76
- slideNumbers
77
- };
78
-
79
- // eslint-disable-next-line lodash-fp/no-unused-result
80
- map(index => {
81
- const previousValue = state[index];
82
- if (stepNumber === index)
83
- _state[stepNumber] = {
84
- ...previousValue,
85
- ...stepItemToUpdateProps
86
- };
87
- /* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
88
- _state[index] = {...previousValue, current: true};
89
- } else _state[index] = previousValue;
90
- }, state.slideNumbers);
91
-
92
- return _state;
93
- };
94
-
95
- // -----------------------------------------------------------------------------
96
-
97
- // eslint-disable-next-line default-param-last
98
- const reducer = (state: StepItemsState = initialState, action: StepItemsAction): StepItemsState => {
99
- switch (action.type) {
100
- case UPDATE_STEP_ITEMS_ON_VALIDATION: {
101
- const {stepNumber, icon} = action.payload;
102
- return recalculateStepItemsState(state, stepNumber, {icon});
103
- }
104
- case UPDATE_STEP_ITEMS_ON_NEXT: {
105
- const {stepNumber, finishedSlides, current} = action.payload;
106
- const nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : -1;
107
- return recalculateStepItemsState(state, stepNumber, {current, nextIndex});
108
- }
109
- default:
110
- return state;
111
- }
112
- };
113
-
114
- // -----------------------------------------------------------------------------
115
-
116
- export default reducer;
@@ -1,25 +0,0 @@
1
- export type UiProgression = {
2
- _id?: string;
3
- // virtual field
4
- slideNumber?: number;
5
- isCorrect?: boolean;
6
- // pass down the successExitNode if all slides are finished, not before
7
- exitNode?: 'successExitNode' | 'failExitNode';
8
- // TODO: create another action, to retrieve the next slide
9
- // ex: nextContent: {ref: "sli_E1n2i2sBo", type: "slide"}
10
- // the middleware should trigger a nextContent request once the result is
11
- // received && update the state accordingly
12
- // nextContent?: {
13
- // questionText?: string;
14
- // answerUI?: AnswerUI;
15
- // };
16
- nextContent?: {
17
- ref: 'successExitNode' | string;
18
- type: 'success' | 'slide';
19
- };
20
- // unused for now / to decide whether to use it when the
21
- // validation-progression is plugged in
22
- // step: {
23
- // current: number;
24
- // };
25
- } | null;
@@ -1,27 +0,0 @@
1
- type SkillCard = {
2
- 'aria-label': string;
3
- skillTitle: string;
4
- skillAriaLabel: string;
5
- buttonLabel: string;
6
- buttonAriaLabel: string;
7
- reviseLabel: string;
8
- reviseAriaLabel: string;
9
- isCustom: boolean;
10
- onClick: Function;
11
- };
12
-
13
- type NoSkillsProps = {
14
- titleNoSkills: string;
15
- textNoSkills: string;
16
- iconSkillAriaLabel: string;
17
- };
18
-
19
- type SkillsProps = NoSkillsProps & {
20
- 'aria-label'?: string;
21
- title: string;
22
- isLoading?: boolean;
23
- isLoadingAriaLabel: string;
24
- listSkills: SkillCard[];
25
- };
26
-
27
- export {SkillsProps};