@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,88 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const selectTemplateSlide = {
3
+ id: 'sli_410xZQxrZ',
4
+ universalRef: 'sli_410xZQxrZ',
5
+ question: {
6
+ type: 'template',
7
+ header: 'sli_410xZQxrZ.header',
8
+ explanation: 'sli_410xZQxrZ.explanation',
9
+ content: {
10
+ template: 'sli_410xZQxrZ.template',
11
+ choices: [
12
+ {
13
+ media: {
14
+ src: [],
15
+ posters: [],
16
+ subtitles: []
17
+ },
18
+ _id: '5fdce726359bf4003ee66967',
19
+ type: 'select',
20
+ name: 'sel36665',
21
+ items: [
22
+ {
23
+ _id: '5fdce726359bf4003ee66968',
24
+ text: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
25
+ value: 'sli_410xZQxrZ.choice_4yeA4Z7lr~'
26
+ },
27
+ {
28
+ _id: '5fdce726359bf4003ee66969',
29
+ text: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
30
+ value: 'sli_410xZQxrZ.choice_VJWCN~mgB~'
31
+ },
32
+ {
33
+ _id: '5fdce726359bf4003ee6696a',
34
+ text: 'sli_410xZQxrZ.choice_VkaH~XgBb',
35
+ value: 'sli_410xZQxrZ.choice_VkaH~XgBb'
36
+ },
37
+ {
38
+ _id: '5fdce726359bf4003ee6696b',
39
+ text: 'sli_410xZQxrZ.choice_E1uUWXeBb',
40
+ value: 'sli_410xZQxrZ.choice_E1uUWXeBb'
41
+ }
42
+ ]
43
+ }
44
+ ]
45
+ }
46
+ },
47
+ clue: 'sli_410xZQxrZ.clue',
48
+ klf: 'sli_410xZQxrZ.klf',
49
+ tips: 'sli_410xZQxrZ.tips'
50
+ };
51
+ export const selectTemplateUISlide = {
52
+ type: 'template',
53
+ template: 'sli_410xZQxrZ.template',
54
+ answers: [
55
+ {
56
+ type: 'select',
57
+ name: 'sel36665',
58
+ onChange: noop,
59
+ options: [
60
+ { name: 'Select an answer', value: '', validOption: false, selected: true },
61
+ {
62
+ name: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
63
+ value: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
64
+ validOption: true,
65
+ selected: false
66
+ },
67
+ {
68
+ name: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
69
+ value: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
70
+ validOption: true,
71
+ selected: false
72
+ },
73
+ {
74
+ name: 'sli_410xZQxrZ.choice_VkaH~XgBb',
75
+ value: 'sli_410xZQxrZ.choice_VkaH~XgBb',
76
+ validOption: true,
77
+ selected: false
78
+ },
79
+ {
80
+ name: 'sli_410xZQxrZ.choice_E1uUWXeBb',
81
+ value: 'sli_410xZQxrZ.choice_E1uUWXeBb',
82
+ validOption: true,
83
+ selected: false
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ };
@@ -0,0 +1,4 @@
1
+ import { QuestionRange } from '../../../types/slides';
2
+ import { SlideFromAPI } from '../../../types/common';
3
+ export declare const sliderSlide: SlideFromAPI;
4
+ export declare const sliderUISlide: QuestionRange;
@@ -0,0 +1,27 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const sliderSlide = {
3
+ id: 'sli_41D5AovN~',
4
+ universalRef: 'sli_41D5AovN~',
5
+ question: {
6
+ type: 'slider',
7
+ header: 'sli_41D5AovN~.header',
8
+ explanation: 'sli_41D5AovN~.explanation',
9
+ content: {
10
+ min: 1,
11
+ max: 10,
12
+ unitLabel: 'sli_41D5AovN~.unitLabel'
13
+ }
14
+ },
15
+ clue: 'sli_41D5AovN~.clue',
16
+ klf: 'sli_41D5AovN~.klf',
17
+ tips: 'sli_41D5AovN~.tips'
18
+ };
19
+ export const sliderUISlide = {
20
+ type: 'slider',
21
+ placeholder: 'sli_41D5AovN~.explanation',
22
+ minLabel: '1 undefined',
23
+ maxLabel: '10 undefined',
24
+ title: '0 sli_41D5AovN~.unitLabel',
25
+ value: -0.1111111111111111,
26
+ onChange: noop
27
+ };
@@ -0,0 +1,4 @@
1
+ import { Template } from '../../../types/slides';
2
+ import { SlideFromAPI } from '../../../types/common';
3
+ export declare const textTemplateSlide: SlideFromAPI;
4
+ export declare const textTemplateUISlide: Template;
@@ -0,0 +1,48 @@
1
+ import noop from 'lodash/fp/noop';
2
+ export const 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 const 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,32 @@
1
+ import test from 'ava';
2
+ import { mapApiSlideToUi } from '../map-api-slide-to-ui';
3
+ import { qcmUISlide, qcmSlide } from './fixtures/qcm';
4
+ import { qcmDragUISlide, qcmDragSlide } from './fixtures/qcm-drag';
5
+ import { freeTextSlide, freeTextUISlide } from './fixtures/free-text';
6
+ import { qcmGraphicUISlide, qcmGraphicSlide } from './fixtures/qcm-graphic';
7
+ import { textTemplateSlide, textTemplateUISlide } from './fixtures/text-template';
8
+ import { selectTemplateSlide, selectTemplateUISlide } from './fixtures/select-template';
9
+ import { sliderSlide, sliderUISlide } from './fixtures/slider';
10
+ const _mapApiSlideToUi = mapApiSlideToUi({ translate: (text) => text });
11
+ const macro = test.macro({
12
+ title(providedTitle) {
13
+ return `should handle ${providedTitle} conversion`.trim();
14
+ },
15
+ exec(t, arg) {
16
+ t.deepEqual(JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide))), JSON.parse(JSON.stringify(arg.expectedUiSlide)));
17
+ }
18
+ });
19
+ test('qcm', macro, { slide: qcmSlide, expectedUiSlide: qcmUISlide });
20
+ test('qcm drag', macro, { slide: qcmDragSlide, expectedUiSlide: qcmDragUISlide });
21
+ test('qcm graphic', macro, { slide: qcmGraphicSlide, expectedUiSlide: qcmGraphicUISlide });
22
+ test('text template', macro, { slide: textTemplateSlide, expectedUiSlide: textTemplateUISlide });
23
+ test('select template', macro, {
24
+ slide: selectTemplateSlide,
25
+ expectedUiSlide: selectTemplateUISlide
26
+ });
27
+ test('free text', macro, { slide: freeTextSlide, expectedUiSlide: freeTextUISlide });
28
+ test('slider', macro, { slide: sliderSlide, expectedUiSlide: sliderUISlide });
29
+ test('should throw an error if the question type can not be handled', t => {
30
+ const faultySlide = { ...qcmSlide, question: { type: 'lol' } };
31
+ t.throws(() => _mapApiSlideToUi(faultySlide));
32
+ });
package/es/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/es/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
  const mapDispatchToProps = {
18
19
  navigateTo,
19
20
  navigateBack,
@@ -26,7 +27,6 @@ const mapDispatchToProps = {
26
27
  updateFinishedSlides
27
28
  };
28
29
  const getCurrentViewName = (storeState) => storeState.ui.navigation[storeState.ui.navigation.length - 1];
29
- // -----------------------------------------------------------------------------
30
30
  const mapStateToSkillsProps = (state) => {
31
31
  if (!state.data.skills) {
32
32
  return null;
@@ -52,7 +52,6 @@ const mapStateToSkillsProps = (state) => {
52
52
  }))
53
53
  };
54
54
  };
