@coorpacademy/app-review 0.1.8 → 0.1.9

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.
@@ -1,10 +1,13 @@
1
- import { Action } from 'redux';
2
- import { Skill } from '../../types/common';
1
+ import type { ThunkAction } from 'redux-thunk';
2
+ import { AnyAction } from 'redux';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, Skill } from '../../types/common';
3
5
  export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
4
6
  export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
5
7
  export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
6
- export declare type ReceivedSkills = {
8
+ export interface ReceivedSkills extends AnyAction {
7
9
  type: '@@skills/FETCH_SUCCESS';
8
10
  payload: Skill[];
9
- };
10
- export declare const fetchSkills: (token: string) => Action;
11
+ }
12
+ export declare type FetchSkillsAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSkills: (token: string) => FetchSkillsAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { SlideFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, SlideFromAPI } from '../../types/common';
3
5
  export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
4
6
  export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
5
7
  export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
6
- export declare type ReceivedSlide = {
8
+ export interface ReceivedSlide extends AnyAction {
7
9
  type: typeof SLIDE_FETCH_SUCCESS;
8
10
  payload: SlideFromAPI;
9
- };
10
- export declare const fetchSlide: (slideRef: string, token: string) => Action;
11
+ }
12
+ export declare type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSlide: (slideRef: string, token: string) => FetchSlideAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { ProgressionFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import { Options, ProgressionFromAPI } from '../../types/common';
4
+ import type { StoreState } from '../../reducers';
3
5
  export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
4
6
  export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
5
7
  export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
6
- export declare type ReceiveProgression = {
8
+ export interface ReceiveProgression extends AnyAction {
7
9
  type: typeof POST_PROGRESSION_SUCCESS;
8
10
  payload: ProgressionFromAPI;
9
- };
10
- export declare const postProgression: (skillRef: string, token: string) => Action;
11
+ }
12
+ export declare type PostProgressionAction = ThunkAction<Promise<ProgressionFromAPI>, StoreState, Options, AnyAction>;
13
+ export declare const postProgression: (skillRef: string, token: string) => PostProgressionAction;
package/es/index.d.ts CHANGED
@@ -4,7 +4,7 @@ declare const AppReview: ({ options }: {
4
4
  }) => JSX.Element | null;
5
5
  declare global {
6
6
  interface Window {
7
- __REDUX_DEVTOOLS_EXTENSION__?: boolean;
7
+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
8
8
  }
9
9
  }
10
10
  export default AppReview;
package/es/index.js CHANGED
@@ -13,7 +13,6 @@ import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui
13
13
  import { fetchSkills } from './actions/api/fetch-skills';
14
14
  import { postProgression } from './actions/api/post-progression';
15
15
  import { VIEWS } from './common';
16
- // -----------------------------------------------------------------------------
17
16
  const mapDispatchToProps = {
18
17
  navigateTo,
19
18
  navigateBack,
@@ -26,7 +25,6 @@ const mapDispatchToProps = {
26
25
  updateFinishedSlides
27
26
  };
28
27
  const getCurrentViewName = (storeState) => storeState.ui.navigation[storeState.ui.navigation.length - 1];
29
- // -----------------------------------------------------------------------------
30
28
  const mapStateToSkillsProps = (state) => {
31
29
  if (!state.data.skills) {
32
30
  return null;
@@ -52,7 +50,6 @@ const mapStateToSkillsProps = (state) => {
52
50
  }))
53
51
  };
54
52
  };
