@coorpacademy/app-review 0.5.4 → 0.5.6-alpha.10
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/locales/en/review.json +14 -0
- package/es/sandbox/index.d.ts +9 -0
- package/es/sandbox/index.js +56 -0
- package/es/{index.js → src/index.js} +6 -5
- package/es/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/es/src/services/fetch-slides-to-review-by-skill-ref.js +8 -0
- package/es/{services → src/services}/index.js +2 -0
- package/es/{test → src/test}/index.test.js +3 -1
- package/{lib → es/src}/test/util/services.mock.d.ts +1 -0
- package/es/{test → src/test}/util/services.mock.js +20 -1
- package/{lib → es/src}/types/common.d.ts +10 -2
- package/{lib → es/src}/views/slides/index.d.ts +2 -1
- package/es/{views → src/views}/slides/index.js +20 -18
- package/lib/locales/en/review.json +14 -0
- package/lib/sandbox/index.d.ts +9 -0
- package/lib/sandbox/index.js +67 -0
- package/lib/{index.js → src/index.js} +6 -6
- package/lib/src/services/fetch-slides-to-review-by-skill-ref.d.ts +2 -0
- package/lib/src/services/fetch-slides-to-review-by-skill-ref.js +52 -0
- package/lib/{services → src/services}/index.js +2 -0
- package/lib/{test → src/test}/index.test.js +3 -1
- package/{es → lib/src}/test/util/services.mock.d.ts +1 -0
- package/lib/{test → src/test}/util/services.mock.js +20 -1
- package/{es → lib/src}/types/common.d.ts +10 -2
- package/{es → lib/src}/views/slides/index.d.ts +2 -1
- package/lib/{views → src/views}/slides/index.js +20 -18
- package/locales/en/review.json +14 -0
- package/package.json +9 -6
- package/src/index.tsx +7 -7
- package/src/services/fetch-slides-to-review-by-skill-ref.ts +18 -0
- package/src/services/index.ts +2 -0
- package/src/services/test/fetch-slides-to-review-by-skill-ref.test.ts +51 -0
- package/src/test/index.test.tsx +3 -1
- package/src/test/util/services.mock.ts +24 -2
- package/src/types/common.ts +16 -2
- package/src/types/globals.d.ts +1 -0
- package/src/views/slides/index.ts +43 -19
- package/src/views/slides/test/header.on-click.test.ts +10 -3
- package/src/views/slides/test/index.test.ts +58 -55
- package/src/views/slides/test/on-quit-popin.on-click.test.ts +12 -3
- package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +6 -3
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.qcm.on-click.test.ts +3 -2
- package/src/views/slides/test/slide.slider.on-change.test.ts +3 -2
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +3 -2
- package/src/views/slides/test/slide.template.on-change.test.ts +5 -4
- /package/es/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-correction.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-rank.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-skills.js +0 -0
- /package/es/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
- /package/es/{actions → src/actions}/api/fetch-slide.js +0 -0
- /package/es/{actions → src/actions}/api/post-answer.d.ts +0 -0
- /package/es/{actions → src/actions}/api/post-answer.js +0 -0
- /package/es/{actions → src/actions}/api/post-progression.d.ts +0 -0
- /package/es/{actions → src/actions}/api/post-progression.js +0 -0
- /package/es/{actions → src/actions}/data/token.d.ts +0 -0
- /package/es/{actions → src/actions}/data/token.js +0 -0
- /package/es/{actions → src/actions}/index.d.ts +0 -0
- /package/es/{actions → src/actions}/index.js +0 -0
- /package/es/{actions → src/actions}/test/create-test-store.d.ts +0 -0
- /package/es/{actions → src/actions}/test/create-test-store.js +0 -0
- /package/es/{actions → src/actions}/ui/answers.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/answers.js +0 -0
- /package/es/{actions → src/actions}/ui/navigation.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/navigation.js +0 -0
- /package/es/{actions → src/actions}/ui/next-slide.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/next-slide.js +0 -0
- /package/es/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/quit-popin.js +0 -0
- /package/es/{actions → src/actions}/ui/slides.d.ts +0 -0
- /package/es/{actions → src/actions}/ui/slides.js +0 -0
- /package/es/{common → src/common}/index.d.ts +0 -0
- /package/es/{common → src/common}/index.js +0 -0
- /package/es/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
- /package/es/{configure-store.js → src/configure-store.js} +0 -0
- /package/es/{helpers → src/helpers}/css-register.d.ts +0 -0
- /package/es/{helpers → src/helpers}/css-register.js +0 -0
- /package/es/{index.d.ts → src/index.d.ts} +0 -0
- /package/es/{reducers → src/reducers}/data/corrections.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/corrections.js +0 -0
- /package/es/{reducers → src/reducers}/data/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/index.js +0 -0
- /package/es/{reducers → src/reducers}/data/progression.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/progression.js +0 -0
- /package/es/{reducers → src/reducers}/data/rank.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/rank.js +0 -0
- /package/es/{reducers → src/reducers}/data/skills.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/skills.js +0 -0
- /package/es/{reducers → src/reducers}/data/slides.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/slides.js +0 -0
- /package/es/{reducers → src/reducers}/data/token.d.ts +0 -0
- /package/es/{reducers → src/reducers}/data/token.js +0 -0
- /package/es/{reducers → src/reducers}/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/index.js +0 -0
- /package/es/{reducers → src/reducers}/ui/answers.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/answers.js +0 -0
- /package/es/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
- /package/es/{reducers → src/reducers}/ui/index.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/index.js +0 -0
- /package/es/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/navigation.js +0 -0
- /package/es/{reducers → src/reducers}/ui/positions.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/positions.js +0 -0
- /package/es/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/quit-popin.js +0 -0
- /package/es/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/show-congrats.js +0 -0
- /package/es/{reducers → src/reducers}/ui/slide.d.ts +0 -0
- /package/es/{reducers → src/reducers}/ui/slide.js +0 -0
- /package/es/{services → src/services}/fetch-correction.d.ts +0 -0
- /package/es/{services → src/services}/fetch-correction.js +0 -0
- /package/es/{services → src/services}/fetch-rank.d.ts +0 -0
- /package/es/{services → src/services}/fetch-rank.js +0 -0
- /package/es/{services → src/services}/fetch-skills.d.ts +0 -0
- /package/es/{services → src/services}/fetch-skills.js +0 -0
- /package/es/{services → src/services}/fetch-slide.d.ts +0 -0
- /package/es/{services → src/services}/fetch-slide.js +0 -0
- /package/es/{services → src/services}/index.d.ts +0 -0
- /package/es/{services → src/services}/post-answer.d.ts +0 -0
- /package/es/{services → src/services}/post-answer.js +0 -0
- /package/es/{services → src/services}/post-progression.d.ts +0 -0
- /package/es/{services → src/services}/post-progression.js +0 -0
- /package/es/{services → src/services}/tools/fetch-responses.d.ts +0 -0
- /package/es/{services → src/services}/tools/fetch-responses.js +0 -0
- /package/es/{services → src/services}/tools/sleep.d.ts +0 -0
- /package/es/{services → src/services}/tools/sleep.js +0 -0
- /package/es/{test → src/test}/index.test.d.ts +0 -0
- /package/es/{types → src/types}/common.js +0 -0
- /package/es/{types → src/types}/slides.d.ts +0 -0
- /package/es/{types → src/types}/slides.js +0 -0
- /package/es/{views → src/views}/skills/index.d.ts +0 -0
- /package/es/{views → src/views}/skills/index.js +0 -0
- /package/es/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
- /package/es/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/slider.js +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
- /package/es/{views → src/views}/slides/test/fixtures/template.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-correction.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-correction.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-rank.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-rank.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-skills.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-skills.js +0 -0
- /package/lib/{actions → src/actions}/api/fetch-slide.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/fetch-slide.js +0 -0
- /package/lib/{actions → src/actions}/api/post-answer.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/post-answer.js +0 -0
- /package/lib/{actions → src/actions}/api/post-progression.d.ts +0 -0
- /package/lib/{actions → src/actions}/api/post-progression.js +0 -0
- /package/lib/{actions → src/actions}/data/token.d.ts +0 -0
- /package/lib/{actions → src/actions}/data/token.js +0 -0
- /package/lib/{actions → src/actions}/index.d.ts +0 -0
- /package/lib/{actions → src/actions}/index.js +0 -0
- /package/lib/{actions → src/actions}/test/create-test-store.d.ts +0 -0
- /package/lib/{actions → src/actions}/test/create-test-store.js +0 -0
- /package/lib/{actions → src/actions}/ui/answers.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/answers.js +0 -0
- /package/lib/{actions → src/actions}/ui/navigation.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/navigation.js +0 -0
- /package/lib/{actions → src/actions}/ui/next-slide.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/next-slide.js +0 -0
- /package/lib/{actions → src/actions}/ui/quit-popin.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/quit-popin.js +0 -0
- /package/lib/{actions → src/actions}/ui/slides.d.ts +0 -0
- /package/lib/{actions → src/actions}/ui/slides.js +0 -0
- /package/lib/{common → src/common}/index.d.ts +0 -0
- /package/lib/{common → src/common}/index.js +0 -0
- /package/lib/{configure-store.d.ts → src/configure-store.d.ts} +0 -0
- /package/lib/{configure-store.js → src/configure-store.js} +0 -0
- /package/lib/{helpers → src/helpers}/css-register.d.ts +0 -0
- /package/lib/{helpers → src/helpers}/css-register.js +0 -0
- /package/lib/{index.d.ts → src/index.d.ts} +0 -0
- /package/lib/{reducers → src/reducers}/data/corrections.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/corrections.js +0 -0
- /package/lib/{reducers → src/reducers}/data/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/index.js +0 -0
- /package/lib/{reducers → src/reducers}/data/progression.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/progression.js +0 -0
- /package/lib/{reducers → src/reducers}/data/rank.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/rank.js +0 -0
- /package/lib/{reducers → src/reducers}/data/skills.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/skills.js +0 -0
- /package/lib/{reducers → src/reducers}/data/slides.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/slides.js +0 -0
- /package/lib/{reducers → src/reducers}/data/token.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/data/token.js +0 -0
- /package/lib/{reducers → src/reducers}/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/index.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/answers.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/answers.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/current-slide-ref.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/current-slide-ref.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/index.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/index.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/navigation.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/navigation.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/positions.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/positions.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/quit-popin.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/quit-popin.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/show-congrats.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/show-congrats.js +0 -0
- /package/lib/{reducers → src/reducers}/ui/slide.d.ts +0 -0
- /package/lib/{reducers → src/reducers}/ui/slide.js +0 -0
- /package/lib/{services → src/services}/fetch-correction.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-correction.js +0 -0
- /package/lib/{services → src/services}/fetch-rank.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-rank.js +0 -0
- /package/lib/{services → src/services}/fetch-skills.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-skills.js +0 -0
- /package/lib/{services → src/services}/fetch-slide.d.ts +0 -0
- /package/lib/{services → src/services}/fetch-slide.js +0 -0
- /package/lib/{services → src/services}/index.d.ts +0 -0
- /package/lib/{services → src/services}/post-answer.d.ts +0 -0
- /package/lib/{services → src/services}/post-answer.js +0 -0
- /package/lib/{services → src/services}/post-progression.d.ts +0 -0
- /package/lib/{services → src/services}/post-progression.js +0 -0
- /package/lib/{services → src/services}/tools/fetch-responses.d.ts +0 -0
- /package/lib/{services → src/services}/tools/fetch-responses.js +0 -0
- /package/lib/{services → src/services}/tools/sleep.d.ts +0 -0
- /package/lib/{services → src/services}/tools/sleep.js +0 -0
- /package/lib/{test → src/test}/index.test.d.ts +0 -0
- /package/lib/{types → src/types}/common.js +0 -0
- /package/lib/{types → src/types}/slides.d.ts +0 -0
- /package/lib/{types → src/types}/slides.js +0 -0
- /package/lib/{views → src/views}/skills/index.d.ts +0 -0
- /package/lib/{views → src/views}/skills/index.js +0 -0
- /package/lib/{views → src/views}/slides/map-api-slide-to-ui.d.ts +0 -0
- /package/lib/{views → src/views}/slides/map-api-slide-to-ui.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/free-text.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/free-text.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-drag.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm-graphic.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/qcm.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/slider.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/slider.js +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/template.d.ts +0 -0
- /package/lib/{views → src/views}/slides/test/fixtures/template.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ConnectedOptions } from '../../types/common';
|
|
2
3
|
import { type SlideIndexes } from '../../common';
|
|
3
4
|
import type { StoreState } from '../../reducers';
|
|
4
5
|
import type { AnswerUI } from '../../types/slides';
|
|
@@ -138,5 +139,5 @@ export declare type CongratsProps = {
|
|
|
138
139
|
};
|
|
139
140
|
export declare const initialState: SlidesStack;
|
|
140
141
|
export declare const buildStepItems: (state: StoreState) => StepItem[];
|
|
141
|
-
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch,
|
|
142
|
+
export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, options: ConnectedOptions) => SlidesViewProps;
|
|
142
143
|
export {};
|
|
@@ -161,22 +161,22 @@ export var buildStepItems = function (state) {
|
|
|
161
161
|
return steps;
|
|
162
162
|
};
|
|
163
163
|
var getCorrectionPopinProps = function (dispatch) {
|
|
164
|
-
return function (isCorrect, correctAnswer, klf) {
|
|
164
|
+
return function (isCorrect, correctAnswer, klf, translate) {
|
|
165
165
|
return {
|
|
166
166
|
klf: isCorrect
|
|
167
167
|
? undefined
|
|
168
168
|
: {
|
|
169
|
-
label: '
|
|
169
|
+
label: translate('KLF'),
|
|
170
170
|
tooltip: klf
|
|
171
171
|
},
|
|
172
|
-
resultLabel: isCorrect ? '
|
|
172
|
+
resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
|
|
173
173
|
information: {
|
|
174
|
-
label: isCorrect ? '
|
|
174
|
+
label: isCorrect ? translate('KLF') : translate('Correct Answer'),
|
|
175
175
|
message: isCorrect ? klf : join(',', correctAnswer)
|
|
176
176
|
},
|
|
177
177
|
next: {
|
|
178
|
-
ariaLabel: '
|
|
179
|
-
label: '
|
|
178
|
+
ariaLabel: translate('Next Question'),
|
|
179
|
+
label: translate('Next Question'),
|
|
180
180
|
onClick: function () {
|
|
181
181
|
dispatch(nextSlide);
|
|
182
182
|
}
|
|
@@ -212,7 +212,7 @@ var buildQuitPopinProps = function (dispatch) {
|
|
|
212
212
|
};
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
|
-
var buildRankCard = function (rank) {
|
|
215
|
+
var buildRankCard = function (rank, translate) {
|
|
216
216
|
return {
|
|
217
217
|
'aria-label': 'Review Card Congrats Container',
|
|
218
218
|
'data-name': 'card-rank',
|
|
@@ -227,13 +227,13 @@ var buildRankCard = function (rank) {
|
|
|
227
227
|
cardType: 'card-rank',
|
|
228
228
|
iconAriaLabel: 'Image without information',
|
|
229
229
|
className: undefined,
|
|
230
|
-
reviewCardTitle: 'You are now',
|
|
230
|
+
reviewCardTitle: translate('You are now'),
|
|
231
231
|
reviewCardValue: "".concat(rank),
|
|
232
232
|
rankSuffix: 'th',
|
|
233
233
|
timerAnimation: 200
|
|
234
234
|
};
|
|
235
235
|
};
|
|
236
|
-
var buildCongratsProps = function (state) {
|
|
236
|
+
var buildCongratsProps = function (state, translate) {
|
|
237
237
|
if (!state.ui.showCongrats)
|
|
238
238
|
return;
|
|
239
239
|
var progression = state.data.progression;
|
|
@@ -256,18 +256,18 @@ var buildCongratsProps = function (state) {
|
|
|
256
256
|
iconAriaLabel: 'Image without information',
|
|
257
257
|
className: undefined,
|
|
258
258
|
cardType: 'card-star',
|
|
259
|
-
reviewCardTitle: 'You have won',
|
|
259
|
+
reviewCardTitle: translate('You have won'),
|
|
260
260
|
reviewCardValue: "".concat(stars),
|
|
261
261
|
timerAnimation: 200
|
|
262
262
|
};
|
|
263
263
|
var _a = state.data.rank, start = _a.start, end = _a.end;
|
|
264
264
|
var newRank = start - end;
|
|
265
|
-
var cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
|
|
265
|
+
var cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
|
|
266
266
|
return {
|
|
267
267
|
'aria-label': 'Review Congratulations',
|
|
268
268
|
'data-name': 'review-congrats',
|
|
269
269
|
animationLottie: confettiAnimation,
|
|
270
|
-
title: 'Congratulations!',
|
|
270
|
+
title: translate('Congratulations!'),
|
|
271
271
|
cardCongratsStar: cardCongratsStar,
|
|
272
272
|
cardCongratsRank: cardCongratsRank,
|
|
273
273
|
buttonRevising: undefined,
|
|
@@ -279,7 +279,8 @@ var isEndOfProgression = function (progression) {
|
|
|
279
279
|
return false;
|
|
280
280
|
return progression.state.nextContent.ref === 'successExitNode';
|
|
281
281
|
};
|
|
282
|
-
export var mapStateToSlidesProps = function (state, dispatch,
|
|
282
|
+
export var mapStateToSlidesProps = function (state, dispatch, options) {
|
|
283
|
+
var translate = options.translate, onQuitClick = options.onQuitClick;
|
|
283
284
|
var currentSlideRef = getCurrentSlideRef(state);
|
|
284
285
|
var endReview = isEndOfProgression(state.data.progression);
|
|
285
286
|
var correction = get(['data', 'corrections', currentSlideRef], state);
|
|
@@ -288,8 +289,8 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
|
|
|
288
289
|
var showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
289
290
|
return {
|
|
290
291
|
header: {
|
|
291
|
-
mode: '
|
|
292
|
-
skillName: '
|
|
292
|
+
mode: translate('Review Title'),
|
|
293
|
+
skillName: translate('Content Parent Title'),
|
|
293
294
|
onQuitClick: function () { return dispatch(openQuitPopin); },
|
|
294
295
|
'aria-label': 'aria-header-wrapper',
|
|
295
296
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -298,16 +299,17 @@ export var mapStateToSlidesProps = function (state, dispatch, onQuitClick) {
|
|
|
298
299
|
stack: {
|
|
299
300
|
slides: buildStackSlides(state, dispatch),
|
|
300
301
|
validateButton: {
|
|
301
|
-
label: '
|
|
302
|
+
label: translate('Validate'),
|
|
302
303
|
disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
|
|
303
304
|
onClick: function () {
|
|
304
305
|
dispatch(postAnswer);
|
|
305
306
|
}
|
|
306
307
|
},
|
|
307
|
-
correctionPopinProps: correction &&
|
|
308
|
+
correctionPopinProps: correction &&
|
|
309
|
+
getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, options.translate),
|
|
308
310
|
endReview: endReview && state.ui.showCongrats
|
|
309
311
|
},
|
|
310
|
-
congrats: buildCongratsProps(state),
|
|
312
|
+
congrats: buildCongratsProps(state, options.translate),
|
|
311
313
|
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
312
314
|
};
|
|
313
315
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Review Title": "Review Mode",
|
|
3
|
+
"Content Parent Title": "From `{{contentTitle}}` `{{contentType}}`",
|
|
4
|
+
"Validate": "Validate",
|
|
5
|
+
"Next Question": "Next Question",
|
|
6
|
+
"KLF": "Key Learning Factor",
|
|
7
|
+
"Correct Answer": "Correct Answer",
|
|
8
|
+
"Wrong Answer": "Wrong Answer",
|
|
9
|
+
"You have won": "You have won",
|
|
10
|
+
"You are now": "You are now",
|
|
11
|
+
"Revise another skill": "Revise another skill",
|
|
12
|
+
"Continue reviewing": "Continue reviewing",
|
|
13
|
+
"Congratulations!": "Congratulations!"
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6-alpha.10+0092fc5b2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"lib",
|
|
31
31
|
"es",
|
|
32
32
|
"src",
|
|
33
|
+
"locales",
|
|
33
34
|
"readme.md"
|
|
34
35
|
],
|
|
35
36
|
"main": "./es/index.js",
|
|
@@ -39,11 +40,13 @@
|
|
|
39
40
|
"commonjs": "./lib/index.js",
|
|
40
41
|
"types": "./es/index.d.ts"
|
|
41
42
|
},
|
|
42
|
-
"./package.json": "./package.json"
|
|
43
|
+
"./package.json": "./package.json",
|
|
44
|
+
"./locales/en/review": "./locales/en/review.json"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@coorpacademy/components": "10.24.
|
|
47
|
+
"@coorpacademy/components": "10.24.4",
|
|
46
48
|
"@coorpacademy/redux-task": "1.1.6",
|
|
49
|
+
"@coorpacademy/translate": "6.1.5",
|
|
47
50
|
"cross-fetch": "^3.1.5",
|
|
48
51
|
"jwt-decode": "^3.1.2",
|
|
49
52
|
"react-redux": "^7.2.9",
|
|
@@ -55,9 +58,9 @@
|
|
|
55
58
|
"react": "^17.0.2"
|
|
56
59
|
},
|
|
57
60
|
"devDependencies": {
|
|
58
|
-
"@coorpacademy/css-modules-require-hook": "
|
|
61
|
+
"@coorpacademy/css-modules-require-hook": "3.0.0",
|
|
59
62
|
"@coorpacademy/eslint-plugin-coorpacademy": "^11.0.0",
|
|
60
|
-
"@coorpacademy/webpack-config": "
|
|
63
|
+
"@coorpacademy/webpack-config": "12.0.0",
|
|
61
64
|
"@testing-library/react": "^12.1.5",
|
|
62
65
|
"@types/lodash": "^4.14.182",
|
|
63
66
|
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
@@ -77,5 +80,5 @@
|
|
|
77
80
|
"webpack-cli": "^4.10.0",
|
|
78
81
|
"webpack-dev-server": "^4.11.1"
|
|
79
82
|
},
|
|
80
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "0092fc5b24aa99b5e3ffdd2ee48501bcfb5427d6"
|
|
81
84
|
}
|
package/src/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import isEmpty from 'lodash/fp/isEmpty';
|
|
|
8
8
|
import get from 'lodash/fp/get';
|
|
9
9
|
import configureStore from './configure-store';
|
|
10
10
|
|
|
11
|
-
import type {AppOptions} from './types/common';
|
|
11
|
+
import type {AppOptions, ConnectedOptions} from './types/common';
|
|
12
12
|
import type {StoreState} from './reducers';
|
|
13
13
|
|
|
14
14
|
import {navigateTo, ViewPath} from './actions/ui/navigation';
|
|
@@ -19,15 +19,15 @@ import {VIEWS} from './common';
|
|
|
19
19
|
import {mapStateToSlidesProps} from './views/slides';
|
|
20
20
|
import {mapStateToSkillsProps} from './views/skills';
|
|
21
21
|
|
|
22
|
-
const ConnectedApp = (
|
|
22
|
+
const ConnectedApp = (options: ConnectedOptions): JSX.Element => {
|
|
23
23
|
const dispatch = useDispatch();
|
|
24
|
-
|
|
25
24
|
const props = {
|
|
26
25
|
viewName: useSelector(
|
|
27
26
|
(state: StoreState) => state.ui.navigation[state.ui.navigation.length - 1]
|
|
28
27
|
),
|
|
29
|
-
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch,
|
|
30
|
-
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state))
|
|
28
|
+
slides: useSelector((state: StoreState) => mapStateToSlidesProps(state, dispatch, options)),
|
|
29
|
+
skills: useSelector((state: StoreState) => mapStateToSkillsProps(state)),
|
|
30
|
+
onboarding: {}
|
|
31
31
|
};
|
|
32
32
|
return <AppReviewTemplate {...props} />;
|
|
33
33
|
};
|
|
@@ -36,7 +36,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
36
36
|
const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
|
|
37
37
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
38
38
|
|
|
39
|
-
const onQuitClick = options
|
|
39
|
+
const {translate, onQuitClick} = options;
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
42
|
if (store) return;
|
|
@@ -89,7 +89,7 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<Provider store={store}>
|
|
92
|
-
<ConnectedApp onQuitClick={onQuitClick} />
|
|
92
|
+
<ConnectedApp onQuitClick={onQuitClick} translate={translate} />
|
|
93
93
|
</Provider>
|
|
94
94
|
);
|
|
95
95
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
|
|
4
|
+
import {JWT, SlideIdFromAPI} from '../types/common';
|
|
5
|
+
import {toJSON} from './tools/fetch-responses';
|
|
6
|
+
|
|
7
|
+
export const fetchSlidesToReviewBySkillRef = async (
|
|
8
|
+
url: string,
|
|
9
|
+
token: string,
|
|
10
|
+
skillRef: string
|
|
11
|
+
): Promise<SlideIdFromAPI[]> => {
|
|
12
|
+
const {user: userId}: JWT = decode(token);
|
|
13
|
+
const response = await crossFetch(
|
|
14
|
+
`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
return toJSON<SlideIdFromAPI[]>(response);
|
|
18
|
+
};
|
package/src/services/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {fetchCorrection} from './fetch-correction';
|
|
|
3
3
|
import {fetchRank} from './fetch-rank';
|
|
4
4
|
import {fetchSkills} from './fetch-skills';
|
|
5
5
|
import {fetchSlide} from './fetch-slide';
|
|
6
|
+
import {fetchSlidesToReviewBySkillRef} from './fetch-slides-to-review-by-skill-ref';
|
|
6
7
|
import {postAnswer} from './post-answer';
|
|
7
8
|
import {postProgression} from './post-progression';
|
|
8
9
|
|
|
@@ -11,6 +12,7 @@ export const getServices = (): Services => ({
|
|
|
11
12
|
fetchRank,
|
|
12
13
|
fetchSkills,
|
|
13
14
|
fetchSlide,
|
|
15
|
+
fetchSlidesToReviewBySkillRef,
|
|
14
16
|
postAnswer,
|
|
15
17
|
postProgression
|
|
16
18
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import nock from 'nock';
|
|
3
|
+
import {fetchSlidesToReviewBySkillRef} from '../fetch-slides-to-review-by-skill-ref';
|
|
4
|
+
import {SlideIdFromAPI} from '../../types/common';
|
|
5
|
+
|
|
6
|
+
const url = process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006';
|
|
7
|
+
|
|
8
|
+
const result: SlideIdFromAPI[] = [
|
|
9
|
+
{
|
|
10
|
+
slideId: 'sli_6'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
slideId: 'sli_7'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
slideId: 'sli_8'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
slideId: 'sli_9'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
slideId: 'sli_10'
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
test.before(() => {
|
|
27
|
+
nock(url)
|
|
28
|
+
.get('/api/v1/review/users/592d830b240b923f00bffba6/skills/_skill-ref/slide?limit=5&offset=0')
|
|
29
|
+
.reply(200, result);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test.after(() => {
|
|
33
|
+
nock.cleanAll();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('should fetch slides id with success', async t => {
|
|
37
|
+
const token = process.env.API_TEST_TOKEN || '';
|
|
38
|
+
const slidesId = await fetchSlidesToReviewBySkillRef(url, token, '_skill-ref');
|
|
39
|
+
t.deepEqual(result, slidesId);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('should reject if a bad token is passed', async t => {
|
|
43
|
+
const badToken = 'token is not a jwt';
|
|
44
|
+
const error = await t.throwsAsync(() =>
|
|
45
|
+
fetchSlidesToReviewBySkillRef(url, badToken, '_skill-ref')
|
|
46
|
+
);
|
|
47
|
+
t.is(
|
|
48
|
+
error?.message,
|
|
49
|
+
"Invalid token specified: Cannot read properties of undefined (reading 'replace')"
|
|
50
|
+
);
|
|
51
|
+
});
|
package/src/test/index.test.tsx
CHANGED
|
@@ -61,7 +61,9 @@ const appOptions: AppOptions = {
|
|
|
61
61
|
token: process.env.API_TEST_TOKEN || '',
|
|
62
62
|
skillRef: 'skill_NJC0jFKoH',
|
|
63
63
|
services,
|
|
64
|
-
onQuitClick: identity
|
|
64
|
+
onQuitClick: identity,
|
|
65
|
+
translate: key => key,
|
|
66
|
+
url: process.env.LAMBDA_API_REVIEW_GET_SLIDES_URL || 'http://localhost:7006'
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
test('should show the loader while the app is fetching the data', async t => {
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
ReviewContent,
|
|
12
12
|
ReviewEngine,
|
|
13
13
|
Services,
|
|
14
|
-
SlideFromAPI
|
|
14
|
+
SlideFromAPI,
|
|
15
|
+
SlideIdFromAPI
|
|
15
16
|
} from '../../types/common';
|
|
16
17
|
|
|
17
18
|
const content: ReviewContent = {
|
|
@@ -432,6 +433,24 @@ export const getChoicesCorrection = (ref: string, wrongChoice = false): Correcti
|
|
|
432
433
|
}
|
|
433
434
|
};
|
|
434
435
|
|
|
436
|
+
const fetchSlidesToReviewBySkillRefResponse: SlideIdFromAPI[] = [
|
|
437
|
+
{
|
|
438
|
+
slideId: freeTextSlide._id
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
slideId: templateSlide._id
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
slideId: qcmDragSlide._id
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
slideId: qcmGraphicSlide._id
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
slideId: qcmSlide._id
|
|
451
|
+
}
|
|
452
|
+
];
|
|
453
|
+
|
|
435
454
|
export const services: Services = {
|
|
436
455
|
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
437
456
|
fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, _id: ref}),
|
|
@@ -441,5 +460,8 @@ export const services: Services = {
|
|
|
441
460
|
return Promise.resolve(get(currentSlide, postAnswerResponses));
|
|
442
461
|
},
|
|
443
462
|
fetchCorrection: ref => Promise.resolve(getChoicesCorrection(ref)),
|
|
444
|
-
fetchRank: () => Promise.resolve(fetchRankResponse)
|
|
463
|
+
fetchRank: () => Promise.resolve(fetchRankResponse),
|
|
464
|
+
fetchSlidesToReviewBySkillRef: () => Promise.resolve(fetchSlidesToReviewBySkillRefResponse)
|
|
445
465
|
};
|
|
466
|
+
|
|
467
|
+
export const translate = (key: string): string => `___${key}`;
|
package/src/types/common.ts
CHANGED
|
@@ -82,6 +82,10 @@ export type SlideFromAPI = {
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
export type SlideIdFromAPI = {
|
|
86
|
+
slideId: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
85
89
|
export type Rank = {
|
|
86
90
|
rank: number;
|
|
87
91
|
};
|
|
@@ -164,17 +168,27 @@ export type Services = {
|
|
|
164
168
|
answer: string[]
|
|
165
169
|
): Promise<CorrectionFromAPI | void>;
|
|
166
170
|
fetchRank(token: string): Promise<Rank>;
|
|
171
|
+
fetchSlidesToReviewBySkillRef(
|
|
172
|
+
url: string,
|
|
173
|
+
token: string,
|
|
174
|
+
skillRef: string
|
|
175
|
+
): Promise<SlideIdFromAPI[]>;
|
|
167
176
|
};
|
|
168
177
|
|
|
169
178
|
export type Options = {
|
|
170
179
|
services: Services;
|
|
171
180
|
};
|
|
172
181
|
|
|
173
|
-
export type
|
|
182
|
+
export type ConnectedOptions = {
|
|
183
|
+
translate: (key: string, data?: unknown) => string;
|
|
184
|
+
onQuitClick: Function;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export type AppOptions = ConnectedOptions & {
|
|
174
188
|
token: string;
|
|
175
189
|
skillRef?: string;
|
|
176
190
|
services: Services;
|
|
177
|
-
|
|
191
|
+
url: string;
|
|
178
192
|
};
|
|
179
193
|
|
|
180
194
|
export type JWT = {
|
package/src/types/globals.d.ts
CHANGED
|
@@ -8,7 +8,12 @@ import toInteger from 'lodash/fp/toInteger';
|
|
|
8
8
|
import type {Dispatch} from 'redux';
|
|
9
9
|
import join from 'lodash/fp/join';
|
|
10
10
|
import {closeQuitPopin, openQuitPopin} from '../../actions/ui/quit-popin';
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
ConnectedOptions,
|
|
13
|
+
ProgressionAnswerItem,
|
|
14
|
+
ProgressionFromAPI,
|
|
15
|
+
SlideContent
|
|
16
|
+
} from '../../types/common';
|
|
12
17
|
import {getProgressionSlidesRefs, type SlideIndexes} from '../../common';
|
|
13
18
|
import type {StoreState} from '../../reducers';
|
|
14
19
|
import type {AnswerUI} from '../../types/slides';
|
|
@@ -346,22 +351,27 @@ export const buildStepItems = (state: StoreState): StepItem[] => {
|
|
|
346
351
|
|
|
347
352
|
const getCorrectionPopinProps =
|
|
348
353
|
(dispatch: Dispatch) =>
|
|
349
|
-
(
|
|
354
|
+
(
|
|
355
|
+
isCorrect: boolean,
|
|
356
|
+
correctAnswer: string[],
|
|
357
|
+
klf: string,
|
|
358
|
+
translate: (key: string, data?: unknown) => string
|
|
359
|
+
): CorrectionPopinProps => {
|
|
350
360
|
return {
|
|
351
361
|
klf: isCorrect
|
|
352
362
|
? undefined
|
|
353
363
|
: {
|
|
354
|
-
label: '
|
|
364
|
+
label: translate('KLF'),
|
|
355
365
|
tooltip: klf
|
|
356
366
|
},
|
|
357
|
-
resultLabel: isCorrect ? '
|
|
367
|
+
resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
|
|
358
368
|
information: {
|
|
359
|
-
label: isCorrect ? '
|
|
369
|
+
label: isCorrect ? translate('KLF') : translate('Correct Answer'),
|
|
360
370
|
message: isCorrect ? klf : join(',', correctAnswer)
|
|
361
371
|
},
|
|
362
372
|
next: {
|
|
363
|
-
ariaLabel: '
|
|
364
|
-
label: '
|
|
373
|
+
ariaLabel: translate('Next Question'),
|
|
374
|
+
label: translate('Next Question'),
|
|
365
375
|
onClick: (): void => {
|
|
366
376
|
dispatch(nextSlide);
|
|
367
377
|
}
|
|
@@ -398,7 +408,10 @@ const buildQuitPopinProps =
|
|
|
398
408
|
};
|
|
399
409
|
};
|
|
400
410
|
|
|
401
|
-
const buildRankCard = (
|
|
411
|
+
const buildRankCard = (
|
|
412
|
+
rank: number,
|
|
413
|
+
translate: (key: string, data?: unknown) => string
|
|
414
|
+
): CongratsCardProps => {
|
|
402
415
|
return {
|
|
403
416
|
'aria-label': 'Review Card Congrats Container',
|
|
404
417
|
'data-name': 'card-rank',
|
|
@@ -414,14 +427,17 @@ const buildRankCard = (rank: number): CongratsCardProps => {
|
|
|
414
427
|
cardType: 'card-rank',
|
|
415
428
|
iconAriaLabel: 'Image without information',
|
|
416
429
|
className: undefined,
|
|
417
|
-
reviewCardTitle: 'You are now',
|
|
430
|
+
reviewCardTitle: translate('You are now'),
|
|
418
431
|
reviewCardValue: `${rank}`,
|
|
419
432
|
rankSuffix: 'th',
|
|
420
433
|
timerAnimation: 200
|
|
421
434
|
};
|
|
422
435
|
};
|
|
423
436
|
|
|
424
|
-
const buildCongratsProps = (
|
|
437
|
+
const buildCongratsProps = (
|
|
438
|
+
state: StoreState,
|
|
439
|
+
translate: (key: string, data?: unknown) => string
|
|
440
|
+
): CongratsProps | undefined => {
|
|
425
441
|
if (!state.ui.showCongrats) return;
|
|
426
442
|
|
|
427
443
|
const progression = state.data.progression as ProgressionFromAPI;
|
|
@@ -445,20 +461,21 @@ const buildCongratsProps = (state: StoreState): CongratsProps | undefined => {
|
|
|
445
461
|
iconAriaLabel: 'Image without information',
|
|
446
462
|
className: undefined,
|
|
447
463
|
cardType: 'card-star',
|
|
448
|
-
reviewCardTitle: 'You have won',
|
|
464
|
+
reviewCardTitle: translate('You have won'),
|
|
449
465
|
reviewCardValue: `${stars}`,
|
|
450
466
|
timerAnimation: 200
|
|
451
467
|
};
|
|
452
468
|
|
|
453
469
|
const {start, end} = state.data.rank;
|
|
454
470
|
const newRank = start - end;
|
|
455
|
-
const cardCongratsRank =
|
|
471
|
+
const cardCongratsRank =
|
|
472
|
+
!Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
|
|
456
473
|
|
|
457
474
|
return {
|
|
458
475
|
'aria-label': 'Review Congratulations',
|
|
459
476
|
'data-name': 'review-congrats',
|
|
460
477
|
animationLottie: confettiAnimation,
|
|
461
|
-
title: 'Congratulations!',
|
|
478
|
+
title: translate('Congratulations!'),
|
|
462
479
|
cardCongratsStar,
|
|
463
480
|
cardCongratsRank,
|
|
464
481
|
buttonRevising: undefined, // TODO make boutons and actions
|
|
@@ -474,8 +491,9 @@ const isEndOfProgression = (progression: ProgressionState): boolean => {
|
|
|
474
491
|
export const mapStateToSlidesProps = (
|
|
475
492
|
state: StoreState,
|
|
476
493
|
dispatch: Dispatch,
|
|
477
|
-
|
|
494
|
+
options: ConnectedOptions
|
|
478
495
|
): SlidesViewProps => {
|
|
496
|
+
const {translate, onQuitClick} = options;
|
|
479
497
|
const currentSlideRef = getCurrentSlideRef(state);
|
|
480
498
|
const endReview = isEndOfProgression(state.data.progression);
|
|
481
499
|
const correction = get(['data', 'corrections', currentSlideRef], state);
|
|
@@ -484,8 +502,8 @@ export const mapStateToSlidesProps = (
|
|
|
484
502
|
const showQuitPopin = get(['ui', 'showQuitPopin'], state);
|
|
485
503
|
return {
|
|
486
504
|
header: {
|
|
487
|
-
mode: '
|
|
488
|
-
skillName: '
|
|
505
|
+
mode: translate('Review Title'),
|
|
506
|
+
skillName: translate('Content Parent Title'),
|
|
489
507
|
onQuitClick: () => dispatch(openQuitPopin),
|
|
490
508
|
'aria-label': 'aria-header-wrapper',
|
|
491
509
|
closeButtonAriaLabel: 'aria-close-button',
|
|
@@ -494,17 +512,23 @@ export const mapStateToSlidesProps = (
|
|
|
494
512
|
stack: {
|
|
495
513
|
slides: buildStackSlides(state, dispatch),
|
|
496
514
|
validateButton: {
|
|
497
|
-
label: '
|
|
515
|
+
label: translate('Validate'),
|
|
498
516
|
disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
|
|
499
517
|
onClick: (): void => {
|
|
500
518
|
dispatch(postAnswer);
|
|
501
519
|
}
|
|
502
520
|
},
|
|
503
521
|
correctionPopinProps:
|
|
504
|
-
correction &&
|
|
522
|
+
correction &&
|
|
523
|
+
getCorrectionPopinProps(dispatch)(
|
|
524
|
+
isCorrect,
|
|
525
|
+
correction.correctAnswer,
|
|
526
|
+
klf,
|
|
527
|
+
options.translate
|
|
528
|
+
),
|
|
505
529
|
endReview: endReview && state.ui.showCongrats
|
|
506
530
|
},
|
|
507
|
-
congrats: buildCongratsProps(state),
|
|
531
|
+
congrats: buildCongratsProps(state, options.translate),
|
|
508
532
|
quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
|
|
509
533
|
};
|
|
510
534
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import identity from 'lodash/fp/identity';
|
|
3
3
|
import {createTestStore} from '../../../actions/test/create-test-store';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
incorrectFreeTextPostAnswerResponse,
|
|
6
|
+
services,
|
|
7
|
+
translate
|
|
8
|
+
} from '../../../test/util/services.mock';
|
|
5
9
|
import {StoreState} from '../../../reducers';
|
|
6
10
|
import {OPEN_POPIN} from '../../../actions/ui/quit-popin';
|
|
7
11
|
import {mapStateToSlidesProps} from '..';
|
|
@@ -37,10 +41,13 @@ const state: StoreState = {
|
|
|
37
41
|
test('should dispatch OPEN_POPIN action after a click on close button in header', async t => {
|
|
38
42
|
const expectedAction = [{type: OPEN_POPIN}];
|
|
39
43
|
const {dispatch, getState} = createTestStore(t, state, services, expectedAction);
|
|
40
|
-
const props = mapStateToSlidesProps(getState(), dispatch, identity);
|
|
44
|
+
const props = mapStateToSlidesProps(getState(), dispatch, {translate, onQuitClick: identity});
|
|
41
45
|
t.is(props.quitPopin, undefined);
|
|
42
46
|
await props.header.onQuitClick();
|
|
43
|
-
const updatedProps = mapStateToSlidesProps(getState(), dispatch,
|
|
47
|
+
const updatedProps = mapStateToSlidesProps(getState(), dispatch, {
|
|
48
|
+
translate,
|
|
49
|
+
onQuitClick: identity
|
|
50
|
+
});
|
|
44
51
|
t.not(updatedProps.quitPopin, undefined);
|
|
45
52
|
t.pass();
|
|
46
53
|
});
|