@coorpacademy/app-review 0.1.8 → 0.1.10

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 (82) hide show
  1. package/es/actions/api/fetch-skills.d.ts +8 -5
  2. package/es/actions/api/fetch-slide.d.ts +8 -5
  3. package/es/actions/api/post-progression.d.ts +8 -5
  4. package/es/actions/ui/navigation.d.ts +1 -1
  5. package/es/fixtures/qcm-slide.js +1 -1
  6. package/es/helpers/map-api-slide-to-ui.d.ts +8 -0
  7. package/es/helpers/map-api-slide-to-ui.js +175 -0
  8. package/es/helpers/test/fixtures/free-text.d.ts +4 -0
  9. package/es/helpers/test/fixtures/free-text.js +24 -0
  10. package/es/helpers/test/fixtures/qcm-drag.d.ts +4 -0
  11. package/es/helpers/test/fixtures/qcm-drag.js +106 -0
  12. package/es/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
  13. package/es/helpers/test/fixtures/qcm-graphic.js +70 -0
  14. package/es/helpers/test/fixtures/qcm.d.ts +4 -0
  15. package/es/helpers/test/fixtures/qcm.js +99 -0
  16. package/es/helpers/test/fixtures/select-template.d.ts +4 -0
  17. package/es/helpers/test/fixtures/select-template.js +88 -0
  18. package/es/helpers/test/fixtures/slider.d.ts +4 -0
  19. package/es/helpers/test/fixtures/slider.js +27 -0
  20. package/es/helpers/test/fixtures/text-template.d.ts +4 -0
  21. package/es/helpers/test/fixtures/text-template.js +48 -0
  22. package/es/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
  23. package/es/helpers/test/map-api-slide-to-ui.test.js +32 -0
  24. package/es/index.d.ts +1 -1
  25. package/es/index.js +31 -16
  26. package/es/reducers/ui/navigation.d.ts +1 -1
  27. package/es/test/index.test.js +18 -15
  28. package/es/test/util/services.mock.js +2 -32
  29. package/es/types/common.d.ts +62 -5
  30. package/es/types/slides.d.ts +27 -16
  31. package/lib/actions/api/fetch-skills.d.ts +8 -5
  32. package/lib/actions/api/fetch-slide.d.ts +8 -5
  33. package/lib/actions/api/post-progression.d.ts +8 -5
  34. package/lib/actions/ui/navigation.d.ts +1 -1
  35. package/lib/fixtures/qcm-slide.js +1 -1
  36. package/lib/helpers/map-api-slide-to-ui.d.ts +8 -0
  37. package/lib/helpers/map-api-slide-to-ui.js +181 -0
  38. package/lib/helpers/test/fixtures/free-text.d.ts +4 -0
  39. package/lib/helpers/test/fixtures/free-text.js +24 -0
  40. package/lib/helpers/test/fixtures/qcm-drag.d.ts +4 -0
  41. package/lib/helpers/test/fixtures/qcm-drag.js +106 -0
  42. package/lib/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
  43. package/lib/helpers/test/fixtures/qcm-graphic.js +70 -0
  44. package/lib/helpers/test/fixtures/qcm.d.ts +4 -0
  45. package/lib/helpers/test/fixtures/qcm.js +99 -0
  46. package/lib/helpers/test/fixtures/select-template.d.ts +4 -0
  47. package/lib/helpers/test/fixtures/select-template.js +88 -0
  48. package/lib/helpers/test/fixtures/slider.d.ts +4 -0
  49. package/lib/helpers/test/fixtures/slider.js +27 -0
  50. package/lib/helpers/test/fixtures/text-template.d.ts +4 -0
  51. package/lib/helpers/test/fixtures/text-template.js +48 -0
  52. package/lib/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
  53. package/lib/helpers/test/map-api-slide-to-ui.test.js +43 -0
  54. package/lib/index.d.ts +1 -1
  55. package/lib/index.js +31 -16
  56. package/lib/reducers/ui/navigation.d.ts +1 -1
  57. package/lib/test/index.test.js +19 -16
  58. package/lib/test/util/services.mock.js +13 -32
  59. package/lib/types/common.d.ts +62 -5
  60. package/lib/types/slides.d.ts +27 -16
  61. package/package.json +3 -3
  62. package/src/actions/api/fetch-skills.ts +8 -4
  63. package/src/actions/api/fetch-slide.ts +8 -4
  64. package/src/actions/api/post-progression.ts +14 -4
  65. package/src/actions/ui/navigation.ts +1 -1
  66. package/src/fixtures/qcm-slide.ts +1 -1
  67. package/src/helpers/map-api-slide-to-ui.ts +253 -0
  68. package/src/helpers/test/fixtures/free-text.ts +28 -0
  69. package/src/helpers/test/fixtures/qcm-drag.ts +110 -0
  70. package/src/helpers/test/fixtures/qcm-graphic.ts +74 -0
  71. package/src/helpers/test/fixtures/qcm.ts +108 -0
  72. package/src/helpers/test/fixtures/select-template.ts +92 -0
  73. package/src/helpers/test/fixtures/slider.ts +31 -0
  74. package/src/helpers/test/fixtures/text-template.ts +52 -0
  75. package/src/helpers/test/map-api-slide-to-ui.test.ts +55 -0
  76. package/src/index.tsx +39 -30
  77. package/src/reducers/ui/navigation.ts +1 -1
  78. package/src/test/index.test.tsx +23 -12
  79. package/src/test/util/services.mock.ts +2 -32
  80. package/src/types/common.ts +74 -5
  81. package/src/types/globals.d.ts +0 -5
  82. package/src/types/slides.ts +29 -12
