@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import getOr from 'lodash/fp/getOr';
|
|
2
|
+
import noop from 'lodash/fp/noop';
|
|
3
|
+
import set from 'lodash/fp/set';
|
|
4
|
+
import { STORE_TOKEN } from '../actions/token';
|
|
5
|
+
import { IS_FETCHING_TRUE } from '../actions/data/is-fetching';
|
|
6
|
+
import { VALIDATE_SLIDE } from '../actions/data/validate-slide';
|
|
7
|
+
import { setToken } from './token';
|
|
8
|
+
const defaultState = {
|
|
9
|
+
isFetching: true,
|
|
10
|
+
slideValidationResult: null,
|
|
11
|
+
token: null
|
|
12
|
+
};
|
|
13
|
+
// eslint-disable-next-line default-param-last
|
|
14
|
+
const data = (state = defaultState, action) => {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case STORE_TOKEN: {
|
|
17
|
+
return setToken(action.payload, state);
|
|
18
|
+
}
|
|
19
|
+
case VALIDATE_SLIDE: {
|
|
20
|
+
const previousSlideNumber = getOr(-1, 'slideValidationResult.slideNumber', state);
|
|
21
|
+
// hard coded for now
|
|
22
|
+
return set('slideValidationResult', {
|
|
23
|
+
slideNumber: previousSlideNumber + 1,
|
|
24
|
+
result: 'success',
|
|
25
|
+
// exitNode
|
|
26
|
+
nextSlide: {
|
|
27
|
+
questionText: 'Test',
|
|
28
|
+
answerUI: {
|
|
29
|
+
model: {
|
|
30
|
+
answers: [
|
|
31
|
+
{
|
|
32
|
+
title: 'There is no need for a password',
|
|
33
|
+
onClick: noop,
|
|
34
|
+
selected: false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: 'Lorem ipsum',
|
|
38
|
+
onClick: noop,
|
|
39
|
+
selected: false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Lorem',
|
|
43
|
+
onClick: noop,
|
|
44
|
+
selected: true,
|
|
45
|
+
order: 1
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: 'You need to have a password',
|
|
49
|
+
onClick: noop,
|
|
50
|
+
selected: false
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: 'Pouet',
|
|
54
|
+
onClick: noop,
|
|
55
|
+
selected: true,
|
|
56
|
+
order: 0
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
type: 'qcmDrag'
|
|
60
|
+
},
|
|
61
|
+
help: 'Help text will appear here'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, state);
|
|
65
|
+
}
|
|
66
|
+
case IS_FETCHING_TRUE: {
|
|
67
|
+
return set('isFetching', true, state);
|
|
68
|
+
}
|
|
69
|
+
// case VALIDATE_SLIDE_FAILURE: {
|
|
70
|
+
// return set('entities.isFetching', false, state);
|
|
71
|
+
// }
|
|
72
|
+
default:
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export default data;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UpdateFinishedSlides } from '../actions/finished-slides';
|
|
2
|
+
import { FinishedSlides } from '../types/finished-slides';
|
|
3
|
+
export declare type State = FinishedSlides;
|
|
4
|
+
export declare const initialState: State;
|
|
5
|
+
declare const reducer: (state: State, action: UpdateFinishedSlides) => State;
|
|
6
|
+
export default reducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import forEach from 'lodash/fp/forEach';
|
|
2
|
+
import { UPDATE_FINISHED_SLIDES } from '../actions/finished-slides';
|
|
3
|
+
import { slideNumbers } from '../common';
|
|
4
|
+
const _forEach = forEach.convert({
|
|
5
|
+
cap: false
|
|
6
|
+
});
|
|
7
|
+
export const initialState = {
|
|
8
|
+
slideNumbers
|
|
9
|
+
};
|
|
10
|
+
// -----------------------------------------------------------------------------
|
|
11
|
+
// eslint-disable-next-line default-param-last
|
|
12
|
+
const reducer = (state = initialState, action) => {
|
|
13
|
+
switch (action.type) {
|
|
14
|
+
case UPDATE_FINISHED_SLIDES: {
|
|
15
|
+
const { slideNumbers: _slideNumbers, ...rest } = state;
|
|
16
|
+
const { slideNumber, value } = action.payload;
|
|
17
|
+
const _state = {
|
|
18
|
+
slideNumbers: _slideNumbers
|
|
19
|
+
};
|
|
20
|
+
_forEach((finishedSlide, index) => {
|
|
21
|
+
const previousValue = finishedSlide;
|
|
22
|
+
_state[index] = previousValue;
|
|
23
|
+
}, rest);
|
|
24
|
+
_state[slideNumber] = value;
|
|
25
|
+
return _state;
|
|
26
|
+
}
|
|
27
|
+
default:
|
|
28
|
+
return state;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// -----------------------------------------------------------------------------
|
|
32
|
+
export default reducer;
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
+
ui: import("redux").CombinedState<{
|
|
3
|
+
courses: import("./courses").State;
|
|
4
|
+
finishedSlides: import("../types/finished-slides").FinishedSlides;
|
|
5
|
+
navigation: import("../types/states").NavigationState;
|
|
6
|
+
reviewStatus: import("./review-status").State;
|
|
7
|
+
slides: import("../types/slides").Slides;
|
|
8
|
+
stepItems: import("../types/step-items").StepItems;
|
|
9
|
+
}>;
|
|
10
|
+
data: import("../types/data").DataState;
|
|
5
11
|
}>, import("redux").AnyAction>;
|
|
6
|
-
export default
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
12
|
+
export default _default;
|
package/es/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
|
+
const ui = combineReducers({
|
|
6
10
|
courses,
|
|
11
|
+
finishedSlides,
|
|
7
12
|
navigation,
|
|
8
|
-
|
|
13
|
+
reviewStatus,
|
|
14
|
+
slides,
|
|
15
|
+
stepItems
|
|
16
|
+
});
|
|
17
|
+
export default combineReducers({
|
|
18
|
+
ui,
|
|
19
|
+
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
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NAVIGATE_BACK, NAVIGATE_TO } from '../actions/navigation';
|
|
2
|
+
// -----------------------------------------------------------------------------
|
|
3
|
+
// export type State = Array<string>;
|
|
2
4
|
export const initialState = ['home'];
|
|
3
5
|
// -----------------------------------------------------------------------------
|
|
6
|
+
// eslint-disable-next-line default-param-last
|
|
4
7
|
const reducer = (state = initialState, action) => {
|
|
5
8
|
switch (action.type) {
|
|
6
9
|
case NAVIGATE_TO: {
|
|
@@ -16,6 +19,6 @@ const reducer = (state = initialState, action) => {
|
|
|
16
19
|
}
|
|
17
20
|
};
|
|
18
21
|
// -----------------------------------------------------------------------------
|
|
19
|
-
export const getCurrentViewName = appState => appState.navigation[appState.navigation.length - 1];
|
|
22
|
+
export const getCurrentViewName = (appState) => appState.ui.navigation[appState.ui.navigation.length - 1];
|
|
20
23
|
// -----------------------------------------------------------------------------
|
|
21
24
|
export default reducer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UPDATE_REVIEW_STATUS } from '../actions/review-status';
|
|
2
|
+
export const initialState = 'ongoing';
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
// eslint-disable-next-line default-param-last
|
|
5
|
+
const reducer = (state = initialState, action) => {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case UPDATE_REVIEW_STATUS: {
|
|
8
|
+
return action.payload;
|
|
9
|
+
}
|
|
10
|
+
default:
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
// -----------------------------------------------------------------------------
|
|
15
|
+
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,112 @@
|
|
|
1
|
+
import map from 'lodash/fp/map';
|
|
2
|
+
import { STORE_FIRST_SLIDE, UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../actions/slides';
|
|
3
|
+
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
|
|
4
|
+
const getInitialState = () => {
|
|
5
|
+
const state = {
|
|
6
|
+
slideNumbers
|
|
7
|
+
};
|
|
8
|
+
// eslint-disable-next-line fp/no-loops
|
|
9
|
+
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
10
|
+
state[index] = { hidden: false, position: index };
|
|
11
|
+
}
|
|
12
|
+
return state;
|
|
13
|
+
};
|
|
14
|
+
export const initialState = getInitialState();
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
const setFirstSlide = (state, slide) => {
|
|
17
|
+
const _state = {
|
|
18
|
+
slideNumbers
|
|
19
|
+
};
|
|
20
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
21
|
+
map(index => {
|
|
22
|
+
const previousValue = state[index];
|
|
23
|
+
// Only update the 1st one
|
|
24
|
+
const content = index === 0 ? { ...previousValue, ...slide } : { ...previousValue };
|
|
25
|
+
_state[index] = { ...content };
|
|
26
|
+
}, state.slideNumbers);
|
|
27
|
+
return _state;
|
|
28
|
+
};
|
|
29
|
+
// ||-------> Handles the updates of a given slide on validation,
|
|
30
|
+
// & then updates de remaining slides if this given change should impact their content
|
|
31
|
+
const stateUpdateOnValidation = (state, payload) => {
|
|
32
|
+
const { slideNumber, newSlideContent, numberOfFinishedSlides, nextSlide } = payload;
|
|
33
|
+
const _state = {
|
|
34
|
+
slideNumbers
|
|
35
|
+
};
|
|
36
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
37
|
+
map(index => {
|
|
38
|
+
const previousValue = state[index];
|
|
39
|
+
// the current slide
|
|
40
|
+
if (index === slideNumber) {
|
|
41
|
+
// only one slide remaining, presets the next value
|
|
42
|
+
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
43
|
+
_state[index] = {
|
|
44
|
+
...previousValue,
|
|
45
|
+
nextSlide,
|
|
46
|
+
position: newSlideContent.position,
|
|
47
|
+
validationResult: newSlideContent.validationResult
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
_state[slideNumber] = { ...previousValue, ...newSlideContent };
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// updates the rest of the slides here
|
|
55
|
+
const { hidden, position } = previousValue;
|
|
56
|
+
_state[index] = { ...nextSlide, endReview: newSlideContent.endReview, hidden, position };
|
|
57
|
+
}
|
|
58
|
+
}, state.slideNumbers);
|
|
59
|
+
return _state;
|
|
60
|
+
};
|
|
61
|
+
// ||-------> Handles the updates of a given slide on correction popin's next click,
|
|
62
|
+
// & then updates de remaining slides (updates position to trigger animations)
|
|
63
|
+
const stateUpdateOnNext = (state, payload) => {
|
|
64
|
+
const { slideNumber, newSlideContent, numberOfFinishedSlides } = payload;
|
|
65
|
+
const _state = {
|
|
66
|
+
slideNumbers
|
|
67
|
+
};
|
|
68
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
69
|
+
map(index => {
|
|
70
|
+
const previousValue = state[index];
|
|
71
|
+
// the current slide
|
|
72
|
+
if (index === slideNumber) {
|
|
73
|
+
// when there is only one slide remaining, updates the slide value
|
|
74
|
+
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextSlide) {
|
|
75
|
+
_state[index] = { ...previousValue.nextSlide, position: previousValue.position };
|
|
76
|
+
}
|
|
77
|
+
else
|
|
78
|
+
_state[slideNumber] = newSlideContent;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// updates the rest of the slides here
|
|
82
|
+
const { hidden, position, answerUI, questionText } = previousValue;
|
|
83
|
+
_state[index] = {
|
|
84
|
+
hidden,
|
|
85
|
+
position: position - 1,
|
|
86
|
+
answerUI,
|
|
87
|
+
questionText,
|
|
88
|
+
endReview: newSlideContent.endReview
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}, state.slideNumbers);
|
|
92
|
+
return _state;
|
|
93
|
+
};
|
|
94
|
+
// -----------------------------------------------------------------------------
|
|
95
|
+
// eslint-disable-next-line default-param-last
|
|
96
|
+
const reducer = (state = initialState, action) => {
|
|
97
|
+
switch (action.type) {
|
|
98
|
+
case STORE_FIRST_SLIDE: {
|
|
99
|
+
return setFirstSlide(state, action.payload);
|
|
100
|
+
}
|
|
101
|
+
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
102
|
+
return stateUpdateOnValidation(state, action.payload);
|
|
103
|
+
}
|
|
104
|
+
case UPDATE_SLIDES_ON_NEXT: {
|
|
105
|
+
return stateUpdateOnNext(state, action.payload);
|
|
106
|
+
}
|
|
107
|
+
default:
|
|
108
|
+
return state;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
// -----------------------------------------------------------------------------
|
|
112
|
+
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,75 @@
|
|
|
1
|
+
import isNil from 'lodash/fp/isNil';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import has from 'lodash/fp/has';
|
|
4
|
+
import map from 'lodash/fp/map';
|
|
5
|
+
import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../actions/step-items';
|
|
6
|
+
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../common';
|
|
7
|
+
const getInitialState = () => {
|
|
8
|
+
const state = {
|
|
9
|
+
slideNumbers
|
|
10
|
+
};
|
|
11
|
+
// eslint-disable-next-line fp/no-loops
|
|
12
|
+
for (let index = 0; index < TOTAL_SLIDES_STACK; index++) {
|
|
13
|
+
const current = index === 0;
|
|
14
|
+
state[index] = { current, value: `${index + 1}`, icon: null };
|
|
15
|
+
}
|
|
16
|
+
return state;
|
|
17
|
+
};
|
|
18
|
+
export const initialState = getInitialState();
|
|
19
|
+
// -----------------------------------------------------------------------------
|
|
20
|
+
// ||-------> aux function, finds the next consecutive index
|
|
21
|
+
// to loop from 0 to HIGHEST_INDEX (4) & again to 0
|
|
22
|
+
const getNextIndex = (currentIndex) => currentIndex === HIGHEST_INDEX ? 0 : currentIndex + 1;
|
|
23
|
+
// ||-------> calculates which should be the next step to visit (as there can be already answered slides &&
|
|
24
|
+
// they have to be skipped)
|
|
25
|
+
const calculateNextStepIndex = (currentStepNumber, finishedSlides, lastVisitedIndex = null) => {
|
|
26
|
+
// only one slide remaining, the step should stay on the same number
|
|
27
|
+
if (lastVisitedIndex === currentStepNumber) {
|
|
28
|
+
return currentStepNumber;
|
|
29
|
+
}
|
|
30
|
+
const indexToVisit = getNextIndex(isNil(lastVisitedIndex) ? currentStepNumber : lastVisitedIndex);
|
|
31
|
+
// if the index is already included in the correctly answered (finished) slides, then we proceed to check for the next one
|
|
32
|
+
return has(indexToVisit, finishedSlides)
|
|
33
|
+
? calculateNextStepIndex(currentStepNumber, finishedSlides, indexToVisit)
|
|
34
|
+
: indexToVisit;
|
|
35
|
+
};
|
|
36
|
+
const recalculateStepItemsState = (state, stepNumber, stepItemToUpdateProps) => {
|
|
37
|
+
const nextIndex = get('nextIndex', stepItemToUpdateProps);
|
|
38
|
+
const _state = {
|
|
39
|
+
slideNumbers
|
|
40
|
+
};
|
|
41
|
+
// eslint-disable-next-line lodash-fp/no-unused-result
|
|
42
|
+
map(index => {
|
|
43
|
+
const previousValue = state[index];
|
|
44
|
+
if (stepNumber === index)
|
|
45
|
+
_state[stepNumber] = {
|
|
46
|
+
...previousValue,
|
|
47
|
+
...stepItemToUpdateProps
|
|
48
|
+
};
|
|
49
|
+
/* only for UPDATE_STEP_ITEMS_ON_NEXT -> */ else if (nextIndex === index) {
|
|
50
|
+
_state[index] = { ...previousValue, current: true };
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
_state[index] = previousValue;
|
|
54
|
+
}, state.slideNumbers);
|
|
55
|
+
return _state;
|
|
56
|
+
};
|
|
57
|
+
// -----------------------------------------------------------------------------
|
|
58
|
+
// eslint-disable-next-line default-param-last
|
|
59
|
+
const reducer = (state = initialState, action) => {
|
|
60
|
+
switch (action.type) {
|
|
61
|
+
case UPDATE_STEP_ITEMS_ON_VALIDATION: {
|
|
62
|
+
const { stepNumber, icon } = action.payload;
|
|
63
|
+
return recalculateStepItemsState(state, stepNumber, { icon });
|
|
64
|
+
}
|
|
65
|
+
case UPDATE_STEP_ITEMS_ON_NEXT: {
|
|
66
|
+
const { stepNumber, finishedSlides, current } = action.payload;
|
|
67
|
+
const nextIndex = !current ? calculateNextStepIndex(stepNumber, finishedSlides) : null;
|
|
68
|
+
return recalculateStepItemsState(state, stepNumber, { current, nextIndex });
|
|
69
|
+
}
|
|
70
|
+
default:
|
|
71
|
+
return state;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
// -----------------------------------------------------------------------------
|
|
75
|
+
export default reducer;
|
package/es/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/es/reducers/token.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
// -----------------------------------------------------------------------------
|
|
2
3
|
export const initialState = null;
|
|
3
4
|
// -----------------------------------------------------------------------------
|
|
4
|
-
const
|
|
5
|
-
switch (action.type) {
|
|
6
|
-
case STORE_TOKEN: {
|
|
7
|
-
return action.payload;
|
|
8
|
-
}
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
5
|
+
export const setToken = (token, state) => set('token', token, state);
|
|
13
6
|
// -----------------------------------------------------------------------------
|
|
14
|
-
export const getToken = appState => appState.token;
|
|
7
|
+
export const getToken = (appState) => appState.data.token;
|
|
15
8
|
// -----------------------------------------------------------------------------
|
|
16
|
-
export default reducer;
|
|
@@ -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>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export class ResponseError extends Error {
|
|
2
|
-
constructor(
|
|
2
|
+
constructor(statusCode, statusText, body = '') {
|
|
3
3
|
super(`${statusText} ${body}`.trim());
|
|
4
4
|
this.name = 'ResponseError';
|
|
5
|
-
this.statusCode =
|
|
5
|
+
this.statusCode = statusCode;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export const toJSON = async (response) => {
|
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
export const toResponse = (
|
|
2
|
-
ok:
|
|
3
|
-
status,
|
|
1
|
+
export const toResponse = (statusCode, statusText, body) => Promise.resolve({
|
|
2
|
+
ok: statusCode < 400,
|
|
3
|
+
status: statusCode,
|
|
4
4
|
statusText,
|
|
5
5
|
json: () => Promise.resolve(body).then(JSON.parse),
|
|
6
6
|
text: () => Promise.resolve(body)
|
|
@@ -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 {};
|