55
- // -----------------------------------------------------------------------------
56
53
  const mapStateToSlidesProps = (state) => {
57
54
  if (!state.data.slides) {
58
55
  return null;
@@ -80,7 +77,6 @@ const mapStateToSlidesProps = (state) => {
80
77
  progression: state.data.progression
81
78
  };
82
79
  };
83
- // -----------------------------------------------------------------------------
84
80
  const mapStateToProps = (state) => {
85
81
  return {
86
82
  viewName: getCurrentViewName(state),
@@ -88,9 +84,7 @@ const mapStateToProps = (state) => {
88
84
  skills: mapStateToSkillsProps(state)
89
85
  };
90
86
  };
91
- // Props = StaticProps && Dispatchers
92
87
  const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
93
- // -----------------------------------------------------------------------------
94
88
  const AppReview = ({ options }) => {
95
89
  const [store, setStore] = useState(null);
96
90
  useEffect(() => {
@@ -116,6 +110,8 @@ const AppReview = ({ options }) => {
116
110
  if (store === null)
117
111
  return;
118
112
  const { skillRef, token } = options;
113
+ // ThunkAction is not assignable to parameter of type 'AnyAction'
114
+ // ts problem describre here = https://github.com/reduxjs/redux-thunk/issues/333
119
115
  skillRef
120
116
  ? store.dispatch(postProgression(skillRef, token))
121
117
  : store.dispatch(fetchSkills(token));
@@ -127,5 +123,4 @@ const AppReview = ({ options }) => {
127
123
  React.createElement(TemplateContext, { values: values },
128
124
  React.createElement(App, null))));
129
125
  };
130
- // -----------------------------------------------------------------------------
131
126
  export default AppReview;
@@ -1,10 +1,13 @@
1
- import { Action } from 'redux';
2
- import { Skill } from '../../types/common';
1
+ import type { ThunkAction } from 'redux-thunk';
2
+ import { AnyAction } from 'redux';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, Skill } from '../../types/common';
3
5
  export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
4
6
  export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
5
7
  export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
6
- export declare type ReceivedSkills = {
8
+ export interface ReceivedSkills extends AnyAction {
7
9
  type: '@@skills/FETCH_SUCCESS';
8
10
  payload: Skill[];
9
- };
10
- export declare const fetchSkills: (token: string) => Action;
11
+ }
12
+ export declare type FetchSkillsAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSkills: (token: string) => FetchSkillsAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { SlideFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import type { StoreState } from '../../reducers';
4
+ import { Options, SlideFromAPI } from '../../types/common';
3
5
  export declare const SLIDE_FETCH_REQUEST: "@@slides/FETCH_REQUEST";
4
6
  export declare const SLIDE_FETCH_SUCCESS: "@@slides/FETCH_SUCCESS";
5
7
  export declare const SLIDE_FETCH_FAILURE: "@@slides/FETCH_FAILURE";
6
- export declare type ReceivedSlide = {
8
+ export interface ReceivedSlide extends AnyAction {
7
9
  type: typeof SLIDE_FETCH_SUCCESS;
8
10
  payload: SlideFromAPI;
9
- };
10
- export declare const fetchSlide: (slideRef: string, token: string) => Action;
11
+ }
12
+ export declare type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
13
+ export declare const fetchSlide: (slideRef: string, token: string) => FetchSlideAction;
@@ -1,10 +1,13 @@
1
- import type { Action } from 'redux';
2
- import { ProgressionFromAPI } from '../../types/common';
1
+ import type { AnyAction } from 'redux';
2
+ import type { ThunkAction } from 'redux-thunk';
3
+ import { Options, ProgressionFromAPI } from '../../types/common';
4
+ import type { StoreState } from '../../reducers';
3
5
  export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
4
6
  export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
5
7
  export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
6
- export declare type ReceiveProgression = {
8
+ export interface ReceiveProgression extends AnyAction {
7
9
  type: typeof POST_PROGRESSION_SUCCESS;
8
10
  payload: ProgressionFromAPI;
9
- };
10
- export declare const postProgression: (skillRef: string, token: string) => Action;
11
+ }
12
+ export declare type PostProgressionAction = ThunkAction<Promise<ProgressionFromAPI>, StoreState, Options, AnyAction>;
13
+ export declare const postProgression: (skillRef: string, token: string) => PostProgressionAction;
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ declare const AppReview: ({ options }: {
4
4
  }) => JSX.Element | null;
5
5
  declare global {
6
6
  interface Window {
7
- __REDUX_DEVTOOLS_EXTENSION__?: boolean;
7
+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
8
8
  }
9
9
  }
10
10
  export default AppReview;
package/lib/index.js CHANGED
@@ -13,7 +13,6 @@ import { updateStepItemsOnValidation, updateStepItemsOnNext } from './actions/ui
13
13
  import { fetchSkills } from './actions/api/fetch-skills';
14
14
  import { postProgression } from './actions/api/post-progression';
15
15
  import { VIEWS } from './common';
16
- // -----------------------------------------------------------------------------
17
16
  var mapDispatchToProps = {
18
17
  navigateTo: navigateTo,
19
18
  navigateBack: navigateBack,
@@ -28,7 +27,6 @@ var mapDispatchToProps = {
28
27
  var getCurrentViewName = function (storeState) {
29
28
  return storeState.ui.navigation[storeState.ui.navigation.length - 1];
30
29
  };
31
- // -----------------------------------------------------------------------------
32
30
  var mapStateToSkillsProps = function (state) {
33
31
  if (!state.data.skills) {
34
32
  return null;
@@ -54,7 +52,6 @@ var mapStateToSkillsProps = function (state) {
54
52
  }); })
55
53
  };
56
54
  };
57
- // -----------------------------------------------------------------------------
58
55
  var mapStateToSlidesProps = function (state) {
59
56
  if (!state.data.slides) {
60
57
  return null;
@@ -82,7 +79,6 @@ var mapStateToSlidesProps = function (state) {
82
79
  progression: state.data.progression
83
80
  };
84
81
  };
85
- // -----------------------------------------------------------------------------
86
82
  var mapStateToProps = function (state) {
87
83
  return {
88
84
  viewName: getCurrentViewName(state),
@@ -90,9 +86,7 @@ var mapStateToProps = function (state) {
90
86
  skills: mapStateToSkillsProps(state)
91
87
  };
92
88
  };
93
- // Props = StaticProps && Dispatchers
94
89
  var App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
95
- // -----------------------------------------------------------------------------
96
90
  var AppReview = function (_a) {
97
91
  var options = _a.options;
98
92
  var _b = useState(null), store = _b[0], setStore = _b[1];
@@ -119,6 +113,8 @@ var AppReview = function (_a) {
119
113
  if (store === null)
120
114
  return;
121
115
  var skillRef = options.skillRef, token = options.token;
116
+ // ThunkAction is not assignable to parameter of type 'AnyAction'
117
+ // ts problem describre here = https://github.com/reduxjs/redux-thunk/issues/333
122
118
  skillRef
123
119
  ? store.dispatch(postProgression(skillRef, token))
124
120
  : store.dispatch(fetchSkills(token));
@@ -130,5 +126,4 @@ var AppReview = function (_a) {
130
126
  React.createElement(TemplateContext, { values: values },
131
127
  React.createElement(App, null))));
132
128
  };
133
- // -----------------------------------------------------------------------------
134
129
  export default AppReview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/app-review",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=16.15.0"
@@ -40,7 +40,7 @@
40
40
  "./package.json": "./package.json"
41
41
  },
42
42
  "dependencies": {
43
- "@coorpacademy/components": "10.22.2",
43
+ "@coorpacademy/components": "10.22.3",
44
44
  "@coorpacademy/redux-task": "^1.1.5",
45
45
  "cross-fetch": "^3.1.5",
46
46
  "jwt-decode": "^3.1.2",
@@ -76,6 +76,5 @@
76
76
  "react-dom": "^17.0.2",
77
77
  "ts-node": "^10.8.1",
78
78
  "typescript": "^4.7.4"
79
- },
80
- "gitHead": "b07a280786c4e83e3632779731e62a547d8ba26c"
79
+ }
81
80
  }
@@ -1,5 +1,6 @@
1
1
  import buildTask from '@coorpacademy/redux-task';
2
- import {Action, Dispatch} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
3
+ import {AnyAction} from 'redux';
3
4
  import type {StoreState} from '../../reducers';
4
5
  import {Options, Skill} from '../../types/common';
5
6
 
@@ -7,12 +8,15 @@ export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST' as const;
7
8
  export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS' as const;
8
9
  export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE' as const;
9
10
 
10
- export type ReceivedSkills = {
11
+ export interface ReceivedSkills extends AnyAction {
11
12
  type: '@@skills/FETCH_SUCCESS';
12
13
  payload: Skill[];
13
- };
14
+ }
14
15
 
15
- export const fetchSkills = (token: string): Action =>
16
+ export type FetchSkillsAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
17
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
18
+
19
+ export const fetchSkills = (token: string): FetchSkillsAction =>
16
20
  buildTask({
17
21
  types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
18
22
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) =>
@@ -1,4 +1,5 @@
1
- import type {Action, Dispatch} from 'redux';
1
+ import type {AnyAction} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
2
3
  import buildTask from '@coorpacademy/redux-task';
3
4
  import type {StoreState} from '../../reducers';
4
5
  import {Options, SlideFromAPI} from '../../types/common';
@@ -7,12 +8,15 @@ export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST' as const;
7
8
  export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS' as const;
8
9
  export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE' as const;
9
10
 
10
- export type ReceivedSlide = {
11
+ export interface ReceivedSlide extends AnyAction {
11
12
  type: typeof SLIDE_FETCH_SUCCESS;
12
13
  payload: SlideFromAPI;
13
- };
14
+ }
14
15
 
15
- export const fetchSlide = (slideRef: string, token: string): Action =>
16
+ export type FetchSlideAction = ThunkAction<Promise<void>, StoreState, Options, AnyAction>;
17
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
18
+
19
+ export const fetchSlide = (slideRef: string, token: string): FetchSlideAction =>
16
20
  buildTask({
17
21
  types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
18
22
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) =>
@@ -1,4 +1,5 @@
1
- import type {Action, Dispatch} from 'redux';
1
+ import type {AnyAction} from 'redux';
2
+ import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
2
3
  import buildTask from '@coorpacademy/redux-task';
3
4
  import {Options, ProgressionFromAPI} from '../../types/common';
4
5
  import type {StoreState} from '../../reducers';
@@ -8,12 +9,21 @@ export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST' as const;
8
9
  export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS' as const;
9
10
  export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE' as const;
10
11
 
11
- export type ReceiveProgression = {
12
+ export interface ReceiveProgression extends AnyAction {
12
13
  type: typeof POST_PROGRESSION_SUCCESS;
13
14
  payload: ProgressionFromAPI;
14
- };
15
+ }
15
16
 
16
- export const postProgression = (skillRef: string, token: string): Action =>
17
+ export type PostProgressionAction = ThunkAction<
18
+ Promise<ProgressionFromAPI>,
19
+ StoreState,
20
+ Options,
21
+ AnyAction
22
+ >;
23
+
24
+ type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
25
+
26
+ export const postProgression = (skillRef: string, token: string): PostProgressionAction =>
17
27
  buildTask({
18
28
  types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
19
29
  task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import React, {useEffect, useState} from 'react';
2
+ import type {} from 'redux-thunk/extend-redux'; // https://github.com/reduxjs/redux-thunk/issues/333
2
3
  import {AnyAction, Store} from 'redux';
3
4
  import {connect, Provider} from 'react-redux';
4
5
  import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
@@ -23,16 +24,12 @@ import {fetchSkills} from './actions/api/fetch-skills';
23
24
  import {postProgression} from './actions/api/post-progression';
24
25
  import {VIEWS} from './common';
25
26
 
26
- // -----------------------------------------------------------------------------
27
-
28
27
  type StaticProps = {
29
28
  viewName: 'skills' | 'onboarding' | 'slides';
30
29
  slides: SlidesViewStaticProps | null;
31
30
  skills: SkillsProps | null;
32
31
  };
33
32
 
34
- // -----------------------------------------------------------------------------
35
-
36
33
  const mapDispatchToProps: Dispatchers = {
37
34
  navigateTo,
38
35
  navigateBack,
@@ -48,8 +45,6 @@ const mapDispatchToProps: Dispatchers = {
48
45
  const getCurrentViewName = (storeState: StoreState): ViewPath =>
49
46
  storeState.ui.navigation[storeState.ui.navigation.length - 1];
50
47
 
51
- // -----------------------------------------------------------------------------
52
-
53
48
  const mapStateToSkillsProps = (state: StoreState): SkillsProps | null => {
54
49
  if (!state.data.skills) {
55
50
  return null;
@@ -77,8 +72,6 @@ const mapStateToSkillsProps = (state: StoreState): SkillsProps | null => {
77
72
  };
78
73
  };
79
74
 
80
- // -----------------------------------------------------------------------------
81
-
82
75
  const mapStateToSlidesProps = (state: StoreState): SlidesViewStaticProps | null => {
83
76
  if (!state.data.slides) {
84
77
  return null;
@@ -108,8 +101,6 @@ const mapStateToSlidesProps = (state: StoreState): SlidesViewStaticProps | null
108
101
  };
109
102
  };
110
103
 
111
- // -----------------------------------------------------------------------------
112
-
113
104
  const mapStateToProps = (state: StoreState): StaticProps => {
114
105
  return {
115
106
  viewName: getCurrentViewName(state),
@@ -118,12 +109,8 @@ const mapStateToProps = (state: StoreState): StaticProps => {
118
109
  };
119
110
  };
120
111
 
121
- // Props = StaticProps && Dispatchers
122
-
123
112
  const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
124
113
 
125
- // -----------------------------------------------------------------------------
126
-
127
114
  const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
128
115
  const [store, setStore] = useState<Store<StoreState, AnyAction> | null>(null);
129
116
 
@@ -153,6 +140,8 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
153
140
  if (store === null) return;
154
141
 
155
142
  const {skillRef, token} = options;
143
+ // ThunkAction is not assignable to parameter of type 'AnyAction'
144
+ // ts problem describre here = https://github.com/reduxjs/redux-thunk/issues/333
156
145
  skillRef
157
146
  ? store.dispatch(postProgression(skillRef, token))
158
147
  : store.dispatch(fetchSkills(token));
@@ -171,15 +160,11 @@ const AppReview = ({options}: {options: AppOptions}): JSX.Element | null => {
171
160
  );
172
161
  };
173
162
 
174
- // -----------------------------------------------------------------------------
175
-
176
163
  declare global {
177
164
  // eslint-disable-next-line no-shadow
178
165
  interface Window {
179
- __REDUX_DEVTOOLS_EXTENSION__?: boolean;
166
+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
180
167
  }
181
168
  }
182
169
 
183
- // -----------------------------------------------------------------------------
184
-
185
170
  export default AppReview;
@@ -3,8 +3,3 @@ declare module 'browser-env';
3
3
  declare module '@coorpacademy/components/es/template/app-review';
4
4
  declare module '@coorpacademy/components/es/template/app-review/template-context';
5
5
  declare module '@coorpacademy/redux-task';
6
-
7
- // eslint-disable-next-line no-shadow
8
- declare interface Window {
9
- __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: Function;
10
- }