@coorpacademy/app-review 0.8.1 → 0.8.3-alpha.3

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.
@@ -0,0 +1,5 @@
1
+ import { ReceivedSkill } from '../../actions/api/fetch-skill';
2
+ import { Skill } from '../../types/common';
3
+ export declare type CurrentSkillState = Skill | null;
4
+ declare const reducer: (state: CurrentSkillState | undefined, action: ReceivedSkill) => CurrentSkillState;
5
+ export default reducer;
@@ -0,0 +1,13 @@
1
+ import { SKILL_FETCH_SUCCESS } from '../../actions/api/fetch-skill';
2
+ const initialState = null;
3
+ const reducer = (
4
+ // eslint-disable-next-line default-param-last
5
+ state = initialState, action) => {
6
+ switch (action.type) {
7
+ case SKILL_FETCH_SUCCESS:
8
+ return action.payload;
9
+ default:
10
+ return state;
11
+ }
12
+ };
13
+ export default reducer;
@@ -4,6 +4,7 @@ import { SkillsState } from './skills';
4
4
  import { SlidesState } from './slides';
5
5
  import { TokenState } from './token';
6
6
  import { RankState } from './rank';
7
+ import { CurrentSkillState } from './current-skill';
7
8
  export declare type DataState = {
8
9
  corrections: CorrectionsState;
9
10
  progression: ProgressionState;
@@ -11,6 +12,7 @@ export declare type DataState = {
11
12
  slides: SlidesState;
12
13
  token: TokenState;
13
14
  rank: RankState;
15
+ currentSkill: CurrentSkillState;
14
16
  };
15
17
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
18
  corrections: CorrectionsState;
@@ -19,5 +21,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
21
  slides: SlidesState;
20
22
  token: string;
21
23
  rank: RankState;
22
- }>, import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
24
+ currentSkill: CurrentSkillState;
25
+ }>, import("../../actions/api/fetch-skill").ReceivedSkill | import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
23
26
  export default _default;
@@ -5,4 +5,13 @@ import skills from './skills';
5
5
  import slides from './slides';
6
6
  import token from './token';
7
7
  import rank from './rank';
8
- export default combineReducers({ corrections, progression, skills, slides, token, rank });
8
+ import currentSkill from './current-skill';
9
+ export default combineReducers({
10
+ corrections,
11
+ progression,
12
+ skills,
13
+ slides,
14
+ token,
15
+ rank,
16
+ currentSkill
17
+ });
@@ -12,6 +12,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
12
12
  slides: import("./data/slides").SlidesState;
13
13
  token: string;
14
14
  rank: import("./data/rank").RankState;
15
+ currentSkill: import("./data/current-skill").CurrentSkillState;
15
16
  }>;
16
17
  ui: import("redux").CombinedState<{
17
18
  currentSlideRef: string;
@@ -23,7 +24,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
23
24
  showButtonRevising: boolean;
24
25
  showCongrats: boolean;
25
26
  }>;
26
- }>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
27
+ }>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-skill").ReceivedSkill | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
27
28
  type: "@@ui/OPEN_POPIN";
28
29
  } | {
29
30
  type: "@@ui/CLOSE_POPIN";
@@ -1,24 +1,3 @@
1
+ import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
1
2
  import { StoreState } from '../../reducers';
2
- declare type SkillCard = {
3
- 'aria-label': string;
4
- skillTitle: string;
5
- skillAriaLabel: string;
6
- buttonLabel: string;
7
- buttonAriaLabel: string;
8
- reviseLabel: string;
9
- reviseAriaLabel: string;
10
- isCustom: boolean;
11
- onClick: () => void;
12
- };
13
- declare type NoSkillsProps = {
14
- iconSkillAriaLabel: string;
15
- };
16
- declare type SkillsProps = NoSkillsProps & {
17
- 'aria-label'?: string;
18
- title: string;
19
- isLoading?: boolean;
20
- isLoadingAriaLabel: string;
21
- listSkills: SkillCard[];
22
- };
23
- export { SkillsProps };
24
- export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
3
+ export declare const mapStateToSkillsProps: (state: StoreState) => ReviewSkillsProps;
@@ -1,11 +1,11 @@
1
1
  export const mapStateToSkillsProps = (state) => {
2
2
  return {
3
+ 'aria-label': '@todo aria-label',
3
4
  title: '@todo title',
4
- iconSkillAriaLabel: '@todo iconSkillAriaLabel',
5
5
  isLoading: false,
6
6
  isLoadingAriaLabel: '@todo loading',
7
7
  listSkills: state.data.skills.map(skill => ({
8
- 'aria-label': '',
8
+ 'aria-label': '@todo aria-label skill',
9
9
  isCustom: skill.custom,
10
10
  skillTitle: skill.name,
11
11
  skillAriaLabel: '@todo skill aria label',
@@ -15,6 +15,9 @@ export const mapStateToSkillsProps = (state) => {
15
15
  reviseAriaLabel: '@todo revise aria label',
16
16
  // eslint-disable-next-line no-console
17
17
  onClick: () => console.log('@todo plug dispatcher select skill')
18
- }))
18
+ })),
19
+ titleNoSkills: '@todo title no skills',
20
+ textNoSkills: '@todo text no skills',
21
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel'
19
22
  };
