@coorpacademy/app-review 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-slide.d.ts +3 -3
- package/es/actions/api/fetch-slide.js +22 -2
- package/es/actions/api/post-progression.js +1 -2
- package/es/actions/index.d.ts +1 -10
- package/es/actions/ui/is-fetching.js +0 -2
- package/es/actions/ui/slides.d.ts +26 -0
- package/es/actions/ui/slides.js +9 -0
- package/es/common/index.d.ts +3 -1
- package/es/common/index.js +3 -1
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/fixtures/temp-fixture.d.ts +2 -2
- package/es/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/es/helpers/map-api-slide-to-ui.js +33 -15
- package/es/helpers/test/fixtures/free-text.d.ts +2 -3
- package/es/helpers/test/fixtures/free-text.js +10 -4
- package/es/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-drag.js +38 -32
- package/es/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/es/helpers/test/fixtures/qcm.d.ts +2 -3
- package/es/helpers/test/fixtures/qcm.js +32 -26
- package/es/helpers/test/fixtures/select-template.d.ts +2 -3
- package/es/helpers/test/fixtures/select-template.js +38 -32
- package/es/helpers/test/fixtures/slider.d.ts +2 -3
- package/es/helpers/test/fixtures/slider.js +13 -7
- package/es/helpers/test/fixtures/text-template.d.ts +2 -3
- package/es/helpers/test/fixtures/text-template.js +16 -10
- package/es/index.js +14 -78
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +3 -16
- package/es/reducers/data/progression.js +3 -22
- package/es/reducers/data/slides.d.ts +5 -6
- package/es/reducers/data/slides.js +4 -107
- package/es/reducers/index.d.ts +3 -4
- package/es/reducers/ui/current-slide-ref.d.ts +4 -0
- package/es/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/es/reducers/ui/index.d.ts +7 -10
- package/es/reducers/ui/index.js +4 -6
- package/es/reducers/ui/slides.d.ts +9 -0
- package/es/reducers/ui/slides.js +42 -0
- package/es/services/test/post-progression.test.js +6 -4
- package/es/test/util/services.mock.js +17 -5
- package/es/types/common.d.ts +40 -23
- package/es/types/common.js +0 -5
- package/es/types/slides.d.ts +0 -4
- package/es/types/views/slides.d.ts +41 -27
- package/es/types/views/slides.js +5 -0
- package/{lib/types/views/skills.d.ts → es/views/skills/index.d.ts} +2 -0
- package/es/views/skills/index.js +25 -0
- package/es/views/slides/index.d.ts +3 -0
- package/es/views/slides/index.js +85 -0
- package/lib/actions/api/fetch-slide.d.ts +3 -3
- package/lib/actions/api/fetch-slide.js +20 -2
- package/lib/actions/api/post-progression.js +1 -2
- package/lib/actions/index.d.ts +1 -10
- package/lib/actions/ui/is-fetching.js +0 -2
- package/lib/actions/ui/slides.d.ts +26 -0
- package/lib/actions/ui/slides.js +9 -0
- package/lib/common/index.d.ts +3 -1
- package/lib/common/index.js +3 -1
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/fixtures/temp-fixture.d.ts +2 -2
- package/lib/helpers/map-api-slide-to-ui.d.ts +4 -1
- package/lib/helpers/map-api-slide-to-ui.js +34 -14
- package/lib/helpers/test/fixtures/free-text.d.ts +2 -3
- package/lib/helpers/test/fixtures/free-text.js +10 -4
- package/lib/helpers/test/fixtures/qcm-drag.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-drag.js +38 -32
- package/lib/helpers/test/fixtures/qcm-graphic.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm-graphic.js +20 -14
- package/lib/helpers/test/fixtures/qcm.d.ts +2 -3
- package/lib/helpers/test/fixtures/qcm.js +32 -26
- package/lib/helpers/test/fixtures/select-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/select-template.js +38 -32
- package/lib/helpers/test/fixtures/slider.d.ts +2 -3
- package/lib/helpers/test/fixtures/slider.js +13 -7
- package/lib/helpers/test/fixtures/text-template.d.ts +2 -3
- package/lib/helpers/test/fixtures/text-template.js +16 -10
- package/lib/index.js +14 -78
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +3 -16
- package/lib/reducers/data/progression.js +3 -22
- package/lib/reducers/data/slides.d.ts +5 -6
- package/lib/reducers/data/slides.js +4 -113
- package/lib/reducers/index.d.ts +3 -4
- package/lib/reducers/ui/current-slide-ref.d.ts +4 -0
- package/lib/reducers/ui/{review-status.js → current-slide-ref.js} +4 -4
- package/lib/reducers/ui/index.d.ts +7 -10
- package/lib/reducers/ui/index.js +4 -6
- package/lib/reducers/ui/slides.d.ts +9 -0
- package/lib/reducers/ui/slides.js +43 -0
- package/lib/services/test/post-progression.test.js +6 -4
- package/lib/test/util/services.mock.js +17 -5
- package/lib/types/common.d.ts +40 -23
- package/lib/types/common.js +0 -5
- package/lib/types/slides.d.ts +0 -4
- package/lib/types/views/slides.d.ts +41 -27
- package/lib/types/views/slides.js +5 -0
- package/{es/types/views/skills.d.ts → lib/views/skills/index.d.ts} +2 -0
- package/lib/views/skills/index.js +25 -0
- package/lib/views/slides/index.d.ts +3 -0
- package/lib/views/slides/index.js +89 -0
- package/package.json +3 -3
- package/src/actions/api/fetch-slide.ts +26 -5
- package/src/actions/api/post-progression.ts +1 -2
- package/src/actions/index.ts +1 -10
- package/src/actions/ui/is-fetching.ts +0 -6
- package/src/actions/ui/slides.ts +35 -0
- package/src/common/index.ts +7 -1
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/fixtures/temp-fixture.ts +2 -2
- package/src/helpers/map-api-slide-to-ui.ts +43 -17
- package/src/helpers/test/fixtures/free-text.ts +12 -7
- package/src/helpers/test/fixtures/qcm-drag.ts +40 -35
- package/src/helpers/test/fixtures/qcm-graphic.ts +22 -17
- package/src/helpers/test/fixtures/qcm.ts +38 -32
- package/src/helpers/test/fixtures/select-template.ts +40 -35
- package/src/helpers/test/fixtures/slider.ts +15 -10
- package/src/helpers/test/fixtures/text-template.ts +18 -13
- package/src/helpers/test/map-api-slide-to-ui.test.ts +2 -11
- package/src/index.tsx +15 -84
- package/src/reducers/data/progression.ts +5 -40
- package/src/reducers/data/slides.ts +9 -126
- package/src/reducers/ui/current-slide-ref.ts +19 -0
- package/src/reducers/ui/index.ts +6 -9
- package/src/reducers/ui/slides.ts +58 -0
- package/src/services/test/post-progression.test.ts +6 -4
- package/src/test/util/services.mock.ts +17 -5
- package/src/types/common.ts +44 -27
- package/src/types/slides.ts +0 -5
- package/src/types/views/slides.ts +52 -27
- package/src/views/skills/index.ts +56 -0
- package/src/views/slides/index.ts +92 -0
- package/es/actions/data/slides.d.ts +0 -37
- package/es/actions/data/slides.js +0 -16
- package/es/actions/ui/finished-slides.d.ts +0 -10
- package/es/actions/ui/finished-slides.js +0 -8
- package/es/actions/ui/review-status.d.ts +0 -7
- package/es/actions/ui/review-status.js +0 -7
- package/es/actions/ui/step-items.d.ts +0 -24
- package/es/actions/ui/step-items.js +0 -11
- package/es/reducers/ui/finished-slides.d.ts +0 -7
- package/es/reducers/ui/finished-slides.js +0 -33
- package/es/reducers/ui/review-status.d.ts +0 -4
- package/es/reducers/ui/step-items.d.ts +0 -14
- package/es/reducers/ui/step-items.js +0 -74
- package/es/types/ui-progression.d.ts +0 -10
- package/es/types/ui-progression.js +0 -1
- package/es/types/views/skills.js +0 -1
- package/lib/actions/data/slides.d.ts +0 -37
- package/lib/actions/data/slides.js +0 -16
- package/lib/actions/ui/finished-slides.d.ts +0 -10
- package/lib/actions/ui/finished-slides.js +0 -8
- package/lib/actions/ui/review-status.d.ts +0 -7
- package/lib/actions/ui/review-status.js +0 -7
- package/lib/actions/ui/step-items.d.ts +0 -24
- package/lib/actions/ui/step-items.js +0 -11
- package/lib/reducers/ui/finished-slides.d.ts +0 -7
- package/lib/reducers/ui/finished-slides.js +0 -45
- package/lib/reducers/ui/review-status.d.ts +0 -4
- package/lib/reducers/ui/step-items.d.ts +0 -14
- package/lib/reducers/ui/step-items.js +0 -86
- package/lib/types/ui-progression.d.ts +0 -10
- package/lib/types/ui-progression.js +0 -1
- package/lib/types/views/skills.js +0 -1
- package/src/actions/data/slides.ts +0 -65
- package/src/actions/ui/finished-slides.ts +0 -21
- package/src/actions/ui/review-status.ts +0 -19
- package/src/actions/ui/step-items.ts +0 -45
- package/src/reducers/ui/finished-slides.ts +0 -52
- package/src/reducers/ui/review-status.ts +0 -19
- package/src/reducers/ui/step-items.ts +0 -116
- package/src/types/ui-progression.ts +0 -25
- package/src/types/views/skills.ts +0 -27
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/fp/get';
|
|
2
|
-
import has from 'lodash/fp/has';
|
|
3
|
-
import map from 'lodash/fp/map';
|
|
4
|
-
import {IconValue, FinishedSlides} from '../../types/common';
|
|
5
|
-
import {
|
|
6
|
-
StepItemsAction,
|
|
7
|
-
UPDATE_STEP_ITEMS_ON_NEXT,
|
|
8
|
-
UPDATE_STEP_ITEMS_ON_VALIDATION
|
|
9
|
-
} from '../../actions/ui/step-items';
|
|
10
|
-
import {HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK} from '../../common';
|
|
11
|
-
|
|
12
|
-
export type StepItem = {
|
|
13
|
-
current: boolean;
|
|
14
|
-
icon: IconValue;
|
|
15
|
-
value: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type StepItemsState = {
|
|
19
|
-
slideNumbers: number[];
|
|
20
|
-
[key: number]: StepItem;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const getInitialState = (): StepItemsState => {
|
|
24
|
-
const state: StepItemsState = {
|
|
25
|
-
slideNumbers
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line fp/no-loops
|
|
29
|
-
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
30
|
-
const current = index === 0;
|
|
31
|
-
state[index] = {current, value: `${index + 1}`, icon: 'no-answer'};
|
|
32
|
-
}
|
|
33
|
-
return state;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const initialState: StepItemsState = getInitialState();
|
|
37
|
-
|
|
38
|
-
// -----------------------------------------------------------------------------
|
|
39
|
-
|
|
40
|
-
// ||-------> aux function, finds the next consecutive index
|
|
41
|
-
// to loop from 0 to HIGHEST_INDEX (4) & again to 0
|
|
42
|
-
const getNextIndex = (currentIndex: number): number =>
|
|
43
|
-
currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
|
|
44
|
-
|
|
45
|
-
// ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
|
|
46
|
-
// they have to be skipped)
|
|
47
|
-
const calculateNextStepIndex = (
|
|
48
|
-
currentStepNumber: number,
|
|
49
|
-
finishedSlides: FinishedSlides,
|
|
50
|
-
lastVisitedIndex = -1
|
|
51
|
-
): number => {
|
|
52
|
-
// only one slide remaining, the step should stay on the same number
|
|
53
|
-
if (lastVisitedIndex === currentStepNumber) {
|
|
54
|
-
return currentStepNumber;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const indexToVisit = getNextIndex(lastVisitedIndex === -1 ? currentStepNumber : lastVisitedIndex);
|
|
58
|
-
|
|
59
|
-
// if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
|
|
60
|
-
return has(indexToVisit, finishedSlides)
|
|
61
|
-
? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
|
|
62
|
-
: indexToVisit;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type StepItemToUpdateProps =
|
|
66
|
-
| Pick<StepItem, 'icon'>
|
|
67
|
-
| (Pick<StepItem, 'current'> & {nextIndex: number});
|
|
68
|
-
|
|
69
|
-
const recalculateStepItemsState = (
|
|
70
|
-
state: StepItemsState,
|
|
71
|
-
stepNumber: number,
|
|
72
|
-
stepItemToUpdateProps: StepItemToUpdateProps
|
|
73
|
-
): StepItemsState => {
|
|
74
|
-
const nextIndex: number = get('nextIndex', stepItemToUpdateProps);
|
|
75
|
-
const _state: StepItemsState = {
|
|
76
|
-
slideNumbers
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
80
|
-
map(index => {
|
|
81
|
-
const previousValue = state[index];
|
|
82
|
-
if (stepNumber === index)
|
|
83
|
-
_state[stepNumber] = {
|
|
84
|
-
...previousValue,
|
|
85
|
-
...stepItemToUpdateProps
|
|
86
|
-
};
|
|
87
|
-
/* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
|
|
88
|
-
_state[index] = {...previousValue, current: true};
|
|
89
|
-
} else _state[index] = previousValue;
|
|
90
|
-
}, state.slideNumbers);
|
|
91
|
-
|
|
92
|
-
return _state;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// -----------------------------------------------------------------------------
|
|
96
|
-
|
|
97
|
-
// eslint-disable-next-line default-param-last
|
|
98
|
-
const reducer = (state: StepItemsState = initialState, action: StepItemsAction): StepItemsState => {
|
|
99
|
-
switch (action.type) {
|
|
100
|
-
case UPDATE_STEP_ITEMS_ON_VALIDATION: {
|
|
101
|
-
const {stepNumber, icon} = action.payload;
|
|
102
|
-
return recalculateStepItemsState(state, stepNumber, {icon});
|
|
103
|
-
}
|
|
104
|
-
case UPDATE_STEP_ITEMS_ON_NEXT: {
|
|
105
|
-
const {stepNumber, finishedSlides, current} = action.payload;
|
|
106
|
-
const nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : -1;
|
|
107
|
-
return recalculateStepItemsState(state, stepNumber, {current, nextIndex});
|
|
108
|
-
}
|
|
109
|
-
default:
|
|
110
|
-
return state;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// -----------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
export default reducer;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type UiProgression = {
|
|
2
|
-
_id?: string;
|
|
3
|
-
// virtual field
|
|
4
|
-
slideNumber?: number;
|
|
5
|
-
isCorrect?: boolean;
|
|
6
|
-
// pass down the successExitNode if all slides are finished, not before
|
|
7
|
-
exitNode?: 'successExitNode' | 'failExitNode';
|
|
8
|
-
// TODO: create another action, to retrieve the next slide
|
|
9
|
-
// ex: nextContent: {ref: "sli_E1n2i2sBo", type: "slide"}
|
|
10
|
-
// the middleware should trigger a nextContent request once the result is
|
|
11
|
-
// received && update the state accordingly
|
|
12
|
-
// nextContent?: {
|
|
13
|
-
// questionText?: string;
|
|
14
|
-
// answerUI?: AnswerUI;
|
|
15
|
-
// };
|
|
16
|
-
nextContent?: {
|
|
17
|
-
ref: 'successExitNode' | string;
|
|
18
|
-
type: 'success' | 'slide';
|
|
19
|
-
};
|
|
20
|
-
// unused for now / to decide whether to use it when the
|
|
21
|
-
// validation-progression is plugged in
|
|
22
|
-
// step: {
|
|
23
|
-
// current: number;
|
|
24
|
-
// };
|
|
25
|
-
} | null;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
type SkillCard = {
|
|
2
|
-
'aria-label': string;
|
|
3
|
-
skillTitle: string;
|
|
4
|
-
skillAriaLabel: string;
|
|
5
|
-
buttonLabel: string;
|
|
6
|
-
buttonAriaLabel: string;
|
|
7
|
-
reviseLabel: string;
|
|
8
|
-
reviseAriaLabel: string;
|
|
9
|
-
isCustom: boolean;
|
|
10
|
-
onClick: Function;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type NoSkillsProps = {
|
|
14
|
-
titleNoSkills: string;
|
|
15
|
-
textNoSkills: string;
|
|
16
|
-
iconSkillAriaLabel: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type SkillsProps = NoSkillsProps & {
|
|
20
|
-
'aria-label'?: string;
|
|
21
|
-
title: string;
|
|
22
|
-
isLoading?: boolean;
|
|
23
|
-
isLoadingAriaLabel: string;
|
|
24
|
-
listSkills: SkillCard[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export {SkillsProps};
|