@coorpacademy/app-review 0.7.4 → 0.7.5-alpha.32

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.
Files changed (52) hide show
  1. package/es/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +11 -0
  2. package/es/actions/api/fetch-slides-to-review-by-skill-ref.js +21 -0
  3. package/es/actions/api/post-answer.js +2 -0
  4. package/es/index.js +5 -7
  5. package/es/reducers/index.d.ts +2 -1
  6. package/es/reducers/ui/index.d.ts +4 -1
  7. package/es/reducers/ui/index.js +2 -0
  8. package/es/reducers/ui/show-button-revising.d.ts +4 -0
  9. package/es/reducers/ui/show-button-revising.js +13 -0
  10. package/es/services/fetch-slides-to-review-by-skill-ref.d.ts +1 -1
  11. package/es/services/fetch-slides-to-review-by-skill-ref.js +5 -3
  12. package/es/types/common.d.ts +6 -3
  13. package/es/views/slides/index.js +12 -10
  14. package/lib/actions/api/fetch-slides-to-review-by-skill-ref.d.ts +11 -0
  15. package/lib/actions/api/fetch-slides-to-review-by-skill-ref.js +28 -0
  16. package/lib/actions/api/post-answer.js +2 -0
  17. package/lib/index.js +5 -7
  18. package/lib/reducers/index.d.ts +2 -1
  19. package/lib/reducers/ui/index.d.ts +4 -1
  20. package/lib/reducers/ui/index.js +2 -0
  21. package/lib/reducers/ui/show-button-revising.d.ts +4 -0
  22. package/lib/reducers/ui/show-button-revising.js +15 -0
  23. package/lib/services/fetch-slides-to-review-by-skill-ref.d.ts +1 -1
  24. package/lib/services/fetch-slides-to-review-by-skill-ref.js +5 -3
  25. package/lib/types/common.d.ts +6 -3
  26. package/lib/views/slides/index.js +12 -10
  27. package/locales/bs/review.json +16 -12
  28. package/locales/cs/review.json +16 -12
  29. package/locales/de/review.json +16 -12
  30. package/locales/en/review.json +4 -0
  31. package/locales/es/review.json +16 -12
  32. package/locales/et/review.json +5 -1
  33. package/locales/fr/review.json +16 -12
  34. package/locales/hr/review.json +16 -12
  35. package/locales/hu/review.json +16 -12
  36. package/locales/hy/review.json +16 -12
  37. package/locales/it/review.json +16 -12
  38. package/locales/ja/review.json +16 -12
  39. package/locales/ko/review.json +16 -12
  40. package/locales/nl/review.json +16 -12
  41. package/locales/pl/review.json +16 -12
  42. package/locales/pt/review.json +16 -12
  43. package/locales/ro/review.json +16 -12
  44. package/locales/ru/review.json +16 -12
  45. package/locales/sk/review.json +16 -12
  46. package/locales/tl/review.json +16 -12
  47. package/locales/tr/review.json +16 -12
  48. package/locales/uk/review.json +16 -12
  49. package/locales/vi/review.json +16 -12
  50. package/locales/zh/review.json +16 -12
  51. package/locales/zh_TW/review.json +16 -12
  52. package/package.json +3 -3
