@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,74 +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 { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../../actions/ui/step-items';
|
|
5
|
-
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
|
|
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
|
-
const current = index === 0;
|
|
13
|
-
state[index] = { current, value: `${index + 1}`, icon: 'no-answer' };
|
|
14
|
-
}
|
|
15
|
-
return state;
|
|
16
|
-
};
|
|
17
|
-
export const initialState = getInitialState();
|
|
18
|
-
// -----------------------------------------------------------------------------
|
|
19
|
-
// ||-------> aux function, finds the next consecutive index
|
|
20
|
-
// to loop from 0 to HIGHEST_INDEX (4) & again to 0
|
|
21
|
-
const getNextIndex = (currentIndex) => currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
|
|
22
|
-
// ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
|
|
23
|
-
// they have to be skipped)
|
|
24
|
-
const calculateNextStepIndex = (currentStepNumber, finishedSlides, lastVisitedIndex = -1) => {
|
|
25
|
-
// only one slide remaining, the step should stay on the same number
|
|
26
|
-
if (lastVisitedIndex === currentStepNumber) {
|
|
27
|
-
return currentStepNumber;
|
|
28
|
-
}
|
|
29
|
-
const indexToVisit = getNextIndex(lastVisitedIndex === -1 ? currentStepNumber : lastVisitedIndex);
|
|
30
|
-
// if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
|
|
31
|
-
return has(indexToVisit, finishedSlides)
|
|
32
|
-
? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
|
|
33
|
-
: indexToVisit;
|
|
34
|
-
};
|
|
35
|
-
const recalculateStepItemsState = (state, stepNumber, stepItemToUpdateProps) => {
|
|
36
|
-
const nextIndex = get('nextIndex', stepItemToUpdateProps);
|
|
37
|
-
const _state = {
|
|
38
|
-
slideNumbers
|
|
39
|
-
};
|
|
40
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
41
|
-
map(index => {
|
|
42
|
-
const previousValue = state[index];
|
|
43
|
-
if (stepNumber === index)
|
|
44
|
-
_state[stepNumber] = {
|
|
45
|
-
...previousValue,
|
|
46
|
-
...stepItemToUpdateProps
|
|
47
|
-
};
|
|
48
|
-
/* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
|
|
49
|
-
_state[index] = { ...previousValue, current: true };
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
_state[index] = previousValue;
|
|
53
|
-
}, state.slideNumbers);
|
|
54
|
-
return _state;
|
|
55
|
-
};
|
|
56
|
-
// -----------------------------------------------------------------------------
|
|
57
|
-
// eslint-disable-next-line default-param-last
|
|
58
|
-
const reducer = (state = initialState, action) => {
|
|
59
|
-
switch (action.type) {
|
|
60
|
-
case UPDATE_STEP_ITEMS_ON_VALIDATION: {
|
|
61
|
-
const { stepNumber, icon } = action.payload;
|
|
62
|
-
return recalculateStepItemsState(state, stepNumber, { icon });
|
|
63
|
-
}
|
|
64
|
-
case UPDATE_STEP_ITEMS_ON_NEXT: {
|
|
65
|
-
const { stepNumber, finishedSlides, current } = action.payload;
|
|
66
|
-
const nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : -1;
|
|
67
|
-
return recalculateStepItemsState(state, stepNumber, { current, nextIndex });
|
|
68
|
-
}
|
|
69
|
-
default:
|
|
70
|
-
return state;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
// -----------------------------------------------------------------------------
|
|
74
|
-
export default reducer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/es/types/views/skills.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { UISlide } from '../../types/slides';
|
|
2
|
-
import { ReceivedSlide } from '../api/fetch-slide';
|
|
3
|
-
export declare const UPDATE_SLIDES_ON_VALIDATION = "@@slide/UPDATE_SLIDES_ON_VALIDATION";
|
|
4
|
-
export declare const UPDATE_SLIDES_ON_NEXT = "@@slide/UPDATE_SLIDES_ON_NEXT";
|
|
5
|
-
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
6
|
-
declare type SlideUIAnimations = 'unstack' | 'restack';
|
|
7
|
-
export declare type Slide = UISlide & {
|
|
8
|
-
hidden?: boolean;
|
|
9
|
-
position: number;
|
|
10
|
-
animationType?: SlideUIAnimations;
|
|
11
|
-
isCorrect?: boolean;
|
|
12
|
-
endReview?: boolean;
|
|
13
|
-
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
14
|
-
};
|
|
15
|
-
export declare type ValidationPayload = {
|
|
16
|
-
slideNumber: number;
|
|
17
|
-
newSlideContent: Slide;
|
|
18
|
-
numberOfFinishedSlides: number;
|
|
19
|
-
nextContent: Slide;
|
|
20
|
-
};
|
|
21
|
-
export declare type OnNextPayload = Omit<ValidationPayload, 'nextContent'>;
|
|
22
|
-
export declare type UpdateSlidesOnValidation = {
|
|
23
|
-
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
24
|
-
payload: ValidationPayload;
|
|
25
|
-
};
|
|
26
|
-
export declare type UpdateSlidesOnNext = {
|
|
27
|
-
type: typeof UPDATE_SLIDES_ON_NEXT;
|
|
28
|
-
payload: OnNextPayload;
|
|
29
|
-
};
|
|
30
|
-
export declare type ValidateSlide = {
|
|
31
|
-
type: typeof VALIDATE_SLIDE;
|
|
32
|
-
};
|
|
33
|
-
export declare type SlidesAction = ReceivedSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
34
|
-
export declare const updateSlidesOnValidation: (payload: ValidationPayload) => UpdateSlidesOnValidation;
|
|
35
|
-
export declare const updateSlidesOnNext: (payload: OnNextPayload) => UpdateSlidesOnNext;
|
|
36
|
-
export declare const validateSlide: () => ValidateSlide;
|
|
37
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
export var UPDATE_SLIDES_ON_VALIDATION = '@@slide/UPDATE_SLIDES_ON_VALIDATION';
|
|
3
|
-
export var UPDATE_SLIDES_ON_NEXT = '@@slide/UPDATE_SLIDES_ON_NEXT';
|
|
4
|
-
export var VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
export var updateSlidesOnValidation = function (payload) { return ({
|
|
7
|
-
type: UPDATE_SLIDES_ON_VALIDATION,
|
|
8
|
-
payload: payload
|
|
9
|
-
}); };
|
|
10
|
-
export var updateSlidesOnNext = function (payload) { return ({
|
|
11
|
-
type: UPDATE_SLIDES_ON_NEXT,
|
|
12
|
-
payload: payload
|
|
13
|
-
}); };
|
|
14
|
-
export var validateSlide = function () { return ({
|
|
15
|
-
type: VALIDATE_SLIDE
|
|
16
|
-
}); };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare type FinishedSlide = {
|
|
2
|
-
slideNumber: number;
|
|
3
|
-
value: true;
|
|
4
|
-
};
|
|
5
|
-
export declare const UPDATE_FINISHED_SLIDES = "@@finished-slides/UPDATE_FINISHED_SLIDES";
|
|
6
|
-
export declare type UpdateFinishedSlides = {
|
|
7
|
-
type: typeof UPDATE_FINISHED_SLIDES;
|
|
8
|
-
payload: FinishedSlide;
|
|
9
|
-
};
|
|
10
|
-
export declare const updateFinishedSlides: (payload: FinishedSlide) => UpdateFinishedSlides;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Stores only successful slides
|
|
2
|
-
// -----------------------------------------------------------------------------
|
|
3
|
-
export var UPDATE_FINISHED_SLIDES = '@@finished-slides/UPDATE_FINISHED_SLIDES';
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
|
-
export var updateFinishedSlides = function (payload) { return ({
|
|
6
|
-
type: UPDATE_FINISHED_SLIDES,
|
|
7
|
-
payload: payload
|
|
8
|
-
}); };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const UPDATE_REVIEW_STATUS = "@@review-status/UPDATE_REVIEW_STATUS";
|
|
2
|
-
export declare type FinishedStatus = 'finished';
|
|
3
|
-
export declare type UpdateReviewStatus = {
|
|
4
|
-
type: typeof UPDATE_REVIEW_STATUS;
|
|
5
|
-
payload: FinishedStatus;
|
|
6
|
-
};
|
|
7
|
-
export declare const updateReviewStatus: (payload: FinishedStatus) => UpdateReviewStatus;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
export var UPDATE_REVIEW_STATUS = '@@review-status/UPDATE_REVIEW_STATUS';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
export var updateReviewStatus = function (payload) { return ({
|
|
5
|
-
type: UPDATE_REVIEW_STATUS,
|
|
6
|
-
payload: payload
|
|
7
|
-
}); };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FinishedSlides, IconValue } from '../../types/common';
|
|
2
|
-
export declare const UPDATE_STEP_ITEMS_ON_VALIDATION = "@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION";
|
|
3
|
-
export declare const UPDATE_STEP_ITEMS_ON_NEXT = "@@step-items/UPDATE_STEP_ITEMS_ON_NEXT";
|
|
4
|
-
declare type UpdateStepItemsOnValidationClickPayload = {
|
|
5
|
-
stepNumber: number;
|
|
6
|
-
icon: IconValue;
|
|
7
|
-
};
|
|
8
|
-
declare type UpdateStepItemsOnNextClickPayload = {
|
|
9
|
-
stepNumber: number;
|
|
10
|
-
finishedSlides: FinishedSlides;
|
|
11
|
-
current: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare type UpdateStepItemsOnValidation = {
|
|
14
|
-
type: typeof UPDATE_STEP_ITEMS_ON_VALIDATION;
|
|
15
|
-
payload: UpdateStepItemsOnValidationClickPayload;
|
|
16
|
-
};
|
|
17
|
-
export declare type UpdateStepItemsOnNext = {
|
|
18
|
-
type: typeof UPDATE_STEP_ITEMS_ON_NEXT;
|
|
19
|
-
payload: UpdateStepItemsOnNextClickPayload;
|
|
20
|
-
};
|
|
21
|
-
export declare type StepItemsAction = UpdateStepItemsOnValidation | UpdateStepItemsOnNext;
|
|
22
|
-
export declare const updateStepItemsOnValidation: (payload: UpdateStepItemsOnValidationClickPayload) => UpdateStepItemsOnValidation;
|
|
23
|
-
export declare const updateStepItemsOnNext: (payload: UpdateStepItemsOnNextClickPayload) => UpdateStepItemsOnNext;
|
|
24
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export var UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
|
|
2
|
-
export var UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
export var updateStepItemsOnValidation = function (payload) { return ({
|
|
5
|
-
type: UPDATE_STEP_ITEMS_ON_VALIDATION,
|
|
6
|
-
payload: payload
|
|
7
|
-
}); };
|
|
8
|
-
export var updateStepItemsOnNext = function (payload) { return ({
|
|
9
|
-
type: UPDATE_STEP_ITEMS_ON_NEXT,
|
|
10
|
-
payload: payload
|
|
11
|
-
}); };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { UpdateFinishedSlides } from '../../actions/ui/finished-slides';
|
|
2
|
-
export declare type FinishedSlidesState = {
|
|
3
|
-
slideNumbers: number[];
|
|
4
|
-
[key: number]: true;
|
|
5
|
-
};
|
|
6
|
-
declare const reducer: (state: FinishedSlidesState | undefined, action: UpdateFinishedSlides) => FinishedSlidesState;
|
|
7
|
-
export default reducer;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import forEach from 'lodash/fp/forEach';
|
|
13
|
-
import { UPDATE_FINISHED_SLIDES } from '../../actions/ui/finished-slides';
|
|
14
|
-
import { slideNumbers } from '../../common';
|
|
15
|
-
var initialState = {
|
|
16
|
-
slideNumbers: slideNumbers
|
|
17
|
-
};
|
|
18
|
-
var _forEach = forEach.convert({
|
|
19
|
-
cap: false
|
|
20
|
-
});
|
|
21
|
-
// -----------------------------------------------------------------------------
|
|
22
|
-
var reducer = function (
|
|
23
|
-
// eslint-disable-next-line default-param-last
|
|
24
|
-
state, action) {
|
|
25
|
-
if (state === void 0) { state = initialState; }
|
|
26
|
-
switch (action.type) {
|
|
27
|
-
case UPDATE_FINISHED_SLIDES: {
|
|
28
|
-
var _slideNumbers = state.slideNumbers, rest = __rest(state, ["slideNumbers"]);
|
|
29
|
-
var _a = action.payload, slideNumber = _a.slideNumber, value = _a.value;
|
|
30
|
-
var _state_1 = {
|
|
31
|
-
slideNumbers: _slideNumbers
|
|
32
|
-
};
|
|
33
|
-
_forEach(function (finishedSlide, index) {
|
|
34
|
-
var previousValue = finishedSlide;
|
|
35
|
-
_state_1[index] = previousValue;
|
|
36
|
-
}, rest);
|
|
37
|
-
_state_1[slideNumber] = value;
|
|
38
|
-
return _state_1;
|
|
39
|
-
}
|
|
40
|
-
default:
|
|
41
|
-
return state;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
// -----------------------------------------------------------------------------
|
|
45
|
-
export default reducer;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { UpdateReviewStatus } from '../../actions/ui/review-status';
|
|
2
|
-
export declare type ReviewStatusState = 'finished' | 'ongoing';
|
|
3
|
-
declare const reducer: (state: ReviewStatusState | undefined, action: UpdateReviewStatus) => ReviewStatusState;
|
|
4
|
-
export default reducer;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IconValue } from '../../types/common';
|
|
2
|
-
import { StepItemsAction } from '../../actions/ui/step-items';
|
|
3
|
-
export declare type StepItem = {
|
|
4
|
-
current: boolean;
|
|
5
|
-
icon: IconValue;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type StepItemsState = {
|
|
9
|
-
slideNumbers: number[];
|
|
10
|
-
[key: number]: StepItem;
|
|
11
|
-
};
|
|
12
|
-
export declare const initialState: StepItemsState;
|
|
13
|
-
declare const reducer: (state: StepItemsState | undefined, action: StepItemsAction) => StepItemsState;
|
|
14
|
-
export default reducer;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import get from 'lodash/fp/get';
|
|
13
|
-
import has from 'lodash/fp/has';
|
|
14
|
-
import map from 'lodash/fp/map';
|
|
15
|
-
import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../../actions/ui/step-items';
|
|
16
|
-
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
|
|
17
|
-
var getInitialState = function () {
|
|
18
|
-
var state = {
|
|
19
|
-
slideNumbers: slideNumbers
|
|
20
|
-
};
|
|
21
|
-
// eslint-disable-next-line fp/no-loops
|
|
22
|
-
for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
23
|
-
var current = index === 0;
|
|
24
|
-
state[index] = { current: current, value: "".concat(index + 1), icon: 'no-answer' };
|
|
25
|
-
}
|
|
26
|
-
return state;
|
|
27
|
-
};
|
|
28
|
-
export var initialState = getInitialState();
|
|
29
|
-
// -----------------------------------------------------------------------------
|
|
30
|
-
// ||-------> aux function, finds the next consecutive index
|
|
31
|
-
// to loop from 0 to HIGHEST_INDEX (4) & again to 0
|
|
32
|
-
var getNextIndex = function (currentIndex) {
|
|
33
|
-
return currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
|
|
34
|
-
};
|
|
35
|
-
// ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
|
|
36
|
-
// they have to be skipped)
|
|
37
|
-
var calculateNextStepIndex = function (currentStepNumber, finishedSlides, lastVisitedIndex) {
|
|
38
|
-
if (lastVisitedIndex === void 0) { lastVisitedIndex = -1; }
|
|
39
|
-
// only one slide remaining, the step should stay on the same number
|
|
40
|
-
if (lastVisitedIndex === currentStepNumber) {
|
|
41
|
-
return currentStepNumber;
|
|
42
|
-
}
|
|
43
|
-
var indexToVisit = getNextIndex(lastVisitedIndex === -1 ? currentStepNumber : lastVisitedIndex);
|
|
44
|
-
// if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
|
|
45
|
-
return has(indexToVisit, finishedSlides)
|
|
46
|
-
? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
|
|
47
|
-
: indexToVisit;
|
|
48
|
-
};
|
|
49
|
-
var recalculateStepItemsState = function (state, stepNumber, stepItemToUpdateProps) {
|
|
50
|
-
var nextIndex = get('nextIndex', stepItemToUpdateProps);
|
|
51
|
-
var _state = {
|
|
52
|
-
slideNumbers: slideNumbers
|
|
53
|
-
};
|
|
54
|
-
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
55
|
-
map(function (index) {
|
|
56
|
-
var previousValue = state[index];
|
|
57
|
-
if (stepNumber === index)
|
|
58
|
-
_state[stepNumber] = __assign(__assign({}, previousValue), stepItemToUpdateProps);
|
|
59
|
-
/* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
|
|
60
|
-
_state[index] = __assign(__assign({}, previousValue), { current: true });
|
|
61
|
-
}
|
|
62
|
-
else
|
|
63
|
-
_state[index] = previousValue;
|
|
64
|
-
}, state.slideNumbers);
|
|
65
|
-
return _state;
|
|
66
|
-
};
|
|
67
|
-
// -----------------------------------------------------------------------------
|
|
68
|
-
// eslint-disable-next-line default-param-last
|
|
69
|
-
var reducer = function (state, action) {
|
|
70
|
-
if (state === void 0) { state = initialState; }
|
|
71
|
-
switch (action.type) {
|
|
72
|
-
case UPDATE_STEP_ITEMS_ON_VALIDATION: {
|
|
73
|
-
var _a = action.payload, stepNumber = _a.stepNumber, icon = _a.icon;
|
|
74
|
-
return recalculateStepItemsState(state, stepNumber, { icon: icon });
|
|
75
|
-
}
|
|
76
|
-
case UPDATE_STEP_ITEMS_ON_NEXT: {
|
|
77
|
-
var _b = action.payload, stepNumber = _b.stepNumber, finishedSlides = _b.finishedSlides, current = _b.current;
|
|
78
|
-
var nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : -1;
|
|
79
|
-
return recalculateStepItemsState(state, stepNumber, { current: current, nextIndex: nextIndex });
|
|
80
|
-
}
|
|
81
|
-
default:
|
|
82
|
-
return state;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
// -----------------------------------------------------------------------------
|
|
86
|
-
export default reducer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {UISlide} from '../../types/slides';
|
|
2
|
-
import {ReceivedSlide} from '../api/fetch-slide';
|
|
3
|
-
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
export const UPDATE_SLIDES_ON_VALIDATION = '@@slide/UPDATE_SLIDES_ON_VALIDATION';
|
|
7
|
-
export const UPDATE_SLIDES_ON_NEXT = '@@slide/UPDATE_SLIDES_ON_NEXT';
|
|
8
|
-
export const VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
9
|
-
|
|
10
|
-
// -----------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
type SlideUIAnimations = 'unstack' | 'restack';
|
|
13
|
-
|
|
14
|
-
export type Slide = UISlide & {
|
|
15
|
-
hidden?: boolean;
|
|
16
|
-
position: number;
|
|
17
|
-
animationType?: SlideUIAnimations;
|
|
18
|
-
isCorrect?: boolean;
|
|
19
|
-
endReview?: boolean;
|
|
20
|
-
nextContent?: Omit<Slide, 'endReview' | 'hidden' | 'position' | 'nextContent'>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// TODO: complete or modify typing as needed on Fetch Slide ticket
|
|
24
|
-
export type ValidationPayload = {
|
|
25
|
-
slideNumber: number;
|
|
26
|
-
newSlideContent: Slide;
|
|
27
|
-
numberOfFinishedSlides: number;
|
|
28
|
-
nextContent: Slide;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type OnNextPayload = Omit<ValidationPayload, 'nextContent'>;
|
|
32
|
-
|
|
33
|
-
// -----------------------------------------------------------------------------
|
|
34
|
-
|
|
35
|
-
export type UpdateSlidesOnValidation = {
|
|
36
|
-
type: typeof UPDATE_SLIDES_ON_VALIDATION;
|
|
37
|
-
payload: ValidationPayload;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type UpdateSlidesOnNext = {
|
|
41
|
-
type: typeof UPDATE_SLIDES_ON_NEXT;
|
|
42
|
-
payload: OnNextPayload;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type ValidateSlide = {
|
|
46
|
-
type: typeof VALIDATE_SLIDE;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type SlidesAction = ReceivedSlide | UpdateSlidesOnValidation | UpdateSlidesOnNext;
|
|
50
|
-
|
|
51
|
-
// -----------------------------------------------------------------------------
|
|
52
|
-
|
|
53
|
-
export const updateSlidesOnValidation = (payload: ValidationPayload): UpdateSlidesOnValidation => ({
|
|
54
|
-
type: UPDATE_SLIDES_ON_VALIDATION,
|
|
55
|
-
payload
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const updateSlidesOnNext = (payload: OnNextPayload): UpdateSlidesOnNext => ({
|
|
59
|
-
type: UPDATE_SLIDES_ON_NEXT,
|
|
60
|
-
payload
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export const validateSlide = (): ValidateSlide => ({
|
|
64
|
-
type: VALIDATE_SLIDE
|
|
65
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Stores only successful slides
|
|
2
|
-
|
|
3
|
-
export type FinishedSlide = {slideNumber: number; value: true};
|
|
4
|
-
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
export const UPDATE_FINISHED_SLIDES = '@@finished-slides/UPDATE_FINISHED_SLIDES';
|
|
8
|
-
|
|
9
|
-
// -----------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
export type UpdateFinishedSlides = {
|
|
12
|
-
type: typeof UPDATE_FINISHED_SLIDES;
|
|
13
|
-
payload: FinishedSlide;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// -----------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
export const updateFinishedSlides = (payload: FinishedSlide): UpdateFinishedSlides => ({
|
|
19
|
-
type: UPDATE_FINISHED_SLIDES,
|
|
20
|
-
payload
|
|
21
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
|
|
3
|
-
export const UPDATE_REVIEW_STATUS = '@@review-status/UPDATE_REVIEW_STATUS';
|
|
4
|
-
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
export type FinishedStatus = 'finished';
|
|
8
|
-
|
|
9
|
-
export type UpdateReviewStatus = {
|
|
10
|
-
type: typeof UPDATE_REVIEW_STATUS;
|
|
11
|
-
payload: FinishedStatus;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// -----------------------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
export const updateReviewStatus = (payload: FinishedStatus): UpdateReviewStatus => ({
|
|
17
|
-
type: UPDATE_REVIEW_STATUS,
|
|
18
|
-
payload
|
|
19
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {FinishedSlides, IconValue} from '../../types/common';
|
|
2
|
-
|
|
3
|
-
export const UPDATE_STEP_ITEMS_ON_VALIDATION = '@@step-items/UPDATE_STEP_ITEMS_ON_VALIDATION';
|
|
4
|
-
export const UPDATE_STEP_ITEMS_ON_NEXT = '@@step-items/UPDATE_STEP_ITEMS_ON_NEXT';
|
|
5
|
-
|
|
6
|
-
type UpdateStepItemsOnValidationClickPayload = {
|
|
7
|
-
stepNumber: number;
|
|
8
|
-
icon: IconValue;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type UpdateStepItemsOnNextClickPayload = {
|
|
12
|
-
stepNumber: number;
|
|
13
|
-
finishedSlides: FinishedSlides;
|
|
14
|
-
current: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// -----------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
export type UpdateStepItemsOnValidation = {
|
|
20
|
-
type: typeof UPDATE_STEP_ITEMS_ON_VALIDATION;
|
|
21
|
-
payload: UpdateStepItemsOnValidationClickPayload;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type UpdateStepItemsOnNext = {
|
|
25
|
-
type: typeof UPDATE_STEP_ITEMS_ON_NEXT;
|
|
26
|
-
payload: UpdateStepItemsOnNextClickPayload;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type StepItemsAction = UpdateStepItemsOnValidation | UpdateStepItemsOnNext;
|
|
30
|
-
|
|
31
|
-
// -----------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
export const updateStepItemsOnValidation = (
|
|
34
|
-
payload: UpdateStepItemsOnValidationClickPayload
|
|
35
|
-
): UpdateStepItemsOnValidation => ({
|
|
36
|
-
type: UPDATE_STEP_ITEMS_ON_VALIDATION,
|
|
37
|
-
payload
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const updateStepItemsOnNext = (
|
|
41
|
-
payload: UpdateStepItemsOnNextClickPayload
|
|
42
|
-
): UpdateStepItemsOnNext => ({
|
|
43
|
-
type: UPDATE_STEP_ITEMS_ON_NEXT,
|
|
44
|
-
payload
|
|
45
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import forEach from 'lodash/fp/forEach';
|
|
2
|
-
import {UpdateFinishedSlides, UPDATE_FINISHED_SLIDES} from '../../actions/ui/finished-slides';
|
|
3
|
-
import {slideNumbers} from '../../common';
|
|
4
|
-
|
|
5
|
-
export type FinishedSlidesState = {
|
|
6
|
-
slideNumbers: number[];
|
|
7
|
-
[key: number]: true;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const initialState: FinishedSlidesState = {
|
|
11
|
-
slideNumbers
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const _forEach: <T>(
|
|
15
|
-
iteratee: (value: T[keyof T], index: number) => void,
|
|
16
|
-
collection: T
|
|
17
|
-
// @ts-expect-error to remove lodash's forEach iteratee args number cap
|
|
18
|
-
) => void = forEach.convert({
|
|
19
|
-
cap: false
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// -----------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
const reducer = (
|
|
25
|
-
// eslint-disable-next-line default-param-last
|
|
26
|
-
state: FinishedSlidesState = initialState,
|
|
27
|
-
action: UpdateFinishedSlides
|
|
28
|
-
): FinishedSlidesState => {
|
|
29
|
-
switch (action.type) {
|
|
30
|
-
case UPDATE_FINISHED_SLIDES: {
|
|
31
|
-
const {slideNumbers: _slideNumbers, ...rest} = state;
|
|
32
|
-
const {slideNumber, value} = action.payload;
|
|
33
|
-
const _state: FinishedSlidesState = {
|
|
34
|
-
slideNumbers: _slideNumbers
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
_forEach<Omit<FinishedSlidesState, 'slideNumbers'>>((finishedSlide, index) => {
|
|
38
|
-
const previousValue = finishedSlide;
|
|
39
|
-
_state[index] = previousValue;
|
|
40
|
-
}, rest);
|
|
41
|
-
|
|
42
|
-
_state[slideNumber] = value;
|
|
43
|
-
return _state;
|
|
44
|
-
}
|
|
45
|
-
default:
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// -----------------------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
export default reducer;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {UpdateReviewStatus, UPDATE_REVIEW_STATUS} from '../../actions/ui/review-status';
|
|
2
|
-
|
|
3
|
-
export type ReviewStatusState = 'finished' | 'ongoing';
|
|
4
|
-
|
|
5
|
-
const reducer = (
|
|
6
|
-
// eslint-disable-next-line default-param-last
|
|
7
|
-
state: ReviewStatusState = 'ongoing',
|
|
8
|
-
action: UpdateReviewStatus
|
|
9
|
-
): ReviewStatusState => {
|
|
10
|
-
switch (action.type) {
|
|
11
|
-
case UPDATE_REVIEW_STATUS: {
|
|
12
|
-
return action.payload;
|
|
13
|
-
}
|
|
14
|
-
default:
|
|
15
|
-
return state;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default reducer;
|