@@ -0,0 +1,48 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export var textTemplateSlide = {
3
+ question: {
4
+ content: {
5
+ media: {
6
+ src: [],
7
+ posters: [],
8
+ subtitles: []
9
+ },
10
+ template: 'Un {{inp58402}} model.',
11
+ choices: [
12
+ {
13
+ media: {
14
+ src: [],
15
+ posters: [],
16
+ subtitles: []
17
+ },
18
+ items: [],
19
+ _id: '62433c2c58920f02c4950de0',
20
+ type: 'text',
21
+ name: 'inp58402',
22
+ id: '62433c2c58920f02c4950de0'
23
+ }
24
+ ]
25
+ },
26
+ type: 'template',
27
+ header: 'Comment le protégé doit-il percevoir son mentor ?',
28
+ explanation: 'Saisissez votre réponse (en anglais).'
29
+ },
30
+ klf: "Le mentoré voit dans son mentor un <i>role model</i>, c'est-à-dire un exemple inspirant qui lui permet de se projeter dans un poste à responsabilité.",
31
+ tips: "L'origine de l'expression <i>role model</i> est attribué au sociologue Robert K. Merton.",
32
+ universalRef: 'sli_VJKQonm2g',
33
+ hasClue: true,
34
+ id: 'sli_VJKQonm2g'
35
+ };
36
+ export var textTemplateUISlide = {
37
+ type: 'template',
38
+ template: 'Un {{inp58402}} model.',
39
+ answers: [
40
+ {
41
+ type: 'text',
42
+ name: 'inp58402',
43
+ placeholder: 'Type here',
44
+ value: undefined,
45
+ onChange: noop
46
+ }
47
+ ]
48
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
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 test from 'ava';
13
+ import { mapApiSlideToUi } from '../map-api-slide-to-ui';
14
+ import { qcmUISlide, qcmSlide } from './fixtures/qcm';
15
+ import { qcmDragUISlide, qcmDragSlide } from './fixtures/qcm-drag';
16
+ import { freeTextSlide, freeTextUISlide } from './fixtures/free-text';
17
+ import { qcmGraphicUISlide, qcmGraphicSlide } from './fixtures/qcm-graphic';
18
+ import { textTemplateSlide, textTemplateUISlide } from './fixtures/text-template';
19
+ import { selectTemplateSlide, selectTemplateUISlide } from './fixtures/select-template';
20
+ import { sliderSlide, sliderUISlide } from './fixtures/slider';
21
+ var _mapApiSlideToUi = mapApiSlideToUi({ translate: function (text) { return text; } });
22
+ var macro = test.macro({
23
+ title: function (providedTitle) {
24
+ return "should handle ".concat(providedTitle, " conversion").trim();
25
+ },
26
+ exec: function (t, arg) {
27
+ t.deepEqual(JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide))), JSON.parse(JSON.stringify(arg.expectedUiSlide)));
28
+ }
29
+ });
30
+ test('qcm', macro, { slide: qcmSlide, expectedUiSlide: qcmUISlide });
31
+ test('qcm drag', macro, { slide: qcmDragSlide, expectedUiSlide: qcmDragUISlide });
32
+ test('qcm graphic', macro, { slide: qcmGraphicSlide, expectedUiSlide: qcmGraphicUISlide });
33
+ test('text template', macro, { slide: textTemplateSlide, expectedUiSlide: textTemplateUISlide });
34
+ test('select template', macro, {
35
+ slide: selectTemplateSlide,
36
+ expectedUiSlide: selectTemplateUISlide
37
+ });
38
+ test('free text', macro, { slide: freeTextSlide, expectedUiSlide: freeTextUISlide });
39
+ test('slider', macro, { slide: sliderSlide, expectedUiSlide: sliderUISlide });
40
+ test('should throw an error if the question type can not be handled', function (t) {
41
+ var faultySlide = __assign(__assign({}, qcmSlide), { question: { type: 'lol' } });
42
+ t.throws(function () { return _mapApiSlideToUi(faultySlide); });
43
+ });
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ declare const AppReview: ({ options }: {
4
4
  }) => JSX.Element | null;
