@coorpacademy/app-review 0.1.5 → 0.1.8

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 (192) hide show
  1. package/es/actions/api/fetch-skills.d.ts +10 -0
  2. package/es/actions/api/fetch-skills.js +8 -0
  3. package/es/actions/api/fetch-slide.d.ts +10 -0
  4. package/es/actions/api/fetch-slide.js +8 -0
  5. package/es/actions/api/post-progression.d.ts +10 -0
  6. package/es/actions/api/post-progression.js +15 -0
  7. package/es/actions/data/slides.d.ts +7 -24
  8. package/es/actions/data/slides.js +0 -6
  9. package/es/actions/data/token.d.ts +2 -2
  10. package/es/actions/data/token.js +1 -1
  11. package/es/actions/index.d.ts +5 -3
  12. package/es/actions/ui/navigation.d.ts +0 -1
  13. package/es/actions/ui/navigation.js +0 -4
  14. package/es/actions/ui/step-items.d.ts +2 -8
  15. package/es/actions/ui/step-items.js +0 -6
  16. package/es/configure-store.d.ts +3 -34
  17. package/es/configure-store.js +4 -4
  18. package/es/fixtures/qcm-slide.d.ts +2 -2
  19. package/es/index.d.ts +1 -1
  20. package/es/index.js +78 -42
  21. package/es/reducers/data/index.d.ts +16 -5
  22. package/es/reducers/data/progression.d.ts +14 -9
  23. package/es/reducers/data/progression.js +18 -58
  24. package/es/reducers/data/skills.d.ts +4 -5
  25. package/es/reducers/data/skills.js +3 -6
  26. package/es/reducers/data/slides.d.ts +2 -1
  27. package/es/reducers/data/slides.js +14 -9
  28. package/es/reducers/data/token.d.ts +0 -1
  29. package/es/reducers/data/token.js +1 -5
  30. package/es/reducers/index.d.ts +9 -3
  31. package/es/reducers/ui/finished-slides.d.ts +0 -1
  32. package/es/reducers/ui/finished-slides.js +1 -3
  33. package/es/reducers/ui/index.d.ts +14 -4
  34. package/es/reducers/ui/navigation.d.ts +0 -1
  35. package/es/reducers/ui/navigation.js +1 -3
  36. package/es/reducers/ui/review-status.d.ts +0 -1
  37. package/es/reducers/ui/review-status.js +1 -4
  38. package/es/reducers/ui/step-items.d.ts +5 -5
  39. package/es/reducers/ui/step-items.js +0 -1
  40. package/es/services/fetch-skills.d.ts +2 -8
  41. package/es/services/fetch-skills.js +3 -16
  42. package/es/services/fetch-slide.d.ts +2 -0
  43. package/es/services/fetch-slide.js +11 -0
  44. package/es/services/index.d.ts +2 -0
  45. package/es/services/index.js +8 -0
  46. package/es/services/post-progression.d.ts +2 -0
  47. package/es/services/post-progression.js +21 -0
  48. package/es/services/test/fetch-skills.test.js +29 -0
  49. package/es/services/test/post-progression.test.js +35 -0
  50. package/es/services/tools/fetch-responses.d.ts +1 -1
  51. package/es/services/tools/sleep.d.ts +1 -0
  52. package/es/services/tools/sleep.js +3 -0
  53. package/es/{index.test.js → test/index.test.js} +18 -7
  54. package/es/test/util/services.mock.d.ts +2 -0
  55. package/es/test/util/services.mock.js +68 -0
  56. package/es/types/common.d.ts +66 -2
  57. package/es/types/common.js +5 -0
  58. package/es/types/slides.d.ts +1 -1
  59. package/es/types/ui-progression.d.ts +10 -0
  60. package/es/types/views/slides.d.ts +1 -1
  61. package/lib/actions/api/fetch-skills.d.ts +10 -0
  62. package/lib/actions/api/fetch-skills.js +13 -0
  63. package/lib/actions/api/fetch-slide.d.ts +10 -0
  64. package/lib/actions/api/fetch-slide.js +13 -0
  65. package/lib/actions/api/post-progression.d.ts +10 -0
  66. package/lib/actions/api/post-progression.js +18 -0
  67. package/lib/actions/data/slides.d.ts +7 -24
  68. package/lib/actions/data/slides.js +0 -6
  69. package/lib/actions/data/token.d.ts +2 -2
  70. package/lib/actions/data/token.js +1 -1
  71. package/lib/actions/index.d.ts +5 -3
  72. package/lib/actions/ui/navigation.d.ts +0 -1
  73. package/lib/actions/ui/navigation.js +0 -4
  74. package/lib/actions/ui/step-items.d.ts +2 -8
  75. package/lib/actions/ui/step-items.js +0 -6
  76. package/lib/configure-store.d.ts +3 -34
  77. package/lib/configure-store.js +4 -4
  78. package/lib/fixtures/qcm-slide.d.ts +2 -2
  79. package/lib/index.d.ts +1 -1
  80. package/lib/index.js +78 -86
  81. package/lib/reducers/data/index.d.ts +16 -5
  82. package/lib/reducers/data/progression.d.ts +14 -9
  83. package/lib/reducers/data/progression.js +18 -58
  84. package/lib/reducers/data/skills.d.ts +4 -5
  85. package/lib/reducers/data/skills.js +3 -6
  86. package/lib/reducers/data/slides.d.ts +2 -1
  87. package/lib/reducers/data/slides.js +14 -9
  88. package/lib/reducers/data/token.d.ts +0 -1
  89. package/lib/reducers/data/token.js +1 -5
  90. package/lib/reducers/index.d.ts +9 -3
  91. package/lib/reducers/ui/finished-slides.d.ts +0 -1
  92. package/lib/reducers/ui/finished-slides.js +1 -3
  93. package/lib/reducers/ui/index.d.ts +14 -4
  94. package/lib/reducers/ui/navigation.d.ts +0 -1
  95. package/lib/reducers/ui/navigation.js +1 -3
  96. package/lib/reducers/ui/review-status.d.ts +0 -1
  97. package/lib/reducers/ui/review-status.js +1 -4
  98. package/lib/reducers/ui/step-items.d.ts +5 -5
  99. package/lib/reducers/ui/step-items.js +0 -1
  100. package/lib/services/fetch-skills.d.ts +2 -8
  101. package/lib/services/fetch-skills.js +5 -20
  102. package/lib/services/fetch-slide.d.ts +2 -0
  103. package/lib/services/fetch-slide.js +57 -0
  104. package/lib/services/index.d.ts +2 -0
  105. package/lib/services/index.js +8 -0
  106. package/lib/services/post-progression.d.ts +2 -0
  107. package/lib/services/post-progression.js +65 -0
  108. package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
  109. package/lib/services/test/post-progression.test.js +89 -0
  110. package/lib/services/tools/fetch-responses.d.ts +1 -1
  111. package/lib/services/tools/sleep.d.ts +1 -0
  112. package/lib/services/tools/sleep.js +5 -0
  113. package/lib/test/index.test.d.ts +1 -0
  114. package/lib/{index.test.js → test/index.test.js} +23 -15
  115. package/lib/test/util/services.mock.d.ts +2 -0
  116. package/lib/test/util/services.mock.js +68 -0
  117. package/lib/types/common.d.ts +66 -2
  118. package/lib/types/common.js +5 -0
  119. package/lib/types/slides.d.ts +1 -1
  120. package/lib/types/ui-progression.d.ts +10 -0
  121. package/lib/types/ui-progression.js +1 -0
  122. package/lib/types/views/slides.d.ts +1 -1
  123. package/package.json +6 -5
  124. package/readme.md +4 -5
  125. package/src/actions/api/fetch-skills.ts +20 -0
  126. package/src/actions/api/fetch-slide.ts +20 -0
  127. package/src/actions/api/post-progression.ts +26 -0
  128. package/src/actions/data/slides.ts +8 -32
  129. package/src/actions/data/token.ts +2 -2
  130. package/src/actions/index.ts +7 -10
  131. package/src/actions/ui/navigation.ts +0 -5
  132. package/src/actions/ui/step-items.ts +2 -14
  133. package/src/configure-store.ts +6 -45
  134. package/src/fixtures/qcm-slide.ts +2 -2
  135. package/src/index.tsx +94 -45
  136. package/src/reducers/data/index.ts +12 -4
  137. package/src/reducers/data/progression.ts +34 -79
  138. package/src/reducers/data/skills.ts +5 -10
  139. package/src/reducers/data/slides.ts +16 -15
  140. package/src/reducers/data/token.ts +1 -11
  141. package/src/reducers/index.ts +7 -2
  142. package/src/reducers/ui/finished-slides.ts +1 -7
  143. package/src/reducers/ui/index.ts +11 -4
  144. package/src/reducers/ui/navigation.ts +1 -6
  145. package/src/reducers/ui/review-status.ts +1 -8
  146. package/src/reducers/ui/step-items.ts +5 -14
  147. package/src/services/fetch-skills.ts +4 -30
  148. package/src/services/fetch-slide.ts +15 -0
  149. package/src/services/index.ts +10 -0
  150. package/src/services/post-progression.ts +28 -0
  151. package/src/services/test/fetch-skills.test.ts +39 -0
  152. package/src/services/test/post-progression.test.ts +45 -0
  153. package/src/services/tools/fetch-responses.ts +1 -1
  154. package/src/services/tools/sleep.ts +4 -0
  155. package/src/{index.test.tsx → test/index.test.tsx} +16 -10
  156. package/src/test/util/services.mock.ts +70 -0
  157. package/src/types/common.ts +78 -2
  158. package/src/types/globals.d.ts +2 -0
  159. package/src/types/slides.ts +1 -1
  160. package/src/types/ui-progression.ts +25 -0
  161. package/src/types/views/slides.ts +1 -1
  162. package/es/actions/data/skills.d.ts +0 -13
  163. package/es/actions/data/skills.js +0 -10
  164. package/es/middlewares/on-start-app.d.ts +0 -5
  165. package/es/middlewares/on-start-app.js +0 -29
  166. package/es/services/fetch-skills.mock.d.ts +0 -3
  167. package/es/services/fetch-skills.mock.js +0 -17
  168. package/es/services/fetch-skills.test.js +0 -22
  169. package/es/services/tools/fetch.mocks.d.ts +0 -8
  170. package/es/services/tools/fetch.mocks.js +0 -13
  171. package/es/types/skills.d.ts +0 -7
  172. package/lib/actions/data/skills.d.ts +0 -13
  173. package/lib/actions/data/skills.js +0 -10
  174. package/lib/middlewares/on-start-app.d.ts +0 -5
  175. package/lib/middlewares/on-start-app.js +0 -34
  176. package/lib/services/fetch-skills.mock.d.ts +0 -3
  177. package/lib/services/fetch-skills.mock.js +0 -17
  178. package/lib/services/tools/fetch.mocks.d.ts +0 -8
  179. package/lib/services/tools/fetch.mocks.js +0 -35
  180. package/lib/types/skills.d.ts +0 -7
  181. package/src/actions/data/skills.ts +0 -24
  182. package/src/middlewares/on-start-app.ts +0 -42
  183. package/src/services/fetch-skills.mock.ts +0 -21
  184. package/src/services/fetch-skills.test.ts +0 -32
  185. package/src/services/tools/fetch.mocks.ts +0 -41
  186. package/src/types/skills.ts +0 -8
  187. /package/es/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
  188. /package/es/{index.test.d.ts → services/test/post-progression.test.d.ts} +0 -0
  189. /package/{lib → es/test}/index.test.d.ts +0 -0
  190. /package/es/types/{skills.js → ui-progression.js} +0 -0
  191. /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
  192. /package/lib/{types/skills.js → services/test/post-progression.test.d.ts} +0 -0