55
- // -----------------------------------------------------------------------------
56
55
  const mapStateToSlidesProps = (state) => {
57
56
  if (!state.data.slides) {
58
57
  return null;
@@ -80,7 +79,6 @@ const mapStateToSlidesProps = (state) => {
80
79
  progression: state.data.progression
81
80
  };
82
81
  };
83
- // -----------------------------------------------------------------------------
84
82
  const mapStateToProps = (state) => {
85
83
  return {
86
84
  viewName: getCurrentViewName(state),
@@ -88,11 +86,10 @@ const mapStateToProps = (state) => {
88
86
  skills: mapStateToSkillsProps(state)
89
87
  };
90
88
  };
91
- // Props = StaticProps && Dispatchers
92
89
  const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
93
- // -----------------------------------------------------------------------------
94
90
  const AppReview = ({ options }) => {
95
91
  const [store, setStore] = useState(null);
92
+ const [isSlideFetched, setIsSlideFetched] = useState(false);
96
93
  useEffect(() => {
97
94
  if (store)
98
95
  return;
@@ -100,26 +97,45 @@ const AppReview = ({ options }) => {
100
97
  setStore(newStore);
101
98
  }, [options, store]);
102
99
  useEffect(() => {
103
- if (store === null)
100
+ if (!store || isSlideFetched)
104
101
  return;
105
- const { skillRef } = options;
106
- const initialView = skillRef ? VIEWS.slides : VIEWS.skills;
107
- store.dispatch(navigateTo(initialView));
108
- }, [options, store]);
102
+ return store.subscribe(() => {
103
+ const isSlidePresent = !isEmpty(store.getState().data.slides[0].questionText);
104
+ return isSlidePresent && setIsSlideFetched(isSlidePresent);
105
+ }); // using the first slide questionText for now, should only check for a slide's presence
106
+ // when the refactor is done (slides will be feed one by one on api's side)
107
+ }, [isSlideFetched, options, store]);
109
108
  useEffect(() => {
110
- if (store === null)
109
+ const token = get('token', options);
110
+ if (store === null || isEmpty(token))
111
111
  return;
112
- const { token } = options;
113
112
  store.dispatch(storeToken(token));
114
113
  }, [options, store]);
115
114
  useEffect(() => {
116
- if (store === null)
115
+ const token = get('token', options);
116
+ if (store === null || isEmpty(token))
117
117
  return;
118
- const { skillRef, token } = options;
118
+ const skillRef = get('skillRef', options);
119
+ // ThunkAction is not assignable to parameter of type 'AnyAction'
120
+ // ts problem describre here = https://github.com/reduxjs/redux-thunk/issues/333
119
121
  skillRef
120
122
  ? store.dispatch(postProgression(skillRef, token))
121
123
  : store.dispatch(fetchSkills(token));
122
124
  }, [options, store]);
125
+ useEffect(() => {
126
+ if (store === null)
127
+ return;
128
+ const { skillRef } = options;
129
+ if (skillRef && !isSlideFetched) {
130
+ store.dispatch(navigateTo('loader')); // use loader while posting progression
131
+ return;
132
+ }
133
+ // TODO: when slides state is refactored (data + mapping),
134
+ // use loader in case a skillRef is found && no slides from the API
135
+ // are found
136
+ const initialView = skillRef ? VIEWS.slides : VIEWS.skills;
137
+ store.dispatch(navigateTo(initialView));
138
+ }, [isSlideFetched, options, store]);
123
139
  if (!store)
124
140
  return null;
125
141
  const { templateContext: values } = options;
@@ -127,5 +143,4 @@ const AppReview = ({ options }) => {
127
143
  React.createElement(TemplateContext, { values: values },
128
144
  React.createElement(App, null))));
129
145
  };