5
5
  declare global {
6
6
  interface Window {
7
- __REDUX_DEVTOOLS_EXTENSION__?: boolean;
7
+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
8
8
  }
9
9
  }
10
10
  export default AppReview;
package/lib/index.js CHANGED
@@ -2,6 +2,8 @@ import React, { useEffect, useState } from 'react';
2
2
  import { connect, Provider } from 'react-redux';
3
3
  import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
4
4
  import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
5
+ import isEmpty from 'lodash/fp/isEmpty';
6
+ import get from 'lodash/fp/get';
5
7
  import configureStore from './configure-store';
6
8
  import { congratsProps, correctionPopinProps } from './fixtures/temp-fixture';
7
9
  import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
@@ -13,7 +15,6 @@ import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui
13
15
  import { fetchSkills } from './actions/api/fetch-skills';
14
16
  import { postProgression } from './actions/api/post-progression';
15
17
  import { VIEWS } from './common';
16
- // -----------------------------------------------------------------------------
17
18
  var mapDispatchToProps = {
18
19
  navigateTo: navigateTo,
19
20
  navigateBack: navigateBack,
@@ -28,7 +29,6 @@ var mapDispatchToProps = {
28
29
  var getCurrentViewName = function (storeState) {
29
30
  return storeState.ui.navigation[storeState.ui.navigation.length - 1];
30
31
  };
31
- // -----------------------------------------------------------------------------
32
32
  var mapStateToSkillsProps = function (state) {
33
33
  if (!state.data.skills) {
34
34
  return null;
@@ -54,7 +54,6 @@ var mapStateToSkillsProps = function (state) {
54
54
  }); })
55
55
  };
56
56
  };
