@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.
- package/es/actions/api/fetch-skills.d.ts +8 -5
- package/es/actions/api/fetch-slide.d.ts +8 -5
- package/es/actions/api/post-progression.d.ts +8 -5
- package/es/actions/ui/navigation.d.ts +1 -1
- package/es/fixtures/qcm-slide.js +1 -1
- package/es/helpers/map-api-slide-to-ui.d.ts +8 -0
- package/es/helpers/map-api-slide-to-ui.js +175 -0
- package/es/helpers/test/fixtures/free-text.d.ts +4 -0
- package/es/helpers/test/fixtures/free-text.js +24 -0
- package/es/helpers/test/fixtures/qcm-drag.d.ts +4 -0
- package/es/helpers/test/fixtures/qcm-drag.js +106 -0
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
- package/es/helpers/test/fixtures/qcm-graphic.js +70 -0
- package/es/helpers/test/fixtures/qcm.d.ts +4 -0
- package/es/helpers/test/fixtures/qcm.js +99 -0
- package/es/helpers/test/fixtures/select-template.d.ts +4 -0
- package/es/helpers/test/fixtures/select-template.js +88 -0
- package/es/helpers/test/fixtures/slider.d.ts +4 -0
- package/es/helpers/test/fixtures/slider.js +27 -0
- package/es/helpers/test/fixtures/text-template.d.ts +4 -0
- package/es/helpers/test/fixtures/text-template.js +48 -0
- package/es/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/helpers/test/map-api-slide-to-ui.test.js +32 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +31 -16
- package/es/reducers/ui/navigation.d.ts +1 -1
- package/es/test/index.test.js +18 -15
- package/es/test/util/services.mock.js +2 -32
- package/es/types/common.d.ts +62 -5
- package/es/types/slides.d.ts +27 -16
- package/lib/actions/api/fetch-skills.d.ts +8 -5
- package/lib/actions/api/fetch-slide.d.ts +8 -5
- package/lib/actions/api/post-progression.d.ts +8 -5
- package/lib/actions/ui/navigation.d.ts +1 -1
- package/lib/fixtures/qcm-slide.js +1 -1
- package/lib/helpers/map-api-slide-to-ui.d.ts +8 -0
- package/lib/helpers/map-api-slide-to-ui.js +181 -0
- package/lib/helpers/test/fixtures/free-text.d.ts +4 -0
- package/lib/helpers/test/fixtures/free-text.js +24 -0
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +4 -0
- package/lib/helpers/test/fixtures/qcm-drag.js +106 -0
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +4 -0
- package/lib/helpers/test/fixtures/qcm-graphic.js +70 -0
- package/lib/helpers/test/fixtures/qcm.d.ts +4 -0
- package/lib/helpers/test/fixtures/qcm.js +99 -0
- package/lib/helpers/test/fixtures/select-template.d.ts +4 -0
- package/lib/helpers/test/fixtures/select-template.js +88 -0
- package/lib/helpers/test/fixtures/slider.d.ts +4 -0
- package/lib/helpers/test/fixtures/slider.js +27 -0
- package/lib/helpers/test/fixtures/text-template.d.ts +4 -0
- package/lib/helpers/test/fixtures/text-template.js +48 -0
- package/lib/helpers/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/helpers/test/map-api-slide-to-ui.test.js +43 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +31 -16
- package/lib/reducers/ui/navigation.d.ts +1 -1
- package/lib/test/index.test.js +19 -16
- package/lib/test/util/services.mock.js +13 -32
- package/lib/types/common.d.ts +62 -5
- package/lib/types/slides.d.ts +27 -16
- package/package.json +3 -3
- package/src/actions/api/fetch-skills.ts +8 -4
- package/src/actions/api/fetch-slide.ts +8 -4
- package/src/actions/api/post-progression.ts +14 -4
- package/src/actions/ui/navigation.ts +1 -1
- package/src/fixtures/qcm-slide.ts +1 -1
- package/src/helpers/map-api-slide-to-ui.ts +253 -0
- package/src/helpers/test/fixtures/free-text.ts +28 -0
- package/src/helpers/test/fixtures/qcm-drag.ts +110 -0
- package/src/helpers/test/fixtures/qcm-graphic.ts +74 -0
- package/src/helpers/test/fixtures/qcm.ts +108 -0
- package/src/helpers/test/fixtures/select-template.ts +92 -0
- package/src/helpers/test/fixtures/slider.ts +31 -0
- package/src/helpers/test/fixtures/text-template.ts +52 -0
- package/src/helpers/test/map-api-slide-to-ui.test.ts +55 -0
- package/src/index.tsx +39 -30
- package/src/reducers/ui/navigation.ts +1 -1
- package/src/test/index.test.tsx +23 -12
- package/src/test/util/services.mock.ts +2 -32
- package/src/types/common.ts +74 -5
- package/src/types/globals.d.ts +0 -5
- 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
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
|
|
103
|
+
if (!store || isSlideFetched)
|
|
107
104
|
return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
+
var token = get('token', options);
|
|
119
|
+
if (store === null || isEmpty(token))
|
|
120
120
|
return;
|
|
121
|
-
var skillRef =
|
|
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;
|
package/lib/test/index.test.js
CHANGED
|
@@ -138,29 +138,32 @@ var appOptions = {
|
|
|
138
138
|
skillRef: 'skill_NJC0jFKoH',
|
|
139
139
|
services: services
|
|
140
140
|
};
|
|
141
|
-
test('should
|
|
142
|
-
var container,
|
|
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
|
|
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
|
-
|
|
153
|
-
t.truthy(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
t.
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
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({
|
package/lib/types/common.d.ts
CHANGED
|
@@ -4,14 +4,71 @@ declare type TemplateContextValues = {
|
|
|
4
4
|
theme?: unknown;
|
|
5
5
|
translations?: unknown;
|
|
6
6
|
};
|
|
7
|
-
export declare type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
package/lib/types/slides.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export declare type Choice = {
|
|
2
2
|
order?: number;
|
|
3
3
|
selected: boolean;
|
|
4
|
-
title
|
|
5
|
-
help
|
|
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
|
-
|
|
16
|
-
ariaLabel: string;
|
|
17
|
-
})[];
|
|
16
|
+
answers: Choice[];
|
|
18
17
|
};
|
|
19
18
|
export declare type QcmGraphic = {
|
|
20
19
|
type: 'qcmGraphic';
|
|
21
|
-
|
|
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
|
|
27
|
+
value?: string;
|
|
29
28
|
onChange: Function;
|
|
30
|
-
ariaLabel
|
|
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
|
|
39
|
+
onChange?: Function;
|
|
41
40
|
options: DropDownOption[];
|
|
42
|
-
theme
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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": "
|
|
80
|
+
"gitHead": "6a95baa03c98973afdd8d95d1b6959b21c7bb8ee"
|
|
81
81
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
-
import {
|
|
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
|
|
11
|
+
export interface ReceivedSkills extends AnyAction {
|
|
11
12
|
type: '@@skills/FETCH_SUCCESS';
|
|
12
13
|
payload: Skill[];
|
|
13
|
-
}
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
export
|
|
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 {
|
|
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
|
|
11
|
+
export interface ReceivedSlide extends AnyAction {
|
|
11
12
|
type: typeof SLIDE_FETCH_SUCCESS;
|
|
12
13
|
payload: SlideFromAPI;
|
|
13
|
-
}
|
|
14
|
+
}
|
|
14
15
|
|
|
15
|
-
export
|
|
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 {
|
|
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
|
|
12
|
+
export interface ReceiveProgression extends AnyAction {
|
|
12
13
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
13
14
|
payload: ProgressionFromAPI;
|
|
14
|
-
}
|
|
15
|
+
}
|
|
15
16
|
|
|
16
|
-
export
|
|
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';
|