130
- // -----------------------------------------------------------------------------
131
146
  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;
@@ -42,22 +42,25 @@ const appOptions = {
42
42
  skillRef: 'skill_NJC0jFKoH',
43
43
  services
44
44
  };
45
- test('should validate all the slides (all correct scenario)', async (t) => {
46
- // t.plan(13);
45
+ test('should show the loader while the app is fetching the data', async (t) => {
47
46
  t.plan(2);
48
- const { container } = render(React.createElement(AppReview, { options: appOptions, key: 0 }));
47
+ const { container } = render(React.createElement(AppReview, { options: appOptions }));
49
48
  await waitForChanges(1000);
50
- const wrapper = container.querySelector('[data-name="loader"]');
51
- t.truthy(wrapper);
52
- /*
53
- const wrapper = container.querySelector('[data-name="slides-revision-container"]');
54
- t.truthy(wrapper);
55
-
56
- const stackedSlidesContainer = wrapper?.querySelector('[data-name="stacked-slides-container"]');
57
-
58
- t.truthy(stackedSlidesContainer);
59
-
60
- await clickAllSlides(t, container);
61
- */
49
+ const loader = container.querySelector('[data-name="loader"]');
50
+ t.truthy(loader);
51
+ // await waitFor(async () => {
52
+ // // await sleep(500);
53
+ // const result = await t.try(tt => {
54
+ // // rerender(<AppReview options={appOptions} />);
55
+ // const slidesContainer = container.querySelector('[data-name="slides-revision-container"]');
56
+ // tt.truthy(slidesContainer);
57
+ // });
58
+ // if (result.passed) return result.commit();
59
+ // result.discard();
60
+ // throw result.errors;
61
+ // });
62
+ // const stackedSlidesContainer = container.querySelector('[data-name="stacked-slides-container"]');
63
+ // t.truthy(stackedSlidesContainer);
64
+ // await clickAllSlides(t, container);
62
65
  t.pass();
63
66
  });
@@ -1,3 +1,4 @@
1
+ import { qcmSlide } from '../../helpers/test/fixtures/qcm';
1
2
  export const services = {
2
3
  fetchSkills: () => {
3
4
  return Promise.resolve([
@@ -16,38 +17,7 @@ export const services = {
16
17
  ]);
17
18
  },
18
19
  fetchSlide: 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: () => undefined
30
- },
31
- {
32
- selected: false,
33
- title: 'choix2',
34
- help: '(help choix2)',
35
- ariaLabel: '__ariaLabel2',
36
- onClick: () => undefined
37
- },
38
- {
39
- selected: false,
40
- title: 'choix3',
41
- help: '(help choix3)',
42
- ariaLabel: '__ariaLabel3',
43
- onClick: () => undefined
44
- }
45
- ]
46
- }
47
- },
48
- klf: '___klf',
49
- universalRef: ref
50
- });
20
+ return Promise.resolve({ ...qcmSlide, universalRef: ref, id: ref });
51
21
  },