57
- // -----------------------------------------------------------------------------
58
57
  var mapStateToSlidesProps = function (state) {
59
58
  if (!state.data.slides) {
60
59
  return null;
@@ -82,7 +81,6 @@ var mapStateToSlidesProps = function (state) {
82
81
  progression: state.data.progression
83
82
  };
84
83
  };
85
- // -----------------------------------------------------------------------------
86
84
  var mapStateToProps = function (state) {
87
85
  return {
88
86
  viewName: getCurrentViewName(state),
@@ -90,12 +88,11 @@ var mapStateToProps = function (state) {
90
88
  skills: mapStateToSkillsProps(state)
91
89
  };
92
90
  };
93
- // Props = StaticProps && Dispatchers
94
91
  var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
95
- // -----------------------------------------------------------------------------
96
92
  var AppReview = function (_a) {
97
93
  var options = _a.options;
98
94
  var _b = useState(null), store = _b[0], setStore = _b[1];
95
+ var _c = useState(false), isSlideFetched = _c[0], setIsSlideFetched = _c[1];
99
96
  useEffect(function () {
100
97
  if (store)
101
98
  return;
@@ -103,26 +100,45 @@ var AppReview = function (_a) {
103
100
  setStore(newStore);
104
101
  }, [options, store]);
105
102
  useEffect(function () {
106
- if (store === null)
103
+ if (!store || isSlideFetched)
107
104
  return;
108
- var skillRef = options.skillRef;
109
- var initialView = skillRef ? VIEWS.slides : VIEWS.skills;
110
- store.dispatch(navigateTo(initialView));
111
- }, [options, store]);
105
+ return store.subscribe(function () {
106
+ var isSlidePresent = !isEmpty(store.getState().data.slides[0].questionText);
107
+ return isSlidePresent && setIsSlideFetched(isSlidePresent);
108
+ }); // using the first slide questionText for now, should only check for a slide's presence
109
+ // when the refactor is done (slides will be feed one by one on api's side)
110
+ }, [isSlideFetched, options, store]);
112
111
  useEffect(function () {
113
- if (store === null)
112
+ var token = get('token', options);
113
+ if (store === null || isEmpty(token))
114
114
  return;
115
- var token = options.token;
116
115
  store.dispatch(storeToken(token));
117
116
  }, [options, store]);
118
117
  useEffect(function () {
119
- if (store === null)
118
+ var token = get('token', options);
119
+ if (store === null || isEmpty(token))
120
120
  return;
121
- var skillRef = options.skillRef, token = options.token;
121
+ var skillRef = get('skillRef', options);
122
+ // ThunkAction is not assignable to parameter of type 'AnyAction'
123
+ // ts problem describre here = https://github.com/reduxjs/redux-thunk/issues/333
122
124
  skillRef
123
125
  ? store.dispatch(postProgression(skillRef, token))
124
126
  : store.dispatch(fetchSkills(token));
125
127
  }, [options, store]);
128
+ useEffect(function () {
129
+ if (store === null)
130
+ return;
131
+ var skillRef = options.skillRef;
132
+ if (skillRef && !isSlideFetched) {
133
+ store.dispatch(navigateTo('loader')); // use loader while posting progression
134
+ return;
135
+ }
136
+ // TODO: when slides state is refactored (data + mapping),
137
+ // use loader in case a skillRef is found && no slides from the API
138
+ // are found
139
+ var initialView = skillRef ? VIEWS.slides : VIEWS.skills;
140
+ store.dispatch(navigateTo(initialView));
141
+ }, [isSlideFetched, options, store]);
126
142
  if (!store)
127
143
  return null;
128
144
  var values = options.templateContext;
@@ -130,5 +146,4 @@ var AppReview = function (_a) {
130
146
  React.createElement(TemplateContext, { values: values },
131
147
  React.createElement(App, null))));
132
148
  };
133
- // -----------------------------------------------------------------------------
134
149
  export default AppReview;
@@ -1,4 +1,4 @@
1
1
  import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
2
- export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides'>;
2
+ export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides' | 'loader'>;
3
3
  declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
4
4
  export default reducer;
@@ -138,29 +138,32 @@ var appOptions = {
138
138
  skillRef: 'skill_NJC0jFKoH',
139
139
  services: services
140
140
  };
