@coorpacademy/app-review 0.7.7-alpha.61 → 0.8.0
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 +1 -1
- package/es/reducers/data/index.d.ts +1 -4
- package/es/reducers/data/index.js +1 -10
- package/es/reducers/index.d.ts +1 -2
- package/es/services/fetch-skill.js +1 -2
- package/es/types/common.d.ts +2 -5
- package/es/views/skills/index.d.ts +23 -3
- package/es/views/skills/index.js +11 -17
- package/es/views/slides/index.js +10 -18
- package/es/views/slides/map-api-slide-to-ui.d.ts +2 -2
- package/es/views/slides/map-api-slide-to-ui.js +11 -14
- package/lib/index.js +1 -1
- package/lib/reducers/data/index.d.ts +1 -4
- package/lib/reducers/data/index.js +1 -10
- package/lib/reducers/index.d.ts +1 -2
- package/lib/services/fetch-skill.js +1 -2
- package/lib/types/common.d.ts +2 -5
- package/lib/views/skills/index.d.ts +23 -3
- package/lib/views/skills/index.js +11 -17
- package/lib/views/slides/index.js +10 -18
- package/lib/views/slides/map-api-slide-to-ui.d.ts +2 -2
- package/lib/views/slides/map-api-slide-to-ui.js +11 -14
- package/locales/cs/review.json +1 -4
- package/locales/de/review.json +1 -4
- package/locales/en/review.json +11 -10
- package/locales/es/review.json +1 -4
- package/locales/fr/review.json +1 -4
- package/locales/hr/review.json +1 -4
- package/locales/hu/review.json +1 -4
- package/locales/id/review.json +1 -4
- package/locales/it/review.json +1 -4
- package/locales/ja/review.json +1 -4
- package/locales/ko/review.json +1 -4
- package/locales/nl/review.json +1 -4
- package/locales/pl/review.json +1 -4
- package/locales/pt/review.json +1 -4
- package/locales/ro/review.json +1 -4
- package/locales/ru/review.json +1 -4
- package/locales/sk/review.json +1 -4
- package/locales/th/review.json +1 -4
- package/locales/tl/review.json +1 -4
- package/locales/tr/review.json +1 -4
- package/locales/uk/review.json +1 -4
- package/locales/vi/review.json +1 -4
- package/locales/zh/review.json +1 -4
- package/locales/zh_TW/review.json +1 -4
- package/package.json +5 -5
- package/es/reducers/data/current-skill.d.ts +0 -5
- package/es/reducers/data/current-skill.js +0 -13
- package/lib/reducers/data/current-skill.d.ts +0 -5
- package/lib/reducers/data/current-skill.js +0 -15
- package/locales/.mtslconfig.json +0 -1
package/es/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const ConnectedApp = (options) => {
|
|
|
15
15
|
const props = {
|
|
16
16
|
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
17
17
|
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, options)),
|
|
18
|
-
skills: useSelector((state) => mapStateToSkillsProps(state
|
|
18
|
+
skills: useSelector((state) => mapStateToSkillsProps(state)),
|
|
19
19
|
navigateBack: () => dispatch(navigateBack),
|
|
20
20
|
onboarding: {}
|
|
21
21
|
};
|
|
@@ -4,7 +4,6 @@ import { SkillsState } from './skills';
|
|
|
4
4
|
import { SlidesState } from './slides';
|
|
5
5
|
import { TokenState } from './token';
|
|
6
6
|
import { RankState } from './rank';
|
|
7
|
-
import { CurrentSkillState } from './current-skill';
|
|
8
7
|
export declare type DataState = {
|
|
9
8
|
corrections: CorrectionsState;
|
|
10
9
|
progression: ProgressionState;
|
|
@@ -12,7 +11,6 @@ export declare type DataState = {
|
|
|
12
11
|
slides: SlidesState;
|
|
13
12
|
token: TokenState;
|
|
14
13
|
rank: RankState;
|
|
15
|
-
currentSkill: CurrentSkillState;
|
|
16
14
|
};
|
|
17
15
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
18
16
|
corrections: CorrectionsState;
|
|
@@ -21,6 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
21
19
|
slides: SlidesState;
|
|
22
20
|
token: string;
|
|
23
21
|
rank: RankState;
|
|
24
|
-
|
|
25
|
-
}>, import("../../actions/api/fetch-skill").ReceivedSkill | import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
22
|
+
}>, import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
26
23
|
export default _default;
|
|
@@ -5,13 +5,4 @@ import skills from './skills';
|
|
|
5
5
|
import slides from './slides';
|
|
6
6
|
import token from './token';
|
|
7
7
|
import rank from './rank';
|
|
8
|
-
|
|
9
|
-
export default combineReducers({
|
|
10
|
-
corrections,
|
|
11
|
-
progression,
|
|
12
|
-
skills,
|
|
13
|
-
slides,
|
|
14
|
-
token,
|
|
15
|
-
rank,
|
|
16
|
-
currentSkill
|
|
17
|
-
});
|
|
8
|
+
export default combineReducers({ corrections, progression, skills, slides, token, rank });
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
12
12
|
slides: import("./data/slides").SlidesState;
|
|
13
13
|
token: string;
|
|
14
14
|
rank: import("./data/rank").RankState;
|
|
15
|
-
currentSkill: import("./data/current-skill").CurrentSkillState;
|
|
16
15
|
}>;
|
|
17
16
|
ui: import("redux").CombinedState<{
|
|
18
17
|
currentSlideRef: string;
|
|
@@ -24,7 +23,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
24
23
|
showButtonRevising: boolean;
|
|
25
24
|
showCongrats: boolean;
|
|
26
25
|
}>;
|
|
27
|
-
}>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/
|
|
26
|
+
}>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
|
|
28
27
|
type: "@@ui/OPEN_POPIN";
|
|
29
28
|
} | {
|
|
30
29
|
type: "@@ui/CLOSE_POPIN";
|
|
@@ -6,6 +6,5 @@ export const fetchSkill = async (skillRef, token) => {
|
|
|
6
6
|
const response = await crossFetch(`${host}/api/v2/skills?conditions={"ref":"${skillRef}"}`, {
|
|
7
7
|
headers: { authorization: token }
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
return skills[0];
|
|
9
|
+
return toJSON(response);
|
|
11
10
|
};
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
|
|
2
|
-
export interface Translate {
|
|
3
|
-
(key: string, data?: Record<string, string>): string;
|
|
4
|
-
}
|
|
5
2
|
export declare type ChoiceFromAPI = {
|
|
6
3
|
_id: string;
|
|
7
4
|
id?: string;
|
|
@@ -149,13 +146,13 @@ export declare type Options = {
|
|
|
149
146
|
services: Services;
|
|
150
147
|
};
|
|
151
148
|
export declare type ConnectedOptions = {
|
|
152
|
-
translate:
|
|
149
|
+
translate: (key: string, data?: unknown) => string;
|
|
153
150
|
onQuitClick: () => void;
|
|
154
151
|
};
|
|
155
152
|
export declare type AppOptions = ConnectedOptions & {
|
|
156
153
|
token: string;
|
|
157
154
|
skillRef?: string;
|
|
158
|
-
services
|
|
155
|
+
services: Services;
|
|
159
156
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
160
157
|
};
|
|
161
158
|
export declare type ThunkOptions = {
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
|
|
2
1
|
import { StoreState } from '../../reducers';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare type SkillCard = {
|
|
3
|
+
'aria-label': string;
|
|
4
|
+
skillTitle: string;
|
|
5
|
+
skillAriaLabel: string;
|
|
6
|
+
buttonLabel: string;
|
|
7
|
+
buttonAriaLabel: string;
|
|
8
|
+
reviseLabel: string;
|
|
9
|
+
reviseAriaLabel: string;
|
|
10
|
+
isCustom: boolean;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare type NoSkillsProps = {
|
|
14
|
+
iconSkillAriaLabel: string;
|
|
15
|
+
};
|
|
16
|
+
declare type SkillsProps = NoSkillsProps & {
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
isLoadingAriaLabel: string;
|
|
21
|
+
listSkills: SkillCard[];
|
|
22
|
+
};
|
|
23
|
+
export { SkillsProps };
|
|
24
|
+
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
|
package/es/views/skills/index.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
export const mapStateToSkillsProps = (state
|
|
2
|
-
const { translate } = options;
|
|
1
|
+
export const mapStateToSkillsProps = (state) => {
|
|
3
2
|
return {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
title: '@todo title',
|
|
4
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
6
5
|
isLoading: false,
|
|
7
|
-
isLoadingAriaLabel: '
|
|
6
|
+
isLoadingAriaLabel: '@todo loading',
|
|
8
7
|
listSkills: state.data.skills.map(skill => ({
|
|
9
|
-
'aria-label':
|
|
8
|
+
'aria-label': '',
|
|
10
9
|
isCustom: skill.custom,
|
|
11
10
|
skillTitle: skill.name,
|
|
12
|
-
skillAriaLabel: skill
|
|
13
|
-
buttonLabel:
|
|
14
|
-
buttonAriaLabel:
|
|
15
|
-
reviseLabel:
|
|
16
|
-
reviseAriaLabel:
|
|
17
|
-
count: `${skill.slidesToReview}`
|
|
18
|
-
}),
|
|
11
|
+
skillAriaLabel: '@todo skill aria label',
|
|
12
|
+
buttonLabel: '@todo button',
|
|
13
|
+
buttonAriaLabel: '@todo button aria label',
|
|
14
|
+
reviseLabel: '@todo revise',
|
|
15
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
19
16
|
// eslint-disable-next-line no-console
|
|
20
17
|
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
21
|
-
}))
|
|
22
|
-
titleNoSkills: translate('No skill to revise'),
|
|
23
|
-
textNoSkills: translate('Complete courses before revising'),
|
|
24
|
-
iconSkillAriaLabel: 'Image without information'
|
|
18
|
+
}))
|
|
25
19
|
};
|
|
26
20
|
};
|
package/es/views/slides/index.js
CHANGED
|
@@ -60,9 +60,6 @@ const getCurrentSlideRef = (state) => {
|
|
|
60
60
|
const content = progression.state.content;
|
|
61
61
|
return content.ref;
|
|
62
62
|
};
|
|
63
|
-
const isLastSlideAnswered = (slidesRef, slideRef) => {
|
|
64
|
-
return last(slidesRef) === slideRef;
|
|
65
|
-
};
|
|
66
63
|
const buildStackSlides = (state, dispatch, options) => {
|
|
67
64
|
const { translate } = options;
|
|
68
65
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
@@ -73,25 +70,22 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
73
70
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
74
71
|
const stack = reduce.convert({ cap: false })((acc, uiSlide, _index) => {
|
|
75
72
|
const index = toInteger(_index);
|
|
76
|
-
const slideRef = slideRefs[index];
|
|
77
|
-
const lastAnsweredSlideRef = isLastSlideAnswered(progression.state.slides, slideRef);
|
|
78
73
|
const positions = state.ui.positions;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const position = lastAnsweredSlideRef && positions[index] === -1 ? 0 : positions[index];
|
|
74
|
+
const position = positions[index];
|
|
75
|
+
const slideRef = slideRefs[index];
|
|
82
76
|
if (!slideRef)
|
|
83
77
|
return set(index, { ...uiSlide, position }, acc);
|
|
84
78
|
const slideFromAPI = get(slideRef, state.data.slides);
|
|
85
79
|
if (!slideFromAPI)
|
|
86
80
|
return set(index, { ...uiSlide, position }, acc);
|
|
87
81
|
const answers = getOr([], ['ui', 'answers', slideRef], state);
|
|
88
|
-
const { questionText, answerUI } = mapApiSlideToUi(dispatch
|
|
82
|
+
const { questionText, answerUI } = mapApiSlideToUi(dispatch)(slideFromAPI, answers);
|
|
89
83
|
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
90
84
|
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
91
85
|
const slideUI = get(['ui', 'slide', slideRef], state);
|
|
92
86
|
const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
|
|
93
87
|
const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
|
|
94
|
-
const animationType =
|
|
88
|
+
const animationType = slideUI.animationType;
|
|
95
89
|
const updatedUiSlide = {
|
|
96
90
|
...uiSlide,
|
|
97
91
|
position,
|
|
@@ -177,8 +171,7 @@ export const buildStepItems = (state) => {
|
|
|
177
171
|
});
|
|
178
172
|
return steps;
|
|
179
173
|
};
|
|
180
|
-
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate
|
|
181
|
-
const nextLabel = endReview ? translate('Continue') : translate('Next Question');
|
|
174
|
+
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate) => {
|
|
182
175
|
return {
|
|
183
176
|
klf: isCorrect
|
|
184
177
|
? undefined
|
|
@@ -189,11 +182,11 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
|
|
|
189
182
|
resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
|
|
190
183
|
information: {
|
|
191
184
|
label: isCorrect ? translate('KLF') : translate('Correct Answer'),
|
|
192
|
-
message: isCorrect ? klf : join(',
|
|
185
|
+
message: isCorrect ? klf : join(',', correctAnswer)
|
|
193
186
|
},
|
|
194
187
|
next: {
|
|
195
|
-
'aria-label':
|
|
196
|
-
label:
|
|
188
|
+
'aria-label': translate('Next Question'),
|
|
189
|
+
label: translate('Next Question'),
|
|
197
190
|
onClick: () => {
|
|
198
191
|
dispatch(nextSlide);
|
|
199
192
|
}
|
|
@@ -320,11 +313,10 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
320
313
|
const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
321
314
|
const showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
322
315
|
const showCongrats = get(['ui', 'showCongrats'], state);
|
|
323
|
-
const skillName = getOr('', ['data', 'currentSkill', 'name'], state);
|
|
324
316
|
return {
|
|
325
317
|
header: {
|
|
326
318
|
mode: translate('Review Title'),
|
|
327
|
-
skillName,
|
|
319
|
+
skillName: '__agility',
|
|
328
320
|
onQuitClick: () => dispatch(openQuitPopin),
|
|
329
321
|
'aria-label': 'aria-header-wrapper',
|
|
330
322
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -341,7 +333,7 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
341
333
|
}
|
|
342
334
|
},
|
|
343
335
|
correctionPopinProps: correction &&
|
|
344
|
-
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate
|
|
336
|
+
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
|
|
345
337
|
endReview: endReview && state.ui.showCongrats
|
|
346
338
|
},
|
|
347
339
|
congrats: buildCongratsProps(state, dispatch, options),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
2
|
import { AnswerUI } from '../../types/slides';
|
|
3
|
-
import { Question, SlideFromAPI
|
|
3
|
+
import { Question, SlideFromAPI } from '../../types/common';
|
|
4
4
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
5
|
-
export declare const mapApiSlideToUi: (dispatch: Dispatch
|
|
5
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch) => (slide: SlideFromAPI, answers: string[]) => {
|
|
6
6
|
questionText: string;
|
|
7
7
|
answerUI: AnswerUI;
|
|
8
8
|
};
|
|
@@ -54,11 +54,11 @@ const updateTemplateAnswer = (text, _answers, index, max) => {
|
|
|
54
54
|
const answers = isEmpty(_answers) ? times(constant(undefined), max) : _answers;
|
|
55
55
|
return map(a => (isNil(a) ? '' : a), set(index, text, answers));
|
|
56
56
|
};
|
|
57
|
-
const templateTextProps = (dispatch,
|
|
57
|
+
const templateTextProps = (dispatch, answers, choice, index, maxLength) => {
|
|
58
58
|
return {
|
|
59
59
|
type: 'text',
|
|
60
60
|
name: getOr('', 'name', choice),
|
|
61
|
-
placeholder:
|
|
61
|
+
placeholder: 'Type here',
|
|
62
62
|
value: get(index, answers),
|
|
63
63
|
onChange: (text) => {
|
|
64
64
|
const newAnswers = updateTemplateAnswer(text, answers, index, maxLength);
|
|
@@ -66,10 +66,10 @@ const templateTextProps = (dispatch, translate, answers, choice, index, maxLengt
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
const templateSelectProps = (dispatch,
|
|
69
|
+
const templateSelectProps = (dispatch, answers, choice, index, maxLength) => {
|
|
70
70
|
const answer = get(index, answers);
|
|
71
71
|
const temporaryOption = {
|
|
72
|
-
name:
|
|
72
|
+
name: 'Select an answer',
|
|
73
73
|
value: '',
|
|
74
74
|
validOption: false,
|
|
75
75
|
selected: true
|
|
@@ -93,15 +93,15 @@ const templateSelectProps = (dispatch, translate, answers, choice, index, maxLen
|
|
|
93
93
|
options: isEmpty(answer) ? concat([temporaryOption], selectOptions) : selectOptions
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
const templateProps = (dispatch
|
|
96
|
+
const templateProps = (dispatch) => (answers, question) => {
|
|
97
97
|
const choices = question.content.choices;
|
|
98
98
|
const maxLength = size(choices);
|
|
99
99
|
return {
|
|
100
100
|
type: 'template',
|
|
101
101
|
template: get('content.template', question),
|
|
102
102
|
answers: choices.map((choice, index) => choice.type === 'text'
|
|
103
|
-
? templateTextProps(dispatch,
|
|
104
|
-
: templateSelectProps(dispatch,
|
|
103
|
+
? templateTextProps(dispatch, answers, choice, index, maxLength)
|
|
104
|
+
: templateSelectProps(dispatch, answers, choice, index, maxLength))
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
const basicProps = (dispatch) => (answers, question) => {
|
|
@@ -144,7 +144,7 @@ const sliderProps = (dispatch) => (answers, question) => {
|
|
|
144
144
|
};
|
|
145
145
|
export const getQuestionType = (question) => question.type;
|
|
146
146
|
const getHelp = (slide) => get('question.explanation', slide);
|
|
147
|
-
const getAnswerUIModel = (question, answers, dispatch
|
|
147
|
+
const getAnswerUIModel = (question, answers, dispatch) => {
|
|
148
148
|
const type = getQuestionType(question);
|
|
149
149
|
switch (type) {
|
|
150
150
|
case 'qcm':
|
|
@@ -156,20 +156,17 @@ const getAnswerUIModel = (question, answers, dispatch, translate) => {
|
|
|
156
156
|
case 'basic':
|
|
157
157
|
return basicProps(dispatch)(answers, question);
|
|
158
158
|
case 'template':
|
|
159
|
-
return templateProps(dispatch
|
|
159
|
+
return templateProps(dispatch)(answers, question);
|
|
160
160
|
case 'slider':
|
|
161
161
|
return sliderProps(dispatch)(answers, question);
|
|
162
162
|
default:
|
|
163
163
|
throw new Error(`${type} is not an handled question.type`);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
export const mapApiSlideToUi = (dispatch
|
|
166
|
+
export const mapApiSlideToUi = (dispatch) => (slide, answers) => {
|
|
167
167
|
const questionText = getOr('', 'question.header', slide);
|
|
168
168
|
return {
|
|
169
169
|
questionText,
|
|
170
|
-
answerUI: {
|
|
171
|
-
model: getAnswerUIModel(slide.question, answers, dispatch, translate),
|
|
172
|
-
help: getHelp(slide)
|
|
173
|
-
}
|
|
170
|
+
answerUI: { model: getAnswerUIModel(slide.question, answers, dispatch), help: getHelp(slide) }
|
|
174
171
|
};
|
|
175
172
|
};
|
package/lib/index.js
CHANGED
|
@@ -43,7 +43,7 @@ const ConnectedApp = (options) => {
|
|
|
43
43
|
const props = {
|
|
44
44
|
viewName: (0, react_redux_1.useSelector)((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
45
45
|
slides: (0, react_redux_1.useSelector)((state) => (0, slides_1.mapStateToSlidesProps)(state, dispatch, options)),
|
|
46
|
-
skills: (0, react_redux_1.useSelector)((state) => (0, skills_1.mapStateToSkillsProps)(state
|
|
46
|
+
skills: (0, react_redux_1.useSelector)((state) => (0, skills_1.mapStateToSkillsProps)(state)),
|
|
47
47
|
navigateBack: () => dispatch(navigation_1.navigateBack),
|
|
48
48
|
onboarding: {}
|
|
49
49
|
};
|
|
@@ -4,7 +4,6 @@ import { SkillsState } from './skills';
|
|
|
4
4
|
import { SlidesState } from './slides';
|
|
5
5
|
import { TokenState } from './token';
|
|
6
6
|
import { RankState } from './rank';
|
|
7
|
-
import { CurrentSkillState } from './current-skill';
|
|
8
7
|
export declare type DataState = {
|
|
9
8
|
corrections: CorrectionsState;
|
|
10
9
|
progression: ProgressionState;
|
|
@@ -12,7 +11,6 @@ export declare type DataState = {
|
|
|
12
11
|
slides: SlidesState;
|
|
13
12
|
token: TokenState;
|
|
14
13
|
rank: RankState;
|
|
15
|
-
currentSkill: CurrentSkillState;
|
|
16
14
|
};
|
|
17
15
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
18
16
|
corrections: CorrectionsState;
|
|
@@ -21,6 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
21
19
|
slides: SlidesState;
|
|
22
20
|
token: string;
|
|
23
21
|
rank: RankState;
|
|
24
|
-
|
|
25
|
-
}>, import("../../actions/api/fetch-skill").ReceivedSkill | import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
22
|
+
}>, import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
26
23
|
export default _default;
|
|
@@ -10,13 +10,4 @@ const skills_1 = __importDefault(require("./skills"));
|
|
|
10
10
|
const slides_1 = __importDefault(require("./slides"));
|
|
11
11
|
const token_1 = __importDefault(require("./token"));
|
|
12
12
|
const rank_1 = __importDefault(require("./rank"));
|
|
13
|
-
|
|
14
|
-
exports.default = (0, redux_1.combineReducers)({
|
|
15
|
-
corrections: corrections_1.default,
|
|
16
|
-
progression: progression_1.default,
|
|
17
|
-
skills: skills_1.default,
|
|
18
|
-
slides: slides_1.default,
|
|
19
|
-
token: token_1.default,
|
|
20
|
-
rank: rank_1.default,
|
|
21
|
-
currentSkill: current_skill_1.default
|
|
22
|
-
});
|
|
13
|
+
exports.default = (0, redux_1.combineReducers)({ corrections: corrections_1.default, progression: progression_1.default, skills: skills_1.default, slides: slides_1.default, token: token_1.default, rank: rank_1.default });
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
12
12
|
slides: import("./data/slides").SlidesState;
|
|
13
13
|
token: string;
|
|
14
14
|
rank: import("./data/rank").RankState;
|
|
15
|
-
currentSkill: import("./data/current-skill").CurrentSkillState;
|
|
16
15
|
}>;
|
|
17
16
|
ui: import("redux").CombinedState<{
|
|
18
17
|
currentSlideRef: string;
|
|
@@ -24,7 +23,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
24
23
|
showButtonRevising: boolean;
|
|
25
24
|
showCongrats: boolean;
|
|
26
25
|
}>;
|
|
27
|
-
}>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/
|
|
26
|
+
}>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
|
|
28
27
|
type: "@@ui/OPEN_POPIN";
|
|
29
28
|
} | {
|
|
30
29
|
type: "@@ui/CLOSE_POPIN";
|
|
@@ -12,7 +12,6 @@ const fetchSkill = async (skillRef, token) => {
|
|
|
12
12
|
const response = await (0, cross_fetch_1.default)(`${host}/api/v2/skills?conditions={"ref":"${skillRef}"}`, {
|
|
13
13
|
headers: { authorization: token }
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
return skills[0];
|
|
15
|
+
return (0, fetch_responses_1.toJSON)(response);
|
|
17
16
|
};
|
|
18
17
|
exports.fetchSkill = fetchSkill;
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare type ViewName = 'skills' | 'onboarding' | 'slides' | 'loader';
|
|
2
|
-
export interface Translate {
|
|
3
|
-
(key: string, data?: Record<string, string>): string;
|
|
4
|
-
}
|
|
5
2
|
export declare type ChoiceFromAPI = {
|
|
6
3
|
_id: string;
|
|
7
4
|
id?: string;
|
|
@@ -149,13 +146,13 @@ export declare type Options = {
|
|
|
149
146
|
services: Services;
|
|
150
147
|
};
|
|
151
148
|
export declare type ConnectedOptions = {
|
|
152
|
-
translate:
|
|
149
|
+
translate: (key: string, data?: unknown) => string;
|
|
153
150
|
onQuitClick: () => void;
|
|
154
151
|
};
|
|
155
152
|
export declare type AppOptions = ConnectedOptions & {
|
|
156
153
|
token: string;
|
|
157
154
|
skillRef?: string;
|
|
158
|
-
services
|
|
155
|
+
services: Services;
|
|
159
156
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
160
157
|
};
|
|
161
158
|
export declare type ThunkOptions = {
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
|
|
2
1
|
import { StoreState } from '../../reducers';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare type SkillCard = {
|
|
3
|
+
'aria-label': string;
|
|
4
|
+
skillTitle: string;
|
|
5
|
+
skillAriaLabel: string;
|
|
6
|
+
buttonLabel: string;
|
|
7
|
+
buttonAriaLabel: string;
|
|
8
|
+
reviseLabel: string;
|
|
9
|
+
reviseAriaLabel: string;
|
|
10
|
+
isCustom: boolean;
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare type NoSkillsProps = {
|
|
14
|
+
iconSkillAriaLabel: string;
|
|
15
|
+
};
|
|
16
|
+
declare type SkillsProps = NoSkillsProps & {
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
title: string;
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
isLoadingAriaLabel: string;
|
|
21
|
+
listSkills: SkillCard[];
|
|
22
|
+
};
|
|
23
|
+
export { SkillsProps };
|
|
24
|
+
export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapStateToSkillsProps = void 0;
|
|
4
|
-
const mapStateToSkillsProps = (state
|
|
5
|
-
const { translate } = options;
|
|
4
|
+
const mapStateToSkillsProps = (state) => {
|
|
6
5
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
title: '@todo title',
|
|
7
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
9
8
|
isLoading: false,
|
|
10
|
-
isLoadingAriaLabel: '
|
|
9
|
+
isLoadingAriaLabel: '@todo loading',
|
|
11
10
|
listSkills: state.data.skills.map(skill => ({
|
|
12
|
-
'aria-label':
|
|
11
|
+
'aria-label': '',
|
|
13
12
|
isCustom: skill.custom,
|
|
14
13
|
skillTitle: skill.name,
|
|
15
|
-
skillAriaLabel: skill
|
|
16
|
-
buttonLabel:
|
|
17
|
-
buttonAriaLabel:
|
|
18
|
-
reviseLabel:
|
|
19
|
-
reviseAriaLabel:
|
|
20
|
-
count: `${skill.slidesToReview}`
|
|
21
|
-
}),
|
|
14
|
+
skillAriaLabel: '@todo skill aria label',
|
|
15
|
+
buttonLabel: '@todo button',
|
|
16
|
+
buttonAriaLabel: '@todo button aria label',
|
|
17
|
+
reviseLabel: '@todo revise',
|
|
18
|
+
reviseAriaLabel: '@todo revise aria label',
|
|
22
19
|
// eslint-disable-next-line no-console
|
|
23
20
|
onClick: () => console.log('@todo plug dispatcher select skill')
|
|
24
|
-
}))
|
|
25
|
-
titleNoSkills: translate('No skill to revise'),
|
|
26
|
-
textNoSkills: translate('Complete courses before revising'),
|
|
27
|
-
iconSkillAriaLabel: 'Image without information'
|
|
21
|
+
}))
|
|
28
22
|
};
|
|
29
23
|
};
|
|
30
24
|
exports.mapStateToSkillsProps = mapStateToSkillsProps;
|
|
@@ -66,9 +66,6 @@ const getCurrentSlideRef = (state) => {
|
|
|
66
66
|
const content = progression.state.content;
|
|
67
67
|
return content.ref;
|
|
68
68
|
};
|
|
69
|
-
const isLastSlideAnswered = (slidesRef, slideRef) => {
|
|
70
|
-
return (0, last_1.default)(slidesRef) === slideRef;
|
|
71
|
-
};
|
|
72
69
|
const buildStackSlides = (state, dispatch, options) => {
|
|
73
70
|
const { translate } = options;
|
|
74
71
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
@@ -79,25 +76,22 @@ const buildStackSlides = (state, dispatch, options) => {
|
|
|
79
76
|
// @ts-expect-error typescript does not support capped versions of lodash functions
|
|
80
77
|
const stack = reduce_1.default.convert({ cap: false })((acc, uiSlide, _index) => {
|
|
81
78
|
const index = (0, toInteger_1.default)(_index);
|
|
82
|
-
const slideRef = slideRefs[index];
|
|
83
|
-
const lastAnsweredSlideRef = isLastSlideAnswered(progression.state.slides, slideRef);
|
|
84
79
|
const positions = state.ui.positions;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const position = lastAnsweredSlideRef && positions[index] === -1 ? 0 : positions[index];
|
|
80
|
+
const position = positions[index];
|
|
81
|
+
const slideRef = slideRefs[index];
|
|
88
82
|
if (!slideRef)
|
|
89
83
|
return (0, set_1.default)(index, { ...uiSlide, position }, acc);
|
|
90
84
|
const slideFromAPI = (0, get_1.default)(slideRef, state.data.slides);
|
|
91
85
|
if (!slideFromAPI)
|
|
92
86
|
return (0, set_1.default)(index, { ...uiSlide, position }, acc);
|
|
93
87
|
const answers = (0, getOr_1.default)([], ['ui', 'answers', slideRef], state);
|
|
94
|
-
const { questionText, answerUI } = (0, map_api_slide_to_ui_1.mapApiSlideToUi)(dispatch
|
|
88
|
+
const { questionText, answerUI } = (0, map_api_slide_to_ui_1.mapApiSlideToUi)(dispatch)(slideFromAPI, answers);
|
|
95
89
|
const { title: parentContentTitle, type: parentContentType } = slideFromAPI.parentContentTitle;
|
|
96
90
|
const isCurrentSlideRef = currentSlideRef === slideRef;
|
|
97
91
|
const slideUI = (0, get_1.default)(['ui', 'slide', slideRef], state);
|
|
98
92
|
const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
|
|
99
93
|
const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
|
|
100
|
-
const animationType =
|
|
94
|
+
const animationType = slideUI.animationType;
|
|
101
95
|
const updatedUiSlide = {
|
|
102
96
|
...uiSlide,
|
|
103
97
|
position,
|
|
@@ -184,8 +178,7 @@ const buildStepItems = (state) => {
|
|
|
184
178
|
return steps;
|
|
185
179
|
};
|
|
186
180
|
exports.buildStepItems = buildStepItems;
|
|
187
|
-
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate
|
|
188
|
-
const nextLabel = endReview ? translate('Continue') : translate('Next Question');
|
|
181
|
+
const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate) => {
|
|
189
182
|
return {
|
|
190
183
|
klf: isCorrect
|
|
191
184
|
? undefined
|
|
@@ -196,11 +189,11 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
|
|
|
196
189
|
resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
|
|
197
190
|
information: {
|
|
198
191
|
label: isCorrect ? translate('KLF') : translate('Correct Answer'),
|
|
199
|
-
message: isCorrect ? klf : (0, join_1.default)(',
|
|
192
|
+
message: isCorrect ? klf : (0, join_1.default)(',', correctAnswer)
|
|
200
193
|
},
|
|
201
194
|
next: {
|
|
202
|
-
'aria-label':
|
|
203
|
-
label:
|
|
195
|
+
'aria-label': translate('Next Question'),
|
|
196
|
+
label: translate('Next Question'),
|
|
204
197
|
onClick: () => {
|
|
205
198
|
dispatch(next_slide_1.nextSlide);
|
|
206
199
|
}
|
|
@@ -327,11 +320,10 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
327
320
|
const klf = (0, getOr_1.default)('', ['data', 'slides', currentSlideRef, 'klf'], state);
|
|
328
321
|
const showQuitPopin = (0, get_1.default)(['ui', 'showQuitPopin'], state);
|
|
329
322
|
const showCongrats = (0, get_1.default)(['ui', 'showCongrats'], state);
|
|
330
|
-
const skillName = (0, getOr_1.default)('', ['data', 'currentSkill', 'name'], state);
|
|
331
323
|
return {
|
|
332
324
|
header: {
|
|
333
325
|
mode: translate('Review Title'),
|
|
334
|
-
skillName,
|
|
326
|
+
skillName: '__agility',
|
|
335
327
|
onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
|
|
336
328
|
'aria-label': 'aria-header-wrapper',
|
|
337
329
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -348,7 +340,7 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
|
|
|
348
340
|
}
|
|
349
341
|
},
|
|
350
342
|
correctionPopinProps: correction &&
|
|
351
|
-
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate
|
|
343
|
+
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
|
|
352
344
|
endReview: endReview && state.ui.showCongrats
|
|
353
345
|
},
|
|
354
346
|
congrats: buildCongratsProps(state, dispatch, options),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
2
|
import { AnswerUI } from '../../types/slides';
|
|
3
|
-
import { Question, SlideFromAPI
|
|
3
|
+
import { Question, SlideFromAPI } from '../../types/common';
|
|
4
4
|
export declare const getQuestionType: (question: Question) => Question['type'];
|
|
5
|
-
export declare const mapApiSlideToUi: (dispatch: Dispatch
|
|
5
|
+
export declare const mapApiSlideToUi: (dispatch: Dispatch) => (slide: SlideFromAPI, answers: string[]) => {
|
|
6
6
|
questionText: string;
|
|
7
7
|
answerUI: AnswerUI;
|
|
8
8
|
};
|