20
23
  };
@@ -60,6 +60,9 @@ const getCurrentSlideRef = (state) => {
60
60
  const content = progression.state.content;
61
61
  return content.ref;
62
62
  };
63
+ const isLastSlideAnswered = (slidesRef, slideRef) => {
64
+ return last(slidesRef) === slideRef;
65
+ };
63
66
  const buildStackSlides = (state, dispatch, options) => {
64
67
  const { translate } = options;
65
68
  const currentSlideRef = getCurrentSlideRef(state);
@@ -70,9 +73,12 @@ const buildStackSlides = (state, dispatch, options) => {
70
73
  // @ts-expect-error typescript does not support capped versions of lodash functions
71
74
  const stack = reduce.convert({ cap: false })((acc, uiSlide, _index) => {
72
75
  const index = toInteger(_index);
73
- const positions = state.ui.positions;
74
- const position = positions[index];
75
76
  const slideRef = slideRefs[index];
77
+ const lastAnsweredSlideRef = isLastSlideAnswered(progression.state.slides, slideRef);
78
+ const positions = state.ui.positions;
79
+ // when unstack the last answered slide (position -1), we set the position to 0 only during the animation
80
+ // to avoid to hide the slide (caused by the position -1).
81
+ const position = lastAnsweredSlideRef && positions[index] === -1 ? 0 : positions[index];
76
82
  if (!slideRef)
77
83
  return set(index, { ...uiSlide, position }, acc);
78
84
  const slideFromAPI = get(slideRef, state.data.slides);
@@ -85,7 +91,7 @@ const buildStackSlides = (state, dispatch, options) => {
85
91
  const slideUI = get(['ui', 'slide', slideRef], state);
86
92
  const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
87
93
  const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
88
- const animationType = slideUI.animationType;
94
+ const animationType = lastAnsweredSlideRef ? slideUI.animationType : undefined;
89
95
  const updatedUiSlide = {
90
96
  ...uiSlide,
91
97
  position,
@@ -182,7 +188,7 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
182
188
  resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
183
189
  information: {
184
190
  label: isCorrect ? translate('KLF') : translate('Correct Answer'),
185
- message: isCorrect ? klf : join(',', correctAnswer)
191
+ message: isCorrect ? klf : join(', ', correctAnswer)
186
192
  },
187
193
  next: {
188
194
  'aria-label': translate('Next Question'),
@@ -0,0 +1,5 @@
1
+ import { ReceivedSkill } from '../../actions/api/fetch-skill';
2
+ import { Skill } from '../../types/common';
3
+ export declare type CurrentSkillState = Skill | null;
4
+ declare const reducer: (state: CurrentSkillState | undefined, action: ReceivedSkill) => CurrentSkillState;
5
+ export default reducer;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fetch_skill_1 = require("../../actions/api/fetch-skill");
4
+ const initialState = null;
5
+ const reducer = (
6
+ // eslint-disable-next-line default-param-last
7
+ state = initialState, action) => {
8
+ switch (action.type) {
9
+ case fetch_skill_1.SKILL_FETCH_SUCCESS:
10
+ return action.payload;
11
+ default:
12
+ return state;
13
+ }
14
+ };
15
+ exports.default = reducer;
@@ -4,6 +4,7 @@ import { SkillsState } from './skills';
4
4
  import { SlidesState } from './slides';
5
5
  import { TokenState } from './token';
6
6
  import { RankState } from './rank';
7
+ import { CurrentSkillState } from './current-skill';
7
8
  export declare type DataState = {
8
9
  corrections: CorrectionsState;
9
10
  progression: ProgressionState;
@@ -11,6 +12,7 @@ export declare type DataState = {
11
12
  slides: SlidesState;
12
13
  token: TokenState;
13
14
  rank: RankState;
15
+ currentSkill: CurrentSkillState;
14
16
  };
15
17
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
16
18
  corrections: CorrectionsState;
@@ -19,5 +21,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
19
21
  slides: SlidesState;
20
22
  token: string;
21
23
  rank: RankState;
22
- }>, import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
24
+ currentSkill: CurrentSkillState;
25
+ }>, import("../../actions/api/fetch-skill").ReceivedSkill | import("../../actions/api/post-progression").FetchProgression | import("../../actions/api/post-progression").ReceivedProgression | import("./corrections").CorrectionsAction | import("../../actions/api/fetch-rank").RankAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
23
26
  export default _default;
@@ -10,4 +10,13 @@ const skills_1 = __importDefault(require("./skills"));
10
10
  const slides_1 = __importDefault(require("./slides"));
11
11
  const token_1 = __importDefault(require("./token"));
12
12
  const rank_1 = __importDefault(require("./rank"));
13
- exports.default = (0, redux_1.combineReducers)({ corrections: corrections_1.default, progression: progression_1.default, skills: skills_1.default, slides: slides_1.default, token: token_1.default, rank: rank_1.default });
13
+ const current_skill_1 = __importDefault(require("./current-skill"));
14
+ exports.default = (0, redux_1.combineReducers)({
15
+ corrections: corrections_1.default,
16
+ progression: progression_1.default,
17
+ skills: skills_1.default,
18
+ slides: slides_1.default,
19
+ token: token_1.default,
20
+ rank: rank_1.default,
21
+ currentSkill: current_skill_1.default
22
+ });
@@ -12,6 +12,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
12
12
  slides: import("./data/slides").SlidesState;
13
13
  token: string;
14
14
  rank: import("./data/rank").RankState;
15
+ currentSkill: import("./data/current-skill").CurrentSkillState;
15
16
  }>;
16
17
  ui: import("redux").CombinedState<{
17
18
  currentSlideRef: string;
@@ -23,7 +24,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
23
24
  showButtonRevising: boolean;
24
25
  showCongrats: boolean;
25
26
  }>;
26
- }>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
27
+ }>, import("../actions/ui/slides").SetCurrentSlideAction | import("../actions/api/fetch-skill").ReceivedSkill | import("../actions/api/post-progression").FetchProgression | import("../actions/api/post-progression").ReceivedProgression | import("./data/corrections").CorrectionsAction | import("../actions/api/fetch-rank").RankAction | import("../actions/api/fetch-slides-to-review-by-skill-ref").ReceivedSlidesToReviewBySkillRef | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/next-slide").NextSlideAction | import("../actions/ui/navigation").NavigateToAction | import("../actions/ui/navigation").NavigateBackAction | import("../actions/ui/answers").EditAnswerAction | {
27
28
  type: "@@ui/OPEN_POPIN";
28
29
  } | {
29
30
  type: "@@ui/CLOSE_POPIN";
@@ -1,24 +1,3 @@
1
+ import { ReviewSkillsProps } from '@coorpacademy/components/es/template/app-review/skills/prop-types';
1
2
  import { StoreState } from '../../reducers';
2
- declare type SkillCard = {
3
- 'aria-label': string;
4
- skillTitle: string;
5
- skillAriaLabel: string;
6
- buttonLabel: string;
7
- buttonAriaLabel: string;
8
- reviseLabel: string;
9
- reviseAriaLabel: string;
10
- isCustom: boolean;
11
- onClick: () => void;
12
- };
13
- declare type NoSkillsProps = {
14
- iconSkillAriaLabel: string;
15
- };
16
- declare type SkillsProps = NoSkillsProps & {
17
- 'aria-label'?: string;
18
- title: string;
19
- isLoading?: boolean;
20
- isLoadingAriaLabel: string;
21
- listSkills: SkillCard[];
22
- };
23
- export { SkillsProps };
24
- export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
3
+ export declare const mapStateToSkillsProps: (state: StoreState) => ReviewSkillsProps;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapStateToSkillsProps = void 0;
4
4
  const mapStateToSkillsProps = (state) => {
5
5
  return {
6
+ 'aria-label': '@todo aria-label',
6
7
  title: '@todo title',
7
- iconSkillAriaLabel: '@todo iconSkillAriaLabel',
8
8
  isLoading: false,
9
9
  isLoadingAriaLabel: '@todo loading',
10
10
  listSkills: state.data.skills.map(skill => ({
11
- 'aria-label': '',
11
+ 'aria-label': '@todo aria-label skill',
12
12
  isCustom: skill.custom,
13
13
  skillTitle: skill.name,
14
14
  skillAriaLabel: '@todo skill aria label',
@@ -18,7 +18,10 @@ const mapStateToSkillsProps = (state) => {
18
18
  reviseAriaLabel: '@todo revise aria label',
19
19
  // eslint-disable-next-line no-console
20
20
  onClick: () => console.log('@todo plug dispatcher select skill')
21
- }))
21
+ })),
22
+ titleNoSkills: '@todo title no skills',
23
+ textNoSkills: '@todo text no skills',
24
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel'
22
25
  };
23
26
  };
24
27
  exports.mapStateToSkillsProps = mapStateToSkillsProps;
@@ -66,6 +66,9 @@ const getCurrentSlideRef = (state) => {
66
66
  const content = progression.state.content;
67
67
  return content.ref;
68
68
  };
69
+ const isLastSlideAnswered = (slidesRef, slideRef) => {
70
+ return (0, last_1.default)(slidesRef) === slideRef;
71
+ };
69
72
  const buildStackSlides = (state, dispatch, options) => {
70
73
  const { translate } = options;
71
74
  const currentSlideRef = getCurrentSlideRef(state);
@@ -76,9 +79,12 @@ const buildStackSlides = (state, dispatch, options) => {
76
79
  // @ts-expect-error typescript does not support capped versions of lodash functions
77
80
  const stack = reduce_1.default.convert({ cap: false })((acc, uiSlide, _index) => {
78
81
  const index = (0, toInteger_1.default)(_index);
79
- const positions = state.ui.positions;
80
- const position = positions[index];
81
82
  const slideRef = slideRefs[index];
83
+ const lastAnsweredSlideRef = isLastSlideAnswered(progression.state.slides, slideRef);
84
+ const positions = state.ui.positions;
85
+ // when unstack the last answered slide (position -1), we set the position to 0 only during the animation
86
+ // to avoid to hide the slide (caused by the position -1).
87
+ const position = lastAnsweredSlideRef && positions[index] === -1 ? 0 : positions[index];
82
88
  if (!slideRef)
83
89
  return (0, set_1.default)(index, { ...uiSlide, position }, acc);
84
90
  const slideFromAPI = (0, get_1.default)(slideRef, state.data.slides);
@@ -91,7 +97,7 @@ const buildStackSlides = (state, dispatch, options) => {
91
97
  const slideUI = (0, get_1.default)(['ui', 'slide', slideRef], state);
92
98
  const animateCorrectionPopin = isCurrentSlideRef && slideUI.animateCorrectionPopin;
93
99
  const showCorrectionPopin = isCurrentSlideRef && slideUI.showCorrectionPopin;
94
- const animationType = slideUI.animationType;
100
+ const animationType = lastAnsweredSlideRef ? slideUI.animationType : undefined;
95
101
  const updatedUiSlide = {
96
102
  ...uiSlide,
97
103
  position,
@@ -189,7 +195,7 @@ const getCorrectionPopinProps = (dispatch) => (isCorrect, correctAnswer, klf, tr
189
195
  resultLabel: isCorrect ? translate('Correct Answer') : translate('Wrong Answer'),
190
196
  information: {
191
197
  label: isCorrect ? translate('KLF') : translate('Correct Answer'),
192
- message: isCorrect ? klf : (0, join_1.default)(',', correctAnswer)
198
+ message: isCorrect ? klf : (0, join_1.default)(', ', correctAnswer)
193
199
  },
194
200
  next: {
195
201
  'aria-label': translate('Next Question'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.8.1",
3
+ "version": "0.8.3-alpha.3+f2bb79b3c",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -35,9 +35,9 @@
35
35
  "main": "lib/index.js",
36
36
  "module": "es/index.js",
37
37
  "dependencies": {
38
- "@coorpacademy/components": "10.28.1",
38
+ "@coorpacademy/components": "10.28.3-alpha.3+f2bb79b3c",
39
39
  "@coorpacademy/redux-task": "1.1.6",
40
- "@coorpacademy/translate": "^6.1.5",
40
+ "@coorpacademy/translate": "6.1.5",
41
41
  "cross-fetch": "^3.1.5",
42
42
  "jwt-decode": "^3.1.2",
43
43
  "react-redux": "^7.2.9",
@@ -71,5 +71,5 @@
71
71
  "webpack-cli": "^4.10.0",
72
72
  "webpack-dev-server": "^4.11.1"
73
73
  },
74
- "gitHead": "f16cc5fd899c3a83f60b9909d29ea52a3a9c8c60"
74
+ "gitHead": "f2bb79b3cbf9c8299df8a8dde9d05b0ca98cc199"
75
75
  }