@@ -0,0 +1,11 @@
1
+ import type { Dispatch } from 'redux';
2
+ import type { StoreState } from '../../reducers';
3
+ import type { Options, SlideIdFromAPI } from '../../types/common';
4
+ export declare const SLIDES_TO_REVIEW_FETCH_REQUEST: "@@slidesToReview/FETCH_REQUEST";
5
+ export declare const SLIDES_TO_REVIEW_FETCH_SUCCESS: "@@slidesToReview/FETCH_SUCCESS";
6
+ export declare const SLIDES_TO_REVIEW_FETCH_FAILURE: "@@slidesToReview/FETCH_FAILURE";
7
+ export declare type ReceivedSlidesToReviewBySkillRef = {
8
+ type: typeof SLIDES_TO_REVIEW_FETCH_SUCCESS;
9
+ payload: SlideIdFromAPI[];
10
+ };
11
+ export declare const fetchSlidesToReviewBySkillRef: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => ReceivedSlidesToReviewBySkillRef;
@@ -0,0 +1,21 @@
1
+ import buildTask from '@coorpacademy/redux-task';
2
+ export const SLIDES_TO_REVIEW_FETCH_REQUEST = '@@slidesToReview/FETCH_REQUEST';
3
+ export const SLIDES_TO_REVIEW_FETCH_SUCCESS = '@@slidesToReview/FETCH_SUCCESS';
4
+ export const SLIDES_TO_REVIEW_FETCH_FAILURE = '@@slidesToReview/FETCH_FAILURE';
5
+ export const fetchSlidesToReviewBySkillRef = (dispatch, getState, { services }) => {
6
+ const action = buildTask({
7
+ types: [
8
+ SLIDES_TO_REVIEW_FETCH_REQUEST,
9
+ SLIDES_TO_REVIEW_FETCH_SUCCESS,
10
+ SLIDES_TO_REVIEW_FETCH_FAILURE
11
+ ],
12
+ task: () => {
13
+ const state = getState();
14
+ const token = state.data.token;
15
+ const progression = state.data.progression;
16
+ const skillRef = progression.content.ref;
17
+ return services.fetchSlidesToReviewBySkillRef(token, skillRef);
18
+ }
19
+ });
20
+ return dispatch(action);
21
+ };
@@ -3,6 +3,7 @@ import get from 'lodash/fp/get';
3
3
  import { fetchCorrection } from './fetch-correction';
4
4
  import { fetchSlide } from './fetch-slide';
5
5
  import { fetchEndRank, fetchStartRank } from './fetch-rank';
6
+ import { fetchSlidesToReviewBySkillRef } from './fetch-slides-to-review-by-skill-ref';
6
7
  export const POST_ANSWER_REQUEST = '@@answer/POST_REQUEST';
7
8
  export const POST_ANSWER_SUCCESS = '@@answer/POST_SUCCESS';
8
9
  export const POST_ANSWER_FAILURE = '@@answer/POST_FAILURE';
@@ -31,6 +32,7 @@ export const postAnswer = async (dispatch, getState, { services }) => {
31
32
  else {
32
33
  await dispatch(fetchCorrection);
33
34
  await dispatch(fetchEndRank);
35
+ await dispatch(fetchSlidesToReviewBySkillRef);
34
36
  }
35
37
  }
36
38
  };
