@coorpacademy/app-review 0.7.0 → 0.7.1-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/index.js CHANGED
@@ -8,15 +8,15 @@ import { navigateBack, navigateTo } from './actions/ui/navigation';
8
8
  import { storeToken } from './actions/data/token';
9
9
  import { fetchSkills } from './actions/api/fetch-skills';
10
10
  import { postProgression } from './actions/api/post-progression';
11
- import { mapStateToSlidesProps } from './views/slides';
12
11
  import { mapStateToSkillsProps } from './views/skills';
13
- const ConnectedApp = ({ onQuitClick }) => {
12
+ import { mapStateToSlidesProps } from './views/slides';
13
+ const ConnectedApp = (options) => {
14
14
  const dispatch = useDispatch();
15
15
  const props = {
16
- navigateBack: () => dispatch(navigateBack),
17
16
  viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
18
- slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, onQuitClick)),
17
+ slides: useSelector((state) => mapStateToSlidesProps(state, dispatch, options)),
19
18
  skills: useSelector((state) => mapStateToSkillsProps(state)),
19
+ navigateBack: () => dispatch(navigateBack),
20
20
  onboarding: {}
21
21
  };
22
22
  return React.createElement(AppReviewTemplate, { ...props });
@@ -24,7 +24,7 @@ const ConnectedApp = ({ onQuitClick }) => {
24
24
  const AppReview = ({ options }) => {
25
25
  const [store, setStore] = useState(null);
26
26
  const [isProgressionCreated, setIsProgressionCreated] = useState(false);
27
- const onQuitClick = options.onQuitClick;
27
+ const { translate, onQuitClick } = options;
28
28
  useEffect(() => {
29
29
  if (store)
30
30
  return;
@@ -68,6 +68,6 @@ const AppReview = ({ options }) => {
68
68
  if (!store)
69
69
  return null;
70
70
  return (React.createElement(Provider, { store: store },
71
- React.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
71
+ React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
72
72
  };
73
73
  export default AppReview;
@@ -137,11 +137,17 @@ export declare type Services = {
137
137
  fetchRank(token: string): Promise<Rank>;
138
138
  fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
139
139
  };
140
- export declare type AppOptions = {
140
+ export declare type Options = {
141
+ services: Services;
142
+ };
143
+ export declare type ConnectedOptions = {
144
+ translate: (key: string, data?: unknown) => string;
145
+ onQuitClick: () => void;
146
+ };
147
+ export declare type AppOptions = ConnectedOptions & {
141
148
  token: string;
142
149
  skillRef?: string;
143
150
  services: Services;
144
- onQuitClick: () => void;
145
151
  url: string;
146
152
  callbackOnViewChanged?: (viewName: ViewName) => void;
147
153
  };
@@ -1,6 +1,7 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import { ReviewPlayerProps } from '@coorpacademy/components/es/template/app-review/player/prop-types';
3
3
  import { SlideProps } from '@coorpacademy/components/es/organism/review-slide/prop-types';
4
+ import type { ConnectedOptions } from '../../types/common';
4
5
  import type { StoreState } from '../../reducers';
5
6
  import type { AnswerUI } from '../../types/slides';
6
7
  declare const ICON_VALUES: {
@@ -30,5 +31,5 @@ declare type SlidesStack = {
30
31
  };
31
32
  export declare const initialState: SlidesStack;
32
33
  export declare const buildStepItems: (state: StoreState) => StepItem[];
33
- export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: () => void) => ReviewPlayerProps;
34
+ export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, options: ConnectedOptions) => ReviewPlayerProps;
34
35
  export {};
@@ -166,22 +166,22 @@ export const buildStepItems = (state) => {
166
166
  });
167
167
  return steps;
168
168
  };
169
- const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) => {
169
+ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate) => {
170
170
  return {
171
171
  klf: isCorrect
172
172
  ? undefined
173
173
  : {
174
- label: '_klf',
174
+ label: translate('KLF'),
175
175
  tooltip: klf
176
176
  },
177
- resultLabel: isCorrect ? '_right' : '_wrong',
177
+ resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
178
178
  information: {
179
- label: isCorrect ? '_klf' : '_correctAnswer',
179
+ label: isCorrect ? translate('KLF') : translate('Correct Answer'),
180
180
  message: isCorrect ? klf : join(',', correctAnswer)
181
181
  },
182
182
  next: {
183
- 'aria-label': '_correctionNextAriaLabel',
184
- label: '_correctionNextLabel',
183
+ 'aria-label': translate('Next Question'),
184
+ label: translate('Next Question'),
185
185
  onClick: () => {
186
186
  dispatch(nextSlide);
187
187
  }
@@ -214,7 +214,7 @@ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
214
214
  }
215
215
  };
216
216
  };
217
- const buildRankCard = (rank) => {
217
+ const buildRankCard = (rank, translate) => {
218
218
  return {
219
219
  'aria-label': 'Review Card Congrats Container',
220
220
  'data-name': 'card-rank',
@@ -229,13 +229,13 @@ const buildRankCard = (rank) => {
229
229
  cardType: 'card-rank',
230
230
  iconAriaLabel: 'Image without information',
231
231
  className: undefined,
232
- reviewCardTitle: 'You are now',
232
+ reviewCardTitle: translate('You are now'),
233
233
  reviewCardValue: `${rank}`,
234
234
  rankSuffix: 'th',
235
235
  timerAnimation: 200
236
236
  };
237
237
  };
238
- const buildCongratsProps = (state) => {
238
+ const buildCongratsProps = (state, translate) => {
239
239
  if (!state.ui.showCongrats)
240
240
  return;
241
241
  const progression = state.data.progression;
@@ -258,18 +258,18 @@ const buildCongratsProps = (state) => {
258
258
  iconAriaLabel: 'Image without information',
259
259
  className: undefined,
260
260
  cardType: 'card-star',
261
- reviewCardTitle: 'You have won',
261
+ reviewCardTitle: translate('You have won'),
262
262
  reviewCardValue: `${stars}`,
263
263
  timerAnimation: 200
264
264
  };
265
265
  const { start, end } = state.data.rank;
266
266
  const newRank = start - end;
267
- const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
267
+ const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
268
268
  return {
269
269
  'aria-label': 'Review Congratulations',
270
270
  'data-name': 'review-congrats',
271
271
  animationLottie: confettiAnimation,
272
- title: 'Congratulations!',
272
+ title: translate('Congratulations!'),
273
273
  cardCongratsStar,
274
274
  cardCongratsRank,
275
275
  buttonRevising: undefined,
@@ -281,7 +281,8 @@ const isEndOfProgression = (progression) => {
281
281
  return false;
282
282
  return progression.state.nextContent.ref === 'successExitNode';
283
283
  };
284
- export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
284
+ export const mapStateToSlidesProps = (state, dispatch, options) => {
285
+ const { translate, onQuitClick } = options;
285
286
  const currentSlideRef = getCurrentSlideRef(state);
286
287
  const endReview = isEndOfProgression(state.data.progression);
287
288
  const correction = get(['data', 'corrections', currentSlideRef], state);
@@ -291,8 +292,8 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
291
292
  const showCongrats = get(['ui', 'showCongrats'], state);
292
293
  return {
293
294
  header: {
294
- mode: '__revision_mode',
295
- skillName: '__agility',
295
+ mode: translate('Review Title'),
296
+ skillName: translate('Content Parent Title'),
296
297
  onQuitClick: () => dispatch(openQuitPopin),
297
298
  'aria-label': 'aria-header-wrapper',
298
299
  closeButtonAriaLabel: 'aria-close-button',
@@ -302,16 +303,17 @@ export const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
302
303
  stack: {
303
304
  slides: buildStackSlides(state, dispatch),
304
305
  validateButton: {
305
- label: '__validate',
306
+ label: translate('Validate'),
306
307
  disabled: !get(['ui', 'slide', currentSlideRef, 'validateButton'], state),
307
308
  onClick: () => {
308
309
  dispatch(postAnswer);
309
310
  }
310
311
  },
311
- correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
312
+ correctionPopinProps: correction &&
313
+ getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
312
314
  endReview: endReview && state.ui.showCongrats
313
315
  },
314
- congrats: buildCongratsProps(state),
316
+ congrats: buildCongratsProps(state, translate),
315
317
  quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
316
318
  };
317
319
  };
package/lib/index.js CHANGED
@@ -36,15 +36,15 @@ const navigation_1 = require("./actions/ui/navigation");
36
36
  const token_1 = require("./actions/data/token");
37
37
  const fetch_skills_1 = require("./actions/api/fetch-skills");
38
38
  const post_progression_1 = require("./actions/api/post-progression");
39
- const slides_1 = require("./views/slides");
40
39
  const skills_1 = require("./views/skills");
41
- const ConnectedApp = ({ onQuitClick }) => {
40
+ const slides_1 = require("./views/slides");
41
+ const ConnectedApp = (options) => {
42
42
  const dispatch = (0, react_redux_1.useDispatch)();
43
43
  const props = {
44
- navigateBack: () => dispatch(navigation_1.navigateBack),
45
44
  viewName: (0, react_redux_1.useSelector)((state) => state.ui.navigation[state.ui.navigation.length - 1]),
46
- slides: (0, react_redux_1.useSelector)((state) => (0, slides_1.mapStateToSlidesProps)(state, dispatch, onQuitClick)),
45
+ slides: (0, react_redux_1.useSelector)((state) => (0, slides_1.mapStateToSlidesProps)(state, dispatch, options)),
47
46
  skills: (0, react_redux_1.useSelector)((state) => (0, skills_1.mapStateToSkillsProps)(state)),
47
+ navigateBack: () => dispatch(navigation_1.navigateBack),
48
48
  onboarding: {}
49
49
  };
50
50
  return react_1.default.createElement(app_review_1.default, { ...props });
@@ -52,7 +52,7 @@ const ConnectedApp = ({ onQuitClick }) => {
52
52
  const AppReview = ({ options }) => {
53
53
  const [store, setStore] = (0, react_1.useState)(null);
54
54
  const [isProgressionCreated, setIsProgressionCreated] = (0, react_1.useState)(false);
55
- const onQuitClick = options.onQuitClick;
55
+ const { translate, onQuitClick } = options;
56
56
  (0, react_1.useEffect)(() => {
57
57
  if (store)
58
58
  return;
@@ -96,6 +96,6 @@ const AppReview = ({ options }) => {
96
96
  if (!store)
97
97
  return null;
98
98
  return (react_1.default.createElement(react_redux_1.Provider, { store: store },
99
- react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick })));
99
+ react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
100
100
  };
101
101
  exports.default = AppReview;
@@ -137,11 +137,17 @@ export declare type Services = {
137
137
  fetchRank(token: string): Promise<Rank>;
138
138
  fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
139
139
  };
140
- export declare type AppOptions = {
140
+ export declare type Options = {
141
+ services: Services;
142
+ };
143
+ export declare type ConnectedOptions = {
144
+ translate: (key: string, data?: unknown) => string;
145
+ onQuitClick: () => void;
146
+ };
147
+ export declare type AppOptions = ConnectedOptions & {
141
148
  token: string;
142
149
  skillRef?: string;
143
150
  services: Services;
144
- onQuitClick: () => void;
145
151
  url: string;
146
152
  callbackOnViewChanged?: (viewName: ViewName) => void;
147
153
  };
@@ -1,6 +1,7 @@
1
1
  import type { Dispatch } from 'redux';
2
2
  import { ReviewPlayerProps } from '@coorpacademy/components/es/template/app-review/player/prop-types';
3
3
  import { SlideProps } from '@coorpacademy/components/es/organism/review-slide/prop-types';
4
+ import type { ConnectedOptions } from '../../types/common';
4
5
  import type { StoreState } from '../../reducers';
5
6
  import type { AnswerUI } from '../../types/slides';
6
7
  declare const ICON_VALUES: {
@@ -30,5 +31,5 @@ declare type SlidesStack = {
30
31
  };
31
32
  export declare const initialState: SlidesStack;
32
33
  export declare const buildStepItems: (state: StoreState) => StepItem[];
33
- export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, onQuitClick: () => void) => ReviewPlayerProps;
34
+ export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch, options: ConnectedOptions) => ReviewPlayerProps;
34
35
  export {};
@@ -173,22 +173,22 @@ const buildStepItems = (state) => {
173
173
  return steps;
174
174
  };
175
175
  exports.buildStepItems = buildStepItems;
176
- const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf) => {
176
+ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, translate) => {
177
177
  return {
178
178
  klf: isCorrect
179
179
  ? undefined
180
180
  : {
181
- label: '_klf',
181
+ label: translate('KLF'),
182
182
  tooltip: klf
183
183
  },
184
- resultLabel: isCorrect ? '_right' : '_wrong',
184
+ resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
185
185
  information: {
186
- label: isCorrect ? '_klf' : '_correctAnswer',
186
+ label: isCorrect ? translate('KLF') : translate('Correct Answer'),
187
187
  message: isCorrect ? klf : (0, join_1.default)(',', correctAnswer)
188
188
  },
189
189
  next: {
190
- 'aria-label': '_correctionNextAriaLabel',
191
- label: '_correctionNextLabel',
190
+ 'aria-label': translate('Next Question'),
191
+ label: translate('Next Question'),
192
192
  onClick: () => {
193
193
  dispatch(next_slide_1.nextSlide);
194
194
  }
@@ -221,7 +221,7 @@ const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
221
221
  }
222
222
  };
223
223
  };
224
- const buildRankCard = (rank) => {
224
+ const buildRankCard = (rank, translate) => {
225
225
  return {
226
226
  'aria-label': 'Review Card Congrats Container',
227
227
  'data-name': 'card-rank',
@@ -236,13 +236,13 @@ const buildRankCard = (rank) => {
236
236
  cardType: 'card-rank',
237
237
  iconAriaLabel: 'Image without information',
238
238
  className: undefined,
239
- reviewCardTitle: 'You are now',
239
+ reviewCardTitle: translate('You are now'),
240
240
  reviewCardValue: `${rank}`,
241
241
  rankSuffix: 'th',
242
242
  timerAnimation: 200
243
243
  };
244
244
  };
245
- const buildCongratsProps = (state) => {
245
+ const buildCongratsProps = (state, translate) => {
246
246
  if (!state.ui.showCongrats)
247
247
  return;
248
248
  const progression = state.data.progression;
@@ -265,18 +265,18 @@ const buildCongratsProps = (state) => {
265
265
  iconAriaLabel: 'Image without information',
266
266
  className: undefined,
267
267
  cardType: 'card-star',
268
- reviewCardTitle: 'You have won',
268
+ reviewCardTitle: translate('You have won'),
269
269
  reviewCardValue: `${stars}`,
270
270
  timerAnimation: 200
271
271
  };
272
272
  const { start, end } = state.data.rank;
273
273
  const newRank = start - end;
274
- const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end) : undefined;
274
+ const cardCongratsRank = !Number.isNaN(newRank) && newRank > 0 ? buildRankCard(end, translate) : undefined;
275
275
  return {
276
276
  'aria-label': 'Review Congratulations',
277
277
  'data-name': 'review-congrats',
278
278
  animationLottie: confettiAnimation,
279
- title: 'Congratulations!',
279
+ title: translate('Congratulations!'),
280
280
  cardCongratsStar,
281
281
  cardCongratsRank,
282
282
  buttonRevising: undefined,
@@ -288,7 +288,8 @@ const isEndOfProgression = (progression) => {
288
288
  return false;
289
289
  return progression.state.nextContent.ref === 'successExitNode';
290
290
  };
291
- const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
291
+ const mapStateToSlidesProps = (state, dispatch, options) => {
292
+ const { translate, onQuitClick } = options;
292
293
  const currentSlideRef = getCurrentSlideRef(state);
293
294
  const endReview = isEndOfProgression(state.data.progression);
294
295
  const correction = (0, get_1.default)(['data', 'corrections', currentSlideRef], state);
@@ -298,8 +299,8 @@ const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
298
299
  const showCongrats = (0, get_1.default)(['ui', 'showCongrats'], state);
299
300
  return {
300
301
  header: {
301
- mode: '__revision_mode',
302
- skillName: '__agility',
302
+ mode: translate('Review Title'),
303
+ skillName: translate('Content Parent Title'),
303
304
  onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
304
305
  'aria-label': 'aria-header-wrapper',
305
306
  closeButtonAriaLabel: 'aria-close-button',
@@ -309,16 +310,17 @@ const mapStateToSlidesProps = (state, dispatch, onQuitClick) => {
309
310
  stack: {
310
311
  slides: buildStackSlides(state, dispatch),
311
312
  validateButton: {
312
- label: '__validate',
313
+ label: translate('Validate'),
313
314
  disabled: !(0, get_1.default)(['ui', 'slide', currentSlideRef, 'validateButton'], state),
314
315
  onClick: () => {
315
316
  dispatch(post_answer_1.postAnswer);
316
317
  }
317
318
  },
318
- correctionPopinProps: correction && getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf),
319
+ correctionPopinProps: correction &&
320
+ getCorrectionPopinProps(dispatch)(isCorrect, correction.correctAnswer, klf, translate),
319
321
  endReview: endReview && state.ui.showCongrats
320
322
  },
321
- congrats: buildCongratsProps(state),
323
+ congrats: buildCongratsProps(state, translate),
322
324
  quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
323
325
  };
324
326
  };
@@ -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 point",
7
+ "Correct Answer": "Good Answer",
8
+ "Wrong Answer": "Wrong Answer",
9
+ "You have won": "You have won",
10
+ "You are now": "You are now",
11
+ "Revise another skill": "Review another skill",
12
+ "Continue reviewing": "Keep reviewing",
13
+ "Congratulations!": "Congratulations!"
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-alpha.10+c25fc5a79",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -29,6 +29,7 @@
29
29
  "files": [
30
30
  "lib",
31
31
  "es",
32
+ "locales",
32
33
  "readme.md"
33
34
  ],
34
35
  "main": "lib/index.js",
@@ -36,6 +37,7 @@
36
37
  "dependencies": {
37
38
  "@coorpacademy/components": "10.26.0",
38
39
  "@coorpacademy/redux-task": "1.1.6",
40
+ "@coorpacademy/translate": "6.1.5",
39
41
  "cross-fetch": "^3.1.5",
40
42
  "jwt-decode": "^3.1.2",
41
43
  "react-redux": "^7.2.9",
@@ -69,5 +71,5 @@
69
71
  "webpack-cli": "^4.10.0",
70
72
  "webpack-dev-server": "^4.11.1"
71
73
  },
72
- "gitHead": "dd58aa89c267084ec7338274ff946b3af97730b3"
74
+ "gitHead": "c25fc5a790ad6f08d1930a44eb65decd19f9f143"
73
75
  }