@coorpacademy/app-review 0.2.10-alpha.20 → 0.2.10-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/index.js +6 -3
- package/es/test/index.test.js +8 -1
- package/es/types/common.d.ts +9 -0
- package/es/types/slides.d.ts +1 -2
- package/es/views/slides/index.d.ts +1 -1
- package/es/views/slides/index.js +2 -3
- package/es/views/slides/map-api-slide-to-ui.js +0 -5
- package/es/views/slides/test/fixtures/slider.js +1 -2
- package/es/views/slides/test/index.test.js +11 -11
- package/es/views/slides/test/slide.free-text.on-change.test.js +2 -1
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +2 -1
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +2 -1
- package/es/views/slides/test/slide.qcm.on-click.test.js +2 -1
- package/es/views/slides/test/slide.slider.on-change.test.js +2 -1
- package/es/views/slides/test/slide.template.on-change.test.js +3 -2
- package/lib/index.js +7 -3
- package/lib/test/index.test.js +8 -1
- package/lib/types/common.d.ts +9 -0
- package/lib/types/slides.d.ts +1 -2
- package/lib/views/slides/index.d.ts +1 -1
- package/lib/views/slides/index.js +2 -3
- package/lib/views/slides/map-api-slide-to-ui.js +0 -5
- package/lib/views/slides/test/fixtures/slider.js +1 -2
- package/lib/views/slides/test/index.test.js +11 -11
- package/lib/views/slides/test/slide.free-text.on-change.test.js +2 -1
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.qcm.on-click.test.js +2 -1
- package/lib/views/slides/test/slide.slider.on-change.test.js +2 -1
- package/lib/views/slides/test/slide.template.on-change.test.js +3 -2
- package/package.json +3 -3
- package/src/index.tsx +7 -4
- package/src/test/index.test.tsx +8 -1
- package/src/types/common.ts +11 -0
- package/src/types/slides.ts +1 -2
- package/src/views/slides/index.ts +6 -3
- package/src/views/slides/map-api-slide-to-ui.ts +0 -5
- package/src/views/slides/test/fixtures/slider.ts +1 -2
- package/src/views/slides/test/index.test.ts +11 -11
- package/src/views/slides/test/slide.free-text.on-change.test.ts +2 -1
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.qcm.on-click.test.ts +2 -1
- package/src/views/slides/test/slide.slider.on-change.test.ts +2 -1
- package/src/views/slides/test/slide.template.on-change.test.ts +3 -2
- package/es/actions/ui/next-slide.d.ts +0 -14
- package/es/actions/ui/next-slide.js +0 -15
- package/es/actions/ui/test/next-slide.test.d.ts +0 -1
- package/es/actions/ui/test/next-slide.test.js +0 -63
- package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.slider.on-slider-change.test.js +0 -63
- package/lib/actions/ui/next-slide.d.ts +0 -14
- package/lib/actions/ui/next-slide.js +0 -16
- package/lib/actions/ui/test/next-slide.test.d.ts +0 -1
- package/lib/actions/ui/test/next-slide.test.js +0 -64
- package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.slider.on-slider-change.test.js +0 -65
- package/src/actions/ui/next-slide.ts +0 -31
- package/src/actions/ui/test/next-slide.test.ts +0 -75
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +0 -71
package/es/index.js
CHANGED
|
@@ -11,18 +11,21 @@ import { postProgression } from './actions/api/post-progression';
|
|
|
11
11
|
import { VIEWS } from './common';
|
|
12
12
|
import { mapStateToSlidesProps } from './views/slides';
|
|
13
13
|
import { mapStateToSkillsProps } from './views/skills';
|
|
14
|
-
const ConnectedApp = () => {
|
|
14
|
+
const ConnectedApp = ({ onQuitClick }) => {
|
|
15
15
|
const dispatch = useDispatch();
|
|
16
16
|
const props = {
|
|
17
17
|
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
18
|
-
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch)),
|
|
18
|
+
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
|
|
19
19
|
skills: useSelector((state) => mapStateToSkillsProps(state))
|
|
20
20
|
};
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
console.log(props);
|
|
21
23
|
return React.createElement(AppReviewTemplate, { ...props });
|
|
22
24
|
};
|
|
23
25
|
const AppReview = ({ options }) => {
|
|
24
26
|
const [store, setStore] = useState(null);
|
|
25
27
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
28
|
+
const onQuitClick = get('onQuitClick', options);
|
|
26
29
|
useEffect(() => {
|
|
27
30
|
if (store)
|
|
28
31
|
return;
|
|
@@ -66,6 +69,6 @@ const AppReview = ({ options }) => {
|
|
|
66
69
|
if (!store)
|
|
67
70
|
return null;
|
|
68
71
|
return (React.createElement(Provider, { store: store },
|
|
69
|
-
React.createElement(ConnectedApp,
|
|
72
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
|
|
70
73
|
};
|
|
71
74
|
export default AppReview;
|
package/es/test/index.test.js
CHANGED
|
@@ -36,8 +36,15 @@ const clickAllSlides = async (t, container, accumulator = 0) => {
|
|
|
36
36
|
};
|
|
37
37
|
const appOptions = {
|
|
38
38
|
token: process.env.API_TEST_TOKEN || '',
|
|
39
|
+
templateContext: {
|
|
40
|
+
theme: { color: { primary: '#123' } }
|
|
41
|
+
},
|
|
39
42
|
skillRef: 'skill_NJC0jFKoH',
|
|
40
|
-
services
|
|
43
|
+
services,
|
|
44
|
+
onQuitClick: () => {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.log('onQuitClick - options');
|
|
47
|
+
}
|
|
41
48
|
};
|
|
42
49
|
test('should show the loader while the app is fetching the data', async (t) => {
|
|
43
50
|
t.plan(2);
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare type TemplateContextValues = {
|
|
2
|
+
brandTheme?: unknown;
|
|
3
|
+
theme?: unknown;
|
|
4
|
+
translations?: unknown;
|
|
5
|
+
};
|
|
1
6
|
export declare type ChoiceFromAPI = {
|
|
2
7
|
_id: string;
|
|
3
8
|
id?: string;
|
|
@@ -135,8 +140,12 @@ export declare type Options = {
|
|
|
135
140
|
};
|
|
136
141
|
export declare type AppOptions = {
|
|
137
142
|
token: string;
|
|
143
|
+
theme?: unknown;
|
|
144
|
+
translations?: unknown;
|
|
145
|
+
templateContext?: TemplateContextValues;
|
|
138
146
|
skillRef?: string;
|
|
139
147
|
services: Services;
|
|
148
|
+
onQuitClick: Function;
|
|
140
149
|
};
|
|
141
150
|
export declare type JWT = {
|
|
142
151
|
exp: number;
|
package/es/types/slides.d.ts
CHANGED
|
@@ -44,9 +44,8 @@ export declare type DropDown = {
|
|
|
44
44
|
export declare type QuestionRange = {
|
|
45
45
|
type: 'slider';
|
|
46
46
|
placeholder?: string;
|
|
47
|
-
onChange?:
|
|
47
|
+
onChange?: Function;
|
|
48
48
|
onChangeEnd?: Function;
|
|
49
|
-
onSliderChange?: (value: number) => void;
|
|
50
49
|
multi?: boolean;
|
|
51
50
|
value: number | number[];
|
|
52
51
|
title: string;
|
|
@@ -89,5 +89,5 @@ export declare type SlidesViewProps = {
|
|
|
89
89
|
};
|
|
90
90
|
export declare const initialState: SlidesStack;
|
|
91
91
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
|
92
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps;
|
|
92
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: Function) => SlidesViewProps;
|
|
93
93
|
export {};
|
package/es/views/slides/index.js
CHANGED
|
@@ -163,7 +163,7 @@ const getCorrectionPopinProps = (isCorrect, correctAnswer, klf) => ({
|
|
|
163
163
|
},
|
|
164
164
|
type: isCorrect ? 'right' : 'wrong'
|
|
165
165
|
});
|
|
166
|
-
export const mapStateToSlidesProps = (state, dispatch) => {
|
|
166
|
+
export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
|
|
167
167
|
const currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
168
168
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
169
169
|
const isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
@@ -173,8 +173,7 @@ export const mapStateToSlidesProps = (state, dispatch) => {
|
|
|
173
173
|
mode: '__revision_mode',
|
|
174
174
|
skillName: '__agility',
|
|
175
175
|
onQuitClick: () => {
|
|
176
|
-
|
|
177
|
-
console.log('onQuitClick');
|
|
176
|
+
onQuitClick();
|
|
178
177
|
},
|
|
179
178
|
'aria-label': 'aria-header-wrapper',
|
|
180
179
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -132,13 +132,8 @@ const sliderProps = (dispatch) => (answers, question) => {
|
|
|
132
132
|
title: `${currentValue} ${question.content.unitLabel}`,
|
|
133
133
|
value: sliderPosition,
|
|
134
134
|
onChange: (position) => {
|
|
135
|
-
// atom/range handler
|
|
136
135
|
const newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
137
136
|
dispatch(editAnswer([newValue]));
|
|
138
|
-
},
|
|
139
|
-
onSliderChange: (newValue) => {
|
|
140
|
-
// mobile/slider handler
|
|
141
|
-
dispatch(editAnswer([`${newValue}`]));
|
|
142
137
|
}
|
|
143
138
|
};
|
|
144
139
|
};
|
|
@@ -57,7 +57,7 @@ test('should create initial props when fetched slide is not still received', t =
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
60
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
61
61
|
t.is(props.congratsProps, undefined);
|
|
62
62
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
63
63
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -146,7 +146,7 @@ test('should create props when first slide is on the state', t => {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
149
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
150
150
|
t.is(props.congratsProps, undefined);
|
|
151
151
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
152
152
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -248,7 +248,7 @@ test('should create props when slide is on the state and user has selected answe
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
251
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
252
252
|
t.is(props.congratsProps, undefined);
|
|
253
253
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
254
254
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -351,7 +351,7 @@ test('should verify props when first slide was answered correctly and next slide
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
};
|
|
354
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
354
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
355
355
|
t.is(props.congratsProps, undefined);
|
|
356
356
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
357
357
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -454,7 +454,7 @@ test('should verify props when first slide was answered with error and next slid
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
457
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
458
458
|
t.is(props.congratsProps, undefined);
|
|
459
459
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
460
460
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -517,7 +517,7 @@ test('should verify props when first slide was answered, next slide is fetched &
|
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
};
|
|
520
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
520
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
521
521
|
t.is(props.congratsProps, undefined);
|
|
522
522
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
523
523
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -628,7 +628,7 @@ test('should verify props when first slide was answered incorrectly, next slide
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
631
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
632
632
|
t.is(props.congratsProps, undefined);
|
|
633
633
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
634
634
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -737,7 +737,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
};
|
|
740
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
740
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
741
741
|
t.is(props.congratsProps, undefined);
|
|
742
742
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
743
743
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -806,7 +806,7 @@ test('should verify props when progression is in success', t => {
|
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
809
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
810
810
|
t.is(props.congratsProps, undefined);
|
|
811
811
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
812
812
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -875,7 +875,7 @@ test('should verify props when progression has answered a current pendingSlide',
|
|
|
875
875
|
}
|
|
876
876
|
}
|
|
877
877
|
};
|
|
878
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
878
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
879
879
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
880
880
|
'aria-label': 'aria-header-wrapper',
|
|
881
881
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -942,7 +942,7 @@ test('should verify props when progression still has a pendingSlide', t => {
|
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
944
|
};
|
|
945
|
-
const props = mapStateToSlidesProps(state, identity);
|
|
945
|
+
const props = mapStateToSlidesProps(state, identity, identity);
|
|
946
946
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
947
947
|
'aria-label': 'aria-header-wrapper',
|
|
948
948
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -56,7 +57,7 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
|
|
|
56
57
|
}
|
|
57
58
|
];
|
|
58
59
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
59
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
60
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
60
61
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
62
|
animateCorrectionPopin: false,
|
|
62
63
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -56,7 +57,7 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
|
|
|
56
57
|
}
|
|
57
58
|
];
|
|
58
59
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
59
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
60
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
60
61
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
62
|
animateCorrectionPopin: false,
|
|
62
63
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -56,7 +57,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
|
|
|
56
57
|
}
|
|
57
58
|
];
|
|
58
59
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
59
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
60
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
60
61
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
62
|
animateCorrectionPopin: false,
|
|
62
63
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -58,7 +59,7 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
|
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
61
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
61
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
62
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
62
63
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
64
|
animateCorrectionPopin: false,
|
|
64
65
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -56,7 +57,7 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
|
|
|
56
57
|
}
|
|
57
58
|
];
|
|
58
59
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
59
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
60
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
60
61
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
62
|
animateCorrectionPopin: false,
|
|
62
63
|
showCorrectionPopin: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import omit from 'lodash/fp/omit';
|
|
3
3
|
import get from 'lodash/fp/get';
|
|
4
|
+
import identity from 'lodash/fp/identity';
|
|
4
5
|
import { mapStateToSlidesProps } from '..';
|
|
5
6
|
import { services } from '../../../test/util/services.mock';
|
|
6
7
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -51,7 +52,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
51
52
|
t.plan(2);
|
|
52
53
|
const expectedActions = [{ type: EDIT_TEMPLATE, payload: ['', 'test', ''] }];
|
|
53
54
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
54
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
55
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
55
56
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
56
57
|
animateCorrectionPopin: false,
|
|
57
58
|
showCorrectionPopin: false,
|
|
@@ -69,7 +70,7 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
69
70
|
t.plan(2);
|
|
70
71
|
const expectedActions = [{ type: EDIT_TEMPLATE, payload: ['Catalogue', '', ''] }];
|
|
71
72
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
72
|
-
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
73
|
+
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
73
74
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
74
75
|
animateCorrectionPopin: false,
|
|
75
76
|
showCorrectionPopin: false,
|
package/lib/index.js
CHANGED
|
@@ -22,19 +22,23 @@ import { postProgression } from './actions/api/post-progression';
|
|
|
22
22
|
import { VIEWS } from './common';
|
|
23
23
|
import { mapStateToSlidesProps } from './views/slides';
|
|
24
24
|
import { mapStateToSkillsProps } from './views/skills';
|
|
25
|
-
var ConnectedApp = function () {
|
|
25
|
+
var ConnectedApp = function (_a) {
|
|
26
|
+
var onQuitClick = _a.onQuitClick;
|
|
26
27
|
var dispatch = useDispatch();
|
|
27
28
|
var props = {
|
|
28
29
|
viewName: useSelector(function (state) { return state.ui.navigation[state.ui.navigation.length - 1]; }),
|
|
29
|
-
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch); }),
|
|
30
|
+
slides: useSelector(function (state) { return mapStateToSlidesProps(state, dispatch, onQuitClick); }),
|
|
30
31
|
skills: useSelector(function (state) { return mapStateToSkillsProps(state); })
|
|
31
32
|
};
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log(props);
|
|
32
35
|
return React.createElement(AppReviewTemplate, __assign({}, props));
|
|
33
36
|
};
|
|
34
37
|
var AppReview = function (_a) {
|
|
35
38
|
var options = _a.options;
|
|
36
39
|
var _b = useState(null), store = _b[0], setStore = _b[1];
|
|
37
40
|
var _c = useState(false), isProgressionCreated = _c[0], setIsProgressionCreated = _c[1];
|
|
41
|
+
var onQuitClick = get('onQuitClick', options);
|
|
38
42
|
useEffect(function () {
|
|
39
43
|
if (store)
|
|
40
44
|
return;
|
|
@@ -78,6 +82,6 @@ var AppReview = function (_a) {
|
|
|
78
82
|
if (!store)
|
|
79
83
|
return null;
|
|
80
84
|
return (React.createElement(Provider, { store: store },
|
|
81
|
-
React.createElement(ConnectedApp,
|
|
85
|
+
React.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
|
|
82
86
|
};
|
|
83
87
|
export default AppReview;
|
package/lib/test/index.test.js
CHANGED
|
@@ -132,8 +132,15 @@ var clickAllSlides = function (t, container, accumulator) {
|
|
|
132
132
|
};
|
|
133
133
|
var appOptions = {
|
|
134
134
|
token: process.env.API_TEST_TOKEN || '',
|
|
135
|
+
templateContext: {
|
|
136
|
+
theme: { color: { primary: '#123' } }
|
|
137
|
+
},
|
|
135
138
|
skillRef: 'skill_NJC0jFKoH',
|
|
136
|
-
services: services
|
|
139
|
+
services: services,
|
|
140
|
+
onQuitClick: function () {
|
|
141
|
+
// eslint-disable-next-line no-console
|
|
142
|
+
console.log('onQuitClick - options');
|
|
143
|
+
}
|
|
137
144
|
};
|
|
138
145
|
test('should show the loader while the app is fetching the data', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
146
|
var container, loader;
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
declare type TemplateContextValues = {
|
|
2
|
+
brandTheme?: unknown;
|
|
3
|
+
theme?: unknown;
|
|
4
|
+
translations?: unknown;
|
|
5
|
+
};
|
|
1
6
|
export declare type ChoiceFromAPI = {
|
|
2
7
|
_id: string;
|
|
3
8
|
id?: string;
|
|
@@ -135,8 +140,12 @@ export declare type Options = {
|
|
|
135
140
|
};
|
|
136
141
|
export declare type AppOptions = {
|
|
137
142
|
token: string;
|
|
143
|
+
theme?: unknown;
|
|
144
|
+
translations?: unknown;
|
|
145
|
+
templateContext?: TemplateContextValues;
|
|
138
146
|
skillRef?: string;
|
|
139
147
|
services: Services;
|
|
148
|
+
onQuitClick: Function;
|
|
140
149
|
};
|
|
141
150
|
export declare type JWT = {
|
|
142
151
|
exp: number;
|
package/lib/types/slides.d.ts
CHANGED
|
@@ -44,9 +44,8 @@ export declare type DropDown = {
|
|
|
44
44
|
export declare type QuestionRange = {
|
|
45
45
|
type: 'slider';
|
|
46
46
|
placeholder?: string;
|
|
47
|
-
onChange?:
|
|
47
|
+
onChange?: Function;
|
|
48
48
|
onChangeEnd?: Function;
|
|
49
|
-
onSliderChange?: (value: number) => void;
|
|
50
49
|
multi?: boolean;
|
|
51
50
|
value: number | number[];
|
|
52
51
|
title: string;
|
|
@@ -89,5 +89,5 @@ export declare type SlidesViewProps = {
|
|
|
89
89
|
};
|
|
90
90
|
export declare const initialState: SlidesStack;
|
|
91
91
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
|
92
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps;
|
|
92
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: Function) => SlidesViewProps;
|
|
93
93
|
export {};
|
|
@@ -167,7 +167,7 @@ var getCorrectionPopinProps = function (isCorrect, correctAnswer, klf) { return
|
|
|
167
167
|
},
|
|
168
168
|
type: isCorrect ? 'right' : 'wrong'
|
|
169
169
|
}); };
|
|
170
|
-
export var mapStateToSlidesProps = function (state, dispatch) {
|
|
170
|
+
export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
|
|
171
171
|
var currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
172
172
|
var correction = get(['data', 'corrections', currentSlideRef], state);
|
|
173
173
|
var isCorrect = get(['data', 'progression', 'state', 'isCorrect'], state);
|
|
@@ -177,8 +177,7 @@ export var mapStateToSlidesProps = function (state, dispatch) {
|
|
|
177
177
|
mode: '__revision_mode',
|
|
178
178
|
skillName: '__agility',
|
|
179
179
|
onQuitClick: function () {
|
|
180
|
-
|
|
181
|
-
console.log('onQuitClick');
|
|
180
|
+
onQuitClick();
|
|
182
181
|
},
|
|
183
182
|
'aria-label': 'aria-header-wrapper',
|
|
184
183
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -145,13 +145,8 @@ var sliderProps = function (dispatch) {
|
|
|
145
145
|
title: "".concat(currentValue, " ").concat(question.content.unitLabel),
|
|
146
146
|
value: sliderPosition,
|
|
147
147
|
onChange: function (position) {
|
|
148
|
-
// atom/range handler
|
|
149
148
|
var newValue = pipe(multiply(maxValue), round, get(__, values), _toString)(position);
|
|
150
149
|
dispatch(editAnswer([newValue]));
|
|
151
|
-
},
|
|
152
|
-
onSliderChange: function (newValue) {
|
|
153
|
-
// mobile/slider handler
|
|
154
|
-
dispatch(editAnswer(["".concat(newValue)]));
|
|
155
150
|
}
|
|
156
151
|
};
|
|
157
152
|
};
|
|
@@ -62,7 +62,7 @@ test('should create initial props when fetched slide is not still received', fun
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
65
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
66
66
|
t.is(props.congratsProps, undefined);
|
|
67
67
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
68
68
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -151,7 +151,7 @@ test('should create props when first slide is on the state', function (t) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
154
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
155
155
|
t.is(props.congratsProps, undefined);
|
|
156
156
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
157
157
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -253,7 +253,7 @@ test('should create props when slide is on the state and user has selected answe
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
256
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
257
257
|
t.is(props.congratsProps, undefined);
|
|
258
258
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
259
259
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -356,7 +356,7 @@ test('should verify props when first slide was answered correctly and next slide
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
359
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
360
360
|
t.is(props.congratsProps, undefined);
|
|
361
361
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
362
362
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -459,7 +459,7 @@ test('should verify props when first slide was answered with error and next slid
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
462
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
463
463
|
t.is(props.congratsProps, undefined);
|
|
464
464
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
465
465
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -523,7 +523,7 @@ test('should verify props when first slide was answered, next slide is fetched &
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
526
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
527
527
|
t.is(props.congratsProps, undefined);
|
|
528
528
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
529
529
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -635,7 +635,7 @@ test('should verify props when first slide was answered incorrectly, next slide
|
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
};
|
|
638
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
638
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
639
639
|
t.is(props.congratsProps, undefined);
|
|
640
640
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
641
641
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -745,7 +745,7 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
|
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
};
|
|
748
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
748
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
749
749
|
t.is(props.congratsProps, undefined);
|
|
750
750
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
751
751
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -815,7 +815,7 @@ test('should verify props when progression is in success', function (t) {
|
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
};
|
|
818
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
818
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
819
819
|
t.is(props.congratsProps, undefined);
|
|
820
820
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
821
821
|
'aria-label': 'aria-header-wrapper',
|
|
@@ -885,7 +885,7 @@ test('should verify props when progression has answered a current pendingSlide',
|
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
887
|
};
|
|
888
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
888
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
889
889
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
890
890
|
'aria-label': 'aria-header-wrapper',
|
|
891
891
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -953,7 +953,7 @@ test('should verify props when progression still has a pendingSlide', function (
|
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
955
|
};
|
|
956
|
-
var props = mapStateToSlidesProps(state, identity);
|
|
956
|
+
var props = mapStateToSlidesProps(state, identity, identity);
|
|
957
957
|
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
958
958
|
'aria-label': 'aria-header-wrapper',
|
|
959
959
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -58,7 +59,7 @@ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text
|
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
61
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
61
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
62
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
62
63
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
64
|
animateCorrectionPopin: false,
|
|
64
65
|
showCorrectionPopin: false,
|
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -58,7 +59,7 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
|
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
61
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
61
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
62
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
62
63
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
64
|
animateCorrectionPopin: false,
|
|
64
65
|
showCorrectionPopin: false,
|
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import omit from 'lodash/fp/omit';
|
|
4
4
|
import get from 'lodash/fp/get';
|
|
5
|
+
import identity from 'lodash/fp/identity';
|
|
5
6
|
import { mapStateToSlidesProps } from '..';
|
|
6
7
|
import { services } from '../../../test/util/services.mock';
|
|
7
8
|
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
@@ -58,7 +59,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
|
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
61
|
var _b = createTestStore(t, initialState, services, expectedActions), dispatch = _b.dispatch, getState = _b.getState;
|
|
61
|
-
var props = mapStateToSlidesProps(getState(), dispatch);
|
|
62
|
+
var props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
62
63
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
64
|
animateCorrectionPopin: false,
|
|
64
65
|
showCorrectionPopin: false,
|