package/es/index.js CHANGED
@@ -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 { translate, onQuitClick, skill } = options;
28
28
  useEffect(() => {
29
29
  if (store)
30
30
  return;
@@ -49,25 +49,23 @@ const AppReview = ({ options }) => {
49
49
  const token = get('token', options);
50
50
  if (store === null || isEmpty(token))
51
51
  return;
52
- const skillRef = get('skillRef', options);
53
52
  /* ThunkAction is not assignable to parameter of type 'AnyAction'
54
53
  ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
55
- skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
54
+ skill.ref ? store.dispatch(postProgression(skill.ref)) : store.dispatch(fetchSkills);
56
55
  }, [options, store]);
57
56
  useEffect(() => {
58
57
  if (store === null)
59
58
  return;
60
- const { skillRef } = options;
61
- if (skillRef && !isProgressionCreated) {
59
+ if (skill.ref && !isProgressionCreated) {
62
60
  store.dispatch(navigateTo('loader')); // use loader while posting progression
63
61
  return;
64
62
  }
65
- const initialView = skillRef ? 'slides' : 'skills';
63
+ const initialView = skill.ref ? 'slides' : 'skills';
66
64
  store.dispatch(navigateTo(initialView));
67
65
  }, [isProgressionCreated, options, store]);
68
66
  if (!store)
69
67
  return null;
70
68
  return (React.createElement(Provider, { store: store },
71
- React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
69
+ React.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skill: skill })));
72
70
  };
73
71
  export default AppReview;
@@ -20,9 +20,10 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
22
  showQuitPopin: boolean;
23
+ showButtonRevising: boolean;
23
24
  showCongrats: boolean;
24
25
  }>;
25
- }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | 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 | {
26
+ }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | 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/post-progression").ReceivedProgression | 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 | {
26
27
  type: "@@ui/OPEN_POPIN";
27
28
  } | {
28
29
  type: "@@ui/CLOSE_POPIN";
@@ -4,6 +4,7 @@ import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
6
  import { type ShowQuitPopinState } from './quit-popin';
7
+ import { UIShowButtonRevisingState } from './show-button-revising';
7
8
  import { UIShowCongratsState } from './show-congrats';
8
9
  export declare type UIState = {
9
10
  currentSlideRef: CurrentSlideRefState;
@@ -12,6 +13,7 @@ export declare type UIState = {
12
13
  slide: UISlideState;
13
14
  positions: UIPositionState;
14
15
  showQuitPopin: ShowQuitPopinState;
16
+ showButtonRevising: UIShowButtonRevisingState;
15
17
  showCongrats: UIShowCongratsState;
16
18
  };
17
19
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
@@ -21,8 +23,9 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
21
23
  slide: UISlideState;
22
24
  positions: UIPositionState;
23
25
  showQuitPopin: boolean;
26
+ showButtonRevising: boolean;
24
27
  showCongrats: boolean;
25
- }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
28
+ }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
26
29
  type: "@@ui/OPEN_POPIN";
27
30
  } | {
28
31
  type: "@@ui/CLOSE_POPIN";
@@ -5,6 +5,7 @@ import answers from './answers';
5
5
  import positions from './positions';
6
6
  import slide from './slide';
7
7
  import showQuitPopin from './quit-popin';
8
+ import showButtonRevising from './show-button-revising';
8
9
  import showCongrats from './show-congrats';
9
10
  export default combineReducers({
10
11
  currentSlideRef,
@@ -13,5 +14,6 @@ export default combineReducers({
13
14
  slide,
14
15
  positions,
15
16
  showQuitPopin,
17
+ showButtonRevising,
16
18
  showCongrats
17
19
  });
@@ -0,0 +1,4 @@
1
+ import { ReceivedSlidesToReviewBySkillRef } from '../../actions/api/fetch-slides-to-review-by-skill-ref';
2
+ export declare type UIShowButtonRevisingState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: ReceivedSlidesToReviewBySkillRef) => UIShowButtonRevisingState;
4
+ export default reducer;
@@ -0,0 +1,13 @@
1
+ import { SLIDES_TO_REVIEW_FETCH_SUCCESS } from '../../actions/api/fetch-slides-to-review-by-skill-ref';
2
+ const reducer = (
3
+ // eslint-disable-next-line default-param-last
4
+ state = false, action) => {
5
+ switch (action.type) {
6
+ case SLIDES_TO_REVIEW_FETCH_SUCCESS: {
7
+ return action.payload.length === 5;
8
+ }
9
+ default:
10
+ return state;
11
+ }
12
+ };
13
+ export default reducer;
@@ -1,2 +1,2 @@
1
1
  import { SlideIdFromAPI } from '../types/common';
2
- export declare const fetchSlidesToReviewBySkillRef: (url: string, token: string, skillRef: string) => Promise<SlideIdFromAPI[]>;
2
+ export declare const fetchSlidesToReviewBySkillRef: (token: string, skillRef: string) => Promise<SlideIdFromAPI[]>;
@@ -1,8 +1,10 @@
1
1
  import crossFetch from 'cross-fetch';
2
2
  import decode from 'jwt-decode';
3
3
  import { toJSON } from './tools/fetch-responses';
4
- export const fetchSlidesToReviewBySkillRef = async (url, token, skillRef) => {
5
- const { user: userId } = decode(token);
6
- const response = await crossFetch(`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`);
4
+ export const fetchSlidesToReviewBySkillRef = async (token, skillRef) => {
5
+ const { user: userId, host } = decode(token);
6
+ const response = await crossFetch(`${host}/api/v2/skills/${skillRef}/review/user/${userId}/slide`, {
7
+ headers: { authorization: token }
8
+ });
7
9
  return toJSON(response);
8
10
  };
@@ -128,6 +128,10 @@ export declare type Skill = {
128
128
  custom: boolean;
129
129
  name: string;
130
130
  };
131
+ export declare type SkillOptions = {
132
+ name: string;
133
+ ref: string;
134
+ };
131
135
  export declare type Services = {
132
136
  fetchSkills(token: string): Promise<Skill[]>;
133
137
  fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
@@ -135,7 +139,7 @@ export declare type Services = {
135
139
  postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
136
140
  fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
137
141
  fetchRank(token: string): Promise<Rank>;
138
- fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
142
+ fetchSlidesToReviewBySkillRef(token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
139
143
  };
140
144
  export declare type Options = {
141
145
  services: Services;
@@ -143,12 +147,11 @@ export declare type Options = {
143
147
  export declare type ConnectedOptions = {
144
148
  translate: (key: string, data?: unknown) => string;
145
149
  onQuitClick: () => void;
150
+ skill: SkillOptions;
146
151
  };
147
152
  export declare type AppOptions = ConnectedOptions & {
148
153
  token: string;
149
- skillRef?: string;
150
154
  services: Services;
151
- url: string;
152
155
  callbackOnViewChanged?: (viewName: ViewName) => void;
153
156
  };
154
157
  export declare type ThunkOptions = {
@@ -189,28 +189,28 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
189
189
  type: isCorrect ? 'right' : 'wrong'
190
190
  };
191
191
  };
192
- const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
192
+ const buildQuitPopinProps = (dispatch) => (onQuitClick, translate) => {
193
193
  return {
194
- content: `Tu t'en vas déjà ?`,
194
+ content: translate('Quit Title'),
195
195
  icon: `MoonRocket`,
196
196
  mode: 'alert',
197
- descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
197
+ descriptionText: translate('Quit Description Text'),
198
198
  firstButton: {
199
- label: 'Arrêter ma session',
199
+ label: translate('Stop learning'),
200
200
  type: 'tertiary',
201
201
  customStyle: {
202
202
  color: '#ED3436'
203
203
  },
204
204
  handleOnclick: onQuitClick,
205
- 'aria-label': 'Stop session'
205
+ 'aria-label': translate('Stop learning')
206
206
  },
207
207
  secondButton: {
208
- label: `Continuer d'apprendre`,
208
+ label: translate('Continue learning'),
209
209
  type: 'primary',
210
210
  handleOnclick: () => {
211
211
  dispatch(closeQuitPopin);
212
212
  },
213
- 'aria-label': 'Continue review'
213
+ 'aria-label': translate('Continue learning')
214
214
  }
215
215
  };
216
216
  };
@@ -282,7 +282,7 @@ const isEndOfProgression = (progression) => {
282
282
  return progression.state.nextContent.ref === 'successExitNode';
283
283
  };
284
284
  export const mapStateToSlidesProps = (state, dispatch, options) => {
285
- const { translate, onQuitClick } = options;
285
+ const { translate, onQuitClick, skill } = options;
286
286
  const currentSlideRef = getCurrentSlideRef(state);
287
287
  const endReview = isEndOfProgression(state.data.progression);
288
288
  const correction = get(['data', 'corrections', currentSlideRef], state);
@@ -290,10 +290,12 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
290
290
  const klf = getOr('', ['data', 'slides', currentSlideRef, 'klf'], state);
291
291
  const showQuitPopin = get(['ui', 'showQuitPopin'], state);
292
292
  const showCongrats = get(['ui', 'showCongrats'], state);
293
+ // eslint-disable-next-line no-console
294
+ console.log(skill.name);
293
295
  return {
294
296
  header: {
295
297
  mode: translate('Review Title'),
296
- skillName: '__agility',
298
+ skillName: skill.name,
297
299
  onQuitClick: () => dispatch(openQuitPopin),
298
300
  'aria-label': 'aria-header-wrapper',
299
301
  closeButtonAriaLabel: 'aria-close-button',
@@ -314,6 +316,6 @@ export const mapStateToSlidesProps = (state, dispatch, options) => {
314
316
  endReview: endReview && state.ui.showCongrats
315
317
  },
316
318
  congrats: buildCongratsProps(state, translate),
317
- quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
319
+ quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick, translate) : undefined
318
320
  };
319
321
  };
@@ -0,0 +1,11 @@
1
+ import type { Dispatch } from 'redux';
2
+ import type { StoreState } from '../../reducers';
3
+ import type { Options, SlideIdFromAPI } from '../../types/common';
4
+ export declare const SLIDES_TO_REVIEW_FETCH_REQUEST: "@@slidesToReview/FETCH_REQUEST";
5
+ export declare const SLIDES_TO_REVIEW_FETCH_SUCCESS: "@@slidesToReview/FETCH_SUCCESS";
6
+ export declare const SLIDES_TO_REVIEW_FETCH_FAILURE: "@@slidesToReview/FETCH_FAILURE";
7
+ export declare type ReceivedSlidesToReviewBySkillRef = {
8
+ type: typeof SLIDES_TO_REVIEW_FETCH_SUCCESS;
9
+ payload: SlideIdFromAPI[];
10
+ };
11
+ export declare const fetchSlidesToReviewBySkillRef: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => ReceivedSlidesToReviewBySkillRef;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchSlidesToReviewBySkillRef = exports.SLIDES_TO_REVIEW_FETCH_FAILURE = exports.SLIDES_TO_REVIEW_FETCH_SUCCESS = exports.SLIDES_TO_REVIEW_FETCH_REQUEST = void 0;
7
+ const redux_task_1 = __importDefault(require("@coorpacademy/redux-task"));
8
+ exports.SLIDES_TO_REVIEW_FETCH_REQUEST = '@@slidesToReview/FETCH_REQUEST';
9
+ exports.SLIDES_TO_REVIEW_FETCH_SUCCESS = '@@slidesToReview/FETCH_SUCCESS';
10
+ exports.SLIDES_TO_REVIEW_FETCH_FAILURE = '@@slidesToReview/FETCH_FAILURE';
11
+ const fetchSlidesToReviewBySkillRef = (dispatch, getState, { services }) => {
12
+ const action = (0, redux_task_1.default)({
13
+ types: [
14
+ exports.SLIDES_TO_REVIEW_FETCH_REQUEST,
15
+ exports.SLIDES_TO_REVIEW_FETCH_SUCCESS,
16
+ exports.SLIDES_TO_REVIEW_FETCH_FAILURE
17
+ ],
18
+ task: () => {
19
+ const state = getState();
20
+ const token = state.data.token;
21
+ const progression = state.data.progression;
22
+ const skillRef = progression.content.ref;
23
+ return services.fetchSlidesToReviewBySkillRef(token, skillRef);
24
+ }
25
+ });
26
+ return dispatch(action);
27
+ };
28
+ exports.fetchSlidesToReviewBySkillRef = fetchSlidesToReviewBySkillRef;
@@ -9,6 +9,7 @@ const get_1 = __importDefault(require("lodash/fp/get"));
9
9
  const fetch_correction_1 = require("./fetch-correction");
10
10
  const fetch_slide_1 = require("./fetch-slide");
11
11
  const fetch_rank_1 = require("./fetch-rank");
12
+ const fetch_slides_to_review_by_skill_ref_1 = require("./fetch-slides-to-review-by-skill-ref");
12
13
  exports.POST_ANSWER_REQUEST = '@@answer/POST_REQUEST';
13
14
  exports.POST_ANSWER_SUCCESS = '@@answer/POST_SUCCESS';
14
15
  exports.POST_ANSWER_FAILURE = '@@answer/POST_FAILURE';
@@ -37,6 +38,7 @@ const postAnswer = async (dispatch, getState, { services }) => {
37
38
  else {
38
39
  await dispatch(fetch_correction_1.fetchCorrection);
39
40
  await dispatch(fetch_rank_1.fetchEndRank);
41
+ await dispatch(fetch_slides_to_review_by_skill_ref_1.fetchSlidesToReviewBySkillRef);
40
42
  }
41
43
  }
42
44
  };
package/lib/index.js CHANGED
@@ -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 { translate, onQuitClick, skill } = options;
56
56
  (0, react_1.useEffect)(() => {
57
57
  if (store)
58
58
  return;
@@ -77,25 +77,23 @@ const AppReview = ({ options }) => {
77
77
  const token = (0, get_1.default)('token', options);
78
78
  if (store === null || (0, isEmpty_1.default)(token))
79
79
  return;
80
- const skillRef = (0, get_1.default)('skillRef', options);
81
80
  /* ThunkAction is not assignable to parameter of type 'AnyAction'
82
81
  ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
83
- skillRef ? store.dispatch((0, post_progression_1.postProgression)(skillRef)) : store.dispatch(fetch_skills_1.fetchSkills);
82
+ skill.ref ? store.dispatch((0, post_progression_1.postProgression)(skill.ref)) : store.dispatch(fetch_skills_1.fetchSkills);
84
83
  }, [options, store]);
85
84
  (0, react_1.useEffect)(() => {
86
85
  if (store === null)
87
86
  return;
88
- const { skillRef } = options;
89
- if (skillRef && !isProgressionCreated) {
87
+ if (skill.ref && !isProgressionCreated) {
90
88
  store.dispatch((0, navigation_1.navigateTo)('loader')); // use loader while posting progression
91
89
  return;
92
90
  }
93
- const initialView = skillRef ? 'slides' : 'skills';
91
+ const initialView = skill.ref ? 'slides' : 'skills';
94
92
  store.dispatch((0, navigation_1.navigateTo)(initialView));
95
93
  }, [isProgressionCreated, options, store]);
96
94
  if (!store)
97
95
  return null;
98
96
  return (react_1.default.createElement(react_redux_1.Provider, { store: store },
99
- react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate })));
97
+ react_1.default.createElement(ConnectedApp, { onQuitClick: onQuitClick, translate: translate, skill: skill })));
100
98
  };
101
99
  exports.default = AppReview;
@@ -20,9 +20,10 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
20
20
  slide: import("./ui/slide").UISlideState;
21
21
  positions: import("./ui/positions").UIPositionState;
22
22
  showQuitPopin: boolean;
23
+ showButtonRevising: boolean;
23
24
  showCongrats: boolean;
24
25
  }>;
25
- }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | 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 | {
26
+ }>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlideAction | 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/post-progression").ReceivedProgression | 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 | {
26
27
  type: "@@ui/OPEN_POPIN";
27
28
  } | {
28
29
  type: "@@ui/CLOSE_POPIN";
@@ -4,6 +4,7 @@ import { UIAnswerState } from './answers';
4
4
  import { UIPositionState } from './positions';
5
5
  import { UISlideState } from './slide';
6
6
  import { type ShowQuitPopinState } from './quit-popin';
7
+ import { UIShowButtonRevisingState } from './show-button-revising';
7
8
  import { UIShowCongratsState } from './show-congrats';
8
9
  export declare type UIState = {
9
10
  currentSlideRef: CurrentSlideRefState;
@@ -12,6 +13,7 @@ export declare type UIState = {
12
13
  slide: UISlideState;
13
14
  positions: UIPositionState;
14
15
  showQuitPopin: ShowQuitPopinState;
16
+ showButtonRevising: UIShowButtonRevisingState;
15
17
  showCongrats: UIShowCongratsState;
16
18
  };
17
19
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
@@ -21,8 +23,9 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
21
23
  slide: UISlideState;
22
24
  positions: UIPositionState;
23
25
  showQuitPopin: boolean;
26
+ showButtonRevising: boolean;
24
27
  showCongrats: boolean;
25
- }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
28
+ }>, import("../../actions/api/fetch-correction").ReceivedCorrection | import("../../actions/ui/slides").SetCurrentSlideAction | import("../../actions/api/fetch-slide").FetchSlide | import("../../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/ui/next-slide").NextSlideAction | import("../../actions/ui/navigation").NavigateToAction | import("../../actions/ui/navigation").NavigateBackAction | import("../../actions/ui/answers").EditAnswerAction | {
26
29
  type: "@@ui/OPEN_POPIN";
27
30
  } | {
28
31
  type: "@@ui/CLOSE_POPIN";
@@ -10,6 +10,7 @@ const answers_1 = __importDefault(require("./answers"));
10
10
  const positions_1 = __importDefault(require("./positions"));
11
11
  const slide_1 = __importDefault(require("./slide"));
12
12
  const quit_popin_1 = __importDefault(require("./quit-popin"));
13
+ const show_button_revising_1 = __importDefault(require("./show-button-revising"));
13
14
  const show_congrats_1 = __importDefault(require("./show-congrats"));
14
15
  exports.default = (0, redux_1.combineReducers)({
15
16
  currentSlideRef: current_slide_ref_1.default,
@@ -18,5 +19,6 @@ exports.default = (0, redux_1.combineReducers)({
18
19
  slide: slide_1.default,
19
20
  positions: positions_1.default,
20
21
  showQuitPopin: quit_popin_1.default,
22
+ showButtonRevising: show_button_revising_1.default,
21
23
  showCongrats: show_congrats_1.default
22
24
  });
@@ -0,0 +1,4 @@
1
+ import { ReceivedSlidesToReviewBySkillRef } from '../../actions/api/fetch-slides-to-review-by-skill-ref';
2
+ export declare type UIShowButtonRevisingState = boolean;
3
+ declare const reducer: (state: boolean | undefined, action: ReceivedSlidesToReviewBySkillRef) => UIShowButtonRevisingState;
4
+ export default reducer;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fetch_slides_to_review_by_skill_ref_1 = require("../../actions/api/fetch-slides-to-review-by-skill-ref");
4
+ const reducer = (
5
+ // eslint-disable-next-line default-param-last
6
+ state = false, action) => {
7
+ switch (action.type) {
8
+ case fetch_slides_to_review_by_skill_ref_1.SLIDES_TO_REVIEW_FETCH_SUCCESS: {
9
+ return action.payload.length === 5;
10
+ }
11
+ default:
12
+ return state;
13
+ }
14
+ };
15
+ exports.default = reducer;
@@ -1,2 +1,2 @@
1
1
  import { SlideIdFromAPI } from '../types/common';
2
- export declare const fetchSlidesToReviewBySkillRef: (url: string, token: string, skillRef: string) => Promise<SlideIdFromAPI[]>;
2
+ export declare const fetchSlidesToReviewBySkillRef: (token: string, skillRef: string) => Promise<SlideIdFromAPI[]>;
@@ -7,9 +7,11 @@ exports.fetchSlidesToReviewBySkillRef = void 0;
7
7
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
8
8
  const jwt_decode_1 = __importDefault(require("jwt-decode"));
9
9
  const fetch_responses_1 = require("./tools/fetch-responses");
10
- const fetchSlidesToReviewBySkillRef = async (url, token, skillRef) => {
11
- const { user: userId } = (0, jwt_decode_1.default)(token);
12
- const response = await (0, cross_fetch_1.default)(`${url}/api/v1/review/users/${userId}/skills/${skillRef}/slide?limit=5&offset=0`);
10
+ const fetchSlidesToReviewBySkillRef = async (token, skillRef) => {
11
+ const { user: userId, host } = (0, jwt_decode_1.default)(token);
12
+ const response = await (0, cross_fetch_1.default)(`${host}/api/v2/skills/${skillRef}/review/user/${userId}/slide`, {
13
+ headers: { authorization: token }
14
+ });
13
15
  return (0, fetch_responses_1.toJSON)(response);
14
16
  };
15
17
  exports.fetchSlidesToReviewBySkillRef = fetchSlidesToReviewBySkillRef;
@@ -128,6 +128,10 @@ export declare type Skill = {
128
128
  custom: boolean;
129
129
  name: string;
130
130
  };
131
+ export declare type SkillOptions = {
132
+ name: string;
133
+ ref: string;
134
+ };
131
135
  export declare type Services = {
132
136
  fetchSkills(token: string): Promise<Skill[]>;
133
137
  fetchSlide(slideRef: string, token: string): Promise<SlideFromAPI | void>;
@@ -135,7 +139,7 @@ export declare type Services = {
135
139
  postAnswer(progression: ProgressionFromAPI, token: string, answer: string[]): Promise<ProgressionFromAPI>;
136
140
  fetchCorrection(slideRef: string, token: string, progressionId: string, answer: string[]): Promise<CorrectionFromAPI | void>;
137
141
  fetchRank(token: string): Promise<Rank>;
138
- fetchSlidesToReviewBySkillRef(url: string, token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
142
+ fetchSlidesToReviewBySkillRef(token: string, skillRef: string): Promise<SlideIdFromAPI[]>;
139
143
  };
140
144
  export declare type Options = {
141
145
  services: Services;
@@ -143,12 +147,11 @@ export declare type Options = {
143
147
  export declare type ConnectedOptions = {
144
148
  translate: (key: string, data?: unknown) => string;
145
149
  onQuitClick: () => void;
150
+ skill: SkillOptions;
146
151
  };
147
152
  export declare type AppOptions = ConnectedOptions & {
148
153
  token: string;
149
- skillRef?: string;
150
154
  services: Services;
151
- url: string;
152
155
  callbackOnViewChanged?: (viewName: ViewName) => void;
153
156
  };
154
157
  export declare type ThunkOptions = {
@@ -196,28 +196,28 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
196
196
  type: isCorrect ? 'right' : 'wrong'
197
197
  };
198
198
  };
199
- const buildQuitPopinProps = (dispatch) => (onQuitClick) => {
199
+ const buildQuitPopinProps = (dispatch) => (onQuitClick, translate) => {
200
200
  return {
201
- content: `Tu t'en vas déjà ?`,
201
+ content: translate('Quit Title'),
202
202
  icon: `MoonRocket`,
203
203
  mode: 'alert',
204
- descriptionText: `Tu vas t'en sortir ! Si tu arrêtes maintenant, tu vas perdre ta progression.`,
204
+ descriptionText: translate('Quit Description Text'),
205
205
  firstButton: {
206
- label: 'Arrêter ma session',
206
+ label: translate('Stop learning'),
207
207
  type: 'tertiary',
208
208
  customStyle: {
209
209
  color: '#ED3436'
210
210
  },
211
211
  handleOnclick: onQuitClick,
212
- 'aria-label': 'Stop session'
212
+ 'aria-label': translate('Stop learning')
213
213
  },
214
214
  secondButton: {
215
- label: `Continuer d'apprendre`,
215
+ label: translate('Continue learning'),
216
216
  type: 'primary',
217
217
  handleOnclick: () => {
218
218
  dispatch(quit_popin_1.closeQuitPopin);
219
219
  },
220
- 'aria-label': 'Continue review'
220
+ 'aria-label': translate('Continue learning')
221
221
  }
222
222
  };
223
223
  };
@@ -289,7 +289,7 @@ const isEndOfProgression = (progression) => {
289
289
  return progression.state.nextContent.ref === 'successExitNode';
290
290
  };
291
291
  const mapStateToSlidesProps = (state, dispatch, options) => {
292
- const { translate, onQuitClick } = options;
292
+ const { translate, onQuitClick, skill } = options;
293
293
  const currentSlideRef = getCurrentSlideRef(state);
294
294
  const endReview = isEndOfProgression(state.data.progression);
295
295
  const correction = (0, get_1.default)(['data', 'corrections', currentSlideRef], state);
@@ -297,10 +297,12 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
297
297
  const klf = (0, getOr_1.default)('', ['data', 'slides', currentSlideRef, 'klf'], state);
298
298
  const showQuitPopin = (0, get_1.default)(['ui', 'showQuitPopin'], state);
299
299
  const showCongrats = (0, get_1.default)(['ui', 'showCongrats'], state);
300
+ // eslint-disable-next-line no-console
301
+ console.log(skill.name);
300
302
  return {
301
303
  header: {
302
304
  mode: translate('Review Title'),
303
- skillName: '__agility',
305
+ skillName: skill.name,
304
306
  onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
305
307
  'aria-label': 'aria-header-wrapper',
306
308
  closeButtonAriaLabel: 'aria-close-button',
@@ -321,7 +323,7 @@ const mapStateToSlidesProps = (state, dispatch, options) => {
321
323
  endReview: endReview && state.ui.showCongrats
322
324
  },
323
325
  congrats: buildCongratsProps(state, translate),
324
- quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick) : undefined
326
+ quitPopin: showQuitPopin ? buildQuitPopinProps(dispatch)(onQuitClick, translate) : undefined
325
327
  };
326
328
  };
327
329
  exports.mapStateToSlidesProps = mapStateToSlidesProps;
@@ -1,14 +1,18 @@
1
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!"
2
+ "Review Title": "Recenzija Mode",
3
+ "Content Parent Title": "Od `{{contentTitle}}` `{{contentType}}`",
4
+ "Validate": "Potvrdi",
5
+ "Next question": "Sljedeće pitanje",
6
+ "KLF": "Ključni faktor učenja",
7
+ "Correct Answer": "Tačan odgovor",
8
+ "Wrong Answer": "Pogrešan odgovor",
9
+ "You have won": "Pobijedio si",
10
+ "You are now": "Sada jesi",
11
+ "Revise another skill": "Revidirajte drugu vještinu",
12
+ "Continue reviewing": "Nastavite sa pregledom",
13
+ "Congratulations!": "Čestitamo!",
14
+ "Quit Title": "Are you sure you want to quit ?",
15
+ "Quit Description Text": "You’re right on track! If you quit now, you’ll lose your progress.",
16
+ "Stop learning": "End session",
17
+ "Continue learning": "Continue learning"
14
18
  }