@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/src/common/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _toString from 'lodash/fp/toString';
|
|
2
|
+
|
|
1
3
|
export const TOTAL_SLIDES_STACK = 5;
|
|
2
4
|
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
3
5
|
|
|
@@ -11,4 +13,8 @@ export const VIEWS: {
|
|
|
11
13
|
slides: 'slides'
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
export const
|
|
16
|
+
export const slideIndexes = ['0', '1', '2', '3', '4'] as const;
|
|
17
|
+
|
|
18
|
+
export type SlideIndexes = typeof slideIndexes[number];
|
|
19
|
+
|
|
20
|
+
export const indexToString = (index: number): SlideIndexes => _toString(index) as SlideIndexes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import noop from 'lodash/fp/noop';
|
|
2
|
-
import {UISlide} from '../types/
|
|
2
|
+
import {UISlide} from '../types/common';
|
|
3
3
|
|
|
4
|
-
export const slide: UISlide = {
|
|
4
|
+
export const slide: Pick<UISlide, 'questionText' | 'answerUI'> = {
|
|
5
5
|
questionText: 'QCM',
|
|
6
6
|
answerUI: {
|
|
7
7
|
help: '__help',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import {SlidesViewProps} from '../
|
|
2
|
+
import {SlidesViewProps, CorrectionPopinProps} from '../views/slides';
|
|
3
3
|
|
|
4
|
-
export const correctionPopinProps:
|
|
4
|
+
export const correctionPopinProps: CorrectionPopinProps = {
|
|
5
5
|
klf: {
|
|
6
6
|
label: 'Key learning factor',
|
|
7
7
|
tooltip: 'Some tooltip info.',
|
package/src/index.tsx
CHANGED
|
@@ -1,121 +1,42 @@
|
|
|
1
1
|
import React, {useEffect, useState} from 'react';
|
|
2
2
|
import type {} from 'redux-thunk/extend-redux'; // https://github.com/reduxjs/redux-thunk/issues/333
|
|
3
3
|
import {AnyAction, Store} from 'redux';
|
|
4
|
-
import {
|
|
4
|
+
import {useSelector, useDispatch, Provider} from 'react-redux';
|
|
5
5
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
6
6
|
import {TemplateContext} from '@coorpacademy/components/es/template/app-review/template-context';
|
|
7
7
|
|
|
8
8
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
9
9
|
import get from 'lodash/fp/get';
|
|
10
10
|
import configureStore from './configure-store';
|
|
11
|
-
import {congratsProps, correctionPopinProps} from './fixtures/temp-fixture';
|
|
12
11
|
|
|
13
12
|
import type {AppOptions} from './types/common';
|
|
14
13
|
import type {StoreState} from './reducers';
|
|
15
|
-
import {SkillsProps} from './types/views/skills';
|
|
16
|
-
import type {SlidesViewStaticProps} from './types/views/slides';
|
|
17
14
|
|
|
18
|
-
import {
|
|
19
|
-
import {updateSlidesOnNext, updateSlidesOnValidation, validateSlide} from './actions/data/slides';
|
|
20
|
-
import {navigateTo, navigateBack, ViewPath} from './actions/ui/navigation';
|
|
15
|
+
import {navigateTo, ViewPath} from './actions/ui/navigation';
|
|
21
16
|
import {storeToken} from './actions/data/token';
|
|
22
|
-
import {updateFinishedSlides} from './actions/ui/finished-slides';
|
|
23
|
-
import {updateReviewStatus} from './actions/ui/review-status';
|
|
24
|
-
import {updateStepItemsOnValidation, updateStepItemsOnNext} from './actions/ui/step-items';
|
|
25
17
|
import {fetchSkills} from './actions/api/fetch-skills';
|
|
26
18
|
import {postProgression} from './actions/api/post-progression';
|
|
27
19
|
import {VIEWS} from './common';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
updateSlidesOnNext,
|
|
41
|
-
updateReviewStatus,
|
|
42
|
-
updateStepItemsOnValidation,
|
|
43
|
-
updateStepItemsOnNext,
|
|
44
|
-
updateFinishedSlides
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const getCurrentViewName = (storeState: StoreState): ViewPath =>
|
|
48
|
-
storeState.ui.navigation[storeState.ui.navigation.length - 1];
|
|
49
|
-
|
|
50
|
-
const mapStateToSkillsProps = (state: StoreState): SkillsProps | null => {
|
|
51
|
-
if (!state.data.skills) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
title: '@todo title',
|
|
57
|
-
titleNoSkills: '@todo titleNoSkills',
|
|
58
|
-
textNoSkills: '@todo textNoSkills',
|
|
59
|
-
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
60
|
-
isLoading: false,
|
|
61
|
-
isLoadingAriaLabel: '@todo loading',
|
|
62
|
-
listSkills: state.data.skills.map(skill => ({
|
|
63
|
-
'aria-label': '',
|
|
64
|
-
isCustom: skill.custom,
|
|
65
|
-
skillTitle: skill.name,
|
|
66
|
-
skillAriaLabel: '@todo skill aria label',
|
|
67
|
-
buttonLabel: '@todo button',
|
|
68
|
-
buttonAriaLabel: '@todo button aria label',
|
|
69
|
-
reviseLabel: '@todo revise',
|
|
70
|
-
reviseAriaLabel: '@todo revise aria label',
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
|
-
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
73
|
-
}))
|
|
20
|
+
import {mapStateToSlidesProps} from './views/slides';
|
|
21
|
+
import {mapStateToSkillsProps} from './views/skills';
|
|
22
|
+
|
|
23
|
+
const ConnectedApp = (): JSX.Element => {
|
|
24
|
+
const dispatch = useDispatch();
|
|
25
|
+
|
|
26
|
+
const props = {
|
|
27
|
+
viewName: useSelector(
|
|
28
|
+
(state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
|
|
29
|
+
),
|
|
30
|
+
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch)),
|
|
31
|
+
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state))
|
|
74
32
|
};
|
|
75
|
-
};
|
|
76
33
|
|
|
77
|
-
|
|
78
|
-
if (!state.data.slides) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
headerProps: {
|
|
84
|
-
mode: '__revision_mode',
|
|
85
|
-
skillName: '__agility',
|
|
86
|
-
onQuitClick: (): void => {
|
|
87
|
-
// eslint-disable-next-line no-console
|
|
88
|
-
console.log('onQuitClick');
|
|
89
|
-
},
|
|
90
|
-
'aria-label': 'aria-header-wrapper',
|
|
91
|
-
closeButtonAriaLabel: 'aria-close-button'
|
|
92
|
-
},
|
|
93
|
-
slides: state.data.slides,
|
|
94
|
-
validate: {
|
|
95
|
-
label: '__validate'
|
|
96
|
-
},
|
|
97
|
-
finishedSlides: state.ui.finishedSlides,
|
|
98
|
-
stepItems: state.ui.stepItems,
|
|
99
|
-
reviewStatus: state.ui.reviewStatus,
|
|
100
|
-
correctionPopinProps,
|
|
101
|
-
congratsProps,
|
|
102
|
-
progression: state.data.progression
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const mapStateToProps = (state: StoreState): StaticProps => {
|
|
107
|
-
return {
|
|
108
|
-
viewName: getCurrentViewName(state),
|
|
109
|
-
slides: mapStateToSlidesProps(state),
|
|
110
|
-
skills: mapStateToSkillsProps(state)
|
|
111
|
-
};
|
|
34
|
+
return <AppReviewTemplate {...props} />;
|
|
112
35
|
};
|
|
113
36
|
|
|
114
|
-
const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
115
|
-
|
|
116
37
|
const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
117
38
|
const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
|
|
118
|
-
const [
|
|
39
|
+
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
119
40
|
|
|
120
41
|
useEffect(() => {
|
|
121
42
|
if (store) return;
|
|
@@ -125,14 +46,13 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
125
46
|
}, [options, store]);
|
|
126
47
|
|
|
127
48
|
useEffect(() => {
|
|
128
|
-
if (!store ||
|
|
49
|
+
if (!store || isProgressionCreated) return;
|
|
129
50
|
|
|
130
51
|
return store.subscribe(() => {
|
|
131
|
-
const
|
|
132
|
-
return
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
}, [isSlideFetched, options, store]);
|
|
52
|
+
const isProgressionPresent = !isEmpty(store.getState().data.progression);
|
|
53
|
+
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
54
|
+
});
|
|
55
|
+
}, [isProgressionCreated, options, store]);
|
|
136
56
|
|
|
137
57
|
useEffect(() => {
|
|
138
58
|
const token = get('token', options);
|
|
@@ -146,8 +66,8 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
146
66
|
|
|
147
67
|
const skillRef = get('skillRef', options);
|
|
148
68
|
|
|
149
|
-
|
|
150
|
-
|
|
69
|
+
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
70
|
+
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
151
71
|
skillRef
|
|
152
72
|
? store.dispatch(postProgression(skillRef, token))
|
|
153
73
|
: store.dispatch(fetchSkills(token));
|
|
@@ -158,18 +78,14 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
158
78
|
|
|
159
79
|
const {skillRef} = options;
|
|
160
80
|
|
|
161
|
-
if (skillRef && !
|
|
81
|
+
if (skillRef && !isProgressionCreated) {
|
|
162
82
|
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
163
83
|
return;
|
|
164
84
|
}
|
|
165
85
|
|
|
166
|
-
// TODO: when slides state is refactored (data + mapping),
|
|
167
|
-
// use loader in case a skillRef is found && no slides from the API
|
|
168
|
-
// are found
|
|
169
|
-
|
|
170
86
|
const initialView: ViewPath = skillRef ? VIEWS.slides : VIEWS.skills;
|
|
171
87
|
store.dispatch(navigateTo(initialView));
|
|
172
|
-
}, [
|
|
88
|
+
}, [isProgressionCreated, options, store]);
|
|
173
89
|
|
|
174
90
|
if (!store) return null;
|
|
175
91
|
|
|
@@ -178,7 +94,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
178
94
|
return (
|
|
179
95
|
<Provider store={store}>
|
|
180
96
|
<TemplateContext values={values}>
|
|
181
|
-
<
|
|
97
|
+
<ConnectedApp />
|
|
182
98
|
</TemplateContext>
|
|
183
99
|
</Provider>
|
|
184
100
|
);
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {ValidateSlide, VALIDATE_SLIDE} from '../../actions/data/slides';
|
|
1
|
+
import {ValidateSlide, VALIDATE_SLIDE} from '../../actions/ui/slides';
|
|
3
2
|
import {POST_PROGRESSION_SUCCESS, ReceiveProgression} from '../../actions/api/post-progression';
|
|
3
|
+
import {ProgressionFromAPI} from '../../types/common';
|
|
4
4
|
|
|
5
|
-
export type ProgressionState =
|
|
6
|
-
_id?: string;
|
|
7
|
-
state: {
|
|
8
|
-
isCorrect: boolean;
|
|
9
|
-
nextContent: {
|
|
10
|
-
ref: 'successExitNode' | string;
|
|
11
|
-
type: 'success' | 'slide';
|
|
12
|
-
};
|
|
13
|
-
pendingSlides: string[];
|
|
14
|
-
step: {
|
|
15
|
-
current: number;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
// TO refactor: (slideNumber)
|
|
19
|
-
// virtual field
|
|
20
|
-
slideNumber?: number;
|
|
21
|
-
} | null; // TODO: ça ressemble beaucoup à ProgressionFromAPI et ça devrait l'être
|
|
5
|
+
export type ProgressionState = ProgressionFromAPI | null;
|
|
22
6
|
|
|
23
7
|
const reducer = (
|
|
24
8
|
// eslint-disable-next-line default-param-last
|
|
@@ -27,25 +11,8 @@ const reducer = (
|
|
|
27
11
|
): ProgressionState => {
|
|
28
12
|
switch (action.type) {
|
|
29
13
|
case VALIDATE_SLIDE: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// TODO: fix on VALIDATE ticket
|
|
33
|
-
return {
|
|
34
|
-
_id: '1234',
|
|
35
|
-
// virtual field
|
|
36
|
-
slideNumber: previousSlideNumber + 1,
|
|
37
|
-
state: {
|
|
38
|
-
pendingSlides: [],
|
|
39
|
-
step: {
|
|
40
|
-
current: Number.NaN
|
|
41
|
-
},
|
|
42
|
-
isCorrect: true,
|
|
43
|
-
nextContent: {
|
|
44
|
-
ref: 'sli_V1gKpYYZ2',
|
|
45
|
-
type: 'slide'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
14
|
+
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
15
|
+
return state;
|
|
49
16
|
}
|
|
50
17
|
case POST_PROGRESSION_SUCCESS: {
|
|
51
18
|
const progression = action.payload;
|
|
@@ -56,6 +23,4 @@ const reducer = (
|
|
|
56
23
|
}
|
|
57
24
|
};
|
|
58
25
|
|
|
59
|
-
// -----------------------------------------------------------------------------
|
|
60
|
-
|
|
61
26
|
export default reducer;
|
|
@@ -1,140 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
import {ValidateSlide} from '../../actions/ui/slides';
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '../../
|
|
9
|
-
import {UISlide} from '../../types/slides';
|
|
10
|
-
import {HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK} from '../../common';
|
|
11
|
-
import {slide as qcmSlide} from '../../fixtures/qcm-slide';
|
|
12
|
-
import {SLIDE_FETCH_SUCCESS} from '../../actions/api/fetch-slide';
|
|
13
|
-
import {Slide} from '../../types/common';
|
|
4
|
+
ReceivedSlide,
|
|
5
|
+
FetchSlide,
|
|
6
|
+
SLIDE_FETCH_REQUEST,
|
|
7
|
+
SLIDE_FETCH_SUCCESS
|
|
8
|
+
} from '../../actions/api/fetch-slide';
|
|
9
|
+
import {SlideFromAPI} from '../../types/common';
|
|
14
10
|
|
|
15
|
-
export type
|
|
16
|
-
slideNumbers: number[];
|
|
17
|
-
[key: number]: Slide;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getInitialState = (): SlidesState => {
|
|
21
|
-
const state: SlidesState = {
|
|
22
|
-
slideNumbers
|
|
23
|
-
};
|
|
24
|
-
// eslint-disable-next-line fp/no-loops
|
|
25
|
-
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
26
|
-
state[index] = {hidden: false, position: index};
|
|
27
|
-
}
|
|
28
|
-
return state;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const initialState: SlidesState = getInitialState();
|
|
32
|
-
|
|
33
|
-
// -----------------------------------------------------------------------------
|
|
11
|
+
export type SlidesAction = FetchSlide | ReceivedSlide | ValidateSlide;
|
|
34
12
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
slideNumbers
|
|
38
|
-
};
|
|
39
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
40
|
-
map(index => {
|
|
41
|
-
const previousValue = state[index];
|
|
42
|
-
// Only update the 1st one
|
|
43
|
-
const content = index === 0 ? {...previousValue, ...slide} : {...previousValue};
|
|
44
|
-
_state[index] = {...content};
|
|
45
|
-
}, state.slideNumbers);
|
|
46
|
-
|
|
47
|
-
return _state;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// ||-------> Handles the updates of a given slide on validation,
|
|
51
|
-
// & then updates de remaining slides if this given change should impact their content
|
|
52
|
-
const stateUpdateOnValidation = (state: SlidesState, payload: ValidationPayload): SlidesState => {
|
|
53
|
-
const {slideNumber, newSlideContent, numberOfFinishedSlides, nextContent} = payload;
|
|
54
|
-
const _state: SlidesState = {
|
|
55
|
-
slideNumbers
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
59
|
-
map(index => {
|
|
60
|
-
const previousValue = state[index];
|
|
61
|
-
// the current slide
|
|
62
|
-
if (index === slideNumber) {
|
|
63
|
-
// only one slide remaining, presets the next value
|
|
64
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
65
|
-
_state[index] = {
|
|
66
|
-
...previousValue,
|
|
67
|
-
nextContent,
|
|
68
|
-
position: newSlideContent.position,
|
|
69
|
-
isCorrect: newSlideContent.isCorrect
|
|
70
|
-
};
|
|
71
|
-
} else _state[slideNumber] = {...previousValue, ...newSlideContent};
|
|
72
|
-
} else {
|
|
73
|
-
// updates the rest of the slides here
|
|
74
|
-
const {hidden, position} = previousValue;
|
|
75
|
-
_state[index] = {...nextContent, endReview: newSlideContent.endReview, hidden, position};
|
|
76
|
-
}
|
|
77
|
-
}, state.slideNumbers);
|
|
78
|
-
|
|
79
|
-
return _state;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// ||-------> Handles the updates of a given slide on correction popin's next click,
|
|
83
|
-
// & then updates de remaining slides (updates position to trigger animations)
|
|
84
|
-
const stateUpdateOnNext = (state: SlidesState, payload: OnNextPayload): SlidesState => {
|
|
85
|
-
const {slideNumber, newSlideContent, numberOfFinishedSlides} = payload;
|
|
86
|
-
const _state: SlidesState = {
|
|
87
|
-
slideNumbers
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
91
|
-
map(index => {
|
|
92
|
-
const previousValue = state[index];
|
|
93
|
-
// the current slide
|
|
94
|
-
if (index === slideNumber) {
|
|
95
|
-
// when there is only one slide remaining, updates the slide value
|
|
96
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextContent) {
|
|
97
|
-
_state[index] = {...previousValue.nextContent, position: previousValue.position};
|
|
98
|
-
} else _state[slideNumber] = newSlideContent;
|
|
99
|
-
} else {
|
|
100
|
-
// updates the rest of the slides here
|
|
101
|
-
const {hidden, position, answerUI, questionText} = previousValue;
|
|
102
|
-
_state[index] = {
|
|
103
|
-
hidden,
|
|
104
|
-
position: position - 1, // position shift
|
|
105
|
-
answerUI,
|
|
106
|
-
questionText,
|
|
107
|
-
endReview: newSlideContent.endReview
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}, state.slideNumbers);
|
|
111
|
-
|
|
112
|
-
return _state;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// -----------------------------------------------------------------------------
|
|
13
|
+
export type SlidesState = Record<string, SlideFromAPI>;
|
|
14
|
+
export const initialState: SlidesState = {};
|
|
116
15
|
|
|
117
16
|
// eslint-disable-next-line default-param-last
|
|
118
17
|
const reducer = (state: SlidesState = initialState, action: SlidesAction): SlidesState => {
|
|
119
18
|
switch (action.type) {
|
|
120
|
-
case
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// apiSlide adapt to uiSlide
|
|
124
|
-
const uiSlide = qcmSlide;
|
|
125
|
-
return setFirstSlide(state, uiSlide);
|
|
126
|
-
}
|
|
127
|
-
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
128
|
-
return stateUpdateOnValidation(state, action.payload);
|
|
19
|
+
case SLIDE_FETCH_REQUEST: {
|
|
20
|
+
const {meta} = action;
|
|
21
|
+
return set(meta.slideRef, null, state);
|
|
129
22
|
}
|
|
130
|
-
case
|
|
131
|
-
|
|
23
|
+
case SLIDE_FETCH_SUCCESS: {
|
|
24
|
+
const slide = action.payload;
|
|
25
|
+
return set(slide.id, slide, state);
|
|
132
26
|
}
|
|
133
27
|
default:
|
|
134
28
|
return state;
|
|
135
29
|
}
|
|
136
30
|
};
|
|
137
31
|
|
|
138
|
-
// -----------------------------------------------------------------------------
|
|
139
|
-
|
|
140
32
|
export default reducer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../progression';
|
|
3
|
+
import {POST_PROGRESSION_SUCCESS, ReceiveProgression} from '../../../actions/api/post-progression';
|
|
4
|
+
import {ProgressionFromAPI} from '../../../types/common';
|
|
5
|
+
|
|
6
|
+
test('should have inital value', t => {
|
|
7
|
+
const state = reducer(undefined, {} as ReceiveProgression);
|
|
8
|
+
t.is(state, null);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
12
|
+
const progression: ProgressionFromAPI = {
|
|
13
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
14
|
+
content: {
|
|
15
|
+
ref: '_skill-ref',
|
|
16
|
+
type: 'skill'
|
|
17
|
+
},
|
|
18
|
+
engine: {
|
|
19
|
+
ref: 'review'
|
|
20
|
+
},
|
|
21
|
+
state: {
|
|
22
|
+
allAnswers: [],
|
|
23
|
+
isCorrect: true,
|
|
24
|
+
nextContent: {
|
|
25
|
+
ref: 'sli_N1XACJobn',
|
|
26
|
+
type: 'slide'
|
|
27
|
+
},
|
|
28
|
+
pendingSlides: [],
|
|
29
|
+
slides: [],
|
|
30
|
+
step: {
|
|
31
|
+
current: 1
|
|
32
|
+
},
|
|
33
|
+
stars: 0
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const state = reducer(null, {
|
|
38
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
39
|
+
payload: progression
|
|
40
|
+
});
|
|
41
|
+
t.deepEqual(state, progression);
|
|
42
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../skills';
|
|
3
|
+
import {ReceivedSkills, SKILLS_FETCH_SUCCESS} from '../../../actions/api/fetch-skills';
|
|
4
|
+
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {} as ReceivedSkills);
|
|
7
|
+
t.deepEqual(state, []);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should set the value of SKILLS_FETCH_SUCCESS action', t => {
|
|
11
|
+
const skills = [{skillRef: 'skill', name: 'skill name', slidesToReview: 5, custom: false}];
|
|
12
|
+
const state = reducer([], {type: SKILLS_FETCH_SUCCESS, payload: skills});
|
|
13
|
+
t.deepEqual(state, skills);
|
|
14
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer, {type SlidesAction} 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
|
+
|
|
6
|
+
test('should have inital value', t => {
|
|
7
|
+
const state = reducer(undefined, {} as SlidesAction);
|
|
8
|
+
t.deepEqual(state, {});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('should set the value of SLIDE_FETCH_REQUEST action', t => {
|
|
12
|
+
const state = reducer({}, {type: SLIDE_FETCH_REQUEST, meta: {slideRef: 'slideRef'}});
|
|
13
|
+
t.deepEqual(state, {
|
|
14
|
+
slideRef: null
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should set the value of SLIDE_FETCH_SUCCESS action', t => {
|
|
19
|
+
const state = reducer(
|
|
20
|
+
{},
|
|
21
|
+
{type: SLIDE_FETCH_SUCCESS, payload: freeTextSlide, meta: {slideRef: 'sli_VJYjJnJhg'}}
|
|
22
|
+
);
|
|
23
|
+
t.deepEqual(state, {
|
|
24
|
+
sli_VJYjJnJhg: freeTextSlide
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../token';
|
|
3
|
+
import {StoreToken, STORE_TOKEN} from '../../../actions/data/token';
|
|
4
|
+
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {} as StoreToken);
|
|
7
|
+
t.is(state, null);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should set the value of STORE_TOKEN action', t => {
|
|
11
|
+
const state = reducer(null, {type: STORE_TOKEN, payload: 'token'});
|
|
12
|
+
t.is(state, 'token');
|
|
13
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {EditBasicAction, EDIT_BASIC} from '../../actions/ui/answers';
|
|
2
|
+
|
|
3
|
+
export type AnswerState = string[];
|
|
4
|
+
|
|
5
|
+
const reducer = (
|
|
6
|
+
// eslint-disable-next-line default-param-last
|
|
7
|
+
state: AnswerState = [],
|
|
8
|
+
action: EditBasicAction
|
|
9
|
+
): AnswerState => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case EDIT_BASIC: {
|
|
12
|
+
return action.payload;
|
|
13
|
+
}
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default reducer;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {SET_CURRENT_SLIDE, UISlidesAction} from '../../actions/ui/slides';
|
|
2
|
+
|
|
3
|
+
export type CurrentSlideRefState = string;
|
|
4
|
+
|
|
5
|
+
const reducer = (
|
|
6
|
+
// eslint-disable-next-line default-param-last
|
|
7
|
+
state: CurrentSlideRefState = '',
|
|
8
|
+
action: UISlidesAction
|
|
9
|
+
): CurrentSlideRefState => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case SET_CURRENT_SLIDE: {
|
|
12
|
+
return action.payload.id;
|
|
13
|
+
}
|
|
14
|
+
default:
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default reducer;
|
package/src/reducers/ui/index.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import {combineReducers} from 'redux';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import currentSlideRef, {CurrentSlideRefState} from './current-slide-ref';
|
|
4
4
|
import navigation, {NavigationState} from './navigation';
|
|
5
|
-
import
|
|
6
|
-
import stepItems, {StepItemsState} from './step-items';
|
|
5
|
+
import answers, {AnswerState} from './answers';
|
|
7
6
|
|
|
8
7
|
export type UIState = {
|
|
8
|
+
currentSlideRef: CurrentSlideRefState;
|
|
9
9
|
navigation: NavigationState;
|
|
10
|
-
|
|
11
|
-
finishedSlides: FinishedSlidesState;
|
|
12
|
-
reviewStatus: ReviewStatusState;
|
|
10
|
+
answers: AnswerState;
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
export default combineReducers({
|
|
16
|
-
|
|
14
|
+
currentSlideRef,
|
|
17
15
|
navigation,
|
|
18
|
-
|
|
19
|
-
stepItems
|
|
16
|
+
answers
|
|
20
17
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../answers';
|
|
3
|
+
import {EditBasicAction, EDIT_BASIC} from '../../../actions/ui/answers';
|
|
4
|
+
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {} as EditBasicAction);
|
|
7
|
+
t.deepEqual(state, []);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('should set the value of EDIT_BASIC action', t => {
|
|
11
|
+
const state = reducer([], {type: EDIT_BASIC, payload: ['value']});
|
|
12
|
+
t.deepEqual(state, ['value']);
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../current-slide-ref';
|
|
3
|
+
import {SetCurrentSlide, SET_CURRENT_SLIDE} from '../../../actions/ui/slides';
|
|
4
|
+
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
|
|
6
|
+
test('should have inital value', t => {
|
|
7
|
+
const state = reducer(undefined, {} as SetCurrentSlide);
|
|
8
|
+
t.is(state, '');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('should set the value of SET_CURRENT_SLIDE action', t => {
|
|
12
|
+
const state = reducer('', {type: SET_CURRENT_SLIDE, payload: freeTextSlide});
|
|
13
|
+
t.is(state, 'sli_VJYjJnJhg');
|
|
14
|
+
});
|