@@ -1 +1,6 @@
1
+ const ICON_VALUES = {
2
+ right: 'right',
3
+ wrong: 'wrong',
4
+ 'no-answer': 'no-answer'
5
+ };
1
6
  export {};
@@ -63,7 +63,7 @@ export declare type AnswerUI = {
63
63
  help: string;
64
64
  };
65
65
  export declare type SlideUIAnimations = 'unstack' | 'restack';
66
- export declare type Slide = {
66
+ export declare type UISlide = {
67
67
  questionText?: string;
68
68
  answerUI?: AnswerUI;
69
69
  };
@@ -0,0 +1,10 @@
1
+ export declare type UiProgression = {
2
+ _id?: string;
3
+ slideNumber?: number;
4
+ isCorrect?: boolean;
5
+ exitNode?: 'successExitNode' | 'failExitNode';
6
+ nextContent?: {
7
+ ref: 'successExitNode' | string;
8
+ type: 'success' | 'slide';
9
+ };
10
+ } | null;
@@ -1,5 +1,5 @@
1
+ import type { StoreState } from '../../reducers';
1
2
  import { Dispatchers } from '../../actions';
2
- import { StoreState } from '../../configure-store';
3
3
  declare type SlidesViewStaticProps = {
4
4
  slides: StoreState['data']['slides'];
5
5
  headerProps: {
@@ -0,0 +1,10 @@
1
+ import { Action } from 'redux';
2
+ import { Skill } from '../../types/common';
3
+ export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
4
+ export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
5
+ export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
6
+ export declare type ReceivedSkills = {
7
+ type: '@@skills/FETCH_SUCCESS';
8
+ payload: Skill[];
9
+ };
10
+ export declare const fetchSkills: (token: string) => Action;
@@ -0,0 +1,13 @@
1
+ import buildTask from '@coorpacademy/redux-task';
2
+ export var SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST';
3
+ export var SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS';
4
+ export var SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE';
5
+ export var fetchSkills = function (token) {
6
+ return buildTask({
7
+ types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
8
+ task: function (dispatch, getState, _a) {
9
+ var services = _a.services;
10
+ return services.fetchSkills(token);
11
+ }
12
+ });
13
+ };
@@ -0,0 +1,10 @@
1
+ import type { Action } from 'redux';
2
+ import { SlideFromAPI } from '../../types/common';
3
+ export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
4
+ export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
5
+ export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
6
+ export declare type ReceivedSlide = {
7
+ type: typeof SLIDE_FETCH_SUCCESS;
8
+ payload: SlideFromAPI;
9
+ };
10
+ export declare const fetchSlide: (slideRef: string, token: string) => Action;
@@ -0,0 +1,13 @@
1
+ import buildTask from '@coorpacademy/redux-task';
2
+ export var SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
3
+ export var SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
4
+ export var SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
5
+ export var fetchSlide = function (slideRef, token) {
6
+ return buildTask({
7
+ types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
8
+ task: function (dispatch, getState, _a) {
9
+ var services = _a.services;
10
+ return services.fetchSlide(slideRef, token);
11
+ }
12
+ });
13
+ };
@@ -0,0 +1,10 @@
1
+ import type { Action } from 'redux';
2
+ import { ProgressionFromAPI } from '../../types/common';
3
+ export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
4
+ export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
5
+ export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
6
+ export declare type ReceiveProgression = {
7
+ type: typeof POST_PROGRESSION_SUCCESS;
8
+ payload: ProgressionFromAPI;
9
+ };
10
+ export declare const postProgression: (skillRef: string, token: string) => Action;
@@ -0,0 +1,18 @@
1
+ import buildTask from '@coorpacademy/redux-task';
2
+ import { fetchSlide } from './fetch-slide';
3
+ export var POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST';
4
+ export var POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS';
5
+ export var POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE';
6
+ export var postProgression = function (skillRef, token) {
7
+ return buildTask({
8
+ types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
9
+ task: function (dispatch, getState, _a) {
10
+ var services = _a.services;
11
+ return services.postProgression(skillRef, token).then(function (progression) {
12
+ var ref = progression.state.nextContent.ref;
13
+ dispatch(fetchSlide(ref, token));
14
+ return progression;
15
+ });
16
+ }
17
+ });
18
+ };
@@ -1,36 +1,24 @@
1
- import { Slide as SlideFromAPI } from '../../types/slides';
2
- export declare const STORE_FIRST_SLIDE = "@@slide/STORE_FIRST_SLIDE";
1
+ import { UISlide } from '../../types/slides';
2
+ import { ReceivedSlide } from '../api/fetch-slide';
3
3
  export declare const UPDATE_SLIDES_ON_VALIDATION = "@@slide/UPDATE_SLIDES_ON_VALIDATION";
4
4
  export declare const UPDATE_SLIDES_ON_NEXT = "@@slide/UPDATE_SLIDES_ON_NEXT";
5
5
  export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
6
- export declare const FETCH_NEXT_CONTENT = "@@slide/FETCH_NEXT_CONTENT";
7
6
  declare type SlideUIAnimations = 'unstack' | 'restack';
8
- export declare type Slide = SlideFromAPI & {
7
+ export declare type Slide = UISlide & {
9
8
  hidden?: boolean;
10
9
  position: number;
11
10
  animationType?: SlideUIAnimations;
12
11
  isCorrect?: boolean;
13
12
  endReview?: boolean;
14
- nextSlide?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextSlide'>;
13
+ nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
15
14
  };
16
15
  export declare type ValidationPayload = {
17
16
  slideNumber: number;
18
17
  newSlideContent: Slide;
19
18
  numberOfFinishedSlides: number;
20
- nextSlide: Slide;
21
- };
22
- export declare type OnNextPayload = Omit<ValidationPayload, 'nextSlide'>;
23
- export declare type FetchNextPayload = {
24
- answer: string[];
25
- content: {
26
- ref: string;
27
- type: string;
28
- };
29
- };
30
- export declare type StoreFirstSlide = {
31
- type: typeof STORE_FIRST_SLIDE;
32
- payload: SlideFromAPI;
19
+ nextContent: Slide;
33
20
  };
21
+ export declare type OnNextPayload = Omit<ValidationPayload, 'nextContent'>;
34
22
  export declare type UpdateSlidesOnValidation = {
35
23
  type: typeof UPDATE_SLIDES_ON_VALIDATION;
36
24
  payload: ValidationPayload;
@@ -42,12 +30,7 @@ export declare type UpdateSlidesOnNext = {
42
30
  export declare type ValidateSlide = {
43
31
  type: typeof VALIDATE_SLIDE;
44
32
  };
45
- export declare type FetchNextContent = {
46
- type: typeof FETCH_NEXT_CONTENT;
47
- payload: FetchNextPayload;
48
- };
49
- export declare type SlidesAction = StoreFirstSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
50
- export declare const storeFirstSlide: (slide: SlideFromAPI) => StoreFirstSlide;
33
+ export declare type SlidesAction = ReceivedSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
51
34
  export declare const updateSlidesOnValidation: (payload: ValidationPayload) => UpdateSlidesOnValidation;
52
35
  export declare const updateSlidesOnNext: (payload: OnNextPayload) => UpdateSlidesOnNext;
53
36
  export declare const validateSlide: () => ValidateSlide;
@@ -1,14 +1,8 @@
1
1
  // -----------------------------------------------------------------------------
2
- export var STORE_FIRST_SLIDE = '@@slide/STORE_FIRST_SLIDE';
3
2
  export var UPDATE_SLIDES_ON_VALIDATION = '@@slide/UPDATE_SLIDES_ON_VALIDATION';
4
3
  export var UPDATE_SLIDES_ON_NEXT = '@@slide/UPDATE_SLIDES_ON_NEXT';
5
4
  export var VALIDATE_SLIDE = '@@slide/VALIDATE';
6
- export var FETCH_NEXT_CONTENT = '@@slide/FETCH_NEXT_CONTENT';
7
5
  // -----------------------------------------------------------------------------
8
- export var storeFirstSlide = function (slide) { return ({
9
- type: STORE_FIRST_SLIDE,
10
- payload: slide
11
- }); };
12
6
  export var updateSlidesOnValidation = function (payload) { return ({
13
7
  type: UPDATE_SLIDES_ON_VALIDATION,
14
8
  payload: payload
@@ -1,6 +1,6 @@
1
- export declare const STORE_TOKEN = "@@token/STORE_TOKEN";
1
+ export declare const STORE_TOKEN = "@@data/token/STORE_TOKEN";
2
2
  export declare type StoreToken = {
3
- type: '@@token/STORE_TOKEN';
3
+ type: typeof STORE_TOKEN;
4
4
  payload: string;
5
5
  };
6
6
  export declare const storeToken: (token: string) => StoreToken;
@@ -1,4 +1,4 @@
1
- export var STORE_TOKEN = '@@token/STORE_TOKEN';
1
+ export var STORE_TOKEN = '@@data/token/STORE_TOKEN';
2
2
  export var storeToken = function (token) { return ({
3
3
  type: STORE_TOKEN,
4
4
  payload: token
@@ -1,11 +1,13 @@
1
- import { StoreFirstSlide, updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
2
- import { ErrorFetchingSkills, ReceivedSkills } from './data/skills';
1
+ import { updateSlidesOnValidation, updateSlidesOnNext, validateSlide } from './data/slides';
3
2
  import { StoreToken } from './data/token';
4
3
  import { updateFinishedSlides } from './ui/finished-slides';
5
4
  import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
6
5
  import { updateReviewStatus } from './ui/review-status';
7
6
  import { updateStepItemsOnValidation, updateStepItemsOnNext } from './ui/step-items';
8
- export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | ErrorFetchingSkills | StartApp | StoreFirstSlide | StoreToken;
7
+ import { ReceivedSlide } from './api/fetch-slide';
8
+ import { ReceiveProgression } from './api/post-progression';
9
+ import { ReceivedSkills } from './api/fetch-skills';
10
+ export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
9
11
  export declare type Dispatchers = {
10
12
  navigateTo: typeof navigateTo;
11
13
  navigateBack: typeof navigateBack;
@@ -16,4 +16,3 @@ export declare type StartApp = {
16
16
  };
17
17
  export declare const navigateTo: (newPath: ViewPath) => NavigateTo;
18
18
  export declare const navigateBack: () => NavigateBack;
19
- export declare const startApp: (options: AppOptions) => StartApp;
@@ -8,7 +8,3 @@ export var navigateTo = function (newPath) { return ({
8
8
  export var navigateBack = function () { return ({
9
9
  type: NAVIGATE_BACK
10
10
  }); };
11
- export var startApp = function (options) { return ({
12
- type: START_APP,
13
- payload: options
14
- }); };
@@ -1,19 +1,13 @@
1
- import { FinishedSlidesState } from '../../reducers/ui/finished-slides';
1
+ import { FinishedSlides, IconValue } from '../../types/common';
2
2
  export declare const UPDATE_STEP_ITEMS_ON_VALIDATION = "@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION";
3
3
  export declare const UPDATE_STEP_ITEMS_ON_NEXT = "@@step-items/UPDATE_STEP_ITEMS_ON_NEXT";
4
- declare const ICON_VALUES: {
5
- readonly right: "right";
6
- readonly wrong: "wrong";
7
- readonly 'no-answer': "no-answer";
8
- };
9
- export declare type IconValue = keyof typeof ICON_VALUES;
10
4
  declare type UpdateStepItemsOnValidationClickPayload = {
11
5
  stepNumber: number;
12
6
  icon: IconValue;
13
7
  };
14
8
  declare type UpdateStepItemsOnNextClickPayload = {
15
9
  stepNumber: number;
16
- finishedSlides: FinishedSlidesState;
10
+ finishedSlides: FinishedSlides;
17
11
  current: boolean;
18
12
  };
19
13
  export declare type UpdateStepItemsOnValidation = {
@@ -1,11 +1,5 @@
1
- // -----------------------------------------------------------------------------
2
1
  export var UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
3
2
  export var UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
4
- var ICON_VALUES = {
5
- right: 'right',
6
- wrong: 'wrong',
7
- 'no-answer': 'no-answer'
8
- };
9
3
  // -----------------------------------------------------------------------------
10
4
  export var updateStepItemsOnValidation = function (payload) { return ({
11
5
  type: UPDATE_STEP_ITEMS_ON_VALIDATION,
@@ -1,35 +1,4 @@
1
1
  import { AnyAction, Store } from 'redux';
2
- import { SkillsState } from './reducers/data/skills';
3
- import { SlidesState } from './reducers/data/slides';
4
- import { TokenState } from './reducers/data/token';
5
- import { NavigationState } from './reducers/ui/navigation';
6
- import { ReviewStatusState } from './reducers/ui/review-status';
7
- import { StepItemsState } from './reducers/ui/step-items';
8
- import { FinishedSlidesState } from './reducers/ui/finished-slides';
9
- import { AnswerUI } from './types/slides';
10
- declare type DataState = {
11
- isFetching?: boolean;
12
- progression?: {
13
- slideNumber: number;
14
- isCorrect?: boolean;
15
- exitNode?: 'successExitNode' | 'failExitNode';
16
- nextSlide?: {
17
- questionText?: string;
18
- answerUI?: AnswerUI;
19
- };
20
- } | null;
21
- skills: SkillsState;
22
- slides: SlidesState;
23
- token?: TokenState;
24
- };
25
- export declare type StoreState = {
26
- ui: {
27
- navigation: NavigationState;
28
- stepItems: StepItemsState;
29
- finishedSlides: FinishedSlidesState;
30
- reviewStatus: ReviewStatusState;
31
- };
32
- data: DataState;
33
- };
34
- export default function configureStore(): Store<StoreState, AnyAction>;
35
- export {};
2
+ import { StoreState } from './reducers';
3
+ import { AppOptions } from './types/common';
4
+ export default function configureStore(options: AppOptions): Store<StoreState, AnyAction>;
@@ -1,9 +1,8 @@
1
1
  import { applyMiddleware, compose, createStore } from 'redux';
2
2
  import thunk from 'redux-thunk';
3
3
  import rootReducer from './reducers';
4
- import onStartApp from './middlewares/on-start-app';
5
- // -----------------------------------------------------------------------------
6
- export default function configureStore() {
4
+ import { getServices } from './services';
5
+ export default function configureStore(options) {
7
6
  var _compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
8
7
  ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
9
8
  name: 'app-review',
@@ -11,7 +10,8 @@ export default function configureStore() {
11
10
  traceLimit: 25
12
11
  })
13
12
  : compose;
14
- var enhancer = _compose(applyMiddleware(thunk, onStartApp));
13
+ var thunkMiddleware = thunk.withExtraArgument({ services: options.services || getServices() });
14
+ var enhancer = _compose(applyMiddleware(thunkMiddleware));
15
15
  var store = createStore(rootReducer, undefined, enhancer);
16
16
  return store;
17
17
  }
@@ -1,2 +1,2 @@
1
- import { Slide } from '../types/slides';
2
- export declare const slide: Slide;
1
+ import { UISlide } from '../types/slides';
2
+ export declare const slide: UISlide;
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AppOptions } from './types/common';
2
2
  declare const AppReview: ({ options }: {
3
3
  options: AppOptions;
4
- }) => JSX.Element;
4
+ }) => JSX.Element | null;
5
5
  declare global {
6
6
  interface Window {
7
7
  __REDUX_DEVTOOLS_EXTENSION__?: boolean;
package/lib/index.js CHANGED
@@ -1,49 +1,18 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
1
  import React, { useEffect, useState } from 'react';
38
2
  import { connect, Provider } from 'react-redux';
39
3
  import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
4
+ import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
40
5
  import configureStore from './configure-store';
41
6
  import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
42
7
  import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
43
- import { navigateTo, navigateBack, startApp } from './actions/ui/navigation';
8
+ import { navigateTo, navigateBack } from './actions/ui/navigation';
9
+ import { storeToken } from './actions/data/token';
44
10
  import { updateFinishedSlides } from './actions/ui/finished-slides';
45
11
  import { updateReviewStatus } from './actions/ui/review-status';
46
12
  import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui/step-items';
13
+ import { fetchSkills } from './actions/api/fetch-skills';
14
+ import { postProgression } from './actions/api/post-progression';
15
+ import { VIEWS } from './common';
47
16
  // -----------------------------------------------------------------------------
48
17
  var mapDispatchToProps = {
49
18
  navigateTo: navigateTo,
@@ -59,29 +28,38 @@ var mapDispatchToProps = {
59
28
  var getCurrentViewName = function (storeState) {
60
29
  return storeState.ui.navigation[storeState.ui.navigation.length - 1];
61
30
  };
62
- var mapStateToSkillsProps = function (state) { return ({
63
- title: '@todo title',
64
- titleNoSkills: '@todo titleNoSkills',
65
- textNoSkills: '@todo textNoSkills',
66
- iconSkillAriaLabel: '@todo iconSkillAriaLabel',
67
- isLoading: false,
68
- isLoadingAriaLabel: '@todo loading',
69
- listSkills: state.data.skills.map(function (skill) { return ({
70
- 'aria-label': '',
71
- isCustom: skill.custom,
72
- skillTitle: skill.name,
73
- skillAriaLabel: '@todo skill aria label',
74
- buttonLabel: '@todo button',
75
- buttonAriaLabel: '@todo button aria label',
76
- reviseLabel: '@todo revise',
77
- reviseAriaLabel: '@todo revise aria label',
78
- // eslint-disable-next-line no-console
79
- onClick: function () { return console.log('@todo plug dispatcher select skill'); }
80
- }); })
81
- }); };
82
- var mapStateToProps = function (state) { return ({
83
- viewName: getCurrentViewName(state),
84
- slides: {
31
+ // -----------------------------------------------------------------------------
32
+ var mapStateToSkillsProps = function (state) {
33
+ if (!state.data.skills) {
34
+ return null;
35
+ }
36
+ return {
37
+ title: '@todo title',
38
+ titleNoSkills: '@todo titleNoSkills',
39
+ textNoSkills: '@todo textNoSkills',
40
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel',
41
+ isLoading: false,
42
+ isLoadingAriaLabel: '@todo loading',
43
+ listSkills: state.data.skills.map(function (skill) { return ({
44
+ 'aria-label': '',
45
+ isCustom: skill.custom,
46
+ skillTitle: skill.name,
47
+ skillAriaLabel: '@todo skill aria label',
48
+ buttonLabel: '@todo button',
49
+ buttonAriaLabel: '@todo button aria label',
50
+ reviseLabel: '@todo revise',
51
+ reviseAriaLabel: '@todo revise aria label',
52
+ // eslint-disable-next-line no-console
53
+ onClick: function () { return console.log('@todo plug dispatcher select skill'); }
54
+ }); })
55
+ };
56
+ };
57
+ // -----------------------------------------------------------------------------
58
+ var mapStateToSlidesProps = function (state) {
59
+ if (!state.data.slides) {
60
+ return null;
61
+ }
62
+ return {
85
63
  headerProps: {
86
64
  mode: '__revision_mode',
87
65
  skillName: '__agility',
@@ -102,41 +80,55 @@ var mapStateToProps = function (state) { return ({
102
80
  correctionPopinProps: correctionPopinProps,
103
81
  congratsProps: congratsProps,
104
82
  progression: state.data.progression
105
- },
106
- skills: mapStateToSkillsProps(state)
107
- }); };
83
+ };
84
+ };
85
+ // -----------------------------------------------------------------------------
86
+ var mapStateToProps = function (state) {
87
+ return {
88
+ viewName: getCurrentViewName(state),
89
+ slides: mapStateToSlidesProps(state),
90
+ skills: mapStateToSkillsProps(state)
91
+ };
92
+ };
108
93
  // Props = StaticProps && Dispatchers
109
94
  var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
110
95
  // -----------------------------------------------------------------------------
111
96
  var AppReview = function (_a) {
112
97
  var options = _a.options;
113
98
  var _b = useState(null), store = _b[0], setStore = _b[1];
114
- var _c = useState(false), appStarted = _c[0], setAppStarted = _c[1];
115
99
  useEffect(function () {
116
- if (store) {
117
- store.dispatch(startApp(options));
118
- setAppStarted(true);
119
- }
120
- else {
121
- var _configure = function () { return __awaiter(void 0, void 0, void 0, function () {
122
- var newStore;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0: return [4 /*yield*/, configureStore()];
126
- case 1:
127
- newStore = _a.sent();
128
- setStore(newStore);
129
- return [2 /*return*/];
130
- }
131
- });
132
- }); };
133
- _configure();
134
- }
100
+ if (store)
101
+ return;
102
+ var newStore = configureStore(options);
103
+ setStore(newStore);
104
+ }, [options, store]);
105
+ useEffect(function () {
106
+ if (store === null)
107
+ return;
108
+ var skillRef = options.skillRef;
109
+ var initialView = skillRef ? VIEWS.slides : VIEWS.skills;
110
+ store.dispatch(navigateTo(initialView));
111
+ }, [options, store]);
112
+ useEffect(function () {
113
+ if (store === null)
114
+ return;
115
+ var token = options.token;
116
+ store.dispatch(storeToken(token));
117
+ }, [options, store]);
118
+ useEffect(function () {
119
+ if (store === null)
120
+ return;
121
+ var skillRef = options.skillRef, token = options.token;
122
+ skillRef
123
+ ? store.dispatch(postProgression(skillRef, token))
124
+ : store.dispatch(fetchSkills(token));
135
125
  }, [options, store]);
136
- if (!store || !appStarted)
137
- return React.createElement("div", null);
126
+ if (!store)
127
+ return null;
128
+ var values = options.templateContext;
138
129
  return (React.createElement(Provider, { store: store },
139
- React.createElement(App, null)));
130
+ React.createElement(TemplateContext, { values: values },
131
+ React.createElement(App, null))));
140
132
  };
141
133
  // -----------------------------------------------------------------------------
142
134
  export default AppReview;
@@ -1,7 +1,18 @@
1
+ import { ProgressionState } from './progression';
2
+ import { SkillsState } from './skills';
3
+ import { SlidesState } from './slides';
4
+ import { TokenState } from './token';
5
+ export declare type DataState = {
6
+ isFetching?: boolean;
7
+ progression?: ProgressionState;
8
+ skills: SkillsState;
9
+ slides: SlidesState;
10
+ token?: TokenState;
11
+ };
1
12
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
2
- progression: import("./progression").ProgressionState;
3
- skills: import("../../types/skills").Skills;
4
- slides: import("./slides").SlidesState;
5
- token: import("./token").TokenState;
6
- }>, import("../../actions/data/slides").ValidateSlide | import("../../actions/data/slides").SlidesAction | import("../../actions/data/skills").ReceivedSkills | import("../../actions/data/token").StoreToken>;
13
+ progression: ProgressionState;
14
+ skills: SkillsState;
15
+ slides: SlidesState;
16
+ token: TokenState;
17
+ }>, 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>;
7
18
  export default _default;
@@ -1,14 +1,19 @@
1
1
  import { ValidateSlide } from '../../actions/data/slides';
2
- import { AnswerUI } from '../../types/slides';
2
+ import { ReceiveProgression } from '../../actions/api/post-progression';
3
3
  export declare type ProgressionState = {
4
- slideNumber: number;
5
- isCorrect?: boolean;
6
- exitNode?: 'successExitNode' | 'failExitNode';
7
- nextSlide?: {
8
- questionText?: string;
9
- answerUI?: AnswerUI;
4
+ _id?: string;
5
+ state: {
6
+ isCorrect: boolean;
7
+ nextContent: {
8
+ ref: 'successExitNode' | string;
9
+ type: 'success' | 'slide';
10
+ };
11
+ pendingSlides: string[];
12
+ step: {
13
+ current: number;
14
+ };
10
15
  };
16
+ slideNumber?: number;
11
17
  } | null;
12
- export declare const initialState: ProgressionState;
13
- declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide) => ProgressionState;
18
+ declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
14
19
  export default reducer;