@coorpacademy/app-review 0.1.16 → 0.1.17
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 +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +39 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +1 -1
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +19 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +86 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +18 -14
- package/es/views/slides/map-api-slide-to-ui.js +44 -51
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +48 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +1 -1
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +19 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +86 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +18 -14
- package/lib/views/slides/map-api-slide-to-ui.js +77 -76
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +52 -5
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +3 -3
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +24 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +91 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +37 -22
- package/src/views/slides/map-api-slide-to-ui.ts +89 -89
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/select-template.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/text-template.ts +2 -1
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
|
@@ -1,82 +1,100 @@
|
|
|
1
|
+
import {qcmSlide} from '../../views/slides/test/fixtures/qcm';
|
|
2
|
+
import {qcmGraphicSlide} from '../../views/slides/test/fixtures/qcm-graphic';
|
|
1
3
|
import {freeTextSlide} from '../../views/slides/test/fixtures/free-text';
|
|
2
|
-
import {
|
|
4
|
+
import {sliderSlide} from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import {ProgressionFromAPI, Services, SlideFromAPI} from '../../types/common';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const getSlideFixture = (ref: string): SlideFromAPI => {
|
|
8
|
+
switch (ref) {
|
|
9
|
+
case qcmSlide.universalRef:
|
|
10
|
+
return qcmSlide;
|
|
11
|
+
case qcmGraphicSlide.universalRef:
|
|
12
|
+
return qcmGraphicSlide;
|
|
13
|
+
case freeTextSlide.universalRef:
|
|
14
|
+
return freeTextSlide;
|
|
15
|
+
default:
|
|
16
|
+
return sliderSlide;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const fetchSkillsResponse = [
|
|
21
|
+
{
|
|
22
|
+
skillRef: '_skill-ref',
|
|
23
|
+
slidesToReview: 2,
|
|
24
|
+
name: 'skill-test',
|
|
25
|
+
custom: false
|
|
20
26
|
},
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
{
|
|
28
|
+
skillRef: '_skill-ref-2',
|
|
29
|
+
slidesToReview: 2,
|
|
30
|
+
name: 'skill-test-2',
|
|
31
|
+
custom: true
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const postProgressionResponse: ProgressionFromAPI = {
|
|
36
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
37
|
+
content: {
|
|
38
|
+
ref: '_skill-ref',
|
|
39
|
+
type: 'skill'
|
|
23
40
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
41
|
+
engine: {
|
|
42
|
+
ref: 'review'
|
|
43
|
+
},
|
|
44
|
+
state: {
|
|
45
|
+
allAnswers: [],
|
|
46
|
+
isCorrect: true,
|
|
47
|
+
nextContent: {
|
|
48
|
+
ref: 'sli_VJYjJnJhg',
|
|
49
|
+
type: 'slide'
|
|
50
|
+
},
|
|
51
|
+
pendingSlides: [],
|
|
52
|
+
slides: [],
|
|
53
|
+
step: {
|
|
54
|
+
current: 1
|
|
55
|
+
},
|
|
56
|
+
stars: 0
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const postAnswerResponse: ProgressionFromAPI = {
|
|
61
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
62
|
+
content: {
|
|
63
|
+
ref: '_skill-ref',
|
|
64
|
+
type: 'skill'
|
|
49
65
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
engine: {
|
|
58
|
-
ref: 'review'
|
|
59
|
-
},
|
|
60
|
-
state: {
|
|
61
|
-
allAnswers: [
|
|
62
|
-
{
|
|
63
|
-
slideRef: 'sli_N1XACJobn',
|
|
64
|
-
isCorrect: true,
|
|
65
|
-
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
66
|
-
}
|
|
67
|
-
],
|
|
66
|
+
engine: {
|
|
67
|
+
ref: 'review'
|
|
68
|
+
},
|
|
69
|
+
state: {
|
|
70
|
+
allAnswers: [
|
|
71
|
+
{
|
|
72
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
68
73
|
isCorrect: true,
|
|
69
|
-
|
|
70
|
-
ref: 'sli_VkSQroQnx',
|
|
71
|
-
type: 'slide'
|
|
72
|
-
},
|
|
73
|
-
pendingSlides: [],
|
|
74
|
-
slides: ['sli_N1XACJobn'],
|
|
75
|
-
step: {
|
|
76
|
-
current: 2
|
|
77
|
-
},
|
|
78
|
-
stars: 4
|
|
74
|
+
answer: ['Benchmark']
|
|
79
75
|
}
|
|
80
|
-
|
|
76
|
+
],
|
|
77
|
+
isCorrect: true,
|
|
78
|
+
nextContent: {
|
|
79
|
+
ref: 'sli_VkSQroQnx',
|
|
80
|
+
type: 'slide'
|
|
81
|
+
},
|
|
82
|
+
content: {
|
|
83
|
+
ref: 'sli_VJYjJnJhg',
|
|
84
|
+
type: 'slide'
|
|
85
|
+
},
|
|
86
|
+
pendingSlides: [],
|
|
87
|
+
slides: ['sli_VJYjJnJhg'],
|
|
88
|
+
step: {
|
|
89
|
+
current: 2
|
|
90
|
+
},
|
|
91
|
+
stars: 4
|
|
81
92
|
}
|
|
82
93
|
};
|
|
94
|
+
|
|
95
|
+
export const services: Services = {
|
|
96
|
+
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
97
|
+
fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, id: ref}),
|
|
98
|
+
postProgression: () => Promise.resolve(postProgressionResponse),
|
|
99
|
+
postAnswer: () => Promise.resolve(postAnswerResponse)
|
|
100
|
+
};
|
package/src/types/common.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {SlideIndexes} from '../common';
|
|
2
|
-
import {AnswerUI} from './slides';
|
|
3
|
-
|
|
4
1
|
// TODO use type from components
|
|
5
2
|
type TemplateContextValues = {
|
|
6
3
|
brandTheme?: unknown;
|
|
@@ -172,33 +169,6 @@ export type JWT = {
|
|
|
172
169
|
host: string;
|
|
173
170
|
};
|
|
174
171
|
|
|
175
|
-
type SlideUIAnimations = 'unstack' | 'restack';
|
|
176
|
-
|
|
177
|
-
export type NextUISlide = {
|
|
178
|
-
questionText?: string;
|
|
179
|
-
answerUI?: AnswerUI;
|
|
180
|
-
hidden?: boolean;
|
|
181
|
-
position?: number;
|
|
182
|
-
animationType?: SlideUIAnimations;
|
|
183
|
-
isCorrect?: boolean;
|
|
184
|
-
endReview?: boolean;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export type UISlide = {
|
|
188
|
-
questionText?: string;
|
|
189
|
-
answerUI?: AnswerUI;
|
|
190
|
-
hidden?: boolean;
|
|
191
|
-
position: number;
|
|
192
|
-
animationType?: SlideUIAnimations;
|
|
193
|
-
isCorrect?: boolean;
|
|
194
|
-
endReview?: boolean;
|
|
195
|
-
nextContent?: NextUISlide;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export type FinishedSlides = {
|
|
199
|
-
[key in SlideIndexes]?: true;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
172
|
export type WithRequired<T, K extends keyof T> = T & {
|
|
203
173
|
// the "-" is a Mapping Modifier, removes optionality from a prop
|
|
204
174
|
[P in K]-?: T[P];
|
|
@@ -28,11 +28,7 @@ type SkillsProps = NoSkillsProps & {
|
|
|
28
28
|
|
|
29
29
|
export {SkillsProps};
|
|
30
30
|
|
|
31
|
-
export const mapStateToSkillsProps = (state: StoreState): SkillsProps
|
|
32
|
-
if (!state.data.skills) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
31
|
+
export const mapStateToSkillsProps = (state: StoreState): SkillsProps => {
|
|
36
32
|
return {
|
|
37
33
|
title: '@todo title',
|
|
38
34
|
titleNoSkills: '@todo titleNoSkills',
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import {StoreState} from '../../../reducers';
|
|
5
|
+
import {mapStateToSkillsProps} from '..';
|
|
6
|
+
|
|
7
|
+
test('should create initial props when there are no skills on the state', t => {
|
|
8
|
+
const state: StoreState = {
|
|
9
|
+
data: {
|
|
10
|
+
progression: null,
|
|
11
|
+
skills: [],
|
|
12
|
+
slides: {},
|
|
13
|
+
token: '1234'
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
currentSlideRef: '',
|
|
17
|
+
navigation: ['loader', 'skills'],
|
|
18
|
+
answers: [],
|
|
19
|
+
slide: {
|
|
20
|
+
validateButton: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const props = mapStateToSkillsProps(state);
|
|
26
|
+
|
|
27
|
+
t.deepEqual(props, {
|
|
28
|
+
title: '@todo title',
|
|
29
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
30
|
+
textNoSkills: '@todo textNoSkills',
|
|
31
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
32
|
+
isLoading: false,
|
|
33
|
+
isLoadingAriaLabel: '@todo loading',
|
|
34
|
+
listSkills: []
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('should create initial props when skills on the state', t => {
|
|
39
|
+
const state: StoreState = {
|
|
40
|
+
data: {
|
|
41
|
+
progression: null,
|
|
42
|
+
skills: [
|
|
43
|
+
{
|
|
44
|
+
skillRef: '_skill-ref',
|
|
45
|
+
slidesToReview: 2,
|
|
46
|
+
name: 'skill-test',
|
|
47
|
+
custom: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
skillRef: '_skill-ref-2',
|
|
51
|
+
slidesToReview: 5,
|
|
52
|
+
name: 'skill-test-2',
|
|
53
|
+
custom: true
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
slides: {},
|
|
57
|
+
token: '1234'
|
|
58
|
+
},
|
|
59
|
+
ui: {
|
|
60
|
+
currentSlideRef: '',
|
|
61
|
+
navigation: ['loader', 'skills'],
|
|
62
|
+
answers: [],
|
|
63
|
+
slide: {
|
|
64
|
+
validateButton: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const props = mapStateToSkillsProps(state);
|
|
70
|
+
|
|
71
|
+
t.deepEqual(omit('listSkills', props), {
|
|
72
|
+
title: '@todo title',
|
|
73
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
74
|
+
textNoSkills: '@todo textNoSkills',
|
|
75
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
76
|
+
isLoading: false,
|
|
77
|
+
isLoadingAriaLabel: '@todo loading'
|
|
78
|
+
});
|
|
79
|
+
t.deepEqual(map(omit('onClick'), props.listSkills), [
|
|
80
|
+
{
|
|
81
|
+
'aria-label': '',
|
|
82
|
+
isCustom: false,
|
|
83
|
+
skillTitle: 'skill-test',
|
|
84
|
+
skillAriaLabel: '@todo skill aria label',
|
|
85
|
+
buttonLabel: '@todo button',
|
|
86
|
+
buttonAriaLabel: '@todo button aria label',
|
|
87
|
+
reviseLabel: '@todo revise',
|
|
88
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
'aria-label': '',
|
|
92
|
+
isCustom: true,
|
|
93
|
+
skillTitle: 'skill-test-2',
|
|
94
|
+
skillAriaLabel: '@todo skill aria label',
|
|
95
|
+
buttonLabel: '@todo button',
|
|
96
|
+
buttonAriaLabel: '@todo button aria label',
|
|
97
|
+
reviseLabel: '@todo revise',
|
|
98
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
});
|
|
@@ -9,9 +9,11 @@ import set from 'lodash/fp/set';
|
|
|
9
9
|
import slice from 'lodash/fp/slice';
|
|
10
10
|
import toInteger from 'lodash/fp/toInteger';
|
|
11
11
|
import {Dispatch} from 'redux';
|
|
12
|
-
import {ProgressionFromAPI
|
|
12
|
+
import {ProgressionFromAPI} from '../../types/common';
|
|
13
13
|
import {SlideIndexes} from '../../common';
|
|
14
14
|
import {StoreState} from '../../reducers';
|
|
15
|
+
import {AnswerUI} from '../../types/slides';
|
|
16
|
+
import {postAnswer} from '../../actions/api/post-answer';
|
|
15
17
|
import {mapApiSlideToUi} from './map-api-slide-to-ui';
|
|
16
18
|
|
|
17
19
|
const ICON_VALUES = {
|
|
@@ -28,6 +30,19 @@ type StepItem = {
|
|
|
28
30
|
value: string;
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
type SlideUIAnimations = 'unstack' | 'restack';
|
|
34
|
+
|
|
35
|
+
export type UISlide = {
|
|
36
|
+
questionText?: string;
|
|
37
|
+
answerUI?: AnswerUI;
|
|
38
|
+
hidden?: boolean;
|
|
39
|
+
position: number;
|
|
40
|
+
animationType?: SlideUIAnimations;
|
|
41
|
+
isCorrect?: boolean;
|
|
42
|
+
endReview?: boolean;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
31
46
|
type SlidesStack = {
|
|
32
47
|
[key in SlideIndexes]: UISlide;
|
|
33
48
|
};
|
|
@@ -95,27 +110,32 @@ export type SlidesViewProps = {
|
|
|
95
110
|
export const initialState: SlidesStack = {
|
|
96
111
|
'0': {
|
|
97
112
|
hidden: false,
|
|
98
|
-
position: 0
|
|
113
|
+
position: 0,
|
|
114
|
+
loading: true
|
|
99
115
|
},
|
|
100
116
|
'1': {
|
|
101
117
|
hidden: false,
|
|
102
|
-
position: 1
|
|
118
|
+
position: 1,
|
|
119
|
+
loading: true
|
|
103
120
|
},
|
|
104
121
|
'2': {
|
|
105
122
|
hidden: false,
|
|
106
|
-
position: 2
|
|
123
|
+
position: 2,
|
|
124
|
+
loading: true
|
|
107
125
|
},
|
|
108
126
|
'3': {
|
|
109
127
|
hidden: false,
|
|
110
|
-
position: 3
|
|
128
|
+
position: 3,
|
|
129
|
+
loading: true
|
|
111
130
|
},
|
|
112
131
|
'4': {
|
|
113
132
|
hidden: false,
|
|
114
|
-
position: 4
|
|
133
|
+
position: 4,
|
|
134
|
+
loading: true
|
|
115
135
|
}
|
|
116
136
|
};
|
|
117
137
|
|
|
118
|
-
const
|
|
138
|
+
const getProgressionSlidesRefs = (progression: ProgressionFromAPI): string[] => {
|
|
119
139
|
if (progression.state.step.current < 5) {
|
|
120
140
|
const slideRef = progression.state.nextContent.ref;
|
|
121
141
|
return concat([slideRef], progression.state.slides);
|
|
@@ -128,7 +148,7 @@ const buildStackSlides = (state: StoreState, dispatch: Dispatch): SlidesStack =>
|
|
|
128
148
|
const progression = state.data.progression;
|
|
129
149
|
|
|
130
150
|
if (!currentSlideRef || !progression) return initialState;
|
|
131
|
-
const slideRefs =
|
|
151
|
+
const slideRefs = getProgressionSlidesRefs(progression);
|
|
132
152
|
|
|
133
153
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
134
154
|
const stack = reduce.convert({cap: false})(
|
|
@@ -137,15 +157,18 @@ const buildStackSlides = (state: StoreState, dispatch: Dispatch): SlidesStack =>
|
|
|
137
157
|
if (!slideRef) return set(index, uiSlide, acc);
|
|
138
158
|
|
|
139
159
|
const slideFromAPI = get(slideRef, state.data.slides);
|
|
160
|
+
if (!slideFromAPI) return set(index, uiSlide, acc);
|
|
161
|
+
|
|
140
162
|
const answers = state.ui.answers;
|
|
141
163
|
const {questionText, answerUI} = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
142
164
|
const parentContentTitle = getOr('', 'parentContentTitle.title', slideFromAPI);
|
|
143
165
|
const parentContentType = getOr('', 'parentContentTitle.type', slideFromAPI);
|
|
144
166
|
|
|
145
167
|
const updatedUiSlide = pipe(
|
|
146
|
-
set(
|
|
147
|
-
set(
|
|
148
|
-
set(
|
|
168
|
+
set('loading', false),
|
|
169
|
+
set('questionText', questionText),
|
|
170
|
+
set('answerUI', answerUI),
|
|
171
|
+
set('parentContentTitle', `From "${parentContentTitle}" ${parentContentType}`) // TODO translate: -From- .... -Course/chapter-
|
|
149
172
|
// TODO: Set position according to currentSlideRef et slideRefs (or maybe a value on the state ui.slidePositions !!)
|
|
150
173
|
)(uiSlide);
|
|
151
174
|
|
|
@@ -213,14 +236,7 @@ const buildStepItems = (state: StoreState): StepItem[] => {
|
|
|
213
236
|
return steps;
|
|
214
237
|
};
|
|
215
238
|
|
|
216
|
-
export const mapStateToSlidesProps = (
|
|
217
|
-
state: StoreState,
|
|
218
|
-
dispatch: Dispatch
|
|
219
|
-
): SlidesViewProps | null => {
|
|
220
|
-
if (!state.data.slides) {
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
|
|
239
|
+
export const mapStateToSlidesProps = (state: StoreState, dispatch: Dispatch): SlidesViewProps => {
|
|
224
240
|
return {
|
|
225
241
|
header: {
|
|
226
242
|
mode: '__revision_mode',
|
|
@@ -237,10 +253,9 @@ export const mapStateToSlidesProps = (
|
|
|
237
253
|
slides: buildStackSlides(state, dispatch),
|
|
238
254
|
validateButton: {
|
|
239
255
|
label: '__validate',
|
|
240
|
-
disabled:
|
|
256
|
+
disabled: !get('ui.slide.validateButton', state),
|
|
241
257
|
onClick: (): void => {
|
|
242
|
-
|
|
243
|
-
console.log('TODO: validate question');
|
|
258
|
+
dispatch(postAnswer);
|
|
244
259
|
}
|
|
245
260
|
},
|
|
246
261
|
correctionPopinProps: undefined,
|