@coorpacademy/app-review 0.12.7-alpha.1 → 0.13.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 +16 -39
- package/lib/index.js +16 -39
- package/package.json +3 -3
package/es/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import get from 'lodash/fp/get';
|
|
|
6
6
|
import configureStore from './configure-store';
|
|
7
7
|
import { navigateBack, navigateTo } from './actions/ui/navigation';
|
|
8
8
|
import { storeToken } from './actions/data/token';
|
|
9
|
-
import { fetchSkills } from './actions/api/fetch-skills';
|
|
10
9
|
import { postProgression } from './actions/api/post-progression';
|
|
11
10
|
import { mapStateToSkillsProps } from './views/skills';
|
|
12
11
|
import { mapStateToSlidesProps } from './views/slides';
|
|
@@ -21,50 +20,28 @@ const ConnectedApp = (options) => {
|
|
|
21
20
|
};
|
|
22
21
|
return React.createElement(AppReviewTemplate, { ...props });
|
|
23
22
|
};
|
|
23
|
+
const storeTokenAndCreateProgression = async (store, options) => {
|
|
24
|
+
const token = get('token', options);
|
|
25
|
+
if (store === null || isEmpty(token))
|
|
26
|
+
return;
|
|
27
|
+
store.dispatch(storeToken(token));
|
|
28
|
+
const skillRef = get('skillRef', options);
|
|
29
|
+
if (skillRef) {
|
|
30
|
+
store.dispatch(navigateTo('loader'));
|
|
31
|
+
await store.dispatch(postProgression(skillRef));
|
|
32
|
+
store.dispatch(navigateTo('slides'));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
24
35
|
const AppReview = ({ options }) => {
|
|
25
36
|
const [store, setStore] = useState(null);
|
|
26
|
-
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
27
37
|
const { translate, onQuitClick, skin } = options;
|
|
28
38
|
useEffect(() => {
|
|
29
|
-
if (store)
|
|
30
|
-
return;
|
|
31
39
|
const newStore = configureStore(options);
|
|
32
40
|
setStore(newStore);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return store.subscribe(() => {
|
|
38
|
-
const isProgressionPresent = !isEmpty(store.getState().data.progression);
|
|
39
|
-
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
40
|
-
});
|
|
41
|
-
}, [isProgressionCreated, options, store]);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const token = get('token', options);
|
|
44
|
-
if (store === null || isEmpty(token))
|
|
45
|
-
return;
|
|
46
|
-
store.dispatch(storeToken(token));
|
|
47
|
-
}, [options, store]);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
const token = get('token', options);
|
|
50
|
-
if (store === null || isEmpty(token))
|
|
51
|
-
return;
|
|
52
|
-
const skillRef = get('skillRef', options);
|
|
53
|
-
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
54
|
-
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
55
|
-
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
56
|
-
}, [options, store]);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (store === null)
|
|
59
|
-
return;
|
|
60
|
-
const { skillRef } = options;
|
|
61
|
-
if (skillRef && !isProgressionCreated) {
|
|
62
|
-
store.dispatch(navigateTo('loader')); // use loader while posting progression
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const initialView = skillRef ? 'slides' : 'skills';
|
|
66
|
-
store.dispatch(navigateTo(initialView));
|
|
67
|
-
}, [isProgressionCreated, options, store]);
|
|
41
|
+
storeTokenAndCreateProgression(newStore, options);
|
|
42
|
+
// should create store, store token and create progression only once on mount
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, []);
|
|
68
45
|
if (!store)
|
|
69
46
|
return null;
|
|
70
47
|
return (React.createElement(Provider, { store: store },
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,6 @@ const get_1 = __importDefault(require("lodash/fp/get"));
|
|
|
34
34
|
const configure_store_1 = __importDefault(require("./configure-store"));
|
|
35
35
|
const navigation_1 = require("./actions/ui/navigation");
|
|
36
36
|
const token_1 = require("./actions/data/token");
|
|
37
|
-
const fetch_skills_1 = require("./actions/api/fetch-skills");
|
|
38
37
|
const post_progression_1 = require("./actions/api/post-progression");
|
|
39
38
|
const skills_1 = require("./views/skills");
|
|
40
39
|
const slides_1 = require("./views/slides");
|
|
@@ -49,50 +48,28 @@ const ConnectedApp = (options) => {
|
|
|
49
48
|
};
|
|
50
49
|
return react_1.default.createElement(app_review_1.default, { ...props });
|
|
51
50
|
};
|
|
51
|
+
const storeTokenAndCreateProgression = async (store, options) => {
|
|
52
|
+
const token = (0, get_1.default)('token', options);
|
|
53
|
+
if (store === null || (0, isEmpty_1.default)(token))
|
|
54
|
+
return;
|
|
55
|
+
store.dispatch((0, token_1.storeToken)(token));
|
|
56
|
+
const skillRef = (0, get_1.default)('skillRef', options);
|
|
57
|
+
if (skillRef) {
|
|
58
|
+
store.dispatch((0, navigation_1.navigateTo)('loader'));
|
|
59
|
+
await store.dispatch((0, post_progression_1.postProgression)(skillRef));
|
|
60
|
+
store.dispatch((0, navigation_1.navigateTo)('slides'));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
52
63
|
const AppReview = ({ options }) => {
|
|
53
64
|
const [store, setStore] = (0, react_1.useState)(null);
|
|
54
|
-
const [isProgressionCreated, setIsProgressionCreated] = (0, react_1.useState)(false);
|
|
55
65
|
const { translate, onQuitClick, skin } = options;
|
|
56
66
|
(0, react_1.useEffect)(() => {
|
|
57
|
-
if (store)
|
|
58
|
-
return;
|
|
59
67
|
const newStore = (0, configure_store_1.default)(options);
|
|
60
68
|
setStore(newStore);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return store.subscribe(() => {
|
|
66
|
-
const isProgressionPresent = !(0, isEmpty_1.default)(store.getState().data.progression);
|
|
67
|
-
return isProgressionPresent && setIsProgressionCreated(isProgressionPresent);
|
|
68
|
-
});
|
|
69
|
-
}, [isProgressionCreated, options, store]);
|
|
70
|
-
(0, react_1.useEffect)(() => {
|
|
71
|
-
const token = (0, get_1.default)('token', options);
|
|
72
|
-
if (store === null || (0, isEmpty_1.default)(token))
|
|
73
|
-
return;
|
|
74
|
-
store.dispatch((0, token_1.storeToken)(token));
|
|
75
|
-
}, [options, store]);
|
|
76
|
-
(0, react_1.useEffect)(() => {
|
|
77
|
-
const token = (0, get_1.default)('token', options);
|
|
78
|
-
if (store === null || (0, isEmpty_1.default)(token))
|
|
79
|
-
return;
|
|
80
|
-
const skillRef = (0, get_1.default)('skillRef', options);
|
|
81
|
-
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
82
|
-
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);
|
|
84
|
-
}, [options, store]);
|
|
85
|
-
(0, react_1.useEffect)(() => {
|
|
86
|
-
if (store === null)
|
|
87
|
-
return;
|
|
88
|
-
const { skillRef } = options;
|
|
89
|
-
if (skillRef && !isProgressionCreated) {
|
|
90
|
-
store.dispatch((0, navigation_1.navigateTo)('loader')); // use loader while posting progression
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const initialView = skillRef ? 'slides' : 'skills';
|
|
94
|
-
store.dispatch((0, navigation_1.navigateTo)(initialView));
|
|
95
|
-
}, [isProgressionCreated, options, store]);
|
|
69
|
+
storeTokenAndCreateProgression(newStore, options);
|
|
70
|
+
// should create store, store token and create progression only once on mount
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, []);
|
|
96
73
|
if (!store)
|
|
97
74
|
return null;
|
|
98
75
|
return (react_1.default.createElement(react_redux_1.Provider, { store: store },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"main": "lib/index.js",
|
|
36
36
|
"module": "es/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coorpacademy/components": "11.2.5
|
|
38
|
+
"@coorpacademy/components": "11.2.5",
|
|
39
39
|
"@coorpacademy/progression-engine": "11.5.3",
|
|
40
40
|
"@coorpacademy/redux-task": "1.1.6",
|
|
41
41
|
"@coorpacademy/review-services": "1.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"webpack-cli": "^4.10.0",
|
|
75
75
|
"webpack-dev-server": "^4.11.1"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "db081b3bef50ec2159ffd06802abf88ed67df69a"
|
|
78
78
|
}
|