@coorpacademy/app-review 0.7.2-alpha.0 → 0.7.2-alpha.4

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,12 +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
- translate: Function;
146
151
  url: string;
147
152
  callbackOnViewChanged?: (viewName: ViewName) => void;
148
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 {};
@@ -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,7 +292,7 @@ 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
+ mode: translate('Review Title'),
295
296
  skillName: '__agility',
296
297
  onQuitClick: () => dispatch(openQuitPopin),
297
298
  'aria-label': 'aria-header-wrapper',
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,12 +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
- translate: Function;
146
151
  url: string;
147
152
  callbackOnViewChanged?: (viewName: ViewName) => void;
148
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 {};
@@ -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,7 +299,7 @@ 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
+ mode: translate('Review Title'),
302
303
  skillName: '__agility',
303
304
  onQuitClick: () => dispatch(quit_popin_1.openQuitPopin),
304
305
  'aria-label': 'aria-header-wrapper',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.7.2-alpha.0+c67805b5f",
3
+ "version": "0.7.2-alpha.4+e1775899f",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -34,7 +34,7 @@
34
34
  "main": "lib/index.js",
35
35
  "module": "es/index.js",
36
36
  "dependencies": {
37
- "@coorpacademy/components": "10.27.1-alpha.0+c67805b5f",
37
+ "@coorpacademy/components": "10.27.0",
38
38
  "@coorpacademy/redux-task": "1.1.6",
39
39
  "@coorpacademy/translate": "6.1.5",
40
40
  "cross-fetch": "^3.1.5",
@@ -70,5 +70,5 @@
70
70
  "webpack-cli": "^4.10.0",
71
71
  "webpack-dev-server": "^4.11.1"
72
72
  },
73
- "gitHead": "c67805b5f6cd6c8d74a4d9c3ead99fa8a0d5465d"
73
+ "gitHead": "e1775899ff6dac4b740383674f511e550a203ca2"
74
74
  }