@twreporter/redux 7.7.0-rc.5 → 7.7.0
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/CHANGELOG.md +19 -0
- package/lib/actions/index.js +2 -1
- package/lib/actions/user.js +53 -2
- package/lib/constants/api-endpoints.js +2 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.7.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/redux@7.7.0-rc.6...@twreporter/redux@7.7.0) (2023-08-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @twreporter/redux
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [7.7.0-rc.6](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/redux@7.7.0-rc.5...@twreporter/redux@7.7.0-rc.6) (2023-08-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add `onboarding` action ([df87bb1](https://github.com/twreporter/twreporter-npm-packages/commit/df87bb1b35f2e66b4cdb3185002c20b207aaede9))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [7.7.0-rc.5](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/redux@7.7.0-rc.4...@twreporter/redux@7.7.0-rc.5) (2023-08-14)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @twreporter/redux
|
package/lib/actions/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var _default = {
|
|
|
46
46
|
getSingleBookmark: _bookmarks.getSingleBookmark,
|
|
47
47
|
searchAuthorsIfNeeded: _authors.searchAuthorsIfNeeded,
|
|
48
48
|
getUserData: _user.getUserData,
|
|
49
|
-
setUserData: _user.setUserData
|
|
49
|
+
setUserData: _user.setUserData,
|
|
50
|
+
onboarding: _user.onboarding
|
|
50
51
|
};
|
|
51
52
|
exports["default"] = _default;
|
package/lib/actions/user.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getUserData = getUserData;
|
|
7
7
|
exports.setUserData = setUserData;
|
|
8
|
+
exports.onboarding = onboarding;
|
|
8
9
|
|
|
9
10
|
var _url = require("../utils/url");
|
|
10
11
|
|
|
@@ -122,8 +123,6 @@ function getUserData(jwt, userID) {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
126
|
* @export
|
|
128
127
|
* @param {string} jwt - access_token granted for the user
|
|
129
128
|
* @param {number} userID - id of user
|
|
@@ -166,6 +165,58 @@ function setUserData(jwt, userID, readPreference, maillist) {
|
|
|
166
165
|
})["catch"](function (error) {
|
|
167
166
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].user.update.failure);
|
|
168
167
|
|
|
168
|
+
dispatch(failAction);
|
|
169
|
+
return Promise.reject(failAction);
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @export
|
|
175
|
+
* @param {string} jwt - access_token granted for the user
|
|
176
|
+
* @param {number} userID - id of user
|
|
177
|
+
* @param {string[]} readPreference - subscribed topics
|
|
178
|
+
* @param {string[]} maillist - subscribed mail list
|
|
179
|
+
* @param {string} destination - redirect destination
|
|
180
|
+
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
function onboarding(jwt, userID, readPreference, maillist, destination) {
|
|
185
|
+
/**
|
|
186
|
+
* @param {Function} dispatch - Redux store dispatch function
|
|
187
|
+
* @param {Function} getState - Redux store getState function
|
|
188
|
+
* @return {Promise} resolve with success action or reject with fail action
|
|
189
|
+
*/
|
|
190
|
+
return function (dispatch, getState) {
|
|
191
|
+
var state = getState();
|
|
192
|
+
|
|
193
|
+
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
194
|
+
|
|
195
|
+
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].onboarding, "/").concat(userID), {
|
|
196
|
+
destination: destination
|
|
197
|
+
});
|
|
198
|
+
dispatch({
|
|
199
|
+
type: _actionTypes["default"].user.update.request,
|
|
200
|
+
url: url
|
|
201
|
+
});
|
|
202
|
+
var axiosConfig = {
|
|
203
|
+
timeout: apiTimeout,
|
|
204
|
+
headers: {
|
|
205
|
+
Authorization: "Bearer ".concat(jwt)
|
|
206
|
+
},
|
|
207
|
+
withCredentials: true
|
|
208
|
+
};
|
|
209
|
+
var body = {
|
|
210
|
+
read_preference: readPreference,
|
|
211
|
+
maillist: maillist
|
|
212
|
+
};
|
|
213
|
+
return _axios["default"].post(url, body, axiosConfig).then(function (res) {
|
|
214
|
+
var successAction = buildSuccessActionFromRes(res, _actionTypes["default"].user.update.success);
|
|
215
|
+
dispatch(successAction);
|
|
216
|
+
return successAction;
|
|
217
|
+
})["catch"](function (error) {
|
|
218
|
+
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].user.update.failure);
|
|
219
|
+
|
|
169
220
|
dispatch(failAction);
|
|
170
221
|
return Promise.reject(failAction);
|
|
171
222
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twreporter/redux",
|
|
3
|
-
"version": "7.7.0
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"description": "redux actions and reducers for twreporter website",
|
|
5
5
|
"repository": "https://github.com/twreporter/twreporter-npm-packages.git",
|
|
6
6
|
"author": "twreporter <developer@twreporter.org>",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/twreporter/twreporter-redux/#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@twreporter/core": "^1.11.0
|
|
28
|
+
"@twreporter/core": "^1.11.0",
|
|
29
29
|
"axios": "^0.19.0",
|
|
30
30
|
"es6-error": "^4.0.2",
|
|
31
31
|
"humps": "^0.6.0",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"files": [
|
|
45
45
|
"lib"
|
|
46
46
|
],
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a3fcc35f1a2534bb4a08d69d636ba53405160c9f"
|
|
48
48
|
}
|