@coorpacademy/app-review 0.1.5 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-skills.d.ts +10 -0
- package/es/actions/api/fetch-skills.js +8 -0
- package/es/actions/api/fetch-slide.d.ts +10 -0
- package/es/actions/api/fetch-slide.js +8 -0
- package/es/actions/api/post-progression.d.ts +10 -0
- package/es/actions/api/post-progression.js +15 -0
- package/es/actions/data/slides.d.ts +7 -24
- package/es/actions/data/slides.js +0 -6
- package/es/actions/data/token.d.ts +2 -2
- package/es/actions/data/token.js +1 -1
- package/es/actions/index.d.ts +5 -3
- package/es/actions/ui/navigation.d.ts +0 -1
- package/es/actions/ui/navigation.js +0 -4
- package/es/actions/ui/step-items.d.ts +2 -8
- package/es/actions/ui/step-items.js +0 -6
- package/es/configure-store.d.ts +3 -34
- package/es/configure-store.js +4 -4
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +78 -42
- package/es/reducers/data/index.d.ts +16 -5
- package/es/reducers/data/progression.d.ts +14 -9
- package/es/reducers/data/progression.js +18 -58
- package/es/reducers/data/skills.d.ts +4 -5
- package/es/reducers/data/skills.js +3 -6
- package/es/reducers/data/slides.d.ts +2 -1
- package/es/reducers/data/slides.js +14 -9
- package/es/reducers/data/token.d.ts +0 -1
- package/es/reducers/data/token.js +1 -5
- package/es/reducers/index.d.ts +9 -3
- package/es/reducers/ui/finished-slides.d.ts +0 -1
- package/es/reducers/ui/finished-slides.js +1 -3
- package/es/reducers/ui/index.d.ts +14 -4
- package/es/reducers/ui/navigation.d.ts +0 -1
- package/es/reducers/ui/navigation.js +1 -3
- package/es/reducers/ui/review-status.d.ts +0 -1
- package/es/reducers/ui/review-status.js +1 -4
- package/es/reducers/ui/step-items.d.ts +5 -5
- package/es/reducers/ui/step-items.js +0 -1
- package/es/services/fetch-skills.d.ts +2 -8
- package/es/services/fetch-skills.js +3 -16
- package/es/services/fetch-slide.d.ts +2 -0
- package/es/services/fetch-slide.js +11 -0
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +8 -0
- package/es/services/post-progression.d.ts +2 -0
- package/es/services/post-progression.js +21 -0
- package/es/services/test/fetch-skills.test.js +29 -0
- package/es/services/test/post-progression.test.js +35 -0
- package/es/services/tools/fetch-responses.d.ts +1 -1
- package/es/services/tools/sleep.d.ts +1 -0
- package/es/services/tools/sleep.js +3 -0
- package/es/{index.test.js → test/index.test.js} +18 -7
- package/es/test/util/services.mock.d.ts +2 -0
- package/es/test/util/services.mock.js +68 -0
- package/es/types/common.d.ts +66 -2
- package/es/types/common.js +5 -0
- package/es/types/slides.d.ts +1 -1
- package/es/types/ui-progression.d.ts +10 -0
- package/es/types/views/slides.d.ts +1 -1
- package/lib/actions/api/fetch-skills.d.ts +10 -0
- package/lib/actions/api/fetch-skills.js +13 -0
- package/lib/actions/api/fetch-slide.d.ts +10 -0
- package/lib/actions/api/fetch-slide.js +13 -0
- package/lib/actions/api/post-progression.d.ts +10 -0
- package/lib/actions/api/post-progression.js +18 -0
- package/lib/actions/data/slides.d.ts +7 -24
- package/lib/actions/data/slides.js +0 -6
- package/lib/actions/data/token.d.ts +2 -2
- package/lib/actions/data/token.js +1 -1
- package/lib/actions/index.d.ts +5 -3
- package/lib/actions/ui/navigation.d.ts +0 -1
- package/lib/actions/ui/navigation.js +0 -4
- package/lib/actions/ui/step-items.d.ts +2 -8
- package/lib/actions/ui/step-items.js +0 -6
- package/lib/configure-store.d.ts +3 -34
- package/lib/configure-store.js +4 -4
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +78 -86
- package/lib/reducers/data/index.d.ts +16 -5
- package/lib/reducers/data/progression.d.ts +14 -9
- package/lib/reducers/data/progression.js +18 -58
- package/lib/reducers/data/skills.d.ts +4 -5
- package/lib/reducers/data/skills.js +3 -6
- package/lib/reducers/data/slides.d.ts +2 -1
- package/lib/reducers/data/slides.js +14 -9
- package/lib/reducers/data/token.d.ts +0 -1
- package/lib/reducers/data/token.js +1 -5
- package/lib/reducers/index.d.ts +9 -3
- package/lib/reducers/ui/finished-slides.d.ts +0 -1
- package/lib/reducers/ui/finished-slides.js +1 -3
- package/lib/reducers/ui/index.d.ts +14 -4
- package/lib/reducers/ui/navigation.d.ts +0 -1
- package/lib/reducers/ui/navigation.js +1 -3
- package/lib/reducers/ui/review-status.d.ts +0 -1
- package/lib/reducers/ui/review-status.js +1 -4
- package/lib/reducers/ui/step-items.d.ts +5 -5
- package/lib/reducers/ui/step-items.js +0 -1
- package/lib/services/fetch-skills.d.ts +2 -8
- package/lib/services/fetch-skills.js +5 -20
- package/lib/services/fetch-slide.d.ts +2 -0
- package/lib/services/fetch-slide.js +57 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +8 -0
- package/lib/services/post-progression.d.ts +2 -0
- package/lib/services/post-progression.js +65 -0
- package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
- package/lib/services/test/post-progression.test.js +89 -0
- package/lib/services/tools/fetch-responses.d.ts +1 -1
- package/lib/services/tools/sleep.d.ts +1 -0
- package/lib/services/tools/sleep.js +5 -0
- package/lib/test/index.test.d.ts +1 -0
- package/lib/{index.test.js → test/index.test.js} +23 -15
- package/lib/test/util/services.mock.d.ts +2 -0
- package/lib/test/util/services.mock.js +68 -0
- package/lib/types/common.d.ts +66 -2
- package/lib/types/common.js +5 -0
- package/lib/types/slides.d.ts +1 -1
- package/lib/types/ui-progression.d.ts +10 -0
- package/lib/types/ui-progression.js +1 -0
- package/lib/types/views/slides.d.ts +1 -1
- package/package.json +6 -5
- package/readme.md +4 -5
- package/src/actions/api/fetch-skills.ts +20 -0
- package/src/actions/api/fetch-slide.ts +20 -0
- package/src/actions/api/post-progression.ts +26 -0
- package/src/actions/data/slides.ts +8 -32
- package/src/actions/data/token.ts +2 -2
- package/src/actions/index.ts +7 -10
- package/src/actions/ui/navigation.ts +0 -5
- package/src/actions/ui/step-items.ts +2 -14
- package/src/configure-store.ts +6 -45
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/index.tsx +94 -45
- package/src/reducers/data/index.ts +12 -4
- package/src/reducers/data/progression.ts +34 -79
- package/src/reducers/data/skills.ts +5 -10
- package/src/reducers/data/slides.ts +16 -15
- package/src/reducers/data/token.ts +1 -11
- package/src/reducers/index.ts +7 -2
- package/src/reducers/ui/finished-slides.ts +1 -7
- package/src/reducers/ui/index.ts +11 -4
- package/src/reducers/ui/navigation.ts +1 -6
- package/src/reducers/ui/review-status.ts +1 -8
- package/src/reducers/ui/step-items.ts +5 -14
- package/src/services/fetch-skills.ts +4 -30
- package/src/services/fetch-slide.ts +15 -0
- package/src/services/index.ts +10 -0
- package/src/services/post-progression.ts +28 -0
- package/src/services/test/fetch-skills.test.ts +39 -0
- package/src/services/test/post-progression.test.ts +45 -0
- package/src/services/tools/fetch-responses.ts +1 -1
- package/src/services/tools/sleep.ts +4 -0
- package/src/{index.test.tsx → test/index.test.tsx} +16 -10
- package/src/test/util/services.mock.ts +70 -0
- package/src/types/common.ts +78 -2
- package/src/types/globals.d.ts +2 -0
- package/src/types/slides.ts +1 -1
- package/src/types/ui-progression.ts +25 -0
- package/src/types/views/slides.ts +1 -1
- package/es/actions/data/skills.d.ts +0 -13
- package/es/actions/data/skills.js +0 -10
- package/es/middlewares/on-start-app.d.ts +0 -5
- package/es/middlewares/on-start-app.js +0 -29
- package/es/services/fetch-skills.mock.d.ts +0 -3
- package/es/services/fetch-skills.mock.js +0 -17
- package/es/services/fetch-skills.test.js +0 -22
- package/es/services/tools/fetch.mocks.d.ts +0 -8
- package/es/services/tools/fetch.mocks.js +0 -13
- package/es/types/skills.d.ts +0 -7
- package/lib/actions/data/skills.d.ts +0 -13
- package/lib/actions/data/skills.js +0 -10
- package/lib/middlewares/on-start-app.d.ts +0 -5
- package/lib/middlewares/on-start-app.js +0 -34
- package/lib/services/fetch-skills.mock.d.ts +0 -3
- package/lib/services/fetch-skills.mock.js +0 -17
- package/lib/services/tools/fetch.mocks.d.ts +0 -8
- package/lib/services/tools/fetch.mocks.js +0 -35
- package/lib/types/skills.d.ts +0 -7
- package/src/actions/data/skills.ts +0 -24
- package/src/middlewares/on-start-app.ts +0 -42
- package/src/services/fetch-skills.mock.ts +0 -21
- package/src/services/fetch-skills.test.ts +0 -32
- package/src/services/tools/fetch.mocks.ts +0 -41
- package/src/types/skills.ts +0 -8
- /package/es/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/es/{index.test.d.ts → services/test/post-progression.test.d.ts} +0 -0
- /package/{lib → es/test}/index.test.d.ts +0 -0
- /package/es/types/{skills.js → ui-progression.js} +0 -0
- /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/lib/{types/skills.js → services/test/post-progression.test.d.ts} +0 -0
|
@@ -1,76 +1,36 @@
|
|
|
1
|
-
import { getOr
|
|
1
|
+
import { getOr } from 'lodash/fp';
|
|
2
2
|
import { VALIDATE_SLIDE } from '../../actions/data/slides';
|
|
3
|
-
|
|
4
|
-
export var initialState = null;
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
3
|
+
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
6
4
|
var reducer = function (
|
|
7
5
|
// eslint-disable-next-line default-param-last
|
|
8
6
|
state, action) {
|
|
9
|
-
if (state === void 0) { state =
|
|
7
|
+
if (state === void 0) { state = null; }
|
|
10
8
|
switch (action.type) {
|
|
11
9
|
case VALIDATE_SLIDE: {
|
|
12
10
|
var previousSlideNumber = getOr(-1, 'slideNumber', state);
|
|
13
11
|
// hard coded for now
|
|
12
|
+
// TODO: fix on VALIDATE ticket
|
|
14
13
|
return {
|
|
14
|
+
_id: '1234',
|
|
15
15
|
// virtual field
|
|
16
16
|
slideNumber: previousSlideNumber + 1,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
questionText: 'Test',
|
|
27
|
-
answerUI: {
|
|
28
|
-
model: {
|
|
29
|
-
answers: [
|
|
30
|
-
{
|
|
31
|
-
title: 'There is no need for a password',
|
|
32
|
-
// TODO: onClick of each answer should use a dispatcher to
|
|
33
|
-
// update selected answers (in order to use them on validation)
|
|
34
|
-
// in each retrieval, the answers of answerUI need to be augmented
|
|
35
|
-
// for the onClick prop to achieve this.
|
|
36
|
-
onClick: noop,
|
|
37
|
-
selected: false,
|
|
38
|
-
help: 'help'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
title: 'Lorem ipsum',
|
|
42
|
-
onClick: noop,
|
|
43
|
-
selected: false,
|
|
44
|
-
help: 'help'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title: 'Lorem',
|
|
48
|
-
onClick: noop,
|
|
49
|
-
selected: true,
|
|
50
|
-
order: 1,
|
|
51
|
-
help: 'help'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
title: 'You need to have a password',
|
|
55
|
-
onClick: noop,
|
|
56
|
-
selected: false,
|
|
57
|
-
help: 'help'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
title: 'Pouet',
|
|
61
|
-
onClick: noop,
|
|
62
|
-
selected: true,
|
|
63
|
-
order: 0,
|
|
64
|
-
help: 'help'
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
type: 'qcmDrag'
|
|
68
|
-
},
|
|
69
|
-
help: 'Help text will appear here'
|
|
17
|
+
state: {
|
|
18
|
+
pendingSlides: [],
|
|
19
|
+
step: {
|
|
20
|
+
current: Number.NaN
|
|
21
|
+
},
|
|
22
|
+
isCorrect: true,
|
|
23
|
+
nextContent: {
|
|
24
|
+
ref: 'sli_V1gKpYYZ2',
|
|
25
|
+
type: 'slide'
|
|
70
26
|
}
|
|
71
27
|
}
|
|
72
28
|
};
|
|
73
29
|
}
|
|
30
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
31
|
+
var progression = action.payload;
|
|
32
|
+
return progression;
|
|
33
|
+
}
|
|
74
34
|
default:
|
|
75
35
|
return state;
|
|
76
36
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare type SkillsState =
|
|
4
|
-
|
|
5
|
-
declare const reducer: (state: Skills | undefined, action: ReceivedSkills) => Skills;
|
|
1
|
+
import { Skill } from '../../types/common';
|
|
2
|
+
import { ReceivedSkills } from '../../actions/api/fetch-skills';
|
|
3
|
+
export declare type SkillsState = Skill[];
|
|
4
|
+
declare const reducer: (state: SkillsState | undefined, action: ReceivedSkills) => SkillsState;
|
|
6
5
|
export default reducer;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export var initialState = [];
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
1
|
+
import { SKILLS_FETCH_SUCCESS } from '../../actions/api/fetch-skills';
|
|
4
2
|
// eslint-disable-next-line default-param-last
|
|
5
3
|
var reducer = function (state, action) {
|
|
6
|
-
if (state === void 0) { state =
|
|
4
|
+
if (state === void 0) { state = []; }
|
|
7
5
|
switch (action.type) {
|
|
8
|
-
case
|
|
6
|
+
case SKILLS_FETCH_SUCCESS:
|
|
9
7
|
return action.payload;
|
|
10
8
|
default:
|
|
11
9
|
return state;
|
|
12
10
|
}
|
|
13
11
|
};
|
|
14
|
-
// -----------------------------------------------------------------------------
|
|
15
12
|
export default reducer;
|
|
@@ -10,9 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import map from 'lodash/fp/map';
|
|
13
|
-
import {
|
|
13
|
+
import { UPDATE_SLIDES_ON_NEXT, UPDATE_SLIDES_ON_VALIDATION } from '../../actions/data/slides';
|
|
14
14
|
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
|
|
15
|
-
|
|
15
|
+
import { slide as qcmSlide } from '../../fixtures/qcm-slide';
|
|
16
|
+
import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
16
17
|
var getInitialState = function () {
|
|
17
18
|
var state = {
|
|
18
19
|
slideNumbers: slideNumbers
|
|
@@ -41,7 +42,7 @@ var setFirstSlide = function (state, slide) {
|
|
|
41
42
|
// ||-------> Handles the updates of a given slide on validation,
|
|
42
43
|
// & then updates de remaining slides if this given change should impact their content
|
|
43
44
|
var stateUpdateOnValidation = function (state, payload) {
|
|
44
|
-
var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides,
|
|
45
|
+
var slideNumber = payload.slideNumber, newSlideContent = payload.newSlideContent, numberOfFinishedSlides = payload.numberOfFinishedSlides, nextContent = payload.nextContent;
|
|
45
46
|
var _state = {
|
|
46
47
|
slideNumbers: slideNumbers
|
|
47
48
|
};
|
|
@@ -52,7 +53,7 @@ var stateUpdateOnValidation = function (state, payload) {
|
|
|
52
53
|
if (index === slideNumber) {
|
|
53
54
|
// only one slide remaining, presets the next value
|
|
54
55
|
if (numberOfFinishedSlides === HIGHEST_INDEX) {
|
|
55
|
-
_state[index] = __assign(__assign({}, previousValue), {
|
|
56
|
+
_state[index] = __assign(__assign({}, previousValue), { nextContent: nextContent, position: newSlideContent.position, isCorrect: newSlideContent.isCorrect });
|
|
56
57
|
}
|
|
57
58
|
else
|
|
58
59
|
_state[slideNumber] = __assign(__assign({}, previousValue), newSlideContent);
|
|
@@ -60,7 +61,7 @@ var stateUpdateOnValidation = function (state, payload) {
|
|
|
60
61
|
else {
|
|
61
62
|
// updates the rest of the slides here
|
|
62
63
|
var hidden = previousValue.hidden, position = previousValue.position;
|
|
63
|
-
_state[index] = __assign(__assign({},
|
|
64
|
+
_state[index] = __assign(__assign({}, nextContent), { endReview: newSlideContent.endReview, hidden: hidden, position: position });
|
|
64
65
|
}
|
|
65
66
|
}, state.slideNumbers);
|
|
66
67
|
return _state;
|
|
@@ -78,8 +79,8 @@ var stateUpdateOnNext = function (state, payload) {
|
|
|
78
79
|
// the current slide
|
|
79
80
|
if (index === slideNumber) {
|
|
80
81
|
// when there is only one slide remaining, updates the slide value
|
|
81
|
-
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.
|
|
82
|
-
_state[index] = __assign(__assign({}, previousValue.
|
|
82
|
+
if (numberOfFinishedSlides === HIGHEST_INDEX && previousValue.nextContent) {
|
|
83
|
+
_state[index] = __assign(__assign({}, previousValue.nextContent), { position: previousValue.position });
|
|
83
84
|
}
|
|
84
85
|
else
|
|
85
86
|
_state[slideNumber] = newSlideContent;
|
|
@@ -103,8 +104,12 @@ var stateUpdateOnNext = function (state, payload) {
|
|
|
103
104
|
var reducer = function (state, action) {
|
|
104
105
|
if (state === void 0) { state = initialState; }
|
|
105
106
|
switch (action.type) {
|
|
106
|
-
case
|
|
107
|
-
|
|
107
|
+
case SLIDE_FETCH_SUCCESS: {
|
|
108
|
+
// TODO: An intermediate slide transform is needed here (or in fetchSlide)
|
|
109
|
+
// const apiSlide = action.payload;
|
|
110
|
+
// apiSlide adapt to uiSlide
|
|
111
|
+
var uiSlide = qcmSlide;
|
|
112
|
+
return setFirstSlide(state, uiSlide);
|
|
108
113
|
}
|
|
109
114
|
case UPDATE_SLIDES_ON_VALIDATION: {
|
|
110
115
|
return stateUpdateOnValidation(state, action.payload);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { STORE_TOKEN } from '../../actions/data/token';
|
|
2
|
-
// -----------------------------------------------------------------------------
|
|
3
|
-
export var initialState = null;
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
2
|
// eslint-disable-next-line default-param-last
|
|
6
3
|
var reducer = function (state, action) {
|
|
7
|
-
if (state === void 0) { state =
|
|
4
|
+
if (state === void 0) { state = null; }
|
|
8
5
|
switch (action.type) {
|
|
9
6
|
case STORE_TOKEN:
|
|
10
7
|
return action.payload;
|
|
@@ -12,5 +9,4 @@ var reducer = function (state, action) {
|
|
|
12
9
|
return state;
|
|
13
10
|
}
|
|
14
11
|
};
|
|
15
|
-
// -----------------------------------------------------------------------------
|
|
16
12
|
export default reducer;
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { DataState } from './data';
|
|
2
|
+
import { UIState } from './ui';
|
|
3
|
+
export declare type StoreState = {
|
|
4
|
+
ui: UIState;
|
|
5
|
+
data: DataState;
|
|
6
|
+
};
|
|
1
7
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
8
|
data: import("redux").CombinedState<{
|
|
3
9
|
progression: import("./data/progression").ProgressionState;
|
|
4
|
-
skills: import("
|
|
10
|
+
skills: import("./data/skills").SkillsState;
|
|
5
11
|
slides: import("./data/slides").SlidesState;
|
|
6
12
|
token: import("./data/token").TokenState;
|
|
7
13
|
}>;
|
|
@@ -9,7 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
9
15
|
finishedSlides: import("./ui/finished-slides").FinishedSlidesState;
|
|
10
16
|
navigation: import("./ui/navigation").NavigationState;
|
|
11
17
|
reviewStatus: import("./ui/review-status").ReviewStatusState;
|
|
12
|
-
stepItems: import("./ui/step-items").
|
|
18
|
+
stepItems: import("./ui/step-items").StepItemsState;
|
|
13
19
|
}>;
|
|
14
|
-
}>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/
|
|
20
|
+
}>, import("../actions/data/slides").ValidateSlide | import("../actions/data/slides").SlidesAction | import("../actions/api/post-progression").ReceiveProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("../actions/data/token").StoreToken | import("../actions/ui/finished-slides").UpdateFinishedSlides | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/review-status").UpdateReviewStatus | import("../actions/ui/step-items").StepItemsAction>;
|
|
15
21
|
export default _default;
|
|
@@ -3,6 +3,5 @@ export declare type FinishedSlidesState = {
|
|
|
3
3
|
slideNumbers: number[];
|
|
4
4
|
[key: number]: true;
|
|
5
5
|
};
|
|
6
|
-
export declare const initialState: FinishedSlidesState;
|
|
7
6
|
declare const reducer: (state: FinishedSlidesState | undefined, action: UpdateFinishedSlides) => FinishedSlidesState;
|
|
8
7
|
export default reducer;
|
|
@@ -12,11 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import forEach from 'lodash/fp/forEach';
|
|
13
13
|
import { UPDATE_FINISHED_SLIDES } from '../../actions/ui/finished-slides';
|
|
14
14
|
import { slideNumbers } from '../../common';
|
|
15
|
-
|
|
16
|
-
export var initialState = {
|
|
15
|
+
var initialState = {
|
|
17
16
|
slideNumbers: slideNumbers
|
|
18
17
|
};
|
|
19
|
-
// -----------------------------------------------------------------------------
|
|
20
18
|
var _forEach = forEach.convert({
|
|
21
19
|
cap: false
|
|
22
20
|
});
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { FinishedSlidesState } from './finished-slides';
|
|
2
|
+
import { NavigationState } from './navigation';
|
|
3
|
+
import { ReviewStatusState } from './review-status';
|
|
4
|
+
import { StepItemsState } from './step-items';
|
|
5
|
+
export declare type UIState = {
|
|
6
|
+
navigation: NavigationState;
|
|
7
|
+
stepItems: StepItemsState;
|
|
8
|
+
finishedSlides: FinishedSlidesState;
|
|
9
|
+
reviewStatus: ReviewStatusState;
|
|
10
|
+
};
|
|
1
11
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
|
-
finishedSlides:
|
|
3
|
-
navigation:
|
|
4
|
-
reviewStatus:
|
|
5
|
-
stepItems:
|
|
12
|
+
finishedSlides: FinishedSlidesState;
|
|
13
|
+
navigation: NavigationState;
|
|
14
|
+
reviewStatus: ReviewStatusState;
|
|
15
|
+
stepItems: StepItemsState;
|
|
6
16
|
}>, import("../../actions/ui/finished-slides").UpdateFinishedSlides | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/review-status").UpdateReviewStatus | import("../../actions/ui/step-items").StepItemsAction>;
|
|
7
17
|
export default _default;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type NavigateTo, type NavigateBack } from '../../actions/ui/navigation';
|
|
2
2
|
export declare type NavigationState = Array<'skills' | 'onboarding' | 'slides'>;
|
|
3
|
-
export declare const initialState: NavigationState;
|
|
4
3
|
declare const reducer: (state: NavigationState | undefined, action: NavigateTo | NavigateBack) => NavigationState;
|
|
5
4
|
export default reducer;
|
|
@@ -8,12 +8,10 @@ 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/ui/navigation';
|
|
11
|
-
export var initialState = [];
|
|
12
|
-
// -----------------------------------------------------------------------------
|
|
13
11
|
var reducer = function (
|
|
14
12
|
// eslint-disable-next-line default-param-last
|
|
15
13
|
state, action) {
|
|
16
|
-
if (state === void 0) { state =
|
|
14
|
+
if (state === void 0) { state = []; }
|
|
17
15
|
switch (action.type) {
|
|
18
16
|
case NAVIGATE_TO: {
|
|
19
17
|
return __spreadArray(__spreadArray([], state, true), [action.payload], false);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { UpdateReviewStatus } from '../../actions/ui/review-status';
|
|
2
2
|
export declare type ReviewStatusState = 'finished' | 'ongoing';
|
|
3
|
-
export declare const initialState: ReviewStatusState;
|
|
4
3
|
declare const reducer: (state: ReviewStatusState | undefined, action: UpdateReviewStatus) => ReviewStatusState;
|
|
5
4
|
export default reducer;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { UPDATE_REVIEW_STATUS } from '../../actions/ui/review-status';
|
|
2
|
-
export var initialState = 'ongoing';
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
2
|
var reducer = function (
|
|
5
3
|
// eslint-disable-next-line default-param-last
|
|
6
4
|
state, action) {
|
|
7
|
-
if (state === void 0) { state =
|
|
5
|
+
if (state === void 0) { state = 'ongoing'; }
|
|
8
6
|
switch (action.type) {
|
|
9
7
|
case UPDATE_REVIEW_STATUS: {
|
|
10
8
|
return action.payload;
|
|
@@ -13,5 +11,4 @@ state, action) {
|
|
|
13
11
|
return state;
|
|
14
12
|
}
|
|
15
13
|
};
|
|
16
|
-
// -----------------------------------------------------------------------------
|
|
17
14
|
export default reducer;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IconValue
|
|
2
|
-
|
|
1
|
+
import { IconValue } from '../../types/common';
|
|
2
|
+
import { StepItemsAction } from '../../actions/ui/step-items';
|
|
3
|
+
export declare type StepItem = {
|
|
3
4
|
current: boolean;
|
|
4
5
|
icon: IconValue;
|
|
5
6
|
value: string;
|
|
6
7
|
};
|
|
7
|
-
export declare type
|
|
8
|
+
export declare type StepItemsState = {
|
|
8
9
|
slideNumbers: number[];
|
|
9
10
|
[key: number]: StepItem;
|
|
10
11
|
};
|
|
11
|
-
export declare type StepItemsState = StepItems;
|
|
12
12
|
export declare const initialState: StepItemsState;
|
|
13
|
-
declare const reducer: (state:
|
|
13
|
+
declare const reducer: (state: StepItemsState | undefined, action: StepItemsAction) => StepItemsState;
|
|
14
14
|
export default reducer;
|
|
@@ -14,7 +14,6 @@ import has from 'lodash/fp/has';
|
|
|
14
14
|
import map from 'lodash/fp/map';
|
|
15
15
|
import { UPDATE_STEP_ITEMS_ON_NEXT, UPDATE_STEP_ITEMS_ON_VALIDATION } from '../../actions/ui/step-items';
|
|
16
16
|
import { HIGHEST_INDEX, slideNumbers, TOTAL_SLIDES_STACK } from '../../common';
|
|
17
|
-
// -----------------------------------------------------------------------------
|
|
18
17
|
var getInitialState = function () {
|
|
19
18
|
var state = {
|
|
20
19
|
slideNumbers: slideNumbers
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare type FetchSkills = (token: string) => Promise<Skills>;
|
|
4
|
-
declare type CreateFetchSkills = (fetch: typeof crossFetch) => FetchSkills;
|
|
5
|
-
declare const fetchSkills: CreateFetchSkills;
|
|
6
|
-
export { fetchSkills };
|
|
7
|
-
declare const _default: FetchSkills;
|
|
8
|
-
export default _default;
|
|
1
|
+
import { Skill } from '../types/common';
|
|
2
|
+
export declare const fetchSkills: (token: string) => Promise<Skill[]>;
|
|
@@ -37,33 +37,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import crossFetch from 'cross-fetch';
|
|
38
38
|
import decode from 'jwt-decode';
|
|
39
39
|
import { toJSON } from './tools/fetch-responses';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var fetchSkills = function (fetch) { return function (token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var _a, userId, host, response, skills;
|
|
40
|
+
export var fetchSkills = function (token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var _a, userId, host, response;
|
|
44
42
|
return __generator(this, function (_b) {
|
|
45
43
|
switch (_b.label) {
|
|
46
44
|
case 0:
|
|
47
45
|
_a = decode(token), userId = _a.user, host = _a.host;
|
|
48
|
-
return [4 /*yield*/,
|
|
46
|
+
return [4 /*yield*/, crossFetch("".concat(host, "/api/v2/skills/review/user/").concat(userId), {
|
|
49
47
|
headers: { authorization: token }
|
|
50
48
|
})];
|
|
51
49
|
case 1:
|
|
52
50
|
response = _b.sent();
|
|
53
|
-
return [
|
|
54
|
-
case 2:
|
|
55
|
-
skills = (_b.sent());
|
|
56
|
-
return [2 /*return*/, skills];
|
|
51
|
+
return [2 /*return*/, toJSON(response)];
|
|
57
52
|
}
|
|
58
53
|
});
|
|
59
|
-
}); };
|
|
60
|
-
// -----------------------------------------------------------------------------
|
|
61
|
-
var createFetchSkills = function () {
|
|
62
|
-
if (process.env.SERVICES !== 'mocks') {
|
|
63
|
-
return fetchSkills(crossFetch);
|
|
64
|
-
}
|
|
65
|
-
return fetchSkills(mockFetchSkills);
|
|
66
|
-
};
|
|
67
|
-
// -----------------------------------------------------------------------------
|
|
68
|
-
export { fetchSkills };
|
|
69
|
-
export default createFetchSkills();
|
|
54
|
+
}); };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import crossFetch from 'cross-fetch';
|
|
38
|
+
import decode from 'jwt-decode';
|
|
39
|
+
import { toJSON } from './tools/fetch-responses';
|
|
40
|
+
export var fetchSlide = function (slideRef, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var host, response, slide;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
host = decode(token).host;
|
|
46
|
+
return [4 /*yield*/, crossFetch("".concat(host, "/api/v2/slide/").concat(slideRef), {
|
|
47
|
+
headers: { authorization: token }
|
|
48
|
+
})];
|
|
49
|
+
case 1:
|
|
50
|
+
response = _a.sent();
|
|
51
|
+
return [4 /*yield*/, toJSON(response)];
|
|
52
|
+
case 2:
|
|
53
|
+
slide = (_a.sent());
|
|
54
|
+
return [2 /*return*/, slide];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}); };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fetchSkills } from './fetch-skills';
|
|
2
|
+
import { postProgression } from './post-progression';
|
|
3
|
+
import { fetchSlide } from './fetch-slide';
|
|
4
|
+
export var getServices = function () { return ({
|
|
5
|
+
fetchSkills: fetchSkills,
|
|
6
|
+
fetchSlide: fetchSlide,
|
|
7
|
+
postProgression: postProgression
|
|
8
|
+
}); };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import crossFetch from 'cross-fetch';
|
|
38
|
+
import decode from 'jwt-decode';
|
|
39
|
+
import { toJSON } from './tools/fetch-responses';
|
|
40
|
+
export var postProgression = function (skillRef, token) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var host, response;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
host = decode(token).host;
|
|
46
|
+
return [4 /*yield*/, crossFetch("".concat(host, "/api/v2/progressions"), {
|
|
47
|
+
method: 'post',
|
|
48
|
+
headers: { authorization: token },
|
|
49
|
+
body: JSON.stringify({
|
|
50
|
+
content: {
|
|
51
|
+
ref: skillRef,
|
|
52
|
+
type: 'slide'
|
|
53
|
+
},
|
|
54
|
+
engine: {
|
|
55
|
+
ref: 'review',
|
|
56
|
+
version: '1'
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
})];
|
|
60
|
+
case 1:
|
|
61
|
+
response = _a.sent();
|
|
62
|
+
return [2 /*return*/, toJSON(response)];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); };
|
|
@@ -35,23 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import test from 'ava';
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
38
|
+
import nock from 'nock';
|
|
39
|
+
import { fetchSkills } from '../fetch-skills';
|
|
40
|
+
var result = [
|
|
41
|
+
{
|
|
42
|
+
slidesToReview: 1,
|
|
43
|
+
name: 'skill-test',
|
|
44
|
+
custom: false,
|
|
45
|
+
skillRef: '_skill-ref'
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
test.before(function () {
|
|
49
|
+
nock('http://localhost:3000')
|
|
50
|
+
.get('/api/v2/skills/review/user/592d830b240b923f00bffba6')
|
|
51
|
+
.reply(200, result);
|
|
52
|
+
});
|
|
53
|
+
test.after(function () {
|
|
54
|
+
nock.cleanAll();
|
|
55
|
+
});
|
|
40
56
|
test('should fetch skills with success', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
-
var
|
|
57
|
+
var token, skills;
|
|
42
58
|
return __generator(this, function (_a) {
|
|
43
59
|
switch (_a.label) {
|
|
44
60
|
case 0:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
slidesToReview: 1,
|
|
48
|
-
name: 'skill-test',
|
|
49
|
-
custom: false,
|
|
50
|
-
skillRef: '_skill-ref'
|
|
51
|
-
}
|
|
52
|
-
];
|
|
53
|
-
mockedFetchSkills = fetchSkills(okJSONResponse(result));
|
|
54
|
-
return [4 /*yield*/, mockedFetchSkills(token)];
|
|
61
|
+
token = process.env.API_TEST_TOKEN || '';
|
|
62
|
+
return [4 /*yield*/, fetchSkills(token)];
|
|
55
63
|
case 1:
|
|
56
64
|
skills = _a.sent();
|
|
57
65
|
t.deepEqual(result, skills);
|
|
@@ -60,13 +68,12 @@ test('should fetch skills with success', function (t) { return __awaiter(void 0,
|
|
|
60
68
|
});
|
|
61
69
|
}); });
|
|
62
70
|
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
-
var badToken,
|
|
71
|
+
var badToken, error;
|
|
64
72
|
return __generator(this, function (_a) {
|
|
65
73
|
switch (_a.label) {
|
|
66
74
|
case 0:
|
|
67
75
|
badToken = 'token is not a jwt';
|
|
68
|
-
|
|
69
|
-
return [4 /*yield*/, t.throwsAsync(function () { return mockedFetchSkills(badToken); })];
|
|
76
|
+
return [4 /*yield*/, t.throwsAsync(function () { return fetchSkills(badToken); })];
|
|
70
77
|
case 1:
|
|
71
78
|
error = _a.sent();
|
|
72
79
|
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|