@coorpacademy/app-review 0.0.21-alpha.4 → 0.1.1
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/courses.d.ts +2 -3
- package/es/actions/data/is-fetching.d.ts +5 -0
- package/es/actions/data/is-fetching.js +4 -0
- package/es/actions/data/validate-slide.d.ts +5 -0
- package/es/actions/data/validate-slide.js +6 -0
- package/es/actions/finished-slides.d.ts +7 -0
- package/es/actions/finished-slides.js +7 -0
- package/es/actions/index.d.ts +2 -5
- package/es/actions/index.js +1 -3
- package/es/actions/navigation.d.ts +5 -6
- package/es/actions/review-status.d.ts +7 -0
- package/es/actions/review-status.js +7 -0
- package/es/actions/slides.d.ts +20 -0
- package/es/actions/slides.js +17 -0
- package/es/actions/step-items.d.ts +14 -0
- package/es/actions/step-items.js +12 -0
- package/es/actions/token.d.ts +0 -1
- package/es/common/index.d.ts +8 -0
- package/es/common/index.js +8 -0
- package/es/configure-store.d.ts +3 -12
- package/es/configure-store.js +5 -7
- package/es/fixtures/qcm-slide.d.ts +2 -0
- package/es/fixtures/qcm-slide.js +29 -0
- package/es/fixtures/temp-fixture.d.ts +3 -0
- package/es/fixtures/temp-fixture.js +84 -0
- package/es/helpers/css-register.d.ts +1 -0
- package/es/helpers/css-register.js +2 -0
- package/es/index.d.ts +5 -12
- package/es/index.js +62 -14
- package/es/index.test.d.ts +1 -0
- package/es/index.test.js +52 -0
- package/es/middlewares/on-start-app.d.ts +1 -2
- package/es/middlewares/on-start-app.js +20 -9
- package/es/reducers/courses.d.ts +2 -3
- package/es/reducers/courses.js +2 -1
- package/es/reducers/data.d.ts +7 -0
- package/es/reducers/data.js +76 -0
- package/es/reducers/finished-slides.d.ts +6 -0
- package/es/reducers/finished-slides.js +32 -0
- package/es/reducers/index.d.ts +11 -6
- package/es/reducers/index.js +14 -4
- package/es/reducers/navigation.d.ts +4 -3
- package/es/reducers/navigation.js +4 -1
- package/es/reducers/review-status.d.ts +5 -0
- package/es/reducers/review-status.js +15 -0
- package/es/reducers/slides.d.ts +6 -0
- package/es/reducers/slides.js +112 -0
- package/es/reducers/step-items.d.ts +6 -0
- package/es/reducers/step-items.js +75 -0
- package/es/reducers/token.d.ts +5 -7
- package/es/reducers/token.js +4 -12
- package/es/services/fetch-demo.d.ts +0 -1
- package/es/services/fetch-demo.test.d.ts +0 -1
- package/es/services/fetch-responses.d.ts +6 -7
- package/es/services/fetch-responses.js +2 -2
- package/es/services/fetch.mocks.d.ts +3 -4
- package/es/services/fetch.mocks.js +3 -3
- package/es/types/common.d.ts +7 -0
- package/es/types/common.js +1 -0
- package/es/types/data/index.d.ts +14 -0
- package/es/types/data/index.js +1 -0
- package/es/types/dispatchers.d.ts +17 -0
- package/es/types/dispatchers.js +1 -0
- package/es/types/finished-slides.d.ts +9 -0
- package/es/types/finished-slides.js +1 -0
- package/es/types/review-status.d.ts +1 -0
- package/es/types/review-status.js +1 -0
- package/es/types/slides.d.ts +87 -0
- package/es/types/slides.js +1 -0
- package/es/types/states.d.ts +6 -0
- package/es/types/states.js +1 -0
- package/es/types/step-items.d.ts +26 -0
- package/es/types/step-items.js +5 -0
- package/es/types/store-state.d.ts +12 -0
- package/es/types/store-state.js +1 -0
- package/es/types/utils.d.ts +3 -0
- package/es/types/utils.js +1 -0
- package/es/types/views.d.ts +64 -0
- package/es/types/views.js +1 -0
- package/lib/actions/courses.d.ts +2 -3
- package/lib/actions/data/is-fetching.d.ts +5 -0
- package/lib/actions/data/is-fetching.js +4 -0
- package/lib/actions/data/validate-slide.d.ts +5 -0
- package/lib/actions/data/validate-slide.js +6 -0
- package/lib/actions/finished-slides.d.ts +7 -0
- package/lib/actions/finished-slides.js +7 -0
- package/lib/actions/index.d.ts +2 -5
- package/lib/actions/index.js +1 -3
- package/lib/actions/navigation.d.ts +5 -6
- package/lib/actions/review-status.d.ts +7 -0
- package/lib/actions/review-status.js +7 -0
- package/lib/actions/slides.d.ts +20 -0
- package/lib/actions/slides.js +17 -0
- package/lib/actions/step-items.d.ts +14 -0
- package/lib/actions/step-items.js +12 -0
- package/lib/actions/token.d.ts +0 -1
- package/lib/common/index.d.ts +8 -0
- package/lib/common/index.js +8 -0
- package/lib/configure-store.d.ts +3 -12
- package/lib/configure-store.js +10 -59
- package/lib/fixtures/qcm-slide.d.ts +2 -0
- package/lib/fixtures/qcm-slide.js +29 -0
- package/lib/fixtures/temp-fixture.d.ts +3 -0
- package/lib/fixtures/temp-fixture.js +84 -0
- package/lib/helpers/css-register.d.ts +1 -0
- package/lib/helpers/css-register.js +2 -0
- package/lib/index.d.ts +5 -12
- package/lib/index.js +71 -34
- package/lib/index.test.d.ts +1 -0
- package/lib/index.test.js +160 -0
- package/lib/middlewares/on-start-app.d.ts +1 -2
- package/lib/middlewares/on-start-app.js +29 -16
- package/lib/reducers/courses.d.ts +2 -3
- package/lib/reducers/courses.js +2 -1
- package/lib/reducers/data.d.ts +7 -0
- package/lib/reducers/data.js +77 -0
- package/lib/reducers/finished-slides.d.ts +6 -0
- package/lib/reducers/finished-slides.js +44 -0
- package/lib/reducers/index.d.ts +11 -6
- package/lib/reducers/index.js +14 -4
- package/lib/reducers/navigation.d.ts +4 -3
- package/lib/reducers/navigation.js +6 -1
- package/lib/reducers/review-status.d.ts +5 -0
- package/lib/reducers/review-status.js +16 -0
- package/lib/reducers/slides.d.ts +6 -0
- package/lib/reducers/slides.js +119 -0
- package/lib/reducers/step-items.d.ts +6 -0
- package/lib/reducers/step-items.js +87 -0
- package/lib/reducers/token.d.ts +5 -7
- package/lib/reducers/token.js +4 -13
- package/lib/services/fetch-demo.d.ts +0 -1
- package/lib/services/fetch-demo.js +25 -23
- package/lib/services/fetch-demo.test.d.ts +0 -1
- package/lib/services/fetch-responses.d.ts +6 -7
- package/lib/services/fetch-responses.js +2 -2
- package/lib/services/fetch.mocks.d.ts +3 -4
- package/lib/services/fetch.mocks.js +28 -16
- package/lib/types/common.d.ts +7 -0
- package/lib/types/common.js +1 -0
- package/lib/types/data/index.d.ts +14 -0
- package/lib/types/data/index.js +1 -0
- package/lib/types/dispatchers.d.ts +17 -0
- package/lib/types/dispatchers.js +1 -0
- package/lib/types/finished-slides.d.ts +9 -0
- package/lib/types/finished-slides.js +1 -0
- package/lib/types/review-status.d.ts +1 -0
- package/lib/types/review-status.js +1 -0
- package/lib/types/slides.d.ts +87 -0
- package/lib/types/slides.js +1 -0
- package/lib/types/states.d.ts +6 -0
- package/lib/types/states.js +1 -0
- package/lib/types/step-items.d.ts +26 -0
- package/lib/types/step-items.js +5 -0
- package/lib/types/store-state.d.ts +12 -0
- package/lib/types/store-state.js +1 -0
- package/lib/types/utils.d.ts +3 -0
- package/lib/types/utils.js +1 -0
- package/lib/types/views.d.ts +64 -0
- package/lib/types/views.js +1 -0
- package/package.json +21 -7
- package/src/actions/courses.ts +2 -2
- package/src/actions/data/is-fetching.ts +12 -0
- package/src/actions/data/validate-slide.ts +15 -0
- package/src/actions/finished-slides.ts +21 -0
- package/src/actions/index.ts +8 -5
- package/src/actions/navigation.ts +6 -5
- package/src/actions/review-status.ts +19 -0
- package/src/actions/slides.ts +45 -0
- package/src/actions/step-items.ts +39 -0
- package/src/common/index.ts +14 -0
- package/src/configure-store.ts +14 -22
- package/src/fixtures/qcm-slide.ts +31 -0
- package/src/fixtures/temp-fixture.ts +94 -0
- package/src/helpers/css-modules-require-hook.d.ts +4 -0
- package/src/helpers/css-register.ts +3 -0
- package/src/index.test.tsx +82 -0
- package/src/index.tsx +75 -22
- package/src/middlewares/on-start-app.ts +35 -20
- package/src/reducers/courses.ts +3 -2
- package/src/reducers/data.ts +88 -0
- package/src/reducers/finished-slides.ts +48 -0
- package/src/reducers/index.ts +14 -4
- package/src/reducers/navigation.ts +7 -3
- package/src/reducers/review-status.ts +23 -0
- package/src/reducers/slides.ts +136 -0
- package/src/reducers/step-items.ts +112 -0
- package/src/reducers/token.ts +6 -15
- package/src/services/fetch-demo.ts +17 -15
- package/src/services/fetch-responses.ts +7 -7
- package/src/services/fetch.mocks.ts +29 -14
- package/src/types/common.ts +8 -0
- package/src/types/data/index.ts +16 -0
- package/src/types/dispatchers.ts +18 -0
- package/src/types/finished-slides.ts +9 -0
- package/src/types/globals.d.ts +6 -0
- package/src/types/review-status.ts +1 -0
- package/src/types/slides.ts +107 -0
- package/src/types/states.ts +6 -0
- package/src/types/step-items.ts +31 -0
- package/src/types/store-state.ts +20 -0
- package/src/types/utils.ts +4 -0
- package/src/types/views.tsx +69 -0
- package/es/actions/courses.d.ts.map +0 -1
- package/es/actions/index.d.ts.map +0 -1
- package/es/actions/navigation.d.ts.map +0 -1
- package/es/actions/token.d.ts.map +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-home.d.ts +0 -10
- package/es/components/__tmp-backup-vues-mobile/revision-home.d.ts.map +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-home.js +0 -83
- package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts.map +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-home.stories.js +0 -14
- package/es/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts +0 -4
- package/es/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts.map +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-onboarding.js +0 -57
- package/es/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts +0 -19
- package/es/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts.map +0 -1
- package/es/components/__tmp-backup-vues-mobile/revision-quizzer.js +0 -120
- package/es/configure-store.d.ts.map +0 -1
- package/es/index.d.ts.map +0 -1
- package/es/middlewares/on-start-app.d.ts.map +0 -1
- package/es/reducers/courses.d.ts.map +0 -1
- package/es/reducers/index.d.ts.map +0 -1
- package/es/reducers/navigation.d.ts.map +0 -1
- package/es/reducers/token.d.ts.map +0 -1
- package/es/services/fetch-demo.d.ts.map +0 -1
- package/es/services/fetch-demo.test.d.ts.map +0 -1
- package/es/services/fetch-responses.d.ts.map +0 -1
- package/es/services/fetch.mocks.d.ts.map +0 -1
- package/lib/actions/courses.d.ts.map +0 -1
- package/lib/actions/index.d.ts.map +0 -1
- package/lib/actions/navigation.d.ts.map +0 -1
- package/lib/actions/token.d.ts.map +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-home.d.ts +0 -10
- package/lib/components/__tmp-backup-vues-mobile/revision-home.d.ts.map +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-home.js +0 -98
- package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.d.ts.map +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-home.stories.js +0 -14
- package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts +0 -4
- package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.d.ts.map +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-onboarding.js +0 -60
- package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts +0 -19
- package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.d.ts.map +0 -1
- package/lib/components/__tmp-backup-vues-mobile/revision-quizzer.js +0 -128
- package/lib/configure-store.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/middlewares/on-start-app.d.ts.map +0 -1
- package/lib/reducers/courses.d.ts.map +0 -1
- package/lib/reducers/index.d.ts.map +0 -1
- package/lib/reducers/navigation.d.ts.map +0 -1
- package/lib/reducers/token.d.ts.map +0 -1
- package/lib/services/fetch-demo.d.ts.map +0 -1
- package/lib/services/fetch-demo.test.d.ts.map +0 -1
- package/lib/services/fetch-responses.d.ts.map +0 -1
- package/lib/services/fetch.mocks.d.ts.map +0 -1
- package/src/components/__tmp-backup-vues-mobile/revision-home.stories.tsx +0 -16
- package/src/components/__tmp-backup-vues-mobile/revision-home.tsx +0 -125
- package/src/components/__tmp-backup-vues-mobile/revision-onboarding.tsx +0 -84
- package/src/components/__tmp-backup-vues-mobile/revision-quizzer.tsx +0 -176
package/lib/reducers/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
|
+
import data from './data';
|
|
2
3
|
import courses from './courses';
|
|
4
|
+
import finishedSlides from './finished-slides';
|
|
3
5
|
import navigation from './navigation';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
+
import reviewStatus from './review-status';
|
|
7
|
+
import slides from './slides';
|
|
8
|
+
import stepItems from './step-items';
|
|
9
|
+
var ui = combineReducers({
|
|
6
10
|
courses: courses,
|
|
11
|
+
finishedSlides: finishedSlides,
|
|
7
12
|
navigation: navigation,
|
|
8
|
-
|
|
13
|
+
reviewStatus: reviewStatus,
|
|
14
|
+
slides: slides,
|
|
15
|
+
stepItems: stepItems
|
|
16
|
+
});
|
|
17
|
+
export default combineReducers({
|
|
18
|
+
ui: ui,
|
|
19
|
+
data: data
|
|
9
20
|
});
|
|
10
|
-
export default rootReducer;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ViewPath } from '../actions/navigation';
|
|
1
2
|
import type { NavigateTo, NavigateBack } from '../actions/navigation';
|
|
2
|
-
|
|
3
|
+
import { StoreState } from '../types/store-state';
|
|
4
|
+
import { NavigationState as State } from '../types/states';
|
|
3
5
|
export declare const initialState: State;
|
|
4
6
|
declare const reducer: (state: State, action: NavigateTo | NavigateBack) => State;
|
|
5
|
-
export declare const getCurrentViewName: (appState:
|
|
7
|
+
export declare const getCurrentViewName: (appState: StoreState) => ViewPath;
|
|
6
8
|
export default reducer;
|
|
7
|
-
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -8,8 +8,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
10
|
import { NAVIGATE_BACK, NAVIGATE_TO } from '../actions/navigation';
|
|
11
|
+
// -----------------------------------------------------------------------------
|
|
12
|
+
// export type State = Array<string>;
|
|
11
13
|
export var initialState = ['home'];
|
|
12
14
|
// -----------------------------------------------------------------------------
|
|
15
|
+
// eslint-disable-next-line default-param-last
|
|
13
16
|
var reducer = function (state, action) {
|
|
14
17
|
if (state === void 0) { state = initialState; }
|
|
15
18
|
switch (action.type) {
|
|
@@ -26,6 +29,8 @@ var reducer = function (state, action) {
|
|
|
26
29
|
}
|
|
27
30
|
};
|
|
28
31
|
// -----------------------------------------------------------------------------
|
|
29
|
-
export var getCurrentViewName = function (appState) {
|
|
32
|
+
export var getCurrentViewName = function (appState) {
|
|
33
|
+
return appState.ui.navigation[appState.ui.navigation.length - 1];
|
|
34
|
+
};
|
|
30
35
|
// -----------------------------------------------------------------------------
|
|
31
36
|
export default reducer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UPDATE_REVIEW_STATUS } from '../actions/review-status';
|
|
2
|
+
export var initialState = 'ongoing';
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
// eslint-disable-next-line default-param-last
|
|
5
|
+
var reducer = function (state, action) {
|
|
6
|
+
if (state === void 0) { state = initialState; }
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case UPDATE_REVIEW_STATUS: {
|
|
9
|
+
return action.payload;
|
|
10
|
+
}
|
|
11
|
+
default:
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
export default reducer;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SlidesAction } from '../actions/slides';
|
|
2
|
+
import { Slides } from '../types/slides';
|
|
3
|
+
export declare type State = Slides;
|
|
4
|
+
export declare const initialState: State;
|
|
5
|
+
declare const reducer: (state: State, action: SlidesAction) => State;
|
|
6
|
+
export default reducer;
|
|
@@ -0,0 +1,119 @@
|
|
|
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 map from 'lodash/fp/map';
|
|
13
|
+
import { STORE_FIRST_SLIDE, UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../actions/slides';
|
|
14
|
+
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
|
|
15
|
+
var getInitialState = function () {
|
|
16
|
+
var state = {
|
|
17
|
+
slideNumbers: slideNumbers
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line fp/no-loops
|
|
20
|
+
for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
21
|
+
state[index] = { hidden: false, position: index };
|
|
22
|
+
}
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
export var initialState = getInitialState();
|
|
26
|
+
// -----------------------------------------------------------------------------
|
|
27
|
+
var setFirstSlide = function (state, slide) {
|
|
28
|
+
var _state = {
|
|
29
|
+
slideNumbers: slideNumbers
|
|
30
|
+
};
|
|
31
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
32
|
+
map(function (index) {
|
|
33
|
+
var previousValue = state[index];
|
|
34
|
+
// Only update the 1st one
|
|
35
|
+
var content = index === 0 ? __assign(__assign({}, previousValue), slide) : __assign({}, previousValue);
|
|
36
|
+
_state[index] = __assign({}, content);
|
|
37
|
+
}, state.slideNumbers);
|
|
38
|
+
return _state;
|
|
39
|
+
};
|
|
40
|
+
// ||-------> Handles the updates of a given slide on validation,
|
|
41
|
+
// & then updates de remaining slides if this given change should impact their content
|
|
42
|
+
var stateUpdateOnValidation = function (state, payload) {
|
|
43
|
+
var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides, nextSlide = payload.nextSlide;
|
|
44
|
+
var _state = {
|
|
45
|
+
slideNumbers: slideNumbers
|
|
46
|
+
};
|
|
47
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
48
|
+
map(function (index) {
|
|
49
|
+
var previousValue = state[index];
|
|
50
|
+
// the current slide
|
|
51
|
+
if (index === slideNumber) {
|
|
52
|
+
// only one slide remaining, presets the next value
|
|
53
|
+
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
54
|
+
_state[index] = __assign(__assign({}, previousValue), { nextSlide: nextSlide, position: newSlideContent.position, validationResult: newSlideContent.validationResult });
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
_state[slideNumber] = __assign(__assign({}, previousValue), newSlideContent);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// updates the rest of the slides here
|
|
61
|
+
var hidden = previousValue.hidden, position = previousValue.position;
|
|
62
|
+
_state[index] = __assign(__assign({}, nextSlide), { endReview: newSlideContent.endReview, hidden: hidden, position: position });
|
|
63
|
+
}
|
|
64
|
+
}, state.slideNumbers);
|
|
65
|
+
return _state;
|
|
66
|
+
};
|
|
67
|
+
// ||-------> Handles the updates of a given slide on correction popin's next click,
|
|
68
|
+
// & then updates de remaining slides (updates position to trigger animations)
|
|
69
|
+
var stateUpdateOnNext = function (state, payload) {
|
|
70
|
+
var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides;
|
|
71
|
+
var _state = {
|
|
72
|
+
slideNumbers: slideNumbers
|
|
73
|
+
};
|
|
74
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
75
|
+
map(function (index) {
|
|
76
|
+
var previousValue = state[index];
|
|
77
|
+
// the current slide
|
|
78
|
+
if (index === slideNumber) {
|
|
79
|
+
// when there is only one slide remaining, updates the slide value
|
|
80
|
+
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextSlide) {
|
|
81
|
+
_state[index] = __assign(__assign({}, previousValue.nextSlide), { position: previousValue.position });
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
_state[slideNumber] = newSlideContent;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// updates the rest of the slides here
|
|
88
|
+
var hidden = previousValue.hidden, position = previousValue.position, answerUI = previousValue.answerUI, questionText = previousValue.questionText;
|
|
89
|
+
_state[index] = {
|
|
90
|
+
hidden: hidden,
|
|
91
|
+
position: position - 1,
|
|
92
|
+
answerUI: answerUI,
|
|
93
|
+
questionText: questionText,
|
|
94
|
+
endReview: newSlideContent.endReview
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}, state.slideNumbers);
|
|
98
|
+
return _state;
|
|
99
|
+
};
|
|
100
|
+
// -----------------------------------------------------------------------------
|
|
101
|
+
// eslint-disable-next-line default-param-last
|
|
102
|
+
var reducer = function (state, action) {
|
|
103
|
+
if (state === void 0) { state = initialState; }
|
|
104
|
+
switch (action.type) {
|
|
105
|
+
case STORE_FIRST_SLIDE: {
|
|
106
|
+
return setFirstSlide(state, action.payload);
|
|
107
|
+
}
|
|
108
|
+
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
109
|
+
return stateUpdateOnValidation(state, action.payload);
|
|
110
|
+
}
|
|
111
|
+
case UPDATE_SLIDES_ON_NEXT: {
|
|
112
|
+
return stateUpdateOnNext(state, action.payload);
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
return state;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
// -----------------------------------------------------------------------------
|
|
119
|
+
export default reducer;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepItemsAction } from '../actions/step-items';
|
|
2
|
+
import { StepItems } from '../types/step-items';
|
|
3
|
+
export declare type State = StepItems;
|
|
4
|
+
export declare const initialState: State;
|
|
5
|
+
declare const reducer: (state: State, action: StepItemsAction) => State;
|
|
6
|
+
export default reducer;
|
|
@@ -0,0 +1,87 @@
|
|
|
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 isNil from 'lodash/fp/isNil';
|
|
13
|
+
import get from 'lodash/fp/get';
|
|
14
|
+
import has from 'lodash/fp/has';
|
|
15
|
+
import map from 'lodash/fp/map';
|
|
16
|
+
import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../actions/step-items';
|
|
17
|
+
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
|
|
18
|
+
var getInitialState = function () {
|
|
19
|
+
var state = {
|
|
20
|
+
slideNumbers: slideNumbers
|
|
21
|
+
};
|
|
22
|
+
// eslint-disable-next-line fp/no-loops
|
|
23
|
+
for (var index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
24
|
+
var current = index === 0;
|
|
25
|
+
state[index] = { current: current, value: "".concat(index + 1), icon: null };
|
|
26
|
+
}
|
|
27
|
+
return state;
|
|
28
|
+
};
|
|
29
|
+
export var initialState = getInitialState();
|
|
30
|
+
// -----------------------------------------------------------------------------
|
|
31
|
+
// ||-------> aux function, finds the next consecutive index
|
|
32
|
+
// to loop from 0 to HIGHEST_INDEX (4) & again to 0
|
|
33
|
+
var getNextIndex = function (currentIndex) {
|
|
34
|
+
return currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
|
|
35
|
+
};
|
|
36
|
+
// ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
|
|
37
|
+
// they have to be skipped)
|
|
38
|
+
var calculateNextStepIndex = function (currentStepNumber, finishedSlides, lastVisitedIndex) {
|
|
39
|
+
if (lastVisitedIndex === void 0) { lastVisitedIndex = null; }
|
|
40
|
+
// only one slide remaining, the step should stay on the same number
|
|
41
|
+
if (lastVisitedIndex === currentStepNumber) {
|
|
42
|
+
return currentStepNumber;
|
|
43
|
+
}
|
|
44
|
+
var indexToVisit = getNextIndex(isNil(lastVisitedIndex) ? currentStepNumber : lastVisitedIndex);
|
|
45
|
+
// if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
|
|
46
|
+
return has(indexToVisit, finishedSlides)
|
|
47
|
+
? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
|
|
48
|
+
: indexToVisit;
|
|
49
|
+
};
|
|
50
|
+
var recalculateStepItemsState = function (state, stepNumber, stepItemToUpdateProps) {
|
|
51
|
+
var nextIndex = get('nextIndex', stepItemToUpdateProps);
|
|
52
|
+
var _state = {
|
|
53
|
+
slideNumbers: slideNumbers
|
|
54
|
+
};
|
|
55
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
56
|
+
map(function (index) {
|
|
57
|
+
var previousValue = state[index];
|
|
58
|
+
if (stepNumber === index)
|
|
59
|
+
_state[stepNumber] = __assign(__assign({}, previousValue), stepItemToUpdateProps);
|
|
60
|
+
/* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
|
|
61
|
+
_state[index] = __assign(__assign({}, previousValue), { current: true });
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
_state[index] = previousValue;
|
|
65
|
+
}, state.slideNumbers);
|
|
66
|
+
return _state;
|
|
67
|
+
};
|
|
68
|
+
// -----------------------------------------------------------------------------
|
|
69
|
+
// eslint-disable-next-line default-param-last
|
|
70
|
+
var reducer = function (state, action) {
|
|
71
|
+
if (state === void 0) { state = initialState; }
|
|
72
|
+
switch (action.type) {
|
|
73
|
+
case UPDATE_STEP_ITEMS_ON_VALIDATION: {
|
|
74
|
+
var _a = action.payload, stepNumber = _a.stepNumber, icon = _a.icon;
|
|
75
|
+
return recalculateStepItemsState(state, stepNumber, { icon: icon });
|
|
76
|
+
}
|
|
77
|
+
case UPDATE_STEP_ITEMS_ON_NEXT: {
|
|
78
|
+
var _b = action.payload, stepNumber = _b.stepNumber, finishedSlides = _b.finishedSlides, current = _b.current;
|
|
79
|
+
var nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : null;
|
|
80
|
+
return recalculateStepItemsState(state, stepNumber, { current: current, nextIndex: nextIndex });
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
// -----------------------------------------------------------------------------
|
|
87
|
+
export default reducer;
|
package/lib/reducers/token.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const initialState:
|
|
4
|
-
declare const
|
|
5
|
-
export declare const getToken: (appState:
|
|
6
|
-
export default reducer;
|
|
7
|
-
//# sourceMappingURL=token.d.ts.map
|
|
1
|
+
import { StoreState } from '../types/store-state';
|
|
2
|
+
import { DataState } from '../types/data';
|
|
3
|
+
export declare const initialState: DataState['token'];
|
|
4
|
+
export declare const setToken: (token: string, state: DataState) => DataState;
|
|
5
|
+
export declare const getToken: (appState: StoreState) => StoreState['data']['token'];
|
package/lib/reducers/token.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
// -----------------------------------------------------------------------------
|
|
2
3
|
export var initialState = null;
|
|
3
4
|
// -----------------------------------------------------------------------------
|
|
4
|
-
var
|
|
5
|
-
if (state === void 0) { state = initialState; }
|
|
6
|
-
switch (action.type) {
|
|
7
|
-
case STORE_TOKEN: {
|
|
8
|
-
return action.payload;
|
|
9
|
-
}
|
|
10
|
-
default:
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
5
|
+
export var setToken = function (token, state) { return set('token', token, state); };
|
|
14
6
|
// -----------------------------------------------------------------------------
|
|
15
|
-
export var getToken = function (appState) { return appState.token; };
|
|
7
|
+
export var getToken = function (appState) { return appState.data.token; };
|
|
16
8
|
// -----------------------------------------------------------------------------
|
|
17
|
-
export default reducer;
|
|
@@ -46,29 +46,31 @@ var buildUrlQueryParams = function (params) {
|
|
|
46
46
|
.join('&');
|
|
47
47
|
};
|
|
48
48
|
// -----------------------------------------------------------------------------
|
|
49
|
-
var fetchCourse = function (fetch) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
49
|
+
var fetchCourse = function (fetch) {
|
|
50
|
+
return function (token, language, universalRef) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var jwt, query, response, hits;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
jwt = decode(token);
|
|
56
|
+
query = {
|
|
57
|
+
type: 'course',
|
|
58
|
+
universalRef: universalRef,
|
|
59
|
+
lang: language
|
|
60
|
+
};
|
|
61
|
+
return [4 /*yield*/, fetch("".concat(jwt.host, "/api/v2/contents?").concat(buildUrlQueryParams(query)), {
|
|
62
|
+
headers: { authorization: token }
|
|
63
|
+
})];
|
|
64
|
+
case 1:
|
|
65
|
+
response = _a.sent();
|
|
66
|
+
return [4 /*yield*/, toJSON(response)];
|
|
67
|
+
case 2:
|
|
68
|
+
hits = (_a.sent()).hits;
|
|
69
|
+
return [2 /*return*/, hits === null || hits === void 0 ? void 0 : hits[0]];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}); };
|
|
73
|
+
};
|
|
72
74
|
// -----------------------------------------------------------------------------
|
|
73
75
|
export { fetchCourse };
|
|
74
76
|
export default fetchCourse(crossFetch);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type
|
|
1
|
+
export declare type _Response = {
|
|
2
2
|
ok: boolean;
|
|
3
3
|
status: number;
|
|
4
4
|
statusText: string;
|
|
@@ -9,12 +9,11 @@ export declare type Fetch = (url?: string, options?: {
|
|
|
9
9
|
headers: {
|
|
10
10
|
authorization: string;
|
|
11
11
|
};
|
|
12
|
-
}) => Promise<
|
|
12
|
+
}) => Promise<_Response>;
|
|
13
13
|
export declare class ResponseError extends Error {
|
|
14
14
|
statusCode: number;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(statusCode: number, statusText: string, body?: string);
|
|
16
16
|
}
|
|
17
|
-
export declare const toJSON: (response:
|
|
18
|
-
export declare const toText: (response:
|
|
19
|
-
export declare const toVoid: (response:
|
|
20
|
-
//# sourceMappingURL=fetch-responses.d.ts.map
|
|
17
|
+
export declare const toJSON: (response: _Response) => Promise<unknown>;
|
|
18
|
+
export declare const toText: (response: _Response) => Promise<string>;
|
|
19
|
+
export declare const toVoid: (response: _Response) => Promise<void>;
|
|
@@ -51,11 +51,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
51
51
|
};
|
|
52
52
|
var ResponseError = /** @class */ (function (_super) {
|
|
53
53
|
__extends(ResponseError, _super);
|
|
54
|
-
function ResponseError(
|
|
54
|
+
function ResponseError(statusCode, statusText, body) {
|
|
55
55
|
if (body === void 0) { body = ''; }
|
|
56
56
|
var _this = _super.call(this, "".concat(statusText, " ").concat(body).trim()) || this;
|
|
57
57
|
_this.name = 'ResponseError';
|
|
58
|
-
_this.statusCode =
|
|
58
|
+
_this.statusCode = statusCode;
|
|
59
59
|
return _this;
|
|
60
60
|
}
|
|
61
61
|
return ResponseError;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const toResponse: (
|
|
3
|
-
declare type FetchFunction = () => Promise<
|
|
1
|
+
import { _Response } from './fetch-responses';
|
|
2
|
+
export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<_Response>;
|
|
3
|
+
declare type FetchFunction = () => Promise<_Response>;
|
|
4
4
|
export declare const okJSONResponse: (body: unknown) => FetchFunction;
|
|
5
5
|
export declare const internalServerErrorJSONResponse: (body: unknown) => FetchFunction;
|
|
6
6
|
export declare const notFoundJSONResponse: (body: unknown) => FetchFunction;
|
|
7
7
|
export declare const okTextResponse: (body: string) => FetchFunction;
|
|
8
8
|
export declare const internalServerErrorTextResponse: (body: string) => FetchFunction;
|
|
9
9
|
export {};
|
|
10
|
-
//# sourceMappingURL=fetch.mocks.d.ts.map
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
export var toResponse = function (
|
|
1
|
+
export var toResponse = function (statusCode, statusText, body) {
|
|
2
2
|
return Promise.resolve({
|
|
3
|
-
ok:
|
|
4
|
-
status:
|
|
3
|
+
ok: statusCode < 400,
|
|
4
|
+
status: statusCode,
|
|
5
5
|
statusText: statusText,
|
|
6
6
|
json: function () { return Promise.resolve(body).then(JSON.parse); },
|
|
7
7
|
text: function () { return Promise.resolve(body); }
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
export var okJSONResponse = function (body) {
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export var
|
|
21
|
-
return
|
|
22
|
-
|
|
10
|
+
export var okJSONResponse = function (body) {
|
|
11
|
+
return function () {
|
|
12
|
+
return toResponse(200, 'OK', JSON.stringify(body));
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export var internalServerErrorJSONResponse = function (body) {
|
|
16
|
+
return function () {
|
|
17
|
+
return toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var notFoundJSONResponse = function (body) {
|
|
21
|
+
return function () {
|
|
22
|
+
return toResponse(404, 'Not Found', JSON.stringify(body));
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export var okTextResponse = function (body) {
|
|
26
|
+
return function () {
|
|
27
|
+
return toResponse(200, 'OK', body);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export var internalServerErrorTextResponse = function (body) {
|
|
31
|
+
return function () {
|
|
32
|
+
return toResponse(500, 'InternalServerError', body);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnswerUI } from '../slides';
|
|
2
|
+
export declare type DataState = {
|
|
3
|
+
isFetching?: boolean;
|
|
4
|
+
slideValidationResult?: {
|
|
5
|
+
slideNumber: number;
|
|
6
|
+
result: 'success' | 'failure';
|
|
7
|
+
exitNode?: 'successExitNode' | 'failExitNode';
|
|
8
|
+
nextSlide: {
|
|
9
|
+
questionText?: string;
|
|
10
|
+
answerUI?: AnswerUI;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
token?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { validateSlide } from '../actions/data/validate-slide';
|
|
2
|
+
import { updateFinishedSlides } from '../actions/finished-slides';
|
|
3
|
+
import { navigateBack, navigateTo } from '../actions/navigation';
|
|
4
|
+
import { updateReviewStatus } from '../actions/review-status';
|
|
5
|
+
import { updateSlidesOnValidation, updateSlidesOnNext } from '../actions/slides';
|
|
6
|
+
import { updateStepItemsOnValidation, updateStepItemsOnNext } from '../actions/step-items';
|
|
7
|
+
export declare type Dispatchers = {
|
|
8
|
+
navigateTo: typeof navigateTo;
|
|
9
|
+
navigateBack: typeof navigateBack;
|
|
10
|
+
validateSlide: typeof validateSlide;
|
|
11
|
+
updateSlidesOnValidation: typeof updateSlidesOnValidation;
|
|
12
|
+
updateSlidesOnNext: typeof updateSlidesOnNext;
|
|
13
|
+
updateReviewStatus: typeof updateReviewStatus;
|
|
14
|
+
updateStepItemsOnValidation: typeof updateStepItemsOnValidation;
|
|
15
|
+
updateStepItemsOnNext: typeof updateStepItemsOnNext;
|
|
16
|
+
updateFinishedSlides: typeof updateFinishedSlides;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type UpdateReviewStatusPayload = 'finished';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|