141
- test('should validate all the slides (all correct scenario)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
142
- var container, wrapper;
141
+ test('should show the loader while the app is fetching the data', function (t) { return __awaiter(void 0, void 0, void 0, function () {
142
+ var container, loader;
143
143
  return __generator(this, function (_a) {
144
144
  switch (_a.label) {
145
145
  case 0:
146
- // t.plan(13);
147
146
  t.plan(2);
148
- container = render(React.createElement(AppReview, { options: appOptions, key: 0 })).container;
147
+ container = render(React.createElement(AppReview, { options: appOptions })).container;
149
148
  return [4 /*yield*/, waitForChanges(1000)];
150
149
  case 1:
151
150
  _a.sent();
152
- wrapper = container.querySelector('[data-name="loader"]');
153
- t.truthy(wrapper);
154
- /*
155
- const wrapper = container.querySelector('[data-name="slides-revision-container"]');
156
- t.truthy(wrapper);
157
-
158
- const stackedSlidesContainer = wrapper?.querySelector('[data-name="stacked-slides-container"]');
159
-
160
- t.truthy(stackedSlidesContainer);
161
-
162
- await clickAllSlides(t, container);
163
- */
151
+ loader = container.querySelector('[data-name="loader"]');
152
+ t.truthy(loader);
153
+ // await waitFor(async () => {
154
+ // // await sleep(500);
155
+ // const result = await t.try(tt => {
156
+ // // rerender(<AppReview options={appOptions} />);
157
+ // const slidesContainer = container.querySelector('[data-name="slides-revision-container"]');
158
+ // tt.truthy(slidesContainer);
159
+ // });
160
+ // if (result.passed) return result.commit();
161
+ // result.discard();
162
+ // throw result.errors;
163
+ // });
164
+ // const stackedSlidesContainer = container.querySelector('[data-name="stacked-slides-container"]');
165
+ // t.truthy(stackedSlidesContainer);
166
+ // await clickAllSlides(t, container);
164
167
  t.pass();
165
168
  return [2 /*return*/];
166
169
  }
@@ -1,3 +1,15 @@
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 { qcmSlide } from '../../helpers/test/fixtures/qcm';
1
13
  export var services = {
2
14
  fetchSkills: function () {
3
15
  return Promise.resolve([
@@ -16,38 +28,7 @@ export var services = {
16
28
  ]);
17
29
  },
18
30
  fetchSlide: function (ref) {
19
- // return Promise.resolve(qcm); // why qcm does not look like a slide returned from mooc ?
20
- return Promise.resolve({
21
- question: {
22
- content: {
23
- choices: [
24
- {
25
- selected: false,
26
- title: 'choix1',
27
- help: '(help choix1)',
28
- ariaLabel: '__ariaLabel1',
29
- onClick: function () { return undefined; }
30
- },
31
- {
32
- selected: false,
33
- title: 'choix2',
34
- help: '(help choix2)',
35
- ariaLabel: '__ariaLabel2',
36
- onClick: function () { return undefined; }
37
- },
38
- {
39
- selected: false,
40
- title: 'choix3',
41
- help: '(help choix3)',
42
- ariaLabel: '__ariaLabel3',
43
- onClick: function () { return undefined; }
44
- }
45
- ]
46
- }
47
- },
48
- klf: '___klf',
49
- universalRef: ref
50
- });
31
+ return Promise.resolve(__assign(__assign({}, qcmSlide), { universalRef: ref, id: ref }));
51
32
  },
52
33
  postProgression: function () {
53
34
  return Promise.resolve({
@@ -4,14 +4,71 @@ declare type TemplateContextValues = {
4
4
  theme?: unknown;
5
5
  translations?: unknown;
6
6
  };
7
- export declare type SlideFromAPI = {
8
- question: {
9
- content: {
10
- choices: Record<string, unknown>[];
11
- };
7
+ export declare type ChoiceFromAPI = {
8
+ _id: string;
9
+ id?: string;
10
+ value?: string;
11
+ name?: string;
12
+ type?: 'text' | 'select';
13
+ label?: string;
14
+ items: {
15
+ text: string;
16
+ value: string;
17
+ _id: string;
18
+ }[];
19
+ media?: unknown;
20
+ };
21
+ declare type BaseContent = {
22
+ media?: unknown;
23
+ choices: ChoiceFromAPI[];
24
+ };
25
+ declare type Question = {
26
+ header?: string;
27
+ content: BaseContent;
28
+ explanation?: string;
29
+ };
30
+ export declare type QcmQuestion = Question & {
31
+ type: 'qcm';
32
+ };
33
+ export declare type QcmGraphicQuestion = Question & {
34
+ type: 'qcmGraphic';
35
+ };
36
+ export declare type QcmDragQuestion = Question & {
37
+ type: 'qcmDrag';
38
+ };
39
+ export declare type BasicQuestion = Omit<Question, 'content'> & {
40
+ type: 'basic';
41
+ content: {
42
+ media?: unknown;
43
+ label?: string;
44
+ placeholder?: string;
45
+ id: string;
46
+ };
47
+ };
48
+ export declare type SliderQuestion = Omit<Question, 'content'> & {
49
+ content: {
50
+ media?: unknown;
51
+ unitLabel: string;
52
+ min: number;
53
+ max: number;
54
+ step?: number;
12
55
  };
56
+ type: 'slider';
57
+ };
58
+ export declare type TemplateQuestion = Omit<Question, 'content'> & {
59
+ content: BaseContent & {
60
+ template: string;
61
+ };
62
+ type: 'template';
63
+ };
64
+ export declare type SlideFromAPI = {
65
+ question: QcmQuestion | QcmGraphicQuestion | QcmDragQuestion | BasicQuestion | SliderQuestion | TemplateQuestion;
13
66
  klf: string;
14
67
  universalRef: string;
68
+ tips?: string;
69
+ clue?: string;
70
+ hasClue?: boolean;
71
+ id?: string;
15
72
  };
16
73
  export declare type ProgressionFromAPI = {
17
74
  _id: string;
@@ -1,9 +1,10 @@
1
1
  export declare type Choice = {
2
2
  order?: number;
3
3
  selected: boolean;
4
- title: string;
5
- help: string;
4
+ title?: string;
5
+ help?: string;
6
6
  onClick: Function;
7
+ ariaLabel?: string;
7
8
  };
8
9
  export declare type QcmDrag = {
9
10
  type: 'qcmDrag';
@@ -12,22 +13,20 @@ export declare type QcmDrag = {
12
13
  };
13
14
  export declare type Qcm = {
14
15
  type: 'qcm';
15
- choices: (Choice & {
16
- ariaLabel: string;
17
- })[];
16
+ answers: Choice[];
18
17
  };
19
18
  export declare type QcmGraphic = {
20
19
  type: 'qcmGraphic';
21
- choices: (Choice & {
20
+ answers: (Choice & {
22
21
  image: string;
23
22
  })[];
24
23
  };
25
24
  export declare type FreeText = {
26
25
  type: 'freeText';
27
26
  placeholder: string;
28
- value: string;
27
+ value?: string;
29
28
  onChange: Function;
30
- ariaLabel: string;
29
+ ariaLabel?: string;
31
30
  };
32
31
  export declare type DropDownOption = {
33
32
  name: string;
@@ -37,26 +36,38 @@ export declare type DropDownOption = {
37
36
  };
38
37
  export declare type DropDown = {
39
38
  type: 'dropDown';
40
- onChange: Function;
39
+ onChange?: Function;
41
40
  options: DropDownOption[];
42
- theme: 'filter' | 'invalid' | 'header' | 'mooc' | 'question' | 'sort' | 'thematiques' | 'player' | 'template' | 'coorpmanager';
41
+ theme?: 'filter' | 'invalid' | 'header' | 'mooc' | 'question' | 'sort' | 'thematiques' | 'player' | 'template' | 'coorpmanager';
43
42
  };
44
43
  export declare type QuestionRange = {
45
44
  type: 'slider';
46
- onChange: Function;
47
- onChangeEnd: Function;
48
- multi: boolean;
45
+ placeholder?: string;
46
+ onChange?: Function;
47
+ onChangeEnd?: Function;
48
+ multi?: boolean;
49
49
  value: number | number[];
50
50
  title: string;
51
51
  minLabel: string;
52
52
  maxLabel: string;
53
53
  };
54
+ export declare type TextTemplate = {
55
+ type: 'text';
56
+ name: string;
57
+ placeholder: string;
58
+ value?: string;
59
+ onChange: Function;
60
+ };
61
+ export declare type SelectionTemplate = {
62
+ type: 'select';
63
+ name: string;
64
+ onChange?: Function;
65
+ options?: DropDownOption[];
66
+ };
54
67
  export declare type Template = {
55
68
  type: 'template';
56
69
  template: string;
57
- choices: (DropDown & {
58
- type?: string;
59
- })[];
70
+ answers: (TextTemplate | SelectionTemplate)[];
60
71
  };
61
72
  export declare type AnswerUI = {
62
73
  model: QcmDrag | Qcm | QcmGraphic | FreeText | DropDown | QuestionRange | Template;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -40,7 +40,7 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@coorpacademy/components": "10.22.2",
43
+ "@coorpacademy/components": "10.22.4",
44
44
  "@coorpacademy/redux-task": "^1.1.5",
45
45
  "cross-fetch": "^3.1.5",
46
46
  "jwt-decode": "^3.1.2",
@@ -77,5 +77,5 @@
77
77
  "ts-node": "^10.8.1",
78
78
  "typescript": "^4.7.4"
79
79
  },
80
- "gitHead": "b07a280786c4e83e3632779731e62a547d8ba26c"
80
+ "gitHead": "6a95baa03c98973afdd8d95d1b6959b21c7bb8ee"
81
81
  }
@@ -1,5 +1,6 @@
1
1
  import buildTask from '@coorpacademy/redux-task';
2
- import {Action, Dispatch} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
3
+ import {AnyAction} from 'redux';
3
4
  import type {StoreState} from '../../reducers';
4
5
  import {Options, Skill} from '../../types/common';
5
6
 
@@ -7,12 +8,15 @@ export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST' as const;
7
8
  export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS' as const;
8
9
  export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE' as const;
9
10
 
10
- export type ReceivedSkills = {
11
+ export interface ReceivedSkills extends AnyAction {
11
12
  type: '@@skills/FETCH_SUCCESS';
12
13
  payload: Skill[];
13
- };
14
+ }
14
15
 
15
- export const fetchSkills = (token: string): Action =>
16
+ export type FetchSkillsAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
17
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
18
+
19
+ export const fetchSkills = (token: string): FetchSkillsAction =>
16
20
  buildTask({
17
21
  types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
18
22
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) =>
@@ -1,4 +1,5 @@
1
- import type {Action, Dispatch} from 'redux';
1
+ import type {AnyAction} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
2
3
  import buildTask from '@coorpacademy/redux-task';
3
4
  import type {StoreState} from '../../reducers';
4
5
  import {Options, SlideFromAPI} from '../../types/common';
@@ -7,12 +8,15 @@ export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST' as const;
7
8
  export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS' as const;
8
9
  export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE' as const;
9
10
 
10
- export type ReceivedSlide = {
11
+ export interface ReceivedSlide extends AnyAction {
11
12
  type: typeof SLIDE_FETCH_SUCCESS;
12
13
  payload: SlideFromAPI;
13
- };
14
+ }
14
15
 
15
- export const fetchSlide = (slideRef: string, token: string): Action =>
16
+ export type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
17
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
18
+
19
+ export const fetchSlide = (slideRef: string, token: string): FetchSlideAction =>
16
20
  buildTask({
17
21
  types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
18
22
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) =>
@@ -1,4 +1,5 @@
1
- import type {Action, Dispatch} from 'redux';
1
+ import type {AnyAction} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
2
3
  import buildTask from '@coorpacademy/redux-task';
3
4
  import {Options, ProgressionFromAPI} from '../../types/common';
4
5
  import type {StoreState} from '../../reducers';
@@ -8,12 +9,21 @@ export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST' as const;
8
9
  export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS' as const;
9
10
  export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE' as const;
10
11
 
11
- export type ReceiveProgression = {
12
+ export interface ReceiveProgression extends AnyAction {
12
13
  type: typeof POST_PROGRESSION_SUCCESS;
13
14
  payload: ProgressionFromAPI;
14
- };
15
+ }
15
16
 
16
- export const postProgression = (skillRef: string, token: string): Action =>
17
+ export type PostProgressionAction = ThunkAction<
18
+ Promise<ProgressionFromAPI>,
19
+ StoreState,
20
+ Options,
21
+ AnyAction
22
+ >;
23
+
24
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
25
+
26
+ export const postProgression = (skillRef: string, token: string): PostProgressionAction =>
17
27
  buildTask({
18
28
  types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
19
29
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
@@ -4,7 +4,7 @@ export const NAVIGATE_TO = '@@navigation/NAVIGATE_TO';
4
4
  export const NAVIGATE_BACK = '@@navigation/NAVIGATE_BACK';
5
5
  export const START_APP = '@@navigation/START_APP';
6
6
 
7
- export type ViewPath = 'skills' | 'onboarding' | 'slides';
7
+ export type ViewPath = 'skills' | 'onboarding' | 'slides' | 'loader';
8
8
 
9
9
  export type NavigateTo = {
10
10
  type: '@@navigation/NAVIGATE_TO';
@@ -7,7 +7,7 @@ export const slide: UISlide = {
7
7
  help: '__help',
8
8
  model: {
9
9
  type: 'qcm',
10
- choices: [
10
+ answers: [
11
11
  {
12
12
  selected: false,
13
13
  title: 'choix1',