@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
package/es/index.js
CHANGED
|
@@ -1,95 +1,29 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
3
3
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
4
4
|
import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
|
|
5
5
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
6
|
import get from 'lodash/fp/get';
|
|
7
7
|
import configureStore from './configure-store';
|
|
8
|
-
import {
|
|
9
|
-
import { updateSlidesOnNext, updateSlidesOnValidation, validateSlide } from './actions/data/slides';
|
|
10
|
-
import { navigateTo, navigateBack } from './actions/ui/navigation';
|
|
8
|
+
import { navigateTo } from './actions/ui/navigation';
|
|
11
9
|
import { storeToken } from './actions/data/token';
|
|
12
|
-
import { updateFinishedSlides } from './actions/ui/finished-slides';
|
|
13
|
-
import { updateReviewStatus } from './actions/ui/review-status';
|
|
14
|
-
import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui/step-items';
|
|
15
10
|
import { fetchSkills } from './actions/api/fetch-skills';
|
|
16
11
|
import { postProgression } from './actions/api/post-progression';
|
|
17
12
|
import { VIEWS } from './common';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
updateStepItemsOnNext,
|
|
27
|
-
updateFinishedSlides
|
|
28
|
-
};
|
|
29
|
-
const getCurrentViewName = (storeState) => storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
30
|
-
const mapStateToSkillsProps = (state) => {
|
|
31
|
-
if (!state.data.skills) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
title: '@todo title',
|
|
36
|
-
titleNoSkills: '@todo titleNoSkills',
|
|
37
|
-
textNoSkills: '@todo textNoSkills',
|
|
38
|
-
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
39
|
-
isLoading: false,
|
|
40
|
-
isLoadingAriaLabel: '@todo loading',
|
|
41
|
-
listSkills: state.data.skills.map(skill => ({
|
|
42
|
-
'aria-label': '',
|
|
43
|
-
isCustom: skill.custom,
|
|
44
|
-
skillTitle: skill.name,
|
|
45
|
-
skillAriaLabel: '@todo skill aria label',
|
|
46
|
-
buttonLabel: '@todo button',
|
|
47
|
-
buttonAriaLabel: '@todo button aria label',
|
|
48
|
-
reviseLabel: '@todo revise',
|
|
49
|
-
reviseAriaLabel: '@todo revise aria label',
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
52
|
-
}))
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const mapStateToSlidesProps = (state) => {
|
|
56
|
-
if (!state.data.slides) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
headerProps: {
|
|
61
|
-
mode: '__revision_mode',
|
|
62
|
-
skillName: '__agility',
|
|
63
|
-
onQuitClick: () => {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.log('onQuitClick');
|
|
66
|
-
},
|
|
67
|
-
'aria-label': 'aria-header-wrapper',
|
|
68
|
-
closeButtonAriaLabel: 'aria-close-button'
|
|
69
|
-
},
|
|
70
|
-
slides: state.data.slides,
|
|
71
|
-
validate: {
|
|
72
|
-
label: '__validate'
|
|
73
|
-
},
|
|
74
|
-
finishedSlides: state.ui.finishedSlides,
|
|
75
|
-
stepItems: state.ui.stepItems,
|
|
76
|
-
reviewStatus: state.ui.reviewStatus,
|
|
77
|
-
correctionPopinProps,
|
|
78
|
-
congratsProps,
|
|
79
|
-
progression: state.data.progression
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
const mapStateToProps = (state) => {
|
|
83
|
-
return {
|
|
84
|
-
viewName: getCurrentViewName(state),
|
|
85
|
-
slides: mapStateToSlidesProps(state),
|
|
86
|
-
skills: mapStateToSkillsProps(state)
|
|
13
|
+
import { mapStateToSlidesProps } from './views/slides';
|
|
14
|
+
import { mapStateToSkillsProps } from './views/skills';
|
|
15
|
+
const ConnectedApp = () => {
|
|
16
|
+
const dispatch = useDispatch();
|
|
17
|
+
const props = {
|
|
18
|
+
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
19
|
+
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch)),
|
|
20
|
+
skills: useSelector((state) => mapStateToSkillsProps(state))
|
|
87
21
|
};
|
|
22
|
+
return React.createElement(AppReviewTemplate, { ...props });
|
|
88
23
|
};
|
|
89
|
-
const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
90
24
|
const AppReview = ({ options }) => {
|
|
91
25
|
const [store, setStore] = useState(null);
|
|
92
|
-
const [
|
|
26
|
+
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
93
27
|
useEffect(() => {
|
|
94
28
|
if (store)
|
|
95
29
|
return;
|
|
@@ -97,14 +31,13 @@ const AppReview = ({ options }) => {
|
|
|
97
31
|
setStore(newStore);
|
|
98
32
|
}, [options, store]);
|
|
99
33
|
useEffect(() => {
|
|
100
|
-
if (!store ||
|
|
34
|
+
if (!store || isProgressionCreated)
|
|
101
35
|
return;
|
|
102
36
|
return store.subscribe(() => {
|
|
103
|
-
const
|
|
104
|
-
return
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
}, [isSlideFetched, options, store]);
|
|
37
|
+
const isProgressionPresent = !isEmpty(store.getState().data.progression);
|
|
38
|
+
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
39
|
+
});
|
|
40
|
+
}, [isProgressionCreated, options, store]);
|
|
108
41
|
useEffect(() => {
|
|
109
42
|
const token = get('token', options);
|
|
110
43
|
if (store === null || isEmpty(token))
|
|
@@ -116,8 +49,8 @@ const AppReview = ({ options }) => {
|
|
|
116
49
|
if (store === null || isEmpty(token))
|
|
117
50
|
return;
|
|
118
51
|
const skillRef = get('skillRef', options);
|
|
119
|
-
|
|
120
|
-
|
|
52
|
+
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
53
|
+
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
121
54
|
skillRef
|
|
122
55
|
? store.dispatch(postProgression(skillRef, token))
|
|
123
56
|
: store.dispatch(fetchSkills(token));
|
|
@@ -126,21 +59,18 @@ const AppReview = ({ options }) => {
|
|
|
126
59
|
if (store === null)
|
|
127
60
|
return;
|
|
128
61
|
const { skillRef } = options;
|
|
129
|
-
if (skillRef && !
|
|
62
|
+
if (skillRef && !isProgressionCreated) {
|
|
130
63
|
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
131
64
|
return;
|
|
132
65
|
}
|
|
133
|
-
// TODO: when slides state is refactored (data + mapping),
|
|
134
|
-
// use loader in case a skillRef is found && no slides from the API
|
|
135
|
-
// are found
|
|
136
66
|
const initialView = skillRef ? VIEWS.slides : VIEWS.skills;
|
|
137
67
|
store.dispatch(navigateTo(initialView));
|
|
138
|
-
}, [
|
|
68
|
+
}, [isProgressionCreated, options, store]);
|
|
139
69
|
if (!store)
|
|
140
70
|
return null;
|
|
141
71
|
const { templateContext: values } = options;
|
|
142
72
|
return (React.createElement(Provider, { store: store },
|
|
143
73
|
React.createElement(TemplateContext, { values: values },
|
|
144
|
-
React.createElement(
|
|
74
|
+
React.createElement(ConnectedApp, null))));
|
|
145
75
|
};
|
|
146
76
|
export default AppReview;
|
|
@@ -4,7 +4,7 @@ import { SlidesState } from './slides';
|
|
|
4
4
|
import { TokenState } from './token';
|
|
5
5
|
export declare type DataState = {
|
|
6
6
|
isFetching?: boolean;
|
|
7
|
-
progression
|
|
7
|
+
progression: ProgressionState;
|
|
8
8
|
skills: SkillsState;
|
|
9
9
|
slides: SlidesState;
|
|
10
10
|
token?: TokenState;
|
|
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
skills: SkillsState;
|
|
15
15
|
slides: SlidesState;
|
|
16
16
|
token: TokenState;
|
|
17
|
-
}>, import("../../actions/
|
|
17
|
+
}>, import("../../actions/api/post-progression").ReceiveProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
18
18
|
export default _default;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { ValidateSlide } from '../../actions/
|
|
1
|
+
import { ValidateSlide } from '../../actions/ui/slides';
|
|
2
2
|
import { ReceiveProgression } from '../../actions/api/post-progression';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
state: {
|
|
6
|
-
isCorrect: boolean;
|
|
7
|
-
nextContent: {
|
|
8
|
-
ref: 'successExitNode' | string;
|
|
9
|
-
type: 'success' | 'slide';
|
|
10
|
-
};
|
|
11
|
-
pendingSlides: string[];
|
|
12
|
-
step: {
|
|
13
|
-
current: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
slideNumber?: number;
|
|
17
|
-
} | null;
|
|
3
|
+
import { ProgressionFromAPI } from '../../types/common';
|
|
4
|
+
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
18
5
|
declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
|
|
19
6
|
export default reducer;
|
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { VALIDATE_SLIDE } from '../../actions/data/slides';
|
|
1
|
+
import { VALIDATE_SLIDE } from '../../actions/ui/slides';
|
|
3
2
|
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
4
3
|
const reducer = (
|
|
5
4
|
// eslint-disable-next-line default-param-last
|
|
6
5
|
state = null, action) => {
|
|
7
6
|
switch (action.type) {
|
|
8
7
|
case VALIDATE_SLIDE: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// TODO: fix on VALIDATE ticket
|
|
12
|
-
return {
|
|
13
|
-
_id: '1234',
|
|
14
|
-
// virtual field
|
|
15
|
-
slideNumber: previousSlideNumber + 1,
|
|
16
|
-
state: {
|
|
17
|
-
pendingSlides: [],
|
|
18
|
-
step: {
|
|
19
|
-
current: Number.NaN
|
|
20
|
-
},
|
|
21
|
-
isCorrect: true,
|
|
22
|
-
nextContent: {
|
|
23
|
-
ref: 'sli_V1gKpYYZ2',
|
|
24
|
-
type: 'slide'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
8
|
+
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
9
|
+
return state;
|
|
28
10
|
}
|
|
29
11
|
case POST_PROGRESSION_SUCCESS: {
|
|
30
12
|
const progression = action.payload;
|
|
@@ -34,5 +16,4 @@ state = null, action) => {
|
|
|
34
16
|
return state;
|
|
35
17
|
}
|
|
36
18
|
};
|
|
37
|
-
// -----------------------------------------------------------------------------
|
|
38
19
|
export default reducer;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
1
|
+
import { ValidateSlide } from '../../actions/ui/slides';
|
|
2
|
+
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
|
+
import { SlideFromAPI } from '../../types/common';
|
|
4
|
+
export declare type SlidesAction = FetchSlide | ReceivedSlide | ValidateSlide;
|
|
5
|
+
export declare type SlidesState = Record<string, SlideFromAPI>;
|
|
7
6
|
export declare const initialState: SlidesState;
|
|
8
7
|
declare const reducer: (state: SlidesState | undefined, action: SlidesAction) => SlidesState;
|
|
9
8
|
export default reducer;
|
|
@@ -1,118 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { slide as qcmSlide } from '../../fixtures/qcm-slide';
|
|
5
|
-
import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
6
|
-
const getInitialState = () => {
|
|
7
|
-
const state = {
|
|
8
|
-
slideNumbers
|
|
9
|
-
};
|
|
10
|
-
// eslint-disable-next-line fp/no-loops
|
|
11
|
-
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
12
|
-
state[index] = { hidden: false, position: index };
|
|
13
|
-
}
|
|
14
|
-
return state;
|
|
15
|
-
};
|
|
16
|
-
export const initialState = getInitialState();
|
|
17
|
-
// -----------------------------------------------------------------------------
|
|
18
|
-
const setFirstSlide = (state, slide) => {
|
|
19
|
-
const _state = {
|
|
20
|
-
slideNumbers
|
|
21
|
-
};
|
|
22
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
23
|
-
map(index => {
|
|
24
|
-
const previousValue = state[index];
|
|
25
|
-
// Only update the 1st one
|
|
26
|
-
const content = index === 0 ? { ...previousValue, ...slide } : { ...previousValue };
|
|
27
|
-
_state[index] = { ...content };
|
|
28
|
-
}, state.slideNumbers);
|
|
29
|
-
return _state;
|
|
30
|
-
};
|
|
31
|
-
// ||-------> Handles the updates of a given slide on validation,
|
|
32
|
-
// & then updates de remaining slides if this given change should impact their content
|
|
33
|
-
const stateUpdateOnValidation = (state, payload) => {
|
|
34
|
-
const { slideNumber, newSlideContent, numberOfFinishedSlides, nextContent } = payload;
|
|
35
|
-
const _state = {
|
|
36
|
-
slideNumbers
|
|
37
|
-
};
|
|
38
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
39
|
-
map(index => {
|
|
40
|
-
const previousValue = state[index];
|
|
41
|
-
// the current slide
|
|
42
|
-
if (index === slideNumber) {
|
|
43
|
-
// only one slide remaining, presets the next value
|
|
44
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
45
|
-
_state[index] = {
|
|
46
|
-
...previousValue,
|
|
47
|
-
nextContent,
|
|
48
|
-
position: newSlideContent.position,
|
|
49
|
-
isCorrect: newSlideContent.isCorrect
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
else
|
|
53
|
-
_state[slideNumber] = { ...previousValue, ...newSlideContent };
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// updates the rest of the slides here
|
|
57
|
-
const { hidden, position } = previousValue;
|
|
58
|
-
_state[index] = { ...nextContent, endReview: newSlideContent.endReview, hidden, position };
|
|
59
|
-
}
|
|
60
|
-
}, state.slideNumbers);
|
|
61
|
-
return _state;
|
|
62
|
-
};
|
|
63
|
-
// ||-------> Handles the updates of a given slide on correction popin's next click,
|
|
64
|
-
// & then updates de remaining slides (updates position to trigger animations)
|
|
65
|
-
const stateUpdateOnNext = (state, payload) => {
|
|
66
|
-
const { slideNumber, newSlideContent, numberOfFinishedSlides } = payload;
|
|
67
|
-
const _state = {
|
|
68
|
-
slideNumbers
|
|
69
|
-
};
|
|
70
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
71
|
-
map(index => {
|
|
72
|
-
const previousValue = state[index];
|
|
73
|
-
// the current slide
|
|
74
|
-
if (index === slideNumber) {
|
|
75
|
-
// when there is only one slide remaining, updates the slide value
|
|
76
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextContent) {
|
|
77
|
-
_state[index] = { ...previousValue.nextContent, position: previousValue.position };
|
|
78
|
-
}
|
|
79
|
-
else
|
|
80
|
-
_state[slideNumber] = newSlideContent;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// updates the rest of the slides here
|
|
84
|
-
const { hidden, position, answerUI, questionText } = previousValue;
|
|
85
|
-
_state[index] = {
|
|
86
|
-
hidden,
|
|
87
|
-
position: position - 1,
|
|
88
|
-
answerUI,
|
|
89
|
-
questionText,
|
|
90
|
-
endReview: newSlideContent.endReview
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}, state.slideNumbers);
|
|
94
|
-
return _state;
|
|
95
|
-
};
|
|
96
|
-
// -----------------------------------------------------------------------------
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
3
|
+
export const initialState = {};
|
|
97
4
|
// eslint-disable-next-line default-param-last
|
|
98
5
|
const reducer = (state = initialState, action) => {
|
|
99
6
|
switch (action.type) {
|
|
100
|
-
case
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// apiSlide adapt to uiSlide
|
|
104
|
-
const uiSlide = qcmSlide;
|
|
105
|
-
return setFirstSlide(state, uiSlide);
|
|
106
|
-
}
|
|
107
|
-
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
108
|
-
return stateUpdateOnValidation(state, action.payload);
|
|
7
|
+
case SLIDE_FETCH_REQUEST: {
|
|
8
|
+
const { meta } = action;
|
|
9
|
+
return set(meta.slideRef, null, state);
|
|
109
10
|
}
|
|
110
|
-
case
|
|
111
|
-
|
|
11
|
+
case SLIDE_FETCH_SUCCESS: {
|
|
12
|
+
const slide = action.payload;
|
|
13
|
+
return set(slide.id, slide, state);
|
|
112
14
|
}
|
|
113
15
|
default:
|
|
114
16
|
return state;
|
|
115
17
|
}
|
|
116
18
|
};
|
|
117
|
-
// -----------------------------------------------------------------------------
|
|
118
19
|
export default reducer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../progression';
|
|
3
|
+
import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.is(state, null);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
+
content: {
|
|
12
|
+
ref: '_skill-ref',
|
|
13
|
+
type: 'skill'
|
|
14
|
+
},
|
|
15
|
+
engine: {
|
|
16
|
+
ref: 'review'
|
|
17
|
+
},
|
|
18
|
+
state: {
|
|
19
|
+
allAnswers: [],
|
|
20
|
+
isCorrect: true,
|
|
21
|
+
nextContent: {
|
|
22
|
+
ref: 'sli_N1XACJobn',
|
|
23
|
+
type: 'slide'
|
|
24
|
+
},
|
|
25
|
+
pendingSlides: [],
|
|
26
|
+
slides: [],
|
|
27
|
+
step: {
|
|
28
|
+
current: 1
|
|
29
|
+
},
|
|
30
|
+
stars: 0
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const state = reducer(null, {
|
|
34
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
35
|
+
payload: progression
|
|
36
|
+
});
|
|
37
|
+
t.deepEqual(state, progression);
|
|
38
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../skills';
|
|
3
|
+
import { SKILLS_FETCH_SUCCESS } from '../../../actions/api/fetch-skills';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of SKILLS_FETCH_SUCCESS action', t => {
|
|
9
|
+
const skills = [{ skillRef: 'skill', name: 'skill name', slidesToReview: 5, custom: false }];
|
|
10
|
+
const state = reducer([], { type: SKILLS_FETCH_SUCCESS, payload: skills });
|
|
11
|
+
t.deepEqual(state, skills);
|
|
12
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../slides';
|
|
3
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../../actions/api/fetch-slide';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {});
|
|
7
|
+
t.deepEqual(state, {});
|
|
8
|
+
});
|
|
9
|
+
test('should set the value of SLIDE_FETCH_REQUEST action', t => {
|
|
10
|
+
const state = reducer({}, { type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'slideRef' } });
|
|
11
|
+
t.deepEqual(state, {
|
|
12
|
+
slideRef: null
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
test('should set the value of SLIDE_FETCH_SUCCESS action', t => {
|
|
16
|
+
const state = reducer({}, { type: SLIDE_FETCH_SUCCESS, payload: freeTextSlide, meta: { slideRef: 'sli_VJYjJnJhg' } });
|
|
17
|
+
t.deepEqual(state, {
|
|
18
|
+
sli_VJYjJnJhg: freeTextSlide
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../token';
|
|
3
|
+
import { STORE_TOKEN } from '../../../actions/data/token';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.is(state, null);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of STORE_TOKEN action', t => {
|
|
9
|
+
const state = reducer(null, { type: STORE_TOKEN, payload: 'token' });
|
|
10
|
+
t.is(state, 'token');
|
|
11
|
+
});
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -12,10 +12,9 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
12
12
|
token: import("./data/token").TokenState;
|
|
13
13
|
}>;
|
|
14
14
|
ui: import("redux").CombinedState<{
|
|
15
|
-
|
|
15
|
+
currentSlideRef: string;
|
|
16
16
|
navigation: import("./ui/navigation").NavigationState;
|
|
17
|
-
|
|
18
|
-
stepItems: import("./ui/step-items").StepItemsState;
|
|
17
|
+
answers: import("./ui/answers").AnswerState;
|
|
19
18
|
}>;
|
|
20
|
-
}>, import("../actions/
|
|
19
|
+
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditBasicAction>;
|
|
21
20
|
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EDIT_BASIC } from '../../actions/ui/answers';
|
|
2
2
|
const reducer = (
|
|
3
3
|
// eslint-disable-next-line default-param-last
|
|
4
|
-
state =
|
|
4
|
+
state = [], action) => {
|
|
5
5
|
switch (action.type) {
|
|
6
|
-
case
|
|
6
|
+
case EDIT_BASIC: {
|
|
7
7
|
return action.payload;
|
|
8
8
|
}
|
|
9
9
|
default:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SET_CURRENT_SLIDE } from '../../actions/ui/slides';
|
|
2
|
+
const reducer = (
|
|
3
|
+
// eslint-disable-next-line default-param-last
|
|
4
|
+
state = '', action) => {
|
|
5
|
+
switch (action.type) {
|
|
6
|
+
case SET_CURRENT_SLIDE: {
|
|
7
|
+
return action.payload.id;
|
|
8
|
+
}
|
|
9
|
+
default:
|
|
10
|
+
return state;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default reducer;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
|
-
import {
|
|
4
|
-
import { StepItemsState } from './step-items';
|
|
3
|
+
import { AnswerState } from './answers';
|
|
5
4
|
export declare type UIState = {
|
|
5
|
+
currentSlideRef: CurrentSlideRefState;
|
|
6
6
|
navigation: NavigationState;
|
|
7
|
-
|
|
8
|
-
finishedSlides: FinishedSlidesState;
|
|
9
|
-
reviewStatus: ReviewStatusState;
|
|
7
|
+
answers: AnswerState;
|
|
10
8
|
};
|
|
11
9
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
12
|
-
|
|
10
|
+
currentSlideRef: string;
|
|
13
11
|
navigation: NavigationState;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}>, import("../../actions/ui/finished-slides").UpdateFinishedSlides | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/review-status").UpdateReviewStatus | import("../../actions/ui/step-items").StepItemsAction>;
|
|
12
|
+
answers: AnswerState;
|
|
13
|
+
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditBasicAction>;
|
|
17
14
|
export default _default;
|
package/es/reducers/ui/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
|
-
import
|
|
2
|
+
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
|
-
import
|
|
5
|
-
import stepItems from './step-items';
|
|
4
|
+
import answers from './answers';
|
|
6
5
|
export default combineReducers({
|
|
7
|
-
|
|
6
|
+
currentSlideRef,
|
|
8
7
|
navigation,
|
|
9
|
-
|
|
10
|
-
stepItems
|
|
8
|
+
answers
|
|
11
9
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../answers';
|
|
3
|
+
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of EDIT_BASIC action', t => {
|
|
9
|
+
const state = reducer([], { type: EDIT_BASIC, payload: ['value'] });
|
|
10
|
+
t.deepEqual(state, ['value']);
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../current-slide-ref';
|
|
3
|
+
import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {});
|
|
7
|
+
t.is(state, '');
|
|
8
|
+
});
|
|
9
|
+
test('should set the value of SET_CURRENT_SLIDE action', t => {
|
|
10
|
+
const state = reducer('', { type: SET_CURRENT_SLIDE, payload: freeTextSlide });
|
|
11
|
+
t.is(state, 'sli_VJYjJnJhg');
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../navigation';
|
|
3
|
+
import { NAVIGATE_TO, NAVIGATE_BACK } from '../../../actions/ui/navigation';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
9
|
+
const state = reducer([], { type: NAVIGATE_TO, payload: 'loader' });
|
|
10
|
+
t.deepEqual(state, ['loader']);
|
|
11
|
+
const updatedState = reducer(state, { type: NAVIGATE_TO, payload: 'skills' });
|
|
12
|
+
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
13
|
+
const _updatedState = reducer(updatedState, { type: NAVIGATE_BACK });
|
|
14
|
+
t.deepEqual(_updatedState, ['loader']);
|
|
15
|
+
});
|
|
@@ -3,7 +3,7 @@ import decode from 'jwt-decode';
|
|
|
3
3
|
import { toJSON } from './tools/fetch-responses';
|
|
4
4
|
export const fetchSlide = async (slideRef, token) => {
|
|
5
5
|
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}`, {
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}/parentContentTitle`, {
|
|
7
7
|
headers: { authorization: token }
|
|
8
8
|
});
|
|
9
9
|
const slide = (await toJSON(response));
|
package/es/services/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { fetchSkills } from './fetch-skills';
|
|
2
2
|
import { postProgression } from './post-progression';
|
|
3
3
|
import { fetchSlide } from './fetch-slide';
|
|
4
|
+
import { postAnswer } from './post-answer';
|
|
4
5
|
export const getServices = () => ({
|
|
5
6
|
fetchSkills,
|
|
6
7
|
fetchSlide,
|
|
7
|
-
postProgression
|
|
8
|
+
postProgression,
|
|
9
|
+
postAnswer
|
|
8
10
|
});
|