@coorpacademy/app-review 0.7.1-alpha.10 → 0.7.1

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