@coorpacademy/app-review 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-slide.d.ts +3 -3
- package/es/actions/api/fetch-slide.js +22 -2
- package/es/actions/api/post-progression.js +1 -2
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/is-fetching.js +0 -2
- package/es/actions/ui/slides.d.ts +26 -0
- package/es/actions/ui/slides.js +9 -0
- package/es/common/index.d.ts +3 -1
- package/es/common/index.js +3 -1
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/fixtures/temp-fixture.d.ts +2 -2
- package/es/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/es/helpers/map-api-slide-to-ui.js +33 -15
- package/es/helpers/test/fixtures/free-text.d.ts +2 -3
- package/es/helpers/test/fixtures/free-text.js +10 -4
- package/es/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-drag.js +38 -32
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/es/helpers/test/fixtures/qcm.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm.js +32 -26
- package/es/helpers/test/fixtures/select-template.d.ts +2 -3
- package/es/helpers/test/fixtures/select-template.js +38 -32
- package/es/helpers/test/fixtures/slider.d.ts +2 -3
- package/es/helpers/test/fixtures/slider.js +13 -7
- package/es/helpers/test/fixtures/text-template.d.ts +2 -3
- package/es/helpers/test/fixtures/text-template.js +16 -10
- package/es/index.js +14 -78
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -16
- package/es/reducers/data/progression.js +3 -22
- package/es/reducers/data/slides.d.ts +5 -6
- package/es/reducers/data/slides.js +4 -107
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/slides.d.ts +9 -0
- package/es/reducers/ui/slides.js +42 -0
- package/es/services/test/post-progression.test.js +6 -4
- package/es/test/util/services.mock.js +17 -5
- package/es/types/common.d.ts +40 -23
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- package/es/types/views/slides.d.ts +41 -27
- package/es/types/views/slides.js +5 -0
- package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
- package/es/views/skills/index.js +25 -0
- package/es/views/slides/index.d.ts +3 -0
- package/es/views/slides/index.js +85 -0
- package/lib/actions/api/fetch-slide.d.ts +3 -3
- package/lib/actions/api/fetch-slide.js +20 -2
- package/lib/actions/api/post-progression.js +1 -2
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/is-fetching.js +0 -2
- package/lib/actions/ui/slides.d.ts +26 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.js +3 -1
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/fixtures/temp-fixture.d.ts +2 -2
- package/lib/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/lib/helpers/map-api-slide-to-ui.js +34 -14
- package/lib/helpers/test/fixtures/free-text.d.ts +2 -3
- package/lib/helpers/test/fixtures/free-text.js +10 -4
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-drag.js +38 -32
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/lib/helpers/test/fixtures/qcm.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm.js +32 -26
- package/lib/helpers/test/fixtures/select-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/select-template.js +38 -32
- package/lib/helpers/test/fixtures/slider.d.ts +2 -3
- package/lib/helpers/test/fixtures/slider.js +13 -7
- package/lib/helpers/test/fixtures/text-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/text-template.js +16 -10
- package/lib/index.js +14 -78
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -16
- package/lib/reducers/data/progression.js +3 -22
- package/lib/reducers/data/slides.d.ts +5 -6
- package/lib/reducers/data/slides.js +4 -113
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/slides.d.ts +9 -0
- package/lib/reducers/ui/slides.js +43 -0
- package/lib/services/test/post-progression.test.js +6 -4
- package/lib/test/util/services.mock.js +17 -5
- package/lib/types/common.d.ts +40 -23
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- package/lib/types/views/slides.d.ts +41 -27
- package/lib/types/views/slides.js +5 -0
- package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
- package/lib/views/skills/index.js +25 -0
- package/lib/views/slides/index.d.ts +3 -0
- package/lib/views/slides/index.js +89 -0
- package/package.json +3 -3
- package/src/actions/api/fetch-slide.ts +26 -5
- package/src/actions/api/post-progression.ts +1 -2
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/is-fetching.ts +0 -6
- package/src/actions/ui/slides.ts +35 -0
- package/src/common/index.ts +7 -1
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/fixtures/temp-fixture.ts +2 -2
- package/src/helpers/map-api-slide-to-ui.ts +43 -17
- package/src/helpers/test/fixtures/free-text.ts +12 -7
- package/src/helpers/test/fixtures/qcm-drag.ts +40 -35
- package/src/helpers/test/fixtures/qcm-graphic.ts +22 -17
- package/src/helpers/test/fixtures/qcm.ts +38 -32
- package/src/helpers/test/fixtures/select-template.ts +40 -35
- package/src/helpers/test/fixtures/slider.ts +15 -10
- package/src/helpers/test/fixtures/text-template.ts +18 -13
- package/src/helpers/test/map-api-slide-to-ui.test.ts +2 -11
- package/src/index.tsx +15 -84
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +9 -126
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/slides.ts +58 -0
- package/src/services/test/post-progression.test.ts +6 -4
- package/src/test/util/services.mock.ts +17 -5
- package/src/types/common.ts +44 -27
- package/src/types/slides.ts +0 -5
- package/src/types/views/slides.ts +52 -27
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +92 -0
- package/es/actions/data/slides.d.ts +0 -37
- package/es/actions/data/slides.js +0 -16
- package/es/actions/ui/finished-slides.d.ts +0 -10
- package/es/actions/ui/finished-slides.js +0 -8
- package/es/actions/ui/review-status.d.ts +0 -7
- package/es/actions/ui/review-status.js +0 -7
- package/es/actions/ui/step-items.d.ts +0 -24
- package/es/actions/ui/step-items.js +0 -11
- package/es/reducers/ui/finished-slides.d.ts +0 -7
- package/es/reducers/ui/finished-slides.js +0 -33
- package/es/reducers/ui/review-status.d.ts +0 -4
- package/es/reducers/ui/step-items.d.ts +0 -14
- package/es/reducers/ui/step-items.js +0 -74
- package/es/types/ui-progression.d.ts +0 -10
- package/es/types/ui-progression.js +0 -1
- package/es/types/views/skills.js +0 -1
- package/lib/actions/data/slides.d.ts +0 -37
- package/lib/actions/data/slides.js +0 -16
- package/lib/actions/ui/finished-slides.d.ts +0 -10
- package/lib/actions/ui/finished-slides.js +0 -8
- package/lib/actions/ui/review-status.d.ts +0 -7
- package/lib/actions/ui/review-status.js +0 -7
- package/lib/actions/ui/step-items.d.ts +0 -24
- package/lib/actions/ui/step-items.js +0 -11
- package/lib/reducers/ui/finished-slides.d.ts +0 -7
- package/lib/reducers/ui/finished-slides.js +0 -45
- package/lib/reducers/ui/review-status.d.ts +0 -4
- package/lib/reducers/ui/step-items.d.ts +0 -14
- package/lib/reducers/ui/step-items.js +0 -86
- package/lib/types/ui-progression.d.ts +0 -10
- package/lib/types/ui-progression.js +0 -1
- package/lib/types/views/skills.js +0 -1
- package/src/actions/data/slides.ts +0 -65
- package/src/actions/ui/finished-slides.ts +0 -21
- package/src/actions/ui/review-status.ts +0 -19
- package/src/actions/ui/step-items.ts +0 -45
- package/src/reducers/ui/finished-slides.ts +0 -52
- package/src/reducers/ui/review-status.ts +0 -19
- package/src/reducers/ui/step-items.ts +0 -116
- package/src/types/ui-progression.ts +0 -25
- package/src/types/views/skills.ts +0 -27
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
2
|
+
import {SlideFromAPI, UISlide} from '../../../types/common';
|
|
4
3
|
|
|
5
4
|
export const selectTemplateSlide: SlideFromAPI = {
|
|
6
5
|
id: 'sli_410xZQxrZ',
|
|
@@ -52,41 +51,47 @@ export const selectTemplateSlide: SlideFromAPI = {
|
|
|
52
51
|
tips: 'sli_410xZQxrZ.tips'
|
|
53
52
|
};
|
|
54
53
|
|
|
55
|
-
export const selectTemplateUISlide:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
type: '
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
options: [
|
|
64
|
-
{name: 'Select an answer', value: '', validOption: false, selected: true},
|
|
65
|
-
{
|
|
66
|
-
name: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
|
|
67
|
-
value: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
|
|
68
|
-
validOption: true,
|
|
69
|
-
selected: false
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
|
|
73
|
-
value: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
|
|
74
|
-
validOption: true,
|
|
75
|
-
selected: false
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'sli_410xZQxrZ.choice_VkaH~XgBb',
|
|
79
|
-
value: 'sli_410xZQxrZ.choice_VkaH~XgBb',
|
|
80
|
-
validOption: true,
|
|
81
|
-
selected: false
|
|
82
|
-
},
|
|
54
|
+
export const selectTemplateUISlide: Partial<UISlide> = {
|
|
55
|
+
questionText: 'sli_410xZQxrZ.header',
|
|
56
|
+
answerUI: {
|
|
57
|
+
help: 'sli_410xZQxrZ.explanation',
|
|
58
|
+
model: {
|
|
59
|
+
type: 'template',
|
|
60
|
+
template: 'sli_410xZQxrZ.template',
|
|
61
|
+
answers: [
|
|
83
62
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
type: 'select',
|
|
64
|
+
name: 'sel36665',
|
|
65
|
+
onChange: noop,
|
|
66
|
+
options: [
|
|
67
|
+
{name: 'Select an answer', value: '', validOption: false, selected: true},
|
|
68
|
+
{
|
|
69
|
+
name: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
|
|
70
|
+
value: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
|
|
71
|
+
validOption: true,
|
|
72
|
+
selected: false
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
|
|
76
|
+
value: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
|
|
77
|
+
validOption: true,
|
|
78
|
+
selected: false
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'sli_410xZQxrZ.choice_VkaH~XgBb',
|
|
82
|
+
value: 'sli_410xZQxrZ.choice_VkaH~XgBb',
|
|
83
|
+
validOption: true,
|
|
84
|
+
selected: false
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'sli_410xZQxrZ.choice_E1uUWXeBb',
|
|
88
|
+
value: 'sli_410xZQxrZ.choice_E1uUWXeBb',
|
|
89
|
+
validOption: true,
|
|
90
|
+
selected: false
|
|
91
|
+
}
|
|
92
|
+
]
|
|
88
93
|
}
|
|
89
94
|
]
|
|
90
95
|
}
|
|
91
|
-
|
|
96
|
+
}
|
|
92
97
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
2
|
+
import {SlideFromAPI, UISlide} from '../../../types/common';
|
|
4
3
|
|
|
5
4
|
export const sliderSlide: SlideFromAPI = {
|
|
6
5
|
id: 'sli_41D5AovN~',
|
|
@@ -20,12 +19,18 @@ export const sliderSlide: SlideFromAPI = {
|
|
|
20
19
|
tips: 'sli_41D5AovN~.tips'
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
export const sliderUISlide:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
export const sliderUISlide: Partial<UISlide> = {
|
|
23
|
+
questionText: 'sli_41D5AovN~.header',
|
|
24
|
+
answerUI: {
|
|
25
|
+
help: 'sli_41D5AovN~.explanation',
|
|
26
|
+
model: {
|
|
27
|
+
type: 'slider',
|
|
28
|
+
placeholder: 'sli_41D5AovN~.explanation',
|
|
29
|
+
minLabel: '1 undefined',
|
|
30
|
+
maxLabel: '10 undefined',
|
|
31
|
+
title: '0 sli_41D5AovN~.unitLabel',
|
|
32
|
+
value: -0.1111111111111111,
|
|
33
|
+
onChange: noop
|
|
34
|
+
}
|
|
35
|
+
}
|
|
31
36
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
2
|
+
import {SlideFromAPI, UISlide} from '../../../types/common';
|
|
4
3
|
|
|
5
4
|
export const textTemplateSlide: SlideFromAPI = {
|
|
6
5
|
question: {
|
|
@@ -37,16 +36,22 @@ export const textTemplateSlide: SlideFromAPI = {
|
|
|
37
36
|
id: 'sli_VJKQonm2g'
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
export const textTemplateUISlide:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
type: '
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
export const textTemplateUISlide: Partial<UISlide> = {
|
|
40
|
+
questionText: 'Comment le protégé doit-il percevoir son mentor ?',
|
|
41
|
+
answerUI: {
|
|
42
|
+
help: 'Saisissez votre réponse (en anglais).',
|
|
43
|
+
model: {
|
|
44
|
+
type: 'template',
|
|
45
|
+
template: 'Un {{inp58402}} model.',
|
|
46
|
+
answers: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text',
|
|
49
|
+
name: 'inp58402',
|
|
50
|
+
placeholder: 'Type here',
|
|
51
|
+
value: undefined,
|
|
52
|
+
onChange: noop
|
|
53
|
+
}
|
|
54
|
+
]
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
}
|
|
52
57
|
};
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import {SlideFromAPI} from '../../types/common';
|
|
2
|
+
import {SlideFromAPI, UISlide} from '../../types/common';
|
|
3
3
|
import {mapApiSlideToUi} from '../map-api-slide-to-ui';
|
|
4
|
-
import {
|
|
5
|
-
QcmDrag,
|
|
6
|
-
Qcm,
|
|
7
|
-
QcmGraphic,
|
|
8
|
-
FreeText,
|
|
9
|
-
DropDown,
|
|
10
|
-
QuestionRange,
|
|
11
|
-
Template
|
|
12
|
-
} from '../../types/slides';
|
|
13
4
|
import {qcmUISlide, qcmSlide} from './fixtures/qcm';
|
|
14
5
|
import {qcmDragUISlide, qcmDragSlide} from './fixtures/qcm-drag';
|
|
15
6
|
import {freeTextSlide, freeTextUISlide} from './fixtures/free-text';
|
|
@@ -28,7 +19,7 @@ const macro = test.macro({
|
|
|
28
19
|
t,
|
|
29
20
|
arg: {
|
|
30
21
|
slide: SlideFromAPI;
|
|
31
|
-
expectedUiSlide:
|
|
22
|
+
expectedUiSlide: Partial<UISlide>;
|
|
32
23
|
}
|
|
33
24
|
) {
|
|
34
25
|
t.deepEqual(
|
package/src/index.tsx
CHANGED
|
@@ -8,23 +8,21 @@ import {TemplateContext} from '@coorpacademy/components/es/template/app-review/t
|
|
|
8
8
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
9
9
|
import get from 'lodash/fp/get';
|
|
10
10
|
import configureStore from './configure-store';
|
|
11
|
-
import {congratsProps, correctionPopinProps} from './fixtures/temp-fixture';
|
|
12
11
|
|
|
13
12
|
import type {AppOptions} from './types/common';
|
|
14
13
|
import type {StoreState} from './reducers';
|
|
15
|
-
import {SkillsProps} from './types/views/skills';
|
|
16
14
|
import type {SlidesViewStaticProps} from './types/views/slides';
|
|
17
15
|
|
|
18
16
|
import {Dispatchers} from './actions';
|
|
19
|
-
import {
|
|
17
|
+
import {validateSlide} from './actions/ui/slides';
|
|
18
|
+
|
|
20
19
|
import {navigateTo, navigateBack, ViewPath} from './actions/ui/navigation';
|
|
21
20
|
import {storeToken} from './actions/data/token';
|
|
22
|
-
import {updateFinishedSlides} from './actions/ui/finished-slides';
|
|
23
|
-
import {updateReviewStatus} from './actions/ui/review-status';
|
|
24
|
-
import {updateStepItemsOnValidation, updateStepItemsOnNext} from './actions/ui/step-items';
|
|
25
21
|
import {fetchSkills} from './actions/api/fetch-skills';
|
|
26
22
|
import {postProgression} from './actions/api/post-progression';
|
|
27
23
|
import {VIEWS} from './common';
|
|
24
|
+
import {mapStateToSlidesProps} from './views/slides';
|
|
25
|
+
import {mapStateToSkillsProps, SkillsProps} from './views/skills';
|
|
28
26
|
|
|
29
27
|
type StaticProps = {
|
|
30
28
|
viewName: 'skills' | 'onboarding' | 'slides' | 'loader';
|
|
@@ -35,74 +33,12 @@ type StaticProps = {
|
|
|
35
33
|
const mapDispatchToProps: Dispatchers = {
|
|
36
34
|
navigateTo,
|
|
37
35
|
navigateBack,
|
|
38
|
-
validateSlide
|
|
39
|
-
updateSlidesOnValidation,
|
|
40
|
-
updateSlidesOnNext,
|
|
41
|
-
updateReviewStatus,
|
|
42
|
-
updateStepItemsOnValidation,
|
|
43
|
-
updateStepItemsOnNext,
|
|
44
|
-
updateFinishedSlides
|
|
36
|
+
validateSlide
|
|
45
37
|
};
|
|
46
38
|
|
|
47
39
|
const getCurrentViewName = (storeState: StoreState): ViewPath =>
|
|
48
40
|
storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
49
41
|
|
|
50
|
-
const mapStateToSkillsProps = (state: StoreState): SkillsProps | null => {
|
|
51
|
-
if (!state.data.skills) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
title: '@todo title',
|
|
57
|
-
titleNoSkills: '@todo titleNoSkills',
|
|
58
|
-
textNoSkills: '@todo textNoSkills',
|
|
59
|
-
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
60
|
-
isLoading: false,
|
|
61
|
-
isLoadingAriaLabel: '@todo loading',
|
|
62
|
-
listSkills: state.data.skills.map(skill => ({
|
|
63
|
-
'aria-label': '',
|
|
64
|
-
isCustom: skill.custom,
|
|
65
|
-
skillTitle: skill.name,
|
|
66
|
-
skillAriaLabel: '@todo skill aria label',
|
|
67
|
-
buttonLabel: '@todo button',
|
|
68
|
-
buttonAriaLabel: '@todo button aria label',
|
|
69
|
-
reviseLabel: '@todo revise',
|
|
70
|
-
reviseAriaLabel: '@todo revise aria label',
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
|
-
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
73
|
-
}))
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const mapStateToSlidesProps = (state: StoreState): SlidesViewStaticProps | null => {
|
|
78
|
-
if (!state.data.slides) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
headerProps: {
|
|
84
|
-
mode: '__revision_mode',
|
|
85
|
-
skillName: '__agility',
|
|
86
|
-
onQuitClick: (): void => {
|
|
87
|
-
// eslint-disable-next-line no-console
|
|
88
|
-
console.log('onQuitClick');
|
|
89
|
-
},
|
|
90
|
-
'aria-label': 'aria-header-wrapper',
|
|
91
|
-
closeButtonAriaLabel: 'aria-close-button'
|
|
92
|
-
},
|
|
93
|
-
slides: state.data.slides,
|
|
94
|
-
validate: {
|
|
95
|
-
label: '__validate'
|
|
96
|
-
},
|
|
97
|
-
finishedSlides: state.ui.finishedSlides,
|
|
98
|
-
stepItems: state.ui.stepItems,
|
|
99
|
-
reviewStatus: state.ui.reviewStatus,
|
|
100
|
-
correctionPopinProps,
|
|
101
|
-
congratsProps,
|
|
102
|
-
progression: state.data.progression
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
42
|
const mapStateToProps = (state: StoreState): StaticProps => {
|
|
107
43
|
return {
|
|
108
44
|
viewName: getCurrentViewName(state),
|
|
@@ -115,7 +51,7 @@ const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
|
115
51
|
|
|
116
52
|
const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
117
53
|
const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
|
|
118
|
-
const [
|
|
54
|
+
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
119
55
|
|
|
120
56
|
useEffect(() => {
|
|
121
57
|
if (store) return;
|
|
@@ -125,14 +61,13 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
125
61
|
}, [options, store]);
|
|
126
62
|
|
|
127
63
|
useEffect(() => {
|
|
128
|
-
if (!store ||
|
|
64
|
+
if (!store || isProgressionCreated) return;
|
|
129
65
|
|
|
130
66
|
return store.subscribe(() => {
|
|
131
|
-
const
|
|
132
|
-
return
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
}, [isSlideFetched, options, store]);
|
|
67
|
+
const isProgressionPresent = !isEmpty(store.getState().data.progression);
|
|
68
|
+
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
69
|
+
});
|
|
70
|
+
}, [isProgressionCreated, options, store]);
|
|
136
71
|
|
|
137
72
|
useEffect(() => {
|
|
138
73
|
const token = get('token', options);
|
|
@@ -146,8 +81,8 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
146
81
|
|
|
147
82
|
const skillRef = get('skillRef', options);
|
|
148
83
|
|
|
149
|
-
|
|
150
|
-
|
|
84
|
+
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
85
|
+
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
151
86
|
skillRef
|
|
152
87
|
? store.dispatch(postProgression(skillRef, token))
|
|
153
88
|
: store.dispatch(fetchSkills(token));
|
|
@@ -158,18 +93,14 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
158
93
|
|
|
159
94
|
const {skillRef} = options;
|
|
160
95
|
|
|
161
|
-
if (skillRef && !
|
|
96
|
+
if (skillRef && !isProgressionCreated) {
|
|
162
97
|
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
163
98
|
return;
|
|
164
99
|
}
|
|
165
100
|
|
|
166
|
-
// TODO: when slides state is refactored (data + mapping),
|
|
167
|
-
// use loader in case a skillRef is found && no slides from the API
|
|
168
|
-
// are found
|
|
169
|
-
|
|
170
101
|
const initialView: ViewPath = skillRef ? VIEWS.slides : VIEWS.skills;
|
|
171
102
|
store.dispatch(navigateTo(initialView));
|
|
172
|
-
}, [
|
|
103
|
+
}, [isProgressionCreated, options, store]);
|
|
173
104
|
|
|
174
105
|
if (!store) return null;
|
|
175
106
|
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {ValidateSlide, VALIDATE_SLIDE} from '../../actions/data/slides';
|
|
1
|
+
import {ValidateSlide, VALIDATE_SLIDE} from '../../actions/ui/slides';
|
|
3
2
|
import {POST_PROGRESSION_SUCCESS, ReceiveProgression} from '../../actions/api/post-progression';
|
|
3
|
+
import {ProgressionFromAPI} from '../../types/common';
|
|
4
4
|
|
|
5
|
-
export type ProgressionState =
|
|
6
|
-
_id?: string;
|
|
7
|
-
state: {
|
|
8
|
-
isCorrect: boolean;
|
|
9
|
-
nextContent: {
|
|
10
|
-
ref: 'successExitNode' | string;
|
|
11
|
-
type: 'success' | 'slide';
|
|
12
|
-
};
|
|
13
|
-
pendingSlides: string[];
|
|
14
|
-
step: {
|
|
15
|
-
current: number;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
// TO refactor: (slideNumber)
|
|
19
|
-
// virtual field
|
|
20
|
-
slideNumber?: number;
|
|
21
|
-
} | null; // TODO: ça ressemble beaucoup à ProgressionFromAPI et ça devrait l'être
|
|
5
|
+
export type ProgressionState = ProgressionFromAPI | null;
|
|
22
6
|
|
|
23
7
|
const reducer = (
|
|
24
8
|
// eslint-disable-next-line default-param-last
|
|
@@ -27,25 +11,8 @@ const reducer = (
|
|
|
27
11
|
): ProgressionState => {
|
|
28
12
|
switch (action.type) {
|
|
29
13
|
case VALIDATE_SLIDE: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// TODO: fix on VALIDATE ticket
|
|
33
|
-
return {
|
|
34
|
-
_id: '1234',
|
|
35
|
-
// virtual field
|
|
36
|
-
slideNumber: previousSlideNumber + 1,
|
|
37
|
-
state: {
|
|
38
|
-
pendingSlides: [],
|
|
39
|
-
step: {
|
|
40
|
-
current: Number.NaN
|
|
41
|
-
},
|
|
42
|
-
isCorrect: true,
|
|
43
|
-
nextContent: {
|
|
44
|
-
ref: 'sli_V1gKpYYZ2',
|
|
45
|
-
type: 'slide'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
14
|
+
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
15
|
+
return state;
|
|
49
16
|
}
|
|
50
17
|
case POST_PROGRESSION_SUCCESS: {
|
|
51
18
|
const progression = action.payload;
|
|
@@ -56,6 +23,4 @@ const reducer = (
|
|
|
56
23
|
}
|
|
57
24
|
};
|
|
58
25
|
|
|
59
|
-
// -----------------------------------------------------------------------------
|
|
60
|
-
|
|
61
26
|
export default reducer;
|
|
@@ -1,140 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
UPDATE_SLIDES_ON_NEXT,
|
|
6
|
-
UPDATE_SLIDES_ON_VALIDATION,
|
|
7
|
-
ValidationPayload
|
|
8
|
-
} from '../../actions/data/slides';
|
|
9
|
-
import {UISlide} from '../../types/slides';
|
|
10
|
-
import {HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK} from '../../common';
|
|
11
|
-
import {slide as qcmSlide} from '../../fixtures/qcm-slide';
|
|
12
|
-
import {SLIDE_FETCH_SUCCESS} from '../../actions/api/fetch-slide';
|
|
13
|
-
import {Slide} from '../../types/common';
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
import {ValidateSlide} from '../../actions/ui/slides';
|
|
3
|
+
import {ReceivedSlide, SLIDE_FETCH_SUCCESS} from '../../actions/api/fetch-slide';
|
|
4
|
+
import {SlideFromAPI} from '../../types/common';
|
|
14
5
|
|
|
15
|
-
export type
|
|
16
|
-
slideNumbers: number[];
|
|
17
|
-
[key: number]: Slide;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getInitialState = (): SlidesState => {
|
|
21
|
-
const state: SlidesState = {
|
|
22
|
-
slideNumbers
|
|
23
|
-
};
|
|
24
|
-
// eslint-disable-next-line fp/no-loops
|
|
25
|
-
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
26
|
-
state[index] = {hidden: false, position: index};
|
|
27
|
-
}
|
|
28
|
-
return state;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const initialState: SlidesState = getInitialState();
|
|
32
|
-
|
|
33
|
-
// -----------------------------------------------------------------------------
|
|
34
|
-
|
|
35
|
-
const setFirstSlide = (state: SlidesState, slide: UISlide): SlidesState => {
|
|
36
|
-
const _state: SlidesState = {
|
|
37
|
-
slideNumbers
|
|
38
|
-
};
|
|
39
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
40
|
-
map(index => {
|
|
41
|
-
const previousValue = state[index];
|
|
42
|
-
// Only update the 1st one
|
|
43
|
-
const content = index === 0 ? {...previousValue, ...slide} : {...previousValue};
|
|
44
|
-
_state[index] = {...content};
|
|
45
|
-
}, state.slideNumbers);
|
|
46
|
-
|
|
47
|
-
return _state;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// ||-------> Handles the updates of a given slide on validation,
|
|
51
|
-
// & then updates de remaining slides if this given change should impact their content
|
|
52
|
-
const stateUpdateOnValidation = (state: SlidesState, payload: ValidationPayload): SlidesState => {
|
|
53
|
-
const {slideNumber, newSlideContent, numberOfFinishedSlides, nextContent} = payload;
|
|
54
|
-
const _state: SlidesState = {
|
|
55
|
-
slideNumbers
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
59
|
-
map(index => {
|
|
60
|
-
const previousValue = state[index];
|
|
61
|
-
// the current slide
|
|
62
|
-
if (index === slideNumber) {
|
|
63
|
-
// only one slide remaining, presets the next value
|
|
64
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
65
|
-
_state[index] = {
|
|
66
|
-
...previousValue,
|
|
67
|
-
nextContent,
|
|
68
|
-
position: newSlideContent.position,
|
|
69
|
-
isCorrect: newSlideContent.isCorrect
|
|
70
|
-
};
|
|
71
|
-
} else _state[slideNumber] = {...previousValue, ...newSlideContent};
|
|
72
|
-
} else {
|
|
73
|
-
// updates the rest of the slides here
|
|
74
|
-
const {hidden, position} = previousValue;
|
|
75
|
-
_state[index] = {...nextContent, endReview: newSlideContent.endReview, hidden, position};
|
|
76
|
-
}
|
|
77
|
-
}, state.slideNumbers);
|
|
78
|
-
|
|
79
|
-
return _state;
|
|
80
|
-
};
|
|
6
|
+
export type SlidesAction = ReceivedSlide | ValidateSlide;
|
|
81
7
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const stateUpdateOnNext = (state: SlidesState, payload: OnNextPayload): SlidesState => {
|
|
85
|
-
const {slideNumber, newSlideContent, numberOfFinishedSlides} = payload;
|
|
86
|
-
const _state: SlidesState = {
|
|
87
|
-
slideNumbers
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
91
|
-
map(index => {
|
|
92
|
-
const previousValue = state[index];
|
|
93
|
-
// the current slide
|
|
94
|
-
if (index === slideNumber) {
|
|
95
|
-
// when there is only one slide remaining, updates the slide value
|
|
96
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextContent) {
|
|
97
|
-
_state[index] = {...previousValue.nextContent, position: previousValue.position};
|
|
98
|
-
} else _state[slideNumber] = newSlideContent;
|
|
99
|
-
} else {
|
|
100
|
-
// updates the rest of the slides here
|
|
101
|
-
const {hidden, position, answerUI, questionText} = previousValue;
|
|
102
|
-
_state[index] = {
|
|
103
|
-
hidden,
|
|
104
|
-
position: position - 1, // position shift
|
|
105
|
-
answerUI,
|
|
106
|
-
questionText,
|
|
107
|
-
endReview: newSlideContent.endReview
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}, state.slideNumbers);
|
|
111
|
-
|
|
112
|
-
return _state;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// -----------------------------------------------------------------------------
|
|
8
|
+
export type SlidesState = Record<string, SlideFromAPI>;
|
|
9
|
+
export const initialState: SlidesState = {};
|
|
116
10
|
|
|
117
11
|
// eslint-disable-next-line default-param-last
|
|
118
12
|
const reducer = (state: SlidesState = initialState, action: SlidesAction): SlidesState => {
|
|
119
13
|
switch (action.type) {
|
|
120
14
|
case SLIDE_FETCH_SUCCESS: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// apiSlide adapt to uiSlide
|
|
124
|
-
const uiSlide = qcmSlide;
|
|
125
|
-
return setFirstSlide(state, uiSlide);
|
|
126
|
-
}
|
|
127
|
-
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
128
|
-
return stateUpdateOnValidation(state, action.payload);
|
|
129
|
-
}
|
|
130
|
-
case UPDATE_SLIDES_ON_NEXT: {
|
|
131
|
-
return stateUpdateOnNext(state, action.payload);
|
|
15
|
+
const slide = action.payload;
|
|
16
|
+
return set(slide.id, slide, state);
|
|
132
17
|
}
|
|
133
18
|
default:
|
|
134
19
|
return state;
|
|
135
20
|
}
|
|
136
21
|
};
|
|
137
22
|
|
|
138
|
-
// -----------------------------------------------------------------------------
|
|
139
|
-
|
|
140
23
|
export default reducer;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {SET_CURRENT_SLIDE, UISlidesAction} from '../../actions/ui/slides';
|
|
2
|
+
|
|
3
|
+
export type CurrentSlideRefState = string;
|
|
4
|
+
|
|
5
|
+
const reducer = (
|
|
6
|
+
// eslint-disable-next-line default-param-last
|
|
7
|
+
state: CurrentSlideRefState = '',
|
|
8
|
+
action: UISlidesAction
|
|
9
|
+
): CurrentSlideRefState => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case SET_CURRENT_SLIDE: {
|
|
12
|
+
return action.payload.id;
|
|
13
|
+
}
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default reducer;
|
package/src/reducers/ui/index.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import {combineReducers} from 'redux';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import currentSlideRef, {CurrentSlideRefState} from './current-slide-ref';
|
|
4
4
|
import navigation, {NavigationState} from './navigation';
|
|
5
|
-
import
|
|
6
|
-
import stepItems, {StepItemsState} from './step-items';
|
|
5
|
+
import slides, {UISlidesState} from './slides';
|
|
7
6
|
|
|
8
7
|
export type UIState = {
|
|
8
|
+
currentSlideRef: CurrentSlideRefState;
|
|
9
9
|
navigation: NavigationState;
|
|
10
|
-
|
|
11
|
-
finishedSlides: FinishedSlidesState;
|
|
12
|
-
reviewStatus: ReviewStatusState;
|
|
10
|
+
slides: UISlidesState;
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
export default combineReducers({
|
|
16
|
-
|
|
14
|
+
currentSlideRef,
|
|
17
15
|
navigation,
|
|
18
|
-
|
|
19
|
-
stepItems
|
|
16
|
+
slides
|
|
20
17
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import pipe from 'lodash/fp/pipe';
|
|
2
|
+
import set from 'lodash/fp/set';
|
|
3
|
+
import type {SlideFromAPI, UISlide} from '../../types/common';
|
|
4
|
+
import {SlideIndexes} from '../../common';
|
|
5
|
+
import {mapApiSlideToUi} from '../../helpers/map-api-slide-to-ui';
|
|
6
|
+
import {SET_CURRENT_SLIDE, UISlidesAction} from '../../actions/ui/slides';
|
|
7
|
+
|
|
8
|
+
export type UISlidesState = {
|
|
9
|
+
[key in SlideIndexes]: UISlide;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const initialState: UISlidesState = {
|
|
13
|
+
'0': {
|
|
14
|
+
hidden: false,
|
|
15
|
+
position: 0
|
|
16
|
+
},
|
|
17
|
+
'1': {
|
|
18
|
+
hidden: false,
|
|
19
|
+
position: 1
|
|
20
|
+
},
|
|
21
|
+
'2': {
|
|
22
|
+
hidden: false,
|
|
23
|
+
position: 2
|
|
24
|
+
},
|
|
25
|
+
'3': {
|
|
26
|
+
hidden: false,
|
|
27
|
+
position: 3
|
|
28
|
+
},
|
|
29
|
+
'4': {
|
|
30
|
+
hidden: false,
|
|
31
|
+
position: 4
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const setFirstSlide = (state: UISlidesState, slideFromAPI: SlideFromAPI): UISlidesState => {
|
|
36
|
+
const {questionText, answerUI} = mapApiSlideToUi({translate: (text: string) => text})(
|
|
37
|
+
slideFromAPI
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return pipe(
|
|
41
|
+
set(['0', 'questionText'], questionText),
|
|
42
|
+
set(['0', 'answerUI'], answerUI),
|
|
43
|
+
set(['0', 'parentContentTitle'], 'Parent Title') // TODO parentContentTitle + translate
|
|
44
|
+
)(state);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// eslint-disable-next-line default-param-last
|
|
48
|
+
const reducer = (state: UISlidesState = initialState, action: UISlidesAction): UISlidesState => {
|
|
49
|
+
switch (action.type) {
|
|
50
|
+
case SET_CURRENT_SLIDE: {
|
|
51
|
+
return setFirstSlide(state, action.payload);
|
|
52
|
+
}
|
|
53
|
+
default:
|
|
54
|
+
return state;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default reducer;
|