@twreporter/redux 8.0.2 → 8.0.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.
- package/CHANGELOG.md +16 -0
- package/lib/actions/analytics.js +9 -22
- package/lib/actions/auth.js +9 -28
- package/lib/actions/author-articles.js +14 -43
- package/lib/actions/author-details.js +3 -23
- package/lib/actions/authors.js +13 -53
- package/lib/actions/bookmarks.js +26 -54
- package/lib/actions/donation-history.js +5 -23
- package/lib/actions/error-action-creators.js +7 -22
- package/lib/actions/footprints.js +5 -22
- package/lib/actions/index-page.js +9 -26
- package/lib/actions/index.js +2 -18
- package/lib/actions/latest.js +9 -26
- package/lib/actions/post-reviews.js +4 -16
- package/lib/actions/posts.js +28 -82
- package/lib/actions/topics.js +31 -64
- package/lib/actions/user.js +5 -26
- package/lib/component/provider.js +7 -31
- package/lib/constants/action-types.js +2 -4
- package/lib/constants/api-config.js +2 -3
- package/lib/constants/api-endpoints.js +2 -3
- package/lib/constants/author-page.js +3 -7
- package/lib/constants/authors-list.js +3 -7
- package/lib/constants/http-protocol.js +2 -3
- package/lib/constants/latest.js +1 -2
- package/lib/constants/mobile-mockup-specification.js +10 -9
- package/lib/constants/post-styles.js +2 -3
- package/lib/constants/redux-state-field-names.js +13 -11
- package/lib/context/redux-store.js +1 -6
- package/lib/index.js +2 -24
- package/lib/reducers/analytics.js +6 -20
- package/lib/reducers/auth.js +2 -13
- package/lib/reducers/author-articles.js +10 -26
- package/lib/reducers/authors.js +5 -28
- package/lib/reducers/bookmark-widget.js +0 -11
- package/lib/reducers/bookmarks.js +9 -40
- package/lib/reducers/donation-history.js +11 -39
- package/lib/reducers/entities-for-authors.js +2 -10
- package/lib/reducers/entities.js +24 -94
- package/lib/reducers/feature-topic.js +3 -16
- package/lib/reducers/footprints.js +8 -20
- package/lib/reducers/index-page.js +2 -23
- package/lib/reducers/index.js +5 -29
- package/lib/reducers/latest.js +2 -13
- package/lib/reducers/origins.js +0 -7
- package/lib/reducers/post-reviews.js +6 -16
- package/lib/reducers/posts.js +6 -36
- package/lib/reducers/related-posts-of.js +12 -55
- package/lib/reducers/settings.js +0 -9
- package/lib/reducers/topics.js +11 -35
- package/lib/reducers/user.js +6 -33
- package/lib/schemas/article-schema.js +3 -7
- package/lib/store/bind-actions-to-store.js +4 -21
- package/lib/store/create-store.js +22 -22
- package/lib/typedef.js +2 -25
- package/lib/utils/__tests__/denormalize-asset.test.js +1 -1
- package/lib/utils/denormalize-asset.js +3 -23
- package/lib/utils/detect-env.js +2 -6
- package/lib/utils/error.js +9 -55
- package/lib/utils/image-processor.js +3 -9
- package/lib/utils/jwt.js +3 -10
- package/lib/utils/pagination.js +5 -9
- package/lib/utils/url.js +0 -6
- package/package.json +5 -4
package/lib/actions/bookmarks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -7,37 +8,26 @@ exports.createSingleBookmark = createSingleBookmark;
|
|
|
7
8
|
exports.deleteSingleBookmark = deleteSingleBookmark;
|
|
8
9
|
exports.getMultipleBookmarks = getMultipleBookmarks;
|
|
9
10
|
exports.getSingleBookmark = getSingleBookmark;
|
|
10
|
-
|
|
11
11
|
var _url = require("../utils/url");
|
|
12
|
-
|
|
13
12
|
var _apiConfig = _interopRequireDefault(require("../constants/api-config"));
|
|
14
|
-
|
|
15
13
|
var _errorActionCreators = _interopRequireDefault(require("./error-action-creators"));
|
|
16
|
-
|
|
17
14
|
var _reduxStateFieldNames = _interopRequireDefault(require("../constants/redux-state-field-names"));
|
|
18
|
-
|
|
19
15
|
var _actionTypes = _interopRequireDefault(require("../constants/action-types"));
|
|
20
|
-
|
|
21
16
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
22
|
-
|
|
23
|
-
var _excluded = ["published_date"];
|
|
24
|
-
|
|
17
|
+
var _excluded = ["published_date"]; // lodash
|
|
25
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
26
|
-
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
|
-
|
|
19
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
33
24
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
34
|
-
|
|
35
25
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
36
|
-
|
|
37
26
|
var _ = {
|
|
38
27
|
get: _get["default"]
|
|
39
28
|
};
|
|
40
29
|
var apiTimeout = _apiConfig["default"].timeout;
|
|
30
|
+
|
|
41
31
|
/**
|
|
42
32
|
* @typedef {Object} userData
|
|
43
33
|
* @property {string} email - email of user
|
|
@@ -100,7 +90,6 @@ var apiTimeout = _apiConfig["default"].timeout;
|
|
|
100
90
|
* @param {string} actionType
|
|
101
91
|
* @returns {SuccessAction}
|
|
102
92
|
*/
|
|
103
|
-
|
|
104
93
|
function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
105
94
|
return {
|
|
106
95
|
type: actionType,
|
|
@@ -112,6 +101,7 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
112
101
|
}
|
|
113
102
|
};
|
|
114
103
|
}
|
|
104
|
+
|
|
115
105
|
/**
|
|
116
106
|
* @typedef {Object} FailAction
|
|
117
107
|
* @property {string} type - Action error type
|
|
@@ -130,13 +120,12 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
130
120
|
* @param {BookmarkToBeCreated} bookmarkToBeCreated
|
|
131
121
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
132
122
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
123
|
function createSingleBookmark(jwt, userID, bookmarkToBeCreated) {
|
|
136
124
|
/* go-api takes `published_date` as an unix timestamp (in secs) int */
|
|
137
125
|
// eslint-disable-next-line camelcase
|
|
138
126
|
var published_date = bookmarkToBeCreated.published_date,
|
|
139
|
-
|
|
127
|
+
passedBookmarkProperties = _objectWithoutProperties(bookmarkToBeCreated, _excluded);
|
|
128
|
+
|
|
140
129
|
/**
|
|
141
130
|
* @param {Function} dispatch - Redux store dispatch function
|
|
142
131
|
* @param {Function} getState - Redux store getState function
|
|
@@ -144,14 +133,10 @@ function createSingleBookmark(jwt, userID, bookmarkToBeCreated) {
|
|
|
144
133
|
* @param {Object} option.httpClientWithToken
|
|
145
134
|
* @return {Promise} resolve with success action or reject with fail action
|
|
146
135
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
136
|
return function (dispatch, getState, _ref) {
|
|
150
137
|
var httpClientWithToken = _ref.httpClientWithToken;
|
|
151
138
|
var state = getState();
|
|
152
|
-
|
|
153
139
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
154
|
-
|
|
155
140
|
var url = (0, _url.formURL)(apiOrigin, "/v1/users/".concat(userID, "/bookmarks"), {}, false);
|
|
156
141
|
var axiosConfig = {
|
|
157
142
|
timeout: apiTimeout,
|
|
@@ -162,9 +147,9 @@ function createSingleBookmark(jwt, userID, bookmarkToBeCreated) {
|
|
|
162
147
|
};
|
|
163
148
|
var interceptor = httpClientWithToken.interceptors.request.use(function (config) {
|
|
164
149
|
var method = config.method,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
150
|
+
url = config.url,
|
|
151
|
+
headers = config.headers,
|
|
152
|
+
data = config.data;
|
|
168
153
|
dispatch({
|
|
169
154
|
type: _actionTypes["default"].singleBookmark.create.request,
|
|
170
155
|
payload: {
|
|
@@ -185,12 +170,12 @@ function createSingleBookmark(jwt, userID, bookmarkToBeCreated) {
|
|
|
185
170
|
return successAction;
|
|
186
171
|
})["catch"](function (error) {
|
|
187
172
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].singleBookmark.create.failure);
|
|
188
|
-
|
|
189
173
|
dispatch(failAction);
|
|
190
174
|
return Promise.reject(failAction);
|
|
191
175
|
});
|
|
192
176
|
};
|
|
193
177
|
}
|
|
178
|
+
|
|
194
179
|
/**
|
|
195
180
|
*
|
|
196
181
|
*
|
|
@@ -201,8 +186,6 @@ function createSingleBookmark(jwt, userID, bookmarkToBeCreated) {
|
|
|
201
186
|
* @param {number} limit - max amount of records per fetch
|
|
202
187
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
203
188
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
189
|
function getMultipleBookmarks(jwt, userID, offset, limit) {
|
|
207
190
|
/**
|
|
208
191
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -214,9 +197,7 @@ function getMultipleBookmarks(jwt, userID, offset, limit) {
|
|
|
214
197
|
return function (dispatch, getState, _ref2) {
|
|
215
198
|
var httpClientWithToken = _ref2.httpClientWithToken;
|
|
216
199
|
var state = getState();
|
|
217
|
-
|
|
218
200
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
219
|
-
|
|
220
201
|
var url = (0, _url.formURL)(apiOrigin, "/v1/users/".concat(userID, "/bookmarks"), {
|
|
221
202
|
offset: offset,
|
|
222
203
|
limit: limit
|
|
@@ -229,9 +210,9 @@ function getMultipleBookmarks(jwt, userID, offset, limit) {
|
|
|
229
210
|
};
|
|
230
211
|
var interceptor = httpClientWithToken.interceptors.request.use(function (config) {
|
|
231
212
|
var method = config.method,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
213
|
+
url = config.url,
|
|
214
|
+
headers = config.headers,
|
|
215
|
+
data = config.data;
|
|
235
216
|
dispatch({
|
|
236
217
|
type: _actionTypes["default"].multipleBookMarks.read.request,
|
|
237
218
|
payload: {
|
|
@@ -250,12 +231,12 @@ function getMultipleBookmarks(jwt, userID, offset, limit) {
|
|
|
250
231
|
return successAction;
|
|
251
232
|
})["catch"](function (error) {
|
|
252
233
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].multipleBookMarks.read.failure);
|
|
253
|
-
|
|
254
234
|
dispatch(failAction);
|
|
255
235
|
return Promise.reject(failAction);
|
|
256
236
|
});
|
|
257
237
|
};
|
|
258
238
|
}
|
|
239
|
+
|
|
259
240
|
/**
|
|
260
241
|
*
|
|
261
242
|
*
|
|
@@ -266,8 +247,6 @@ function getMultipleBookmarks(jwt, userID, offset, limit) {
|
|
|
266
247
|
* @param {string} bookmarkHost - the hostname of the bookmark. Ex: 'https://www.xxxx.xx'
|
|
267
248
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
268
249
|
*/
|
|
269
|
-
|
|
270
|
-
|
|
271
250
|
function getSingleBookmark(jwt, userID, bookmarkSlug, bookmarkHost) {
|
|
272
251
|
/**
|
|
273
252
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -279,9 +258,7 @@ function getSingleBookmark(jwt, userID, bookmarkSlug, bookmarkHost) {
|
|
|
279
258
|
return function (dispatch, getState, _ref3) {
|
|
280
259
|
var httpClientWithToken = _ref3.httpClientWithToken;
|
|
281
260
|
var state = getState();
|
|
282
|
-
|
|
283
261
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
284
|
-
|
|
285
262
|
var url = (0, _url.formURL)(apiOrigin, "/v1/users/".concat(userID, "/bookmarks/").concat(bookmarkSlug), {
|
|
286
263
|
host: bookmarkHost
|
|
287
264
|
}, false);
|
|
@@ -293,9 +270,9 @@ function getSingleBookmark(jwt, userID, bookmarkSlug, bookmarkHost) {
|
|
|
293
270
|
};
|
|
294
271
|
var interceptor = httpClientWithToken.interceptors.request.use(function (config) {
|
|
295
272
|
var method = config.method,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
273
|
+
url = config.url,
|
|
274
|
+
headers = config.headers,
|
|
275
|
+
data = config.data;
|
|
299
276
|
dispatch({
|
|
300
277
|
type: _actionTypes["default"].singleBookmark.read.request,
|
|
301
278
|
payload: {
|
|
@@ -314,12 +291,12 @@ function getSingleBookmark(jwt, userID, bookmarkSlug, bookmarkHost) {
|
|
|
314
291
|
return successAction;
|
|
315
292
|
})["catch"](function (error) {
|
|
316
293
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].singleBookmark.read.failure);
|
|
317
|
-
|
|
318
294
|
dispatch(failAction);
|
|
319
295
|
return Promise.reject(failAction);
|
|
320
296
|
});
|
|
321
297
|
};
|
|
322
298
|
}
|
|
299
|
+
|
|
323
300
|
/**
|
|
324
301
|
*
|
|
325
302
|
*
|
|
@@ -329,8 +306,6 @@ function getSingleBookmark(jwt, userID, bookmarkSlug, bookmarkHost) {
|
|
|
329
306
|
* @param {number} bookmarkID - id of bookmark
|
|
330
307
|
* @return {Function} - function will be executed in Redux Thunk middleware
|
|
331
308
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
334
309
|
function deleteSingleBookmark(jwt, userID, bookmarkID) {
|
|
335
310
|
/**
|
|
336
311
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -342,9 +317,7 @@ function deleteSingleBookmark(jwt, userID, bookmarkID) {
|
|
|
342
317
|
return function (dispatch, getState, _ref4) {
|
|
343
318
|
var httpClientWithToken = _ref4.httpClientWithToken;
|
|
344
319
|
var state = getState();
|
|
345
|
-
|
|
346
320
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
347
|
-
|
|
348
321
|
var url = (0, _url.formURL)(apiOrigin, "/v1/users/".concat(userID, "/bookmarks/").concat(bookmarkID), {}, false);
|
|
349
322
|
var axiosConfig = {
|
|
350
323
|
timeout: apiTimeout,
|
|
@@ -354,9 +327,9 @@ function deleteSingleBookmark(jwt, userID, bookmarkID) {
|
|
|
354
327
|
};
|
|
355
328
|
var interceptor = httpClientWithToken.interceptors.request.use(function (config) {
|
|
356
329
|
var method = config.method,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
330
|
+
url = config.url,
|
|
331
|
+
headers = config.headers,
|
|
332
|
+
data = config.data;
|
|
360
333
|
dispatch({
|
|
361
334
|
type: _actionTypes["default"].singleBookmark["delete"].request,
|
|
362
335
|
payload: {
|
|
@@ -376,7 +349,6 @@ function deleteSingleBookmark(jwt, userID, bookmarkID) {
|
|
|
376
349
|
return successAction;
|
|
377
350
|
})["catch"](function (error) {
|
|
378
351
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].singleBookmark["delete"].failure);
|
|
379
|
-
|
|
380
352
|
dispatch(failAction);
|
|
381
353
|
return Promise.reject(failAction);
|
|
382
354
|
});
|
|
@@ -5,31 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getUserDonationHistory = getUserDonationHistory;
|
|
7
7
|
exports.getUserPeriodicDonationHistory = getUserPeriodicDonationHistory;
|
|
8
|
-
|
|
9
8
|
var _axios = _interopRequireDefault(require("axios"));
|
|
10
|
-
|
|
11
9
|
var _apiConfig = _interopRequireDefault(require("../constants/api-config"));
|
|
12
|
-
|
|
13
10
|
var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints"));
|
|
14
|
-
|
|
15
11
|
var _reduxStateFieldNames = _interopRequireDefault(require("../constants/redux-state-field-names"));
|
|
16
|
-
|
|
17
12
|
var _actionTypes = _interopRequireDefault(require("../constants/action-types"));
|
|
18
|
-
|
|
19
13
|
var _url = require("../utils/url");
|
|
20
|
-
|
|
21
14
|
var _errorActionCreators = _interopRequireDefault(require("./error-action-creators"));
|
|
22
|
-
|
|
23
15
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
24
|
-
|
|
25
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
26
|
-
|
|
27
17
|
// constants
|
|
18
|
+
|
|
28
19
|
// lodash
|
|
20
|
+
|
|
29
21
|
var _ = {
|
|
30
22
|
get: _get["default"]
|
|
31
23
|
};
|
|
32
24
|
var apiTimeout = _apiConfig["default"].timeout;
|
|
25
|
+
|
|
33
26
|
/**
|
|
34
27
|
* @typedef {Object} RequestAction
|
|
35
28
|
* @property {string} type - The type of action
|
|
@@ -52,7 +45,6 @@ var apiTimeout = _apiConfig["default"].timeout;
|
|
|
52
45
|
* @param {string} actionType
|
|
53
46
|
* @returns {SuccessAction}
|
|
54
47
|
*/
|
|
55
|
-
|
|
56
48
|
function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
57
49
|
return {
|
|
58
50
|
type: actionType,
|
|
@@ -62,6 +54,7 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
62
54
|
}
|
|
63
55
|
};
|
|
64
56
|
}
|
|
57
|
+
|
|
65
58
|
/**
|
|
66
59
|
* @typedef {Object} FailAction
|
|
67
60
|
* @property {string} type - Action error type
|
|
@@ -79,12 +72,9 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
79
72
|
* @param {number} limit - max amount of records per fetch
|
|
80
73
|
* @returns {Function} - function will be executed in Redux Thunk middleware
|
|
81
74
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
75
|
function getUserDonationHistory(jwt, userID) {
|
|
85
76
|
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
86
77
|
var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
|
87
|
-
|
|
88
78
|
/**
|
|
89
79
|
* @param {Function} dispatch - Redux store dispatch function
|
|
90
80
|
* @param {Function} getState - Redux store getState function
|
|
@@ -92,9 +82,7 @@ function getUserDonationHistory(jwt, userID) {
|
|
|
92
82
|
*/
|
|
93
83
|
return function (dispatch, getState) {
|
|
94
84
|
var state = getState();
|
|
95
|
-
|
|
96
85
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
97
|
-
|
|
98
86
|
var url = (0, _url.formURL)(apiOrigin, "/v1/".concat(_apiEndpoints["default"].users, "/").concat(userID, "/donations"), {
|
|
99
87
|
limit: limit,
|
|
100
88
|
offset: offset
|
|
@@ -116,12 +104,12 @@ function getUserDonationHistory(jwt, userID) {
|
|
|
116
104
|
return successAction;
|
|
117
105
|
})["catch"](function (error) {
|
|
118
106
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].donationHistory.donationHistory.read.failure);
|
|
119
|
-
|
|
120
107
|
dispatch(failAction);
|
|
121
108
|
return Promise.reject(failAction);
|
|
122
109
|
});
|
|
123
110
|
};
|
|
124
111
|
}
|
|
112
|
+
|
|
125
113
|
/**
|
|
126
114
|
* get user's periodic donation history
|
|
127
115
|
* @param {string} jwt - access_token granted for the user
|
|
@@ -130,12 +118,9 @@ function getUserDonationHistory(jwt, userID) {
|
|
|
130
118
|
* @param {number} limit - max amount of records per fetch
|
|
131
119
|
* @returns {Function} - function will be executed in Redux Thunk middleware
|
|
132
120
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
121
|
function getUserPeriodicDonationHistory(jwt, orderNumber) {
|
|
136
122
|
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
137
123
|
var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
|
138
|
-
|
|
139
124
|
/**
|
|
140
125
|
* @param {Function} dispatch - Redux store dispatch function
|
|
141
126
|
* @param {Function} getState - Redux store getState function
|
|
@@ -143,9 +128,7 @@ function getUserPeriodicDonationHistory(jwt, orderNumber) {
|
|
|
143
128
|
*/
|
|
144
129
|
return function (dispatch, getState) {
|
|
145
130
|
var state = getState();
|
|
146
|
-
|
|
147
131
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
148
|
-
|
|
149
132
|
var url = (0, _url.formURL)(apiOrigin, "/v1/".concat(_apiEndpoints["default"].periodicDonations, "/orders/").concat(orderNumber, "/payments"), {
|
|
150
133
|
limit: limit,
|
|
151
134
|
offset: offset
|
|
@@ -168,7 +151,6 @@ function getUserPeriodicDonationHistory(jwt, orderNumber) {
|
|
|
168
151
|
return successAction;
|
|
169
152
|
})["catch"](function (error) {
|
|
170
153
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].donationHistory.periodicDonationHistory.read.failure);
|
|
171
|
-
|
|
172
154
|
dispatch(failAction);
|
|
173
155
|
return Promise.reject(failAction);
|
|
174
156
|
});
|
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _httpProtocol = _interopRequireDefault(require("../constants/http-protocol"));
|
|
9
|
-
|
|
10
8
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
11
|
-
|
|
12
9
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
17
|
-
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } // lodash
|
|
18
12
|
var _ = {
|
|
19
13
|
get: _get["default"],
|
|
20
14
|
merge: _merge["default"]
|
|
21
15
|
};
|
|
16
|
+
|
|
22
17
|
/**
|
|
23
18
|
* Refine Axios config to remain the infomative properties.
|
|
24
19
|
* @param {Object} axiosConfig - config provied by Axios
|
|
@@ -39,7 +34,6 @@ var _ = {
|
|
|
39
34
|
* For other removed properties,
|
|
40
35
|
* see https://github.com/axios/axios#request-config
|
|
41
36
|
*/
|
|
42
|
-
|
|
43
37
|
function refineAxiosConfig(axiosConfig) {
|
|
44
38
|
if (_typeof(axiosConfig) === 'object' && axiosConfig !== null) {
|
|
45
39
|
return {
|
|
@@ -65,9 +59,9 @@ function refineAxiosConfig(axiosConfig) {
|
|
|
65
59
|
proxy: axiosConfig.proxy
|
|
66
60
|
};
|
|
67
61
|
}
|
|
68
|
-
|
|
69
62
|
return {};
|
|
70
63
|
}
|
|
64
|
+
|
|
71
65
|
/**
|
|
72
66
|
* Axios Error object
|
|
73
67
|
* @typedef {Error} AxiosError
|
|
@@ -103,16 +97,12 @@ function refineAxiosConfig(axiosConfig) {
|
|
|
103
97
|
* @param {AxiosError} err - Axios Error object
|
|
104
98
|
* @return {RefinedAxiosError}
|
|
105
99
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
100
|
function refineAxiosError(err) {
|
|
109
101
|
var config = refineAxiosConfig(_.get(err, 'config'));
|
|
110
102
|
var data = null;
|
|
111
103
|
var statusCode = _httpProtocol["default"].statusCode.internalServerError;
|
|
112
104
|
var headers = null;
|
|
113
|
-
|
|
114
105
|
var message = _.get(err, 'message');
|
|
115
|
-
|
|
116
106
|
if (err.response) {
|
|
117
107
|
data = _.get(err, 'response.data');
|
|
118
108
|
statusCode = _.get(err, 'response.status');
|
|
@@ -122,7 +112,6 @@ function refineAxiosError(err) {
|
|
|
122
112
|
} else {
|
|
123
113
|
message = 'An error occured when setting up the request: ' + message;
|
|
124
114
|
}
|
|
125
|
-
|
|
126
115
|
var refinedErr = new Error(message);
|
|
127
116
|
refinedErr.name = 'AxiosError';
|
|
128
117
|
refinedErr.data = data;
|
|
@@ -131,6 +120,7 @@ function refineAxiosError(err) {
|
|
|
131
120
|
refinedErr.config = config;
|
|
132
121
|
return refinedErr;
|
|
133
122
|
}
|
|
123
|
+
|
|
134
124
|
/**
|
|
135
125
|
* error action type definition
|
|
136
126
|
* @typedef {Object} ErrorAction
|
|
@@ -143,8 +133,6 @@ function refineAxiosError(err) {
|
|
|
143
133
|
* @param {string} failActionType
|
|
144
134
|
* @returns {ErrorAction}
|
|
145
135
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
136
|
function handleValidationFailureBeforeRequest(invalidFields, failActionType) {
|
|
149
137
|
var error = new Error('Data validation failed before the http request was made.');
|
|
150
138
|
error.name = 'ValidationError';
|
|
@@ -159,14 +147,13 @@ function handleValidationFailureBeforeRequest(invalidFields, failActionType) {
|
|
|
159
147
|
}
|
|
160
148
|
};
|
|
161
149
|
}
|
|
150
|
+
|
|
162
151
|
/**
|
|
163
152
|
* Create an action which carefully records the details about the error.
|
|
164
153
|
* @param {AxiosError} [err={}] - Axios Error
|
|
165
154
|
* @param {string} failActionType
|
|
166
155
|
* @returns {ErrorAction}
|
|
167
156
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
157
|
function createAxiosErrorAction() {
|
|
171
158
|
var err = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
172
159
|
var failActionType = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -177,9 +164,7 @@ function createAxiosErrorAction() {
|
|
|
177
164
|
}
|
|
178
165
|
};
|
|
179
166
|
}
|
|
180
|
-
|
|
181
|
-
var _default = {
|
|
167
|
+
var _default = exports["default"] = {
|
|
182
168
|
axios: createAxiosErrorAction,
|
|
183
169
|
preRequestValidation: handleValidationFailureBeforeRequest
|
|
184
|
-
};
|
|
185
|
-
exports["default"] = _default;
|
|
170
|
+
};
|
|
@@ -5,31 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getUserFootprints = getUserFootprints;
|
|
7
7
|
exports.setUserFootprint = setUserFootprint;
|
|
8
|
-
|
|
9
8
|
var _axios = _interopRequireDefault(require("axios"));
|
|
10
|
-
|
|
11
9
|
var _apiConfig = _interopRequireDefault(require("../constants/api-config"));
|
|
12
|
-
|
|
13
10
|
var _apiEndpoints = _interopRequireDefault(require("../constants/api-endpoints"));
|
|
14
|
-
|
|
15
11
|
var _reduxStateFieldNames = _interopRequireDefault(require("../constants/redux-state-field-names"));
|
|
16
|
-
|
|
17
12
|
var _actionTypes = _interopRequireDefault(require("../constants/action-types"));
|
|
18
|
-
|
|
19
13
|
var _url = require("../utils/url");
|
|
20
|
-
|
|
21
14
|
var _errorActionCreators = _interopRequireDefault(require("./error-action-creators"));
|
|
22
|
-
|
|
23
15
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
24
|
-
|
|
25
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
26
|
-
|
|
27
17
|
// constants
|
|
18
|
+
|
|
28
19
|
// lodash
|
|
20
|
+
|
|
29
21
|
var _ = {
|
|
30
22
|
get: _get["default"]
|
|
31
23
|
};
|
|
32
24
|
var apiTimeout = _apiConfig["default"].timeout;
|
|
25
|
+
|
|
33
26
|
/**
|
|
34
27
|
* @typedef {Object} RequestAction
|
|
35
28
|
* @property {string} type - The type of action
|
|
@@ -52,7 +45,6 @@ var apiTimeout = _apiConfig["default"].timeout;
|
|
|
52
45
|
* @param {string} actionType
|
|
53
46
|
* @returns {SuccessAction}
|
|
54
47
|
*/
|
|
55
|
-
|
|
56
48
|
function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
57
49
|
return {
|
|
58
50
|
type: actionType,
|
|
@@ -62,6 +54,7 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
62
54
|
}
|
|
63
55
|
};
|
|
64
56
|
}
|
|
57
|
+
|
|
65
58
|
/**
|
|
66
59
|
* @typedef {Object} FailAction
|
|
67
60
|
* @property {string} type - Action error type
|
|
@@ -79,12 +72,9 @@ function buildSuccessActionFromRes(axiosResponse, actionType) {
|
|
|
79
72
|
* @param {number} limit - max amount of records per fetch
|
|
80
73
|
* @returns {Function} - function will be executed in Redux Thunk middleware
|
|
81
74
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
75
|
function getUserFootprints(jwt, userID) {
|
|
85
76
|
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
86
77
|
var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
|
87
|
-
|
|
88
78
|
/**
|
|
89
79
|
* @param {Function} dispatch - Redux store dispatch function
|
|
90
80
|
* @param {Function} getState - Redux store getState function
|
|
@@ -92,9 +82,7 @@ function getUserFootprints(jwt, userID) {
|
|
|
92
82
|
*/
|
|
93
83
|
return function (dispatch, getState) {
|
|
94
84
|
var state = getState();
|
|
95
|
-
|
|
96
85
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
97
|
-
|
|
98
86
|
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].users, "/").concat(userID, "/analytics/reading-footprint"), {
|
|
99
87
|
limit: limit,
|
|
100
88
|
offset: offset
|
|
@@ -115,12 +103,12 @@ function getUserFootprints(jwt, userID) {
|
|
|
115
103
|
return successAction;
|
|
116
104
|
})["catch"](function (error) {
|
|
117
105
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].footprints.read.failure);
|
|
118
|
-
|
|
119
106
|
dispatch(failAction);
|
|
120
107
|
return Promise.reject(failAction);
|
|
121
108
|
});
|
|
122
109
|
};
|
|
123
110
|
}
|
|
111
|
+
|
|
124
112
|
/**
|
|
125
113
|
* update user footprint by post_id
|
|
126
114
|
* @param {string} jwt - access_token granted for the user
|
|
@@ -128,8 +116,6 @@ function getUserFootprints(jwt, userID) {
|
|
|
128
116
|
* @param {string} postID - id of post
|
|
129
117
|
* @returns - function will be executed in Redux Thunk middleware
|
|
130
118
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
119
|
function setUserFootprint(jwt, userID, postID) {
|
|
134
120
|
/**
|
|
135
121
|
* @param {Function} dispatch - Redux store dispatch function
|
|
@@ -138,9 +124,7 @@ function setUserFootprint(jwt, userID, postID) {
|
|
|
138
124
|
*/
|
|
139
125
|
return function (dispatch, getState) {
|
|
140
126
|
var state = getState();
|
|
141
|
-
|
|
142
127
|
var apiOrigin = _.get(state, [_reduxStateFieldNames["default"].origins, 'api']);
|
|
143
|
-
|
|
144
128
|
var url = (0, _url.formURL)(apiOrigin, "/v2/".concat(_apiEndpoints["default"].users, "/").concat(userID, "/analytics/reading-footprint"));
|
|
145
129
|
dispatch({
|
|
146
130
|
type: _actionTypes["default"].footprints.update.request,
|
|
@@ -161,7 +145,6 @@ function setUserFootprint(jwt, userID, postID) {
|
|
|
161
145
|
return successAction;
|
|
162
146
|
})["catch"](function (error) {
|
|
163
147
|
var failAction = _errorActionCreators["default"].axios(error, _actionTypes["default"].footprints.update.failure);
|
|
164
|
-
|
|
165
148
|
dispatch(failAction);
|
|
166
149
|
return Promise.reject(failAction);
|
|
167
150
|
});
|