@coorpacademy/app-review 0.1.14 → 0.1.16
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 +4 -6
- package/es/actions/api/fetch-skills.js +7 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +27 -4
- package/es/actions/api/post-progression.d.ts +4 -6
- package/es/actions/api/post-progression.js +13 -9
- package/es/actions/api/test/create-test-store.d.ts +5 -0
- package/es/actions/api/test/create-test-store.js +16 -0
- package/es/actions/api/test/fetch-skills.test.js +54 -0
- package/es/actions/api/test/fetch-slide.test.js +61 -0
- package/es/actions/api/test/post-progression.test.js +102 -0
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/answers.d.ts +7 -0
- package/es/actions/ui/answers.js +7 -0
- 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/index.js +22 -92
- package/es/reducers/data/index.d.ts +2 -2
- 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 +9 -108
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → answers.js} +3 -3
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/current-slide-ref.js +13 -0
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/test/answers.test.js +11 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +14 -4
- package/es/test/util/services.mock.js +46 -4
- package/es/types/common.d.ts +61 -30
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- 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 +79 -0
- package/es/views/slides/index.js +151 -0
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +172 -0
- package/es/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/es/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/views/slides/test/fixtures/slider.d.ts +3 -0
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +4 -6
- package/lib/actions/api/fetch-skills.js +55 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +75 -7
- package/lib/actions/api/post-progression.d.ts +4 -6
- package/lib/actions/api/post-progression.js +63 -10
- package/lib/actions/api/test/create-test-store.d.ts +5 -0
- package/lib/actions/api/test/create-test-store.js +18 -0
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +113 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +120 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +160 -0
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/answers.d.ts +7 -0
- package/lib/actions/ui/answers.js +9 -0
- 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/index.js +33 -94
- package/lib/reducers/data/index.d.ts +2 -2
- 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 +9 -114
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → answers.js} +3 -3
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/current-slide-ref.js +14 -0
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +11 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +14 -4
- package/lib/test/util/services.mock.js +46 -4
- package/lib/types/common.d.ts +61 -30
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- 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 +79 -0
- package/lib/views/slides/index.js +155 -0
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +178 -0
- package/lib/views/slides/test/fixtures/free-text.d.ts +3 -0
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +3 -0
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/views/slides/test/fixtures/qcm.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +37 -27
- package/lib/views/slides/test/fixtures/select-template.d.ts +3 -0
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/views/slides/test/fixtures/slider.d.ts +3 -0
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/views/slides/test/fixtures/text-template.d.ts +3 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +21 -11
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +4 -3
- package/src/actions/api/fetch-skills.ts +12 -12
- package/src/actions/api/fetch-slide.ts +38 -13
- package/src/actions/api/post-progression.ts +18 -22
- package/src/actions/api/test/create-test-store.ts +25 -0
- package/src/actions/api/test/fetch-skills.test.ts +70 -0
- package/src/actions/api/test/fetch-slide.test.ts +77 -0
- package/src/actions/api/test/post-progression.test.ts +119 -0
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/answers.ts +16 -0
- 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/index.tsx +26 -110
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +17 -125
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +19 -0
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/test/answers.test.ts +13 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +14 -4
- package/src/test/util/services.mock.ts +46 -4
- package/src/types/common.ts +77 -40
- package/src/types/slides.ts +0 -5
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +251 -0
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +43 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +111 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +94 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +43 -33
- package/src/views/slides/test/fixtures/select-template.ts +98 -0
- package/src/views/slides/test/fixtures/slider.ts +41 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +23 -14
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -20
- 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/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/es/helpers/map-api-slide-to-ui.js +0 -175
- package/es/helpers/test/fixtures/free-text.d.ts +0 -4
- package/es/helpers/test/fixtures/free-text.js +0 -24
- package/es/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-drag.js +0 -106
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/es/helpers/test/fixtures/qcm.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.d.ts +0 -4
- package/es/helpers/test/fixtures/select-template.js +0 -88
- package/es/helpers/test/fixtures/slider.d.ts +0 -4
- package/es/helpers/test/fixtures/slider.js +0 -27
- package/es/helpers/test/fixtures/text-template.d.ts +0 -4
- 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/views/slides.d.ts +0 -60
- 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/helpers/map-api-slide-to-ui.d.ts +0 -8
- package/lib/helpers/map-api-slide-to-ui.js +0 -181
- package/lib/helpers/test/fixtures/free-text.d.ts +0 -4
- package/lib/helpers/test/fixtures/free-text.js +0 -24
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -106
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +0 -4
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -70
- package/lib/helpers/test/fixtures/qcm.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.d.ts +0 -4
- package/lib/helpers/test/fixtures/select-template.js +0 -88
- package/lib/helpers/test/fixtures/slider.d.ts +0 -4
- package/lib/helpers/test/fixtures/slider.js +0 -27
- package/lib/helpers/test/fixtures/text-template.d.ts +0 -4
- 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/views/slides.d.ts +0 -60
- 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/helpers/map-api-slide-to-ui.ts +0 -253
- package/src/helpers/test/fixtures/free-text.ts +0 -28
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -110
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -74
- package/src/helpers/test/fixtures/select-template.ts +0 -92
- package/src/helpers/test/fixtures/slider.ts +0 -31
- 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
- package/src/types/views/slides.ts +0 -65
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/es/{types/ui-progression.js → actions/api/test/fetch-slide.test.d.ts} +0 -0
- /package/es/{types/views/skills.js → actions/api/test/post-progression.test.d.ts} +0 -0
- /package/es/{types/views/slides.js → reducers/data/test/progression.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/reducers/data/test/skills.test.d.ts} +0 -0
- /package/{lib/types/ui-progression.js → es/reducers/data/test/slides.test.d.ts} +0 -0
- /package/{lib/types/views/skills.js → es/reducers/data/test/token.test.d.ts} +0 -0
- /package/{lib/types/views/slides.js → es/reducers/ui/test/answers.test.d.ts} +0 -0
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
concat,
|
|
3
|
-
divide,
|
|
4
|
-
get,
|
|
5
|
-
getOr,
|
|
6
|
-
head,
|
|
7
|
-
includes,
|
|
8
|
-
indexOf,
|
|
9
|
-
isEmpty,
|
|
10
|
-
map,
|
|
11
|
-
noop,
|
|
12
|
-
pipe,
|
|
13
|
-
rangeStep,
|
|
14
|
-
size,
|
|
15
|
-
toInteger
|
|
16
|
-
} from 'lodash/fp';
|
|
17
|
-
import {
|
|
18
|
-
AnswerUI,
|
|
19
|
-
FreeText,
|
|
20
|
-
Qcm,
|
|
21
|
-
QcmDrag,
|
|
22
|
-
QcmGraphic,
|
|
23
|
-
QuestionRange,
|
|
24
|
-
SelectionTemplate,
|
|
25
|
-
Template,
|
|
26
|
-
TextTemplate
|
|
27
|
-
} from '../types/slides';
|
|
28
|
-
import {
|
|
29
|
-
ChoiceFromAPI,
|
|
30
|
-
QcmDragQuestion,
|
|
31
|
-
QcmGraphicQuestion,
|
|
32
|
-
QcmQuestion,
|
|
33
|
-
SlideFromAPI,
|
|
34
|
-
SliderQuestion,
|
|
35
|
-
TemplateQuestion
|
|
36
|
-
} from '../types/common';
|
|
37
|
-
|
|
38
|
-
type UiUtils = {translate: (text: string) => string};
|
|
39
|
-
|
|
40
|
-
const qcmProps = (question: QcmQuestion): Qcm => {
|
|
41
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
42
|
-
const answers: string[] = [];
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
type: 'qcm',
|
|
46
|
-
answers: map(
|
|
47
|
-
choice => ({
|
|
48
|
-
title: choice.label,
|
|
49
|
-
selected: includes(choice.label, answers),
|
|
50
|
-
// TODO: EDIT_CHOICES
|
|
51
|
-
onClick: noop,
|
|
52
|
-
ariaLabel: choice.label
|
|
53
|
-
}),
|
|
54
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
55
|
-
question.content.choices
|
|
56
|
-
)
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const qcmDragProps = (question: QcmDragQuestion): QcmDrag => {
|
|
61
|
-
// mock the answers
|
|
62
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
63
|
-
const answers: string[] = [];
|
|
64
|
-
return {
|
|
65
|
-
type: 'qcmDrag',
|
|
66
|
-
answers: map(choice => {
|
|
67
|
-
const indexInAnswer = indexOf(choice.label, answers);
|
|
68
|
-
return {
|
|
69
|
-
title: choice.label,
|
|
70
|
-
selected: indexInAnswer !== -1,
|
|
71
|
-
order: indexInAnswer,
|
|
72
|
-
// TODO: EDIT_CHOICES
|
|
73
|
-
onClick: noop
|
|
74
|
-
};
|
|
75
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
76
|
-
}, question.content.choices)
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const qcmGraphicProps = (question: QcmGraphicQuestion): QcmGraphic => {
|
|
81
|
-
// mock the answers
|
|
82
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
83
|
-
const answers: string[] = [];
|
|
84
|
-
return {
|
|
85
|
-
type: 'qcmGraphic',
|
|
86
|
-
answers: map(
|
|
87
|
-
choice => ({
|
|
88
|
-
title: choice.label,
|
|
89
|
-
image: get('media.src.0.url', choice),
|
|
90
|
-
selected: includes(choice.label, answers),
|
|
91
|
-
// TODO: EDIT_CHOICES
|
|
92
|
-
onClick: noop
|
|
93
|
-
}),
|
|
94
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
95
|
-
question.content.choices
|
|
96
|
-
)
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const templateTextProps =
|
|
101
|
-
(uiUtils: UiUtils) =>
|
|
102
|
-
(choice: ChoiceFromAPI, index: number): TextTemplate => {
|
|
103
|
-
const {translate} = uiUtils;
|
|
104
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
105
|
-
const answers: string[] = [];
|
|
106
|
-
return {
|
|
107
|
-
type: 'text',
|
|
108
|
-
name: getOr('', 'name', choice),
|
|
109
|
-
placeholder: translate('Type here'),
|
|
110
|
-
value: get(index, answers),
|
|
111
|
-
// TODO: EDIT_CHOICES
|
|
112
|
-
onChange: noop
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// const getItemText = (item: ChoiceFromAPI['items'][0]): item['text'] is string =>
|
|
117
|
-
|
|
118
|
-
const templateSelectProps = (uiUtils: UiUtils) => {
|
|
119
|
-
return (choice: ChoiceFromAPI, index: number): SelectionTemplate => {
|
|
120
|
-
const {translate} = uiUtils;
|
|
121
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
122
|
-
const answers: string[] = [];
|
|
123
|
-
const answer = get(index, answers);
|
|
124
|
-
const temporaryOption = {
|
|
125
|
-
name: translate('Select an answer'),
|
|
126
|
-
value: '',
|
|
127
|
-
validOption: false,
|
|
128
|
-
selected: true
|
|
129
|
-
};
|
|
130
|
-
const selectOptions = choice.items.map(item => {
|
|
131
|
-
const itemText = getOr('', 'text', item);
|
|
132
|
-
return {
|
|
133
|
-
name: itemText,
|
|
134
|
-
value: itemText,
|
|
135
|
-
validOption: true,
|
|
136
|
-
selected: itemText === answer
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
type: 'select',
|
|
142
|
-
name: getOr('', 'name', choice),
|
|
143
|
-
// TODO: EDIT_CHOICES
|
|
144
|
-
onChange: noop,
|
|
145
|
-
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const templateProps = (uiUtils: UiUtils): ((question: TemplateQuestion) => Template) => {
|
|
151
|
-
const templateTextProps_ = templateTextProps(uiUtils);
|
|
152
|
-
const templateSelectProps_ = templateSelectProps(uiUtils);
|
|
153
|
-
|
|
154
|
-
return question => {
|
|
155
|
-
// TODO: EDIT_CHOICES -> getChoices
|
|
156
|
-
const choices = question.content.choices;
|
|
157
|
-
return {
|
|
158
|
-
type: 'template',
|
|
159
|
-
template: get('content.template', question),
|
|
160
|
-
answers: choices.map((choice, index) =>
|
|
161
|
-
choice.type === 'text'
|
|
162
|
-
? templateTextProps_(choice, index)
|
|
163
|
-
: templateSelectProps_(choice, index)
|
|
164
|
-
)
|
|
165
|
-
};
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const basicProps = (uiUtils: UiUtils): (() => FreeText) => {
|
|
170
|
-
const {translate} = uiUtils;
|
|
171
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
172
|
-
const answers: string[] = [];
|
|
173
|
-
|
|
174
|
-
return () => {
|
|
175
|
-
return {
|
|
176
|
-
type: 'freeText',
|
|
177
|
-
placeholder: translate('Type here'),
|
|
178
|
-
value: head(answers),
|
|
179
|
-
// TODO: EDIT_CHOICES
|
|
180
|
-
onChange: noop
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const sliderProps = (question: SliderQuestion): QuestionRange => {
|
|
186
|
-
const values: number[] = rangeStep(
|
|
187
|
-
getOr(1, 'content.step', question),
|
|
188
|
-
getOr(Number.NaN, 'content.min', question),
|
|
189
|
-
getOr(Number.NaN, 'content.max', question) + 1
|
|
190
|
-
// Lodash doesn't infere the type very well here
|
|
191
|
-
) as unknown as number[];
|
|
192
|
-
|
|
193
|
-
// TODO: EDIT_CHOICES -> getAnswerValues
|
|
194
|
-
const answers: string[] = [];
|
|
195
|
-
|
|
196
|
-
const stateValue = head(answers);
|
|
197
|
-
const currentValue = toInteger(stateValue);
|
|
198
|
-
|
|
199
|
-
const indexValue = indexOf(currentValue, values);
|
|
200
|
-
const sliderPosition = divide(indexValue, size(values) - 1);
|
|
201
|
-
|
|
202
|
-
const unitLabel = get('question.content.unitLabel', question);
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
type: 'slider',
|
|
206
|
-
placeholder: question.explanation,
|
|
207
|
-
minLabel: `${question.content.min} ${unitLabel}`,
|
|
208
|
-
maxLabel: `${question.content.max} ${unitLabel}`,
|
|
209
|
-
title: `${currentValue} ${question.content.unitLabel}`,
|
|
210
|
-
value: sliderPosition,
|
|
211
|
-
// TODO: EDIT_CHOICES
|
|
212
|
-
onChange: noop
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const getQuestionType = (slide: SlideFromAPI): SlideFromAPI['question']['type'] =>
|
|
217
|
-
slide.question.type;
|
|
218
|
-
|
|
219
|
-
export const mapApiSlideToUi = (
|
|
220
|
-
uiUtils: UiUtils
|
|
221
|
-
): ((slide: SlideFromAPI) => AnswerUI['model'] | void) => {
|
|
222
|
-
const basicProps_ = basicProps(uiUtils);
|
|
223
|
-
const templateProps_ = templateProps(uiUtils);
|
|
224
|
-
|
|
225
|
-
return (slide: SlideFromAPI): AnswerUI['model'] | void => {
|
|
226
|
-
if (!slide) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const type = getQuestionType(slide);
|
|
230
|
-
switch (type) {
|
|
231
|
-
case 'qcm':
|
|
232
|
-
return pipe(get('question'), qcmProps)(slide);
|
|
233
|
-
|
|
234
|
-
case 'qcmGraphic':
|
|
235
|
-
return pipe(get('question'), qcmGraphicProps)(slide);
|
|
236
|
-
|
|
237
|
-
case 'qcmDrag':
|
|
238
|
-
return pipe(get('question'), qcmDragProps)(slide);
|
|
239
|
-
|
|
240
|
-
case 'basic':
|
|
241
|
-
return basicProps_();
|
|
242
|
-
|
|
243
|
-
case 'template':
|
|
244
|
-
return pipe(get('question'), templateProps_)(slide);
|
|
245
|
-
|
|
246
|
-
case 'slider':
|
|
247
|
-
return pipe(get('question'), sliderProps)(slide);
|
|
248
|
-
|
|
249
|
-
default:
|
|
250
|
-
throw new Error(`${type} is not an handled question.type`);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {FreeText} from '../../../types/slides';
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
4
|
-
|
|
5
|
-
export const freeTextSlide: SlideFromAPI = {
|
|
6
|
-
id: 'sli_E1Pcl-XAYbi',
|
|
7
|
-
universalRef: 'sli_E1Pcl-XAYbi',
|
|
8
|
-
question: {
|
|
9
|
-
type: 'basic',
|
|
10
|
-
header: 'sli_E1Pcl-XAYbi.header',
|
|
11
|
-
explanation: 'sli_E1Pcl-XAYbi.explanation',
|
|
12
|
-
content: {
|
|
13
|
-
label: 'sli_E1Pcl-XAYbi.label',
|
|
14
|
-
placeholder: 'sli_E1Pcl-XAYbi.placeholder',
|
|
15
|
-
id: 'sli_E1Pcl-XAYbi.choice_1'
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
clue: 'sli_E1Pcl-XAYbi.clue',
|
|
19
|
-
klf: 'sli_E1Pcl-XAYbi.klf',
|
|
20
|
-
tips: 'sli_E1Pcl-XAYbi.tips'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const freeTextUISlide: FreeText = {
|
|
24
|
-
type: 'freeText',
|
|
25
|
-
placeholder: 'Type here',
|
|
26
|
-
value: undefined,
|
|
27
|
-
onChange: noop
|
|
28
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {QcmDrag} from '../../../types/slides';
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
4
|
-
|
|
5
|
-
export const qcmDragSlide: SlideFromAPI = {
|
|
6
|
-
id: 'sli_419IlQQnf',
|
|
7
|
-
universalRef: 'sli_419IlQQnf',
|
|
8
|
-
question: {
|
|
9
|
-
type: 'qcmDrag',
|
|
10
|
-
header: 'sli_419IlQQnf.header',
|
|
11
|
-
explanation: 'sli_419IlQQnf.explanation',
|
|
12
|
-
content: {
|
|
13
|
-
choices: [
|
|
14
|
-
{
|
|
15
|
-
media: {
|
|
16
|
-
src: [],
|
|
17
|
-
posters: [],
|
|
18
|
-
subtitles: []
|
|
19
|
-
},
|
|
20
|
-
_id: '62b1ba3ec4f4015504212571',
|
|
21
|
-
label: 'sli_419IlQQnf.choice_4kWwlQXhG',
|
|
22
|
-
value: 'sli_419IlQQnf.choice_4kWwlQXhG',
|
|
23
|
-
items: []
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
media: {
|
|
27
|
-
src: [],
|
|
28
|
-
posters: [],
|
|
29
|
-
subtitles: []
|
|
30
|
-
},
|
|
31
|
-
_id: '62b1ba3ec4f4015504212572',
|
|
32
|
-
label: 'sli_419IlQQnf.choice_NJxbwgXm2G',
|
|
33
|
-
value: 'sli_419IlQQnf.choice_NJxbwgXm2G',
|
|
34
|
-
items: []
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
media: {
|
|
38
|
-
src: [],
|
|
39
|
-
posters: [],
|
|
40
|
-
subtitles: []
|
|
41
|
-
},
|
|
42
|
-
_id: '62b1ba3ec4f4015504212573',
|
|
43
|
-
label: 'sli_419IlQQnf.choice_41fwgQXnf',
|
|
44
|
-
value: 'sli_419IlQQnf.choice_41fwgQXnf',
|
|
45
|
-
items: []
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
media: {
|
|
49
|
-
src: [],
|
|
50
|
-
posters: [],
|
|
51
|
-
subtitles: []
|
|
52
|
-
},
|
|
53
|
-
_id: '62b1ba3ec4f4015504212574',
|
|
54
|
-
label: 'sli_419IlQQnf.choice_VJmweQ7nz',
|
|
55
|
-
value: 'sli_419IlQQnf.choice_VJmweQ7nz',
|
|
56
|
-
items: []
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
media: {
|
|
60
|
-
src: [],
|
|
61
|
-
posters: [],
|
|
62
|
-
subtitles: []
|
|
63
|
-
},
|
|
64
|
-
_id: '62b1ba3ec4f4015504212575',
|
|
65
|
-
label: 'sli_419IlQQnf.choice_4kDDgXQhz',
|
|
66
|
-
value: 'sli_419IlQQnf.choice_4kDDgXQhz',
|
|
67
|
-
items: []
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
klf: 'sli_419IlQQnf.klf',
|
|
73
|
-
tips: 'sli_419IlQQnf.tips'
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const qcmDragUISlide: QcmDrag = {
|
|
77
|
-
type: 'qcmDrag',
|
|
78
|
-
answers: [
|
|
79
|
-
{
|
|
80
|
-
title: 'sli_419IlQQnf.choice_4kWwlQXhG',
|
|
81
|
-
selected: false,
|
|
82
|
-
order: -1,
|
|
83
|
-
onClick: noop
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
title: 'sli_419IlQQnf.choice_NJxbwgXm2G',
|
|
87
|
-
selected: false,
|
|
88
|
-
order: -1,
|
|
89
|
-
onClick: noop
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
title: 'sli_419IlQQnf.choice_41fwgQXnf',
|
|
93
|
-
selected: false,
|
|
94
|
-
order: -1,
|
|
95
|
-
onClick: noop
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
title: 'sli_419IlQQnf.choice_VJmweQ7nz',
|
|
99
|
-
selected: false,
|
|
100
|
-
order: -1,
|
|
101
|
-
onClick: noop
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
title: 'sli_419IlQQnf.choice_4kDDgXQhz',
|
|
105
|
-
selected: false,
|
|
106
|
-
order: -1,
|
|
107
|
-
onClick: noop
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {QcmGraphic} from '../../../types/slides';
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
4
|
-
|
|
5
|
-
export const qcmGraphicSlide: SlideFromAPI = {
|
|
6
|
-
id: 'sli_41~RSVclH',
|
|
7
|
-
universalRef: 'sli_41~RSVclH',
|
|
8
|
-
question: {
|
|
9
|
-
type: 'qcmGraphic',
|
|
10
|
-
header: 'sli_41~RSVclH.header',
|
|
11
|
-
explanation: 'sli_41~RSVclH.explanation',
|
|
12
|
-
content: {
|
|
13
|
-
choices: [
|
|
14
|
-
{
|
|
15
|
-
media: {
|
|
16
|
-
type: 'img',
|
|
17
|
-
src: [
|
|
18
|
-
{
|
|
19
|
-
_id: '5fdce726359bf4003ee66997',
|
|
20
|
-
mimeType: 'image/png',
|
|
21
|
-
url: 'med_4JVRrE5gH.mediaUrl_VkBtUV9gB'
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
posters: [],
|
|
25
|
-
subtitles: []
|
|
26
|
-
},
|
|
27
|
-
_id: '5fdce726359bf4003ee66996',
|
|
28
|
-
label: 'sli_41~RSVclH.choice_V1gN0r4qgS',
|
|
29
|
-
value: 'sli_41~RSVclH.choice_V1gN0r4qgS',
|
|
30
|
-
items: []
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
media: {
|
|
34
|
-
type: 'img',
|
|
35
|
-
src: [
|
|
36
|
-
{
|
|
37
|
-
_id: '5fdce726359bf4003ee66999',
|
|
38
|
-
mimeType: 'image/png',
|
|
39
|
-
url: 'med_Ek8gIEqxB.mediaUrl_EkcFUEclH'
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
posters: [],
|
|
43
|
-
subtitles: []
|
|
44
|
-
},
|
|
45
|
-
_id: '5fdce726359bf4003ee66998',
|
|
46
|
-
label: 'sli_41~RSVclH.choice_4JlLeLE5lS',
|
|
47
|
-
value: 'sli_41~RSVclH.choice_4JlLeLE5lS',
|
|
48
|
-
items: []
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
clue: 'sli_41~RSVclH.clue',
|
|
54
|
-
klf: 'sli_41~RSVclH.klf',
|
|
55
|
-
tips: 'sli_41~RSVclH.tips'
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const qcmGraphicUISlide: QcmGraphic = {
|
|
59
|
-
type: 'qcmGraphic',
|
|
60
|
-
answers: [
|
|
61
|
-
{
|
|
62
|
-
title: 'sli_41~RSVclH.choice_V1gN0r4qgS',
|
|
63
|
-
image: 'med_4JVRrE5gH.mediaUrl_VkBtUV9gB',
|
|
64
|
-
selected: false,
|
|
65
|
-
onClick: noop
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
title: 'sli_41~RSVclH.choice_4JlLeLE5lS',
|
|
69
|
-
image: 'med_Ek8gIEqxB.mediaUrl_EkcFUEclH',
|
|
70
|
-
selected: false,
|
|
71
|
-
onClick: noop
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {Template} from '../../../types/slides';
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
4
|
-
|
|
5
|
-
export const selectTemplateSlide: SlideFromAPI = {
|
|
6
|
-
id: 'sli_410xZQxrZ',
|
|
7
|
-
universalRef: 'sli_410xZQxrZ',
|
|
8
|
-
question: {
|
|
9
|
-
type: 'template',
|
|
10
|
-
header: 'sli_410xZQxrZ.header',
|
|
11
|
-
explanation: 'sli_410xZQxrZ.explanation',
|
|
12
|
-
content: {
|
|
13
|
-
template: 'sli_410xZQxrZ.template',
|
|
14
|
-
choices: [
|
|
15
|
-
{
|
|
16
|
-
media: {
|
|
17
|
-
src: [],
|
|
18
|
-
posters: [],
|
|
19
|
-
subtitles: []
|
|
20
|
-
},
|
|
21
|
-
_id: '5fdce726359bf4003ee66967',
|
|
22
|
-
type: 'select',
|
|
23
|
-
name: 'sel36665',
|
|
24
|
-
items: [
|
|
25
|
-
{
|
|
26
|
-
_id: '5fdce726359bf4003ee66968',
|
|
27
|
-
text: 'sli_410xZQxrZ.choice_4yeA4Z7lr~',
|
|
28
|
-
value: 'sli_410xZQxrZ.choice_4yeA4Z7lr~'
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
_id: '5fdce726359bf4003ee66969',
|
|
32
|
-
text: 'sli_410xZQxrZ.choice_VJWCN~mgB~',
|
|
33
|
-
value: 'sli_410xZQxrZ.choice_VJWCN~mgB~'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
_id: '5fdce726359bf4003ee6696a',
|
|
37
|
-
text: 'sli_410xZQxrZ.choice_VkaH~XgBb',
|
|
38
|
-
value: 'sli_410xZQxrZ.choice_VkaH~XgBb'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
_id: '5fdce726359bf4003ee6696b',
|
|
42
|
-
text: 'sli_410xZQxrZ.choice_E1uUWXeBb',
|
|
43
|
-
value: 'sli_410xZQxrZ.choice_E1uUWXeBb'
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
clue: 'sli_410xZQxrZ.clue',
|
|
51
|
-
klf: 'sli_410xZQxrZ.klf',
|
|
52
|
-
tips: 'sli_410xZQxrZ.tips'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const selectTemplateUISlide: Template = {
|
|
56
|
-
type: 'template',
|
|
57
|
-
template: 'sli_410xZQxrZ.template',
|
|
58
|
-
answers: [
|
|
59
|
-
{
|
|
60
|
-
type: 'select',
|
|
61
|
-
name: 'sel36665',
|
|
62
|
-
onChange: noop,
|
|
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
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'sli_410xZQxrZ.choice_E1uUWXeBb',
|
|
85
|
-
value: 'sli_410xZQxrZ.choice_E1uUWXeBb',
|
|
86
|
-
validOption: true,
|
|
87
|
-
selected: false
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {QuestionRange} from '../../../types/slides';
|
|
3
|
-
import {SlideFromAPI} from '../../../types/common';
|
|
4
|
-
|
|
5
|
-
export const sliderSlide: SlideFromAPI = {
|
|
6
|
-
id: 'sli_41D5AovN~',
|
|
7
|
-
universalRef: 'sli_41D5AovN~',
|
|
8
|
-
question: {
|
|
9
|
-
type: 'slider',
|
|
10
|
-
header: 'sli_41D5AovN~.header',
|
|
11
|
-
explanation: 'sli_41D5AovN~.explanation',
|
|
12
|
-
content: {
|
|
13
|
-
min: 1,
|
|
14
|
-
max: 10,
|
|
15
|
-
unitLabel: 'sli_41D5AovN~.unitLabel'
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
clue: 'sli_41D5AovN~.clue',
|
|
19
|
-
klf: 'sli_41D5AovN~.klf',
|
|
20
|
-
tips: 'sli_41D5AovN~.tips'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const sliderUISlide: QuestionRange = {
|
|
24
|
-
type: 'slider',
|
|
25
|
-
placeholder: 'sli_41D5AovN~.explanation',
|
|
26
|
-
minLabel: '1 undefined',
|
|
27
|
-
maxLabel: '10 undefined',
|
|
28
|
-
title: '0 sli_41D5AovN~.unitLabel',
|
|
29
|
-
value: -0.1111111111111111,
|
|
30
|
-
onChange: noop
|
|
31
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import forEach from 'lodash/fp/forEach';
|
|
2
|
-
import {UpdateFinishedSlides, UPDATE_FINISHED_SLIDES} from '../../actions/ui/finished-slides';
|
|
3
|
-
import {slideNumbers} from '../../common';
|
|
4
|
-
|
|
5
|
-
export type FinishedSlidesState = {
|
|
6
|
-
slideNumbers: number[];
|
|
7
|
-
[key: number]: true;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const initialState: FinishedSlidesState = {
|
|
11
|
-
slideNumbers
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const _forEach: <T>(
|
|
15
|
-
iteratee: (value: T[keyof T], index: number) => void,
|
|
16
|
-
collection: T
|
|
17
|
-
// @ts-expect-error to remove lodash's forEach iteratee args number cap
|
|
18
|
-
) => void = forEach.convert({
|
|
19
|
-
cap: false
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// -----------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
const reducer = (
|
|
25
|
-
// eslint-disable-next-line default-param-last
|
|
26
|
-
state: FinishedSlidesState = initialState,
|
|
27
|
-
action: UpdateFinishedSlides
|
|
28
|
-
): FinishedSlidesState => {
|
|
29
|
-
switch (action.type) {
|
|
30
|
-
case UPDATE_FINISHED_SLIDES: {
|
|
31
|
-
const {slideNumbers: _slideNumbers, ...rest} = state;
|
|
32
|
-
const {slideNumber, value} = action.payload;
|
|
33
|
-
const _state: FinishedSlidesState = {
|
|
34
|
-
slideNumbers: _slideNumbers
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
_forEach<Omit<FinishedSlidesState, 'slideNumbers'>>((finishedSlide, index) => {
|
|
38
|
-
const previousValue = finishedSlide;
|
|
39
|
-
_state[index] = previousValue;
|
|
40
|
-
}, rest);
|
|
41
|
-
|
|
42
|
-
_state[slideNumber] = value;
|
|
43
|
-
return _state;
|
|
44
|
-
}
|
|
45
|
-
default:
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// -----------------------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
export default reducer;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {UpdateReviewStatus, UPDATE_REVIEW_STATUS} from '../../actions/ui/review-status';
|
|
2
|
-
|
|
3
|
-
export type ReviewStatusState = 'finished' | 'ongoing';
|
|
4
|
-
|
|
5
|
-
const reducer = (
|
|
6
|
-
// eslint-disable-next-line default-param-last
|
|
7
|
-
state: ReviewStatusState = 'ongoing',
|
|
8
|
-
action: UpdateReviewStatus
|
|
9
|
-
): ReviewStatusState => {
|
|
10
|
-
switch (action.type) {
|
|
11
|
-
case UPDATE_REVIEW_STATUS: {
|
|
12
|
-
return action.payload;
|
|
13
|
-
}
|
|
14
|
-
default:
|
|
15
|
-
return state;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default reducer;
|