52
22
  postProgression: () => {
53
23
  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;
@@ -1,10 +1,13 @@
1
- import { Action } from 'redux';
2
- import { Skill } from '../../types/common';
1
+ import type { ThunkAction } from 'redux-thunk';
2
+ import { AnyAction } from 'redux';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, Skill } from '../../types/common';
3
5
  export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
4
6
  export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
5
7
  export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
6
- export declare type ReceivedSkills = {
8
+ export interface ReceivedSkills extends AnyAction {
7
9
  type: '@@skills/FETCH_SUCCESS';
8
10
  payload: Skill[];
9
- };
10
- export declare const fetchSkills: (token: string) => Action;
11
+ }
12
+ export declare type FetchSkillsAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSkills: (token: string) => FetchSkillsAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { SlideFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, SlideFromAPI } from '../../types/common';
3
5
  export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
4
6
  export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
5
7
  export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
6
- export declare type ReceivedSlide = {
8
+ export interface ReceivedSlide extends AnyAction {
7
9
  type: typeof SLIDE_FETCH_SUCCESS;
8
10
  payload: SlideFromAPI;
9
- };
10
- export declare const fetchSlide: (slideRef: string, token: string) => Action;
11
+ }
12
+ export declare type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSlide: (slideRef: string, token: string) => FetchSlideAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { ProgressionFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import { Options, ProgressionFromAPI } from '../../types/common';
4
+ import type { StoreState } from '../../reducers';
3
5
  export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
4
6
  export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
5
7
  export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
6
- export declare type ReceiveProgression = {
8
+ export interface ReceiveProgression extends AnyAction {
7
9
  type: typeof POST_PROGRESSION_SUCCESS;
8
10
  payload: ProgressionFromAPI;
9
- };
10
- export declare const postProgression: (skillRef: string, token: string) => Action;
11
+ }
12
+ export declare type PostProgressionAction = ThunkAction<Promise<ProgressionFromAPI>, StoreState, Options, AnyAction>;
13
+ export declare const postProgression: (skillRef: string, token: string) => PostProgressionAction;
@@ -2,7 +2,7 @@ import { AppOptions } from '../../types/common';
2
2
  export declare const NAVIGATE_TO = "@@navigation/NAVIGATE_TO";
3
3
  export declare const NAVIGATE_BACK = "@@navigation/NAVIGATE_BACK";
4
4
  export declare const START_APP = "@@navigation/START_APP";
5
- export declare type ViewPath = 'skills' | 'onboarding' | 'slides';
5
+ export declare type ViewPath = 'skills' | 'onboarding' | 'slides' | 'loader';
6
6
  export declare type NavigateTo = {
7
7
  type: '@@navigation/NAVIGATE_TO';
8
8
  payload: ViewPath;