@coorpacademy/app-review 0.3.2 → 0.3.4-alpha.5
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/reducers/data/corrections.js +2 -2
- package/es/reducers/index.d.ts +1 -1
- package/es/reducers/ui/answers.d.ts +2 -1
- package/es/reducers/ui/answers.js +18 -6
- package/es/reducers/ui/index.d.ts +1 -1
- package/es/reducers/ui/slide.d.ts +4 -1
- package/es/reducers/ui/slide.js +7 -2
- package/lib/reducers/data/corrections.js +2 -2
- package/lib/reducers/index.d.ts +1 -1
- package/lib/reducers/ui/answers.d.ts +2 -1
- package/lib/reducers/ui/answers.js +18 -6
- package/lib/reducers/ui/index.d.ts +1 -1
- package/lib/reducers/ui/slide.d.ts +4 -1
- package/lib/reducers/ui/slide.js +7 -2
- package/package.json +15 -16
- package/readme.md +1 -12
- package/src/reducers/data/corrections.ts +2 -2
- package/src/reducers/ui/answers.ts +27 -7
- package/src/reducers/ui/slide.ts +16 -7
- package/src/reducers/ui/test/answers.test.ts +17 -0
- package/src/reducers/ui/test/slide.test.ts +30 -0
- package/src/types/globals.d.ts +1 -2
|
@@ -7,12 +7,12 @@ state = initialState, action) => {
|
|
|
7
7
|
switch (action.type) {
|
|
8
8
|
case CORRECTION_FETCH_REQUEST: {
|
|
9
9
|
const { meta } = action;
|
|
10
|
-
return set(meta.slideRef, null, state);
|
|
10
|
+
return set([meta.slideRef], null, state);
|
|
11
11
|
}
|
|
12
12
|
case CORRECTION_FETCH_SUCCESS: {
|
|
13
13
|
const { meta } = action;
|
|
14
14
|
const correction = action.payload;
|
|
15
|
-
return set(meta.slideRef, correction, state);
|
|
15
|
+
return set([meta.slideRef], correction, state);
|
|
16
16
|
}
|
|
17
17
|
default:
|
|
18
18
|
return state;
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
19
19
|
answers: import("./ui/answers").UIAnswerState;
|
|
20
20
|
slide: import("./ui/slide").UISlideState;
|
|
21
21
|
}>;
|
|
22
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction | import("../actions/ui/next-slide").NextSlide>;
|
|
23
23
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
+
import { NextSlide } from '../../actions/ui/next-slide';
|
|
2
3
|
export declare type UISlideAnswer = string[];
|
|
3
4
|
export declare type UIAnswerState = Record<string, UISlideAnswer>;
|
|
4
5
|
export declare const initialState: UIAnswerState;
|
|
5
|
-
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction) => UIAnswerState;
|
|
6
|
+
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlide) => UIAnswerState;
|
|
6
7
|
export default reducer;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { set } from 'lodash/fp';
|
|
2
|
+
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
3
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
4
4
|
export const initialState = {};
|
|
5
5
|
const reducer = (
|
|
6
6
|
// eslint-disable-next-line default-param-last
|
|
7
7
|
state = initialState, action) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
:
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case EDIT_QCM:
|
|
10
|
+
case EDIT_QCM_GRAPHIC:
|
|
11
|
+
case EDIT_QCM_DRAG:
|
|
12
|
+
case EDIT_TEMPLATE:
|
|
13
|
+
case EDIT_BASIC:
|
|
14
|
+
case EDIT_SLIDER: {
|
|
15
|
+
return set([action.meta.slideRef], action.payload, initialState);
|
|
16
|
+
}
|
|
17
|
+
case NEXT_SLIDE: {
|
|
18
|
+
return set([action.payload.nextSlideRef], [], state);
|
|
19
|
+
}
|
|
20
|
+
default:
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
11
23
|
};
|
|
12
24
|
export default reducer;
|
|
@@ -13,5 +13,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
13
13
|
navigation: NavigationState;
|
|
14
14
|
answers: UIAnswerState;
|
|
15
15
|
slide: UISlideState;
|
|
16
|
-
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
16
|
+
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | import("../../actions/ui/next-slide").NextSlide>;
|
|
17
17
|
export default _default;
|
|
@@ -2,12 +2,15 @@ import { EditAnswerAction } from '../../actions/ui/answers';
|
|
|
2
2
|
import { PostAnswerRequestAction } from '../../actions/api/post-answer';
|
|
3
3
|
import { ReceivedCorrection } from '../../actions/api/fetch-correction';
|
|
4
4
|
import { FetchSlide } from '../../actions/api/fetch-slide';
|
|
5
|
+
import { NextSlide } from '../../actions/ui/next-slide';
|
|
6
|
+
import { SlideUIAnimations } from '../../types/slides';
|
|
5
7
|
export declare type UISlide = {
|
|
6
8
|
validateButton: boolean;
|
|
7
9
|
animateCorrectionPopin: boolean;
|
|
8
10
|
showCorrectionPopin: boolean;
|
|
11
|
+
animationType?: SlideUIAnimations;
|
|
9
12
|
};
|
|
10
13
|
export declare type UISlideState = Record<string, UISlide>;
|
|
11
14
|
export declare const initialState: UISlideState;
|
|
12
|
-
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection) => UISlideState;
|
|
15
|
+
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlide) => UISlideState;
|
|
13
16
|
export default reducer;
|
package/es/reducers/ui/slide.js
CHANGED
|
@@ -2,21 +2,23 @@ import compact from 'lodash/fp/compact';
|
|
|
2
2
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
3
|
import pipe from 'lodash/fp/pipe';
|
|
4
4
|
import set from 'lodash/fp/set';
|
|
5
|
+
import unset from 'lodash/fp/unset';
|
|
5
6
|
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
6
7
|
import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
|
|
7
8
|
import { CORRECTION_FETCH_SUCCESS } from '../../actions/api/fetch-correction';
|
|
8
9
|
import { SLIDE_FETCH_REQUEST } from '../../actions/api/fetch-slide';
|
|
10
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
9
11
|
export const initialState = {};
|
|
10
12
|
const reducer = (
|
|
11
13
|
// eslint-disable-next-line default-param-last
|
|
12
14
|
state = initialState, action) => {
|
|
13
15
|
switch (action.type) {
|
|
14
16
|
case SLIDE_FETCH_REQUEST: {
|
|
15
|
-
return set([action.meta.slideRef], {
|
|
17
|
+
return pipe(unset([action.meta.slideRef, 'animationType']), set([action.meta.slideRef], {
|
|
16
18
|
validateButton: false,
|
|
17
19
|
animateCorrectionPopin: false,
|
|
18
20
|
showCorrectionPopin: false
|
|
19
|
-
}
|
|
21
|
+
}))(state);
|
|
20
22
|
}
|
|
21
23
|
case EDIT_QCM:
|
|
22
24
|
case EDIT_QCM_GRAPHIC:
|
|
@@ -32,6 +34,9 @@ state = initialState, action) => {
|
|
|
32
34
|
case CORRECTION_FETCH_SUCCESS: {
|
|
33
35
|
return pipe(set([action.meta.slideRef, 'animateCorrectionPopin'], true), set([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
|
|
34
36
|
}
|
|
37
|
+
case NEXT_SLIDE: {
|
|
38
|
+
return pipe(set([action.payload.currentSlideRef, 'animateCorrectionPopin'], false), set([action.payload.currentSlideRef, 'animationType'], action.payload.animationType))(state);
|
|
39
|
+
}
|
|
35
40
|
default:
|
|
36
41
|
return state;
|
|
37
42
|
}
|
|
@@ -8,12 +8,12 @@ state, action) {
|
|
|
8
8
|
switch (action.type) {
|
|
9
9
|
case CORRECTION_FETCH_REQUEST: {
|
|
10
10
|
var meta = action.meta;
|
|
11
|
-
return set(meta.slideRef, null, state);
|
|
11
|
+
return set([meta.slideRef], null, state);
|
|
12
12
|
}
|
|
13
13
|
case CORRECTION_FETCH_SUCCESS: {
|
|
14
14
|
var meta = action.meta;
|
|
15
15
|
var correction = action.payload;
|
|
16
|
-
return set(meta.slideRef, correction, state);
|
|
16
|
+
return set([meta.slideRef], correction, state);
|
|
17
17
|
}
|
|
18
18
|
default:
|
|
19
19
|
return state;
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
19
19
|
answers: import("./ui/answers").UIAnswerState;
|
|
20
20
|
slide: import("./ui/slide").UISlideState;
|
|
21
21
|
}>;
|
|
22
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction | import("../actions/ui/next-slide").NextSlide>;
|
|
23
23
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
+
import { NextSlide } from '../../actions/ui/next-slide';
|
|
2
3
|
export declare type UISlideAnswer = string[];
|
|
3
4
|
export declare type UIAnswerState = Record<string, UISlideAnswer>;
|
|
4
5
|
export declare const initialState: UIAnswerState;
|
|
5
|
-
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction) => UIAnswerState;
|
|
6
|
+
declare const reducer: (state: UIAnswerState | undefined, action: EditAnswerAction | NextSlide) => UIAnswerState;
|
|
6
7
|
export default reducer;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { set } from 'lodash/fp';
|
|
2
|
+
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
3
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
4
4
|
export var initialState = {};
|
|
5
5
|
var reducer = function (
|
|
6
6
|
// eslint-disable-next-line default-param-last
|
|
7
7
|
state, action) {
|
|
8
8
|
if (state === void 0) { state = initialState; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
:
|
|
9
|
+
switch (action.type) {
|
|
10
|
+
case EDIT_QCM:
|
|
11
|
+
case EDIT_QCM_GRAPHIC:
|
|
12
|
+
case EDIT_QCM_DRAG:
|
|
13
|
+
case EDIT_TEMPLATE:
|
|
14
|
+
case EDIT_BASIC:
|
|
15
|
+
case EDIT_SLIDER: {
|
|
16
|
+
return set([action.meta.slideRef], action.payload, initialState);
|
|
17
|
+
}
|
|
18
|
+
case NEXT_SLIDE: {
|
|
19
|
+
return set([action.payload.nextSlideRef], [], state);
|
|
20
|
+
}
|
|
21
|
+
default:
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
12
24
|
};
|
|
13
25
|
export default reducer;
|
|
@@ -13,5 +13,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
13
13
|
navigation: NavigationState;
|
|
14
14
|
answers: UIAnswerState;
|
|
15
15
|
slide: UISlideState;
|
|
16
|
-
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
|
|
16
|
+
}>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | import("../../actions/ui/next-slide").NextSlide>;
|
|
17
17
|
export default _default;
|
|
@@ -2,12 +2,15 @@ import { EditAnswerAction } from '../../actions/ui/answers';
|
|
|
2
2
|
import { PostAnswerRequestAction } from '../../actions/api/post-answer';
|
|
3
3
|
import { ReceivedCorrection } from '../../actions/api/fetch-correction';
|
|
4
4
|
import { FetchSlide } from '../../actions/api/fetch-slide';
|
|
5
|
+
import { NextSlide } from '../../actions/ui/next-slide';
|
|
6
|
+
import { SlideUIAnimations } from '../../types/slides';
|
|
5
7
|
export declare type UISlide = {
|
|
6
8
|
validateButton: boolean;
|
|
7
9
|
animateCorrectionPopin: boolean;
|
|
8
10
|
showCorrectionPopin: boolean;
|
|
11
|
+
animationType?: SlideUIAnimations;
|
|
9
12
|
};
|
|
10
13
|
export declare type UISlideState = Record<string, UISlide>;
|
|
11
14
|
export declare const initialState: UISlideState;
|
|
12
|
-
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection) => UISlideState;
|
|
15
|
+
declare const reducer: (state: UISlideState | undefined, action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlide) => UISlideState;
|
|
13
16
|
export default reducer;
|
package/lib/reducers/ui/slide.js
CHANGED
|
@@ -2,10 +2,12 @@ import compact from 'lodash/fp/compact';
|
|
|
2
2
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
3
|
import pipe from 'lodash/fp/pipe';
|
|
4
4
|
import set from 'lodash/fp/set';
|
|
5
|
+
import unset from 'lodash/fp/unset';
|
|
5
6
|
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
6
7
|
import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
|
|
7
8
|
import { CORRECTION_FETCH_SUCCESS } from '../../actions/api/fetch-correction';
|
|
8
9
|
import { SLIDE_FETCH_REQUEST } from '../../actions/api/fetch-slide';
|
|
10
|
+
import { NEXT_SLIDE } from '../../actions/ui/next-slide';
|
|
9
11
|
export var initialState = {};
|
|
10
12
|
var reducer = function (
|
|
11
13
|
// eslint-disable-next-line default-param-last
|
|
@@ -13,11 +15,11 @@ state, action) {
|
|
|
13
15
|
if (state === void 0) { state = initialState; }
|
|
14
16
|
switch (action.type) {
|
|
15
17
|
case SLIDE_FETCH_REQUEST: {
|
|
16
|
-
return set([action.meta.slideRef], {
|
|
18
|
+
return pipe(unset([action.meta.slideRef, 'animationType']), set([action.meta.slideRef], {
|
|
17
19
|
validateButton: false,
|
|
18
20
|
animateCorrectionPopin: false,
|
|
19
21
|
showCorrectionPopin: false
|
|
20
|
-
}
|
|
22
|
+
}))(state);
|
|
21
23
|
}
|
|
22
24
|
case EDIT_QCM:
|
|
23
25
|
case EDIT_QCM_GRAPHIC:
|
|
@@ -33,6 +35,9 @@ state, action) {
|
|
|
33
35
|
case CORRECTION_FETCH_SUCCESS: {
|
|
34
36
|
return pipe(set([action.meta.slideRef, 'animateCorrectionPopin'], true), set([action.meta.slideRef, 'showCorrectionPopin'], true))(state);
|
|
35
37
|
}
|
|
38
|
+
case NEXT_SLIDE: {
|
|
39
|
+
return pipe(set([action.payload.currentSlideRef, 'animateCorrectionPopin'], false), set([action.payload.currentSlideRef, 'animationType'], action.payload.animationType))(state);
|
|
40
|
+
}
|
|
36
41
|
default:
|
|
37
42
|
return state;
|
|
38
43
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4-alpha.5+61f74b9c6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
7
7
|
},
|
|
8
8
|
"license": "UNLICENSED",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"static": "webpack --progress --output-path static/dist",
|
|
11
|
+
"poststatic": "cp sandbox/index.html static/index.html",
|
|
12
|
+
"start": "cross-env BABEL_ENV=es webpack-dev-server --content-base sandbox --host 0.0.0.0 --history-api-fallback true --hot true",
|
|
13
13
|
"prepare": "npm run clean && npm run build --production",
|
|
14
14
|
"build:commonjs": "tsc -p tsconfig.lib.json",
|
|
15
15
|
"build:es": "tsc -p tsconfig.es.json",
|
|
16
16
|
"build": "concurrently \"npm run build:commonjs\" \"npm run build:es\"",
|
|
17
17
|
"clean:commonjs": "rm -rf lib",
|
|
18
18
|
"clean:es": "rm -rf es",
|
|
19
|
-
"clean
|
|
19
|
+
"clean:static": "rm -rf static",
|
|
20
|
+
"clean": "concurrently \"npm run clean:commonjs\" \"npm run clean:es\" \"npm run clean:static\"",
|
|
20
21
|
"typecheck": "tsc --noEmit",
|
|
21
22
|
"ava": "ava",
|
|
22
23
|
"test:unit": "nyc npm run ava",
|
|
@@ -42,10 +43,10 @@
|
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@coorpacademy/components": "10.23.1",
|
|
45
|
-
"@coorpacademy/redux-task": "
|
|
46
|
+
"@coorpacademy/redux-task": "1.1.5",
|
|
46
47
|
"cross-fetch": "^3.1.5",
|
|
47
48
|
"jwt-decode": "^3.1.2",
|
|
48
|
-
"react-redux": "
|
|
49
|
+
"react-redux": "7.2.8",
|
|
49
50
|
"redux": "^4.2.0",
|
|
50
51
|
"redux-thunk": "^2.4.1"
|
|
51
52
|
},
|
|
@@ -56,27 +57,25 @@
|
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@coorpacademy/css-modules-require-hook": "2.1.5",
|
|
58
59
|
"@coorpacademy/eslint-plugin-coorpacademy": "^11.0.0",
|
|
60
|
+
"@coorpacademy/webpack-config": "10.0.4",
|
|
59
61
|
"@testing-library/react": "^12.1.5",
|
|
60
62
|
"@types/lodash": "^4.14.182",
|
|
61
63
|
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
62
64
|
"@typescript-eslint/parser": "^5.28.0",
|
|
63
65
|
"ava": "^4.3.0",
|
|
64
66
|
"browser-env": "^3.3.0",
|
|
65
|
-
"chalk": "^4.1.2",
|
|
66
67
|
"concurrently": "^5.2.0",
|
|
67
|
-
"connect-history-api-fallback": "^1.6.0",
|
|
68
68
|
"dotenv": "^16.0.1",
|
|
69
|
-
"esbuild": "^0.14.39",
|
|
70
|
-
"esbuild-css-modules-plugin": "https://github.com/chrisdugne/esbuild-css-modules-plugin#main",
|
|
71
|
-
"esbuild-plugin-svgr": "^1.0.1",
|
|
72
69
|
"eslint": "^8.18.0",
|
|
73
70
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
74
|
-
"live-server": "^1.2.2",
|
|
75
71
|
"nock": "^13.2.9",
|
|
76
|
-
"postcss-modules-values-replace": "^3.4.0",
|
|
77
72
|
"react-dom": "^17.0.2",
|
|
73
|
+
"ts-loader": "^8.2.0",
|
|
78
74
|
"ts-node": "^10.9.1",
|
|
79
|
-
"typescript": "^4.7.4"
|
|
75
|
+
"typescript": "^4.7.4",
|
|
76
|
+
"webpack": "^4.43.0",
|
|
77
|
+
"webpack-cli": "^3.3.11",
|
|
78
|
+
"webpack-dev-server": "^3.11.0"
|
|
80
79
|
},
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "61f74b9c65517172cad944c10392fd89913f0d6f"
|
|
82
81
|
}
|
package/readme.md
CHANGED
|
@@ -14,7 +14,7 @@ npm start
|
|
|
14
14
|
requirements:
|
|
15
15
|
|
|
16
16
|
- [mooc](https://github.com/CoorpAcademy/coorpacademy) installed and running to expose a local API.
|
|
17
|
-
-
|
|
17
|
+
- copy and rename `.env.sample` to `.env` with a local token (`API_TEST_TOKEN`) to access the mooc API.
|
|
18
18
|
|
|
19
19
|
## developing views locally
|
|
20
20
|
|
|
@@ -51,14 +51,3 @@ npx ava --watch
|
|
|
51
51
|
|
|
52
52
|
`react` must also be the same version on this package and the rootApp
|
|
53
53
|
*(possible generic error Warning: Invalid hook call. [...] 3. You might have more than one copy of React in the same app)*
|
|
54
|
-
|
|
55
|
-
### tmp notes
|
|
56
|
-
|
|
57
|
-
export: <https://stackoverflow.com/a/70020984/959219>
|
|
58
|
-
|
|
59
|
-
css modules:
|
|
60
|
-
|
|
61
|
-
- <https://github.com/evanw/esbuild/issues/20>
|
|
62
|
-
- <https://github.com/indooorsman/esbuild-css-modules-plugin/issues/35>
|
|
63
|
-
- <https://github.com/princed/postcss-modules-values-replace>
|
|
64
|
-
- <https://github.com/CoorpAcademy/coorpacademy-lambda/blob/master/teams/postcss.config.js#L4>
|
|
@@ -21,12 +21,12 @@ const reducer = (
|
|
|
21
21
|
switch (action.type) {
|
|
22
22
|
case CORRECTION_FETCH_REQUEST: {
|
|
23
23
|
const {meta} = action;
|
|
24
|
-
return set(meta.slideRef, null, state);
|
|
24
|
+
return set([meta.slideRef], null, state);
|
|
25
25
|
}
|
|
26
26
|
case CORRECTION_FETCH_SUCCESS: {
|
|
27
27
|
const {meta} = action;
|
|
28
28
|
const correction = action.payload;
|
|
29
|
-
return set(meta.slideRef, correction, state);
|
|
29
|
+
return set([meta.slideRef], correction, state);
|
|
30
30
|
}
|
|
31
31
|
default:
|
|
32
32
|
return state;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {set} from 'lodash/fp';
|
|
2
|
+
import {
|
|
3
|
+
EditAnswerAction,
|
|
4
|
+
EDIT_BASIC,
|
|
5
|
+
EDIT_QCM,
|
|
6
|
+
EDIT_QCM_DRAG,
|
|
7
|
+
EDIT_QCM_GRAPHIC,
|
|
8
|
+
EDIT_SLIDER,
|
|
9
|
+
EDIT_TEMPLATE
|
|
10
|
+
} from '../../actions/ui/answers';
|
|
11
|
+
import {NextSlide, NEXT_SLIDE} from '../../actions/ui/next-slide';
|
|
3
12
|
|
|
4
13
|
export type UISlideAnswer = string[];
|
|
5
|
-
const ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
|
|
6
14
|
|
|
7
15
|
export type UIAnswerState = Record<string, UISlideAnswer>;
|
|
8
16
|
|
|
@@ -11,11 +19,23 @@ export const initialState: UIAnswerState = {};
|
|
|
11
19
|
const reducer = (
|
|
12
20
|
// eslint-disable-next-line default-param-last
|
|
13
21
|
state: UIAnswerState = initialState,
|
|
14
|
-
action: EditAnswerAction
|
|
22
|
+
action: EditAnswerAction | NextSlide
|
|
15
23
|
): UIAnswerState => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
24
|
+
switch (action.type) {
|
|
25
|
+
case EDIT_QCM:
|
|
26
|
+
case EDIT_QCM_GRAPHIC:
|
|
27
|
+
case EDIT_QCM_DRAG:
|
|
28
|
+
case EDIT_TEMPLATE:
|
|
29
|
+
case EDIT_BASIC:
|
|
30
|
+
case EDIT_SLIDER: {
|
|
31
|
+
return set([action.meta.slideRef], action.payload, initialState);
|
|
32
|
+
}
|
|
33
|
+
case NEXT_SLIDE: {
|
|
34
|
+
return set([action.payload.nextSlideRef], [], state);
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
return state;
|
|
38
|
+
}
|
|
19
39
|
};
|
|
20
40
|
|
|
21
41
|
export default reducer;
|
package/src/reducers/ui/slide.ts
CHANGED
|
@@ -2,6 +2,7 @@ import compact from 'lodash/fp/compact';
|
|
|
2
2
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
3
|
import pipe from 'lodash/fp/pipe';
|
|
4
4
|
import set from 'lodash/fp/set';
|
|
5
|
+
import unset from 'lodash/fp/unset';
|
|
5
6
|
import {
|
|
6
7
|
EditAnswerAction,
|
|
7
8
|
EDIT_BASIC,
|
|
@@ -14,11 +15,14 @@ import {
|
|
|
14
15
|
import {PostAnswerRequestAction, POST_ANSWER_REQUEST} from '../../actions/api/post-answer';
|
|
15
16
|
import {ReceivedCorrection, CORRECTION_FETCH_SUCCESS} from '../../actions/api/fetch-correction';
|
|
16
17
|
import {FetchSlide, SLIDE_FETCH_REQUEST} from '../../actions/api/fetch-slide';
|
|
18
|
+
import {NextSlide, NEXT_SLIDE} from '../../actions/ui/next-slide';
|
|
19
|
+
import {SlideUIAnimations} from '../../types/slides';
|
|
17
20
|
|
|
18
21
|
export type UISlide = {
|
|
19
22
|
validateButton: boolean;
|
|
20
23
|
animateCorrectionPopin: boolean;
|
|
21
24
|
showCorrectionPopin: boolean;
|
|
25
|
+
animationType?: SlideUIAnimations;
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export type UISlideState = Record<string, UISlide>;
|
|
@@ -28,19 +32,18 @@ export const initialState: UISlideState = {};
|
|
|
28
32
|
const reducer = (
|
|
29
33
|
// eslint-disable-next-line default-param-last
|
|
30
34
|
state: UISlideState = initialState,
|
|
31
|
-
action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection
|
|
35
|
+
action: FetchSlide | PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection | NextSlide
|
|
32
36
|
): UISlideState => {
|
|
33
37
|
switch (action.type) {
|
|
34
38
|
case SLIDE_FETCH_REQUEST: {
|
|
35
|
-
return
|
|
36
|
-
[action.meta.slideRef],
|
|
37
|
-
{
|
|
39
|
+
return pipe(
|
|
40
|
+
unset([action.meta.slideRef, 'animationType']),
|
|
41
|
+
set([action.meta.slideRef], {
|
|
38
42
|
validateButton: false,
|
|
39
43
|
animateCorrectionPopin: false,
|
|
40
44
|
showCorrectionPopin: false
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
);
|
|
45
|
+
})
|
|
46
|
+
)(state);
|
|
44
47
|
}
|
|
45
48
|
case EDIT_QCM:
|
|
46
49
|
case EDIT_QCM_GRAPHIC:
|
|
@@ -63,6 +66,12 @@ const reducer = (
|
|
|
63
66
|
set([action.meta.slideRef, 'showCorrectionPopin'], true)
|
|
64
67
|
)(state);
|
|
65
68
|
}
|
|
69
|
+
case NEXT_SLIDE: {
|
|
70
|
+
return pipe(
|
|
71
|
+
set([action.payload.currentSlideRef, 'animateCorrectionPopin'], false),
|
|
72
|
+
set([action.payload.currentSlideRef, 'animationType'], action.payload.animationType)
|
|
73
|
+
)(state);
|
|
74
|
+
}
|
|
66
75
|
default:
|
|
67
76
|
return state;
|
|
68
77
|
}
|
|
@@ -7,6 +7,7 @@ import {qcmSlide} from '../../../views/slides/test/fixtures/qcm';
|
|
|
7
7
|
import {qcmGraphicSlide} from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
8
8
|
import {sliderSlide} from '../../../views/slides/test/fixtures/slider';
|
|
9
9
|
import {templateSlide} from '../../../views/slides/test/fixtures/template';
|
|
10
|
+
import {NEXT_SLIDE} from '../../../actions/ui/next-slide';
|
|
10
11
|
|
|
11
12
|
test('should have initial value', t => {
|
|
12
13
|
const state = reducer(undefined, {} as EditAnswerAction);
|
|
@@ -84,3 +85,19 @@ test('should set the value of EDIT_TEMPLATE action', t => {
|
|
|
84
85
|
);
|
|
85
86
|
t.deepEqual(state, {[templateSlide.universalRef]: ['value1', 'value2']});
|
|
86
87
|
});
|
|
88
|
+
|
|
89
|
+
test('should set the next slide ref with an empty array if NEXT_SLIDE action is received', t => {
|
|
90
|
+
const state = reducer(
|
|
91
|
+
{'1234': ['Answer'], '5678': ['Other Answer']},
|
|
92
|
+
{
|
|
93
|
+
type: NEXT_SLIDE,
|
|
94
|
+
payload: {
|
|
95
|
+
currentSlideRef: '1234',
|
|
96
|
+
nextSlideRef: '5678',
|
|
97
|
+
animationType: 'unstack'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
t.truthy(state);
|
|
102
|
+
t.deepEqual(state, {'1234': ['Answer'], '5678': []});
|
|
103
|
+
});
|
|
@@ -4,6 +4,7 @@ import {EDIT_BASIC} from '../../../actions/ui/answers';
|
|
|
4
4
|
import {PostAnswerRequestAction, POST_ANSWER_REQUEST} from '../../../actions/api/post-answer';
|
|
5
5
|
import {CORRECTION_FETCH_SUCCESS} from '../../../actions/api/fetch-correction';
|
|
6
6
|
import {SLIDE_FETCH_REQUEST} from '../../../actions/api/fetch-slide';
|
|
7
|
+
import {NEXT_SLIDE} from '../../../actions/ui/next-slide';
|
|
7
8
|
|
|
8
9
|
test('should set validateButton, animateCorrectionPopin and showCorrectionPopin to false if SLIDE_FETCH_REQUEST is received', t => {
|
|
9
10
|
const state = reducer(undefined, {
|
|
@@ -51,6 +52,35 @@ test('should set animateCorrectionPopin to true if CORRECTION_FETCH_SUCCESS is r
|
|
|
51
52
|
t.deepEqual(state, {'1234': {animateCorrectionPopin: true, showCorrectionPopin: true}});
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
test('should set animateCorrectionPopin to false and animationType to unstack or restack if NEXT_SLIDE is received', t => {
|
|
56
|
+
const state = reducer(
|
|
57
|
+
{
|
|
58
|
+
'1234': {
|
|
59
|
+
validateButton: false,
|
|
60
|
+
animateCorrectionPopin: true,
|
|
61
|
+
showCorrectionPopin: true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: NEXT_SLIDE,
|
|
66
|
+
payload: {
|
|
67
|
+
currentSlideRef: '1234',
|
|
68
|
+
nextSlideRef: '5678',
|
|
69
|
+
animationType: 'unstack'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
t.truthy(state);
|
|
74
|
+
t.deepEqual(state, {
|
|
75
|
+
'1234': {
|
|
76
|
+
validateButton: false,
|
|
77
|
+
animateCorrectionPopin: false,
|
|
78
|
+
showCorrectionPopin: true,
|
|
79
|
+
animationType: 'unstack'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
54
84
|
test('should return state directly when there is no corresponding action handler + have an initial state', t => {
|
|
55
85
|
const state = reducer(undefined, {type: 'NOPE'} as unknown as PostAnswerRequestAction);
|
|
56
86
|
t.deepEqual(state, initialState);
|
package/src/types/globals.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare module '*.css';
|
|
2
2
|
declare module 'browser-env';
|
|
3
|
-
declare module '@coorpacademy/components/es
|
|
4
|
-
declare module '@coorpacademy/components/es/template/app-review/template-context';
|
|
3
|
+
declare module '@coorpacademy/components/es/*';
|
|
5
4
|
declare module '@coorpacademy/redux-task';
|