@techstuff-dev/foundation-api-utils 1.23.1 → 1.25.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/dist/@types/lib/hooks/index.d.ts +4 -4
- package/dist/@types/lib/services/cart/slice.d.ts +155 -0
- package/dist/@types/lib/services/content/content.interfaces.d.ts +306 -40
- package/dist/@types/lib/services/index.d.ts +1 -0
- package/dist/@types/lib/store/index.d.ts +10 -10
- package/dist/@types/lib/utils/dataFormat/index.d.ts +9 -37
- package/dist/@types/lib/utils/helpers/index.d.ts +12 -0
- package/dist/index.esm.js +386 -118
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +410 -116
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75,13 +75,23 @@ function __generator(thisArg, body) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
function __spreadArray(to, from, pack) {
|
|
79
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
80
|
+
if (ar || !(i in from)) {
|
|
81
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
82
|
+
ar[i] = from[i];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
79
89
|
var e = new Error(message);
|
|
80
90
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
var _a$
|
|
84
|
-
var initialState = {
|
|
93
|
+
var _a$2, _b$2;
|
|
94
|
+
var initialState$1 = {
|
|
85
95
|
authenticated: false,
|
|
86
96
|
verifying: false,
|
|
87
97
|
user: {
|
|
@@ -105,29 +115,13 @@ var initialState = {
|
|
|
105
115
|
email: '',
|
|
106
116
|
sub: '',
|
|
107
117
|
},
|
|
108
|
-
// creating: {
|
|
109
|
-
// details: '',
|
|
110
|
-
// payment: '',
|
|
111
|
-
// },
|
|
112
118
|
loading: false,
|
|
113
119
|
error: false,
|
|
114
120
|
session: undefined,
|
|
115
121
|
};
|
|
116
|
-
// interface AuthReducers {
|
|
117
|
-
// setCredentials: (
|
|
118
|
-
// state: AuthState,
|
|
119
|
-
// data: {
|
|
120
|
-
// payload: any;
|
|
121
|
-
// type: string;
|
|
122
|
-
// },
|
|
123
|
-
// ) => AuthState;
|
|
124
|
-
// resetCreating: (state: AuthState) => void;
|
|
125
|
-
// updateSubscription: (state: AuthState, data: any) => void;
|
|
126
|
-
// logout: () => void;
|
|
127
|
-
// }
|
|
128
122
|
var authSlice = toolkit.createSlice({
|
|
129
123
|
name: 'auth',
|
|
130
|
-
initialState: initialState,
|
|
124
|
+
initialState: initialState$1,
|
|
131
125
|
reducers: {
|
|
132
126
|
setCredentials: function (state, data) {
|
|
133
127
|
return __assign(__assign({}, state), { session: data.payload.accessToken, authenticated: true, verifying: true, user: __assign(__assign({}, state.user), data.payload) });
|
|
@@ -141,15 +135,13 @@ var authSlice = toolkit.createSlice({
|
|
|
141
135
|
updateSubscription: function (state, data) {
|
|
142
136
|
return __assign(__assign({}, state), { user: __assign(__assign({}, state.user), { details: __assign(__assign({}, state.user.details), { customerId: data.payload.customerId, subscription: data.payload.subscription, subscriptionDetails: data.payload.subscriptionDetails }) }) });
|
|
143
137
|
},
|
|
144
|
-
logout: function () { return initialState; },
|
|
138
|
+
logout: function () { return initialState$1; },
|
|
145
139
|
},
|
|
146
140
|
selectors: {
|
|
147
141
|
isAuthenticated: function (auth) { return auth.authenticated; },
|
|
148
142
|
selectAccessToken: function (auth) { return auth.user.accessToken; },
|
|
149
143
|
selectRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
150
144
|
selectCurrentUser: function (auth) { return auth.user.details; },
|
|
151
|
-
// selectUserCreating: (auth) => auth.creating,
|
|
152
|
-
// selectUserCreatingDetails: (auth) => auth.creating.details,
|
|
153
145
|
isVerifying: function (auth) { return auth.verifying; },
|
|
154
146
|
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
155
147
|
selectCurrentUserSub: function (auth) { return auth.user.sub; },
|
|
@@ -176,12 +168,9 @@ var authSlice = toolkit.createSlice({
|
|
|
176
168
|
},
|
|
177
169
|
});
|
|
178
170
|
// Action creators are generated for each case reducer function.
|
|
179
|
-
var setCredentials = (_a$
|
|
171
|
+
var setCredentials = (_a$2 = authSlice.actions, _a$2.setCredentials), resetCreating = _a$2.resetCreating, logout = _a$2.logout, updateSubscription = _a$2.updateSubscription;
|
|
180
172
|
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
181
|
-
var isAuthenticated = (_b$
|
|
182
|
-
// selectUserCreating,
|
|
183
|
-
// selectUserCreatingDetails,
|
|
184
|
-
isVerifying = _b$1.isVerifying, getUserSession = _b$1.getUserSession, selectCurrentUserSub = _b$1.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$1.selectCurrentUserRefreshToken, selectUserTokens = _b$1.selectUserTokens, selectUserSubscriptionStatus = _b$1.selectUserSubscriptionStatus, selectSubscription = _b$1.selectSubscription, selectSubscriptionPrice = _b$1.selectSubscriptionPrice;
|
|
173
|
+
var isAuthenticated = (_b$2 = authSlice.selectors, _b$2.isAuthenticated), selectAccessToken = _b$2.selectAccessToken, selectRefreshToken = _b$2.selectRefreshToken, selectCurrentUser = _b$2.selectCurrentUser, isVerifying = _b$2.isVerifying, getUserSession = _b$2.getUserSession, selectCurrentUserSub = _b$2.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$2.selectCurrentUserRefreshToken, selectUserTokens = _b$2.selectUserTokens, selectUserSubscriptionStatus = _b$2.selectUserSubscriptionStatus, selectSubscription = _b$2.selectSubscription, selectSubscriptionPrice = _b$2.selectSubscriptionPrice;
|
|
185
174
|
authSlice.reducer;
|
|
186
175
|
|
|
187
176
|
// TODO: typing.
|
|
@@ -208,28 +197,28 @@ var formatUserPayload = function (payload) {
|
|
|
208
197
|
};
|
|
209
198
|
function formatPromos(data) {
|
|
210
199
|
return data.map(function (item) {
|
|
211
|
-
var
|
|
200
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
212
201
|
return {
|
|
213
|
-
uuid: _source.uuid
|
|
214
|
-
id: _source.uuid
|
|
215
|
-
title: _source.title
|
|
216
|
-
video: _source.video
|
|
217
|
-
align: _source.align
|
|
218
|
-
section: _source.section
|
|
219
|
-
image: _source.image
|
|
220
|
-
imageFormatted: _source.image_formatted
|
|
221
|
-
backgroundImage: _source.background_image
|
|
222
|
-
backgroundVideo: _source.background_video
|
|
223
|
-
backgroundImageFormatted: _source.background_image_formatted
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
202
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
203
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
204
|
+
title: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f[0],
|
|
205
|
+
video: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.video) === null || _h === void 0 ? void 0 : _h[0],
|
|
206
|
+
align: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.align) === null || _k === void 0 ? void 0 : _k[0],
|
|
207
|
+
section: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.section) === null || _m === void 0 ? void 0 : _m[0],
|
|
208
|
+
image: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.image) === null || _p === void 0 ? void 0 : _p[0],
|
|
209
|
+
imageFormatted: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.image_formatted) === null || _r === void 0 ? void 0 : _r[0],
|
|
210
|
+
backgroundImage: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.background_image) === null || _t === void 0 ? void 0 : _t[0],
|
|
211
|
+
backgroundVideo: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.background_video) === null || _v === void 0 ? void 0 : _v[0],
|
|
212
|
+
backgroundImageFormatted: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.background_image_formatted) === null || _x === void 0 ? void 0 : _x[0],
|
|
213
|
+
description: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.description) === null || _z === void 0 ? void 0 : _z[0],
|
|
214
|
+
created: (_1 = (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.created) === null || _1 === void 0 ? void 0 : _1[0],
|
|
215
|
+
updated: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.updated) === null || _3 === void 0 ? void 0 : _3[0],
|
|
216
|
+
langcode: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.langcode) === null || _5 === void 0 ? void 0 : _5[0],
|
|
217
|
+
weight: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.weight) === null || _7 === void 0 ? void 0 : _7[0],
|
|
218
|
+
authPanel: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.auth_panel) === null || _9 === void 0 ? void 0 : _9[0],
|
|
219
|
+
buttonText: (_11 = (_10 = item === null || item === void 0 ? void 0 : item._source) === null || _10 === void 0 ? void 0 : _10.button_text) === null || _11 === void 0 ? void 0 : _11[0],
|
|
220
|
+
link: (_13 = (_12 = item === null || item === void 0 ? void 0 : item._source) === null || _12 === void 0 ? void 0 : _12.link) === null || _13 === void 0 ? void 0 : _13[0],
|
|
221
|
+
term: (_15 = (_14 = item === null || item === void 0 ? void 0 : item._source) === null || _14 === void 0 ? void 0 : _14.term) === null || _15 === void 0 ? void 0 : _15[0],
|
|
233
222
|
};
|
|
234
223
|
});
|
|
235
224
|
}
|
|
@@ -258,24 +247,24 @@ function formatWorkout(data) {
|
|
|
258
247
|
};
|
|
259
248
|
});
|
|
260
249
|
}
|
|
261
|
-
function formatSeries(data, channel) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
250
|
+
// export function formatSeries(data: Series[], channel: string) {
|
|
251
|
+
// const formattedSeriesSelection = data.map((series) => {
|
|
252
|
+
// return {
|
|
253
|
+
// uuid: series.uuid,
|
|
254
|
+
// id: series.uuid,
|
|
255
|
+
// title: series.title,
|
|
256
|
+
// subtitle: series.subtitle,
|
|
257
|
+
// thumb: series.imageThumbnailURL,
|
|
258
|
+
// mainImage: series.imageURL,
|
|
259
|
+
// description: series.summary.value,
|
|
260
|
+
// body: series.body.value,
|
|
261
|
+
// nid: series.nid,
|
|
262
|
+
// seasonList: series.season,
|
|
263
|
+
// channel,
|
|
264
|
+
// };
|
|
265
|
+
// });
|
|
266
|
+
// return formattedSeriesSelection;
|
|
267
|
+
// }
|
|
279
268
|
function formatShortform(data) {
|
|
280
269
|
return data.map(function (item) {
|
|
281
270
|
var _source = item._source;
|
|
@@ -297,34 +286,35 @@ function formatShortform(data) {
|
|
|
297
286
|
};
|
|
298
287
|
});
|
|
299
288
|
}
|
|
300
|
-
function formatLongform(data) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
289
|
+
// export function formatLongform(data: ESLongForm[]) {
|
|
290
|
+
// return data.map((item) => {
|
|
291
|
+
// const { _source } = item;
|
|
292
|
+
// return {
|
|
293
|
+
// uuid: _source.uuid && _source.uuid[0],
|
|
294
|
+
// id: _source.uuid && _source.uuid[0],
|
|
295
|
+
// nid: _source.nid && _source.nid[0],
|
|
296
|
+
// title: _source.title && _source.title[0],
|
|
297
|
+
// image: _source.image && _source.image[0],
|
|
298
|
+
// image_promo: _source.image_promo && _source.image_promo[0],
|
|
299
|
+
// image_promo_large:
|
|
300
|
+
// _source.image_promo_large && _source.image_promo_large[0],
|
|
301
|
+
// image_poster: _source.image_poster && _source.image_poster[0],
|
|
302
|
+
// summary: _source.summary && _source.summary[0],
|
|
303
|
+
// created: _source.created && _source.created[0],
|
|
304
|
+
// updated: _source.revision_timestamp && _source.revision_timestamp[0],
|
|
305
|
+
// video: _source.video_manifest && _source.video_manifest[0],
|
|
306
|
+
// rating: _source.rating && _source.rating[0],
|
|
307
|
+
// released: _source.released_date && _source.released_date[0],
|
|
308
|
+
// source_id: _source.source_id && _source.source_id[0],
|
|
309
|
+
// director: _source.director && _source.director[0],
|
|
310
|
+
// duration: _source.duration && _source.duration[0],
|
|
311
|
+
// path: _source.path && _source.path[0],
|
|
312
|
+
// genres: _source.genres,
|
|
313
|
+
// actors: _source.actors,
|
|
314
|
+
// writers: _source.writers,
|
|
315
|
+
// };
|
|
316
|
+
// });
|
|
317
|
+
// }
|
|
328
318
|
function formatFaqs(data) {
|
|
329
319
|
return data.map(function (item) {
|
|
330
320
|
var _source = item._source;
|
|
@@ -340,16 +330,16 @@ function formatFaqs(data) {
|
|
|
340
330
|
}
|
|
341
331
|
function formatPages(data) {
|
|
342
332
|
return data.map(function (item) {
|
|
343
|
-
var
|
|
333
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
344
334
|
return {
|
|
345
|
-
uuid: _source.uuid
|
|
346
|
-
id: _source.uuid
|
|
347
|
-
title: _source.title
|
|
348
|
-
body: _source.body
|
|
349
|
-
created: _source.created
|
|
350
|
-
updated: _source.updated
|
|
351
|
-
langcode: _source.langcode
|
|
352
|
-
url: _source.url
|
|
335
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
336
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
337
|
+
title: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f[0],
|
|
338
|
+
body: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.body) === null || _h === void 0 ? void 0 : _h[0],
|
|
339
|
+
created: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.created) === null || _k === void 0 ? void 0 : _k[0],
|
|
340
|
+
updated: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.updated) === null || _m === void 0 ? void 0 : _m[0],
|
|
341
|
+
langcode: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.langcode) === null || _p === void 0 ? void 0 : _p[0],
|
|
342
|
+
url: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.url) === null || _r === void 0 ? void 0 : _r[0],
|
|
353
343
|
};
|
|
354
344
|
});
|
|
355
345
|
}
|
|
@@ -649,15 +639,172 @@ function formatSocialAuthSession(tokens) {
|
|
|
649
639
|
},
|
|
650
640
|
};
|
|
651
641
|
}
|
|
642
|
+
function formatConfig(data) {
|
|
643
|
+
return data.map(function (item) {
|
|
644
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
645
|
+
return {
|
|
646
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
647
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
648
|
+
created: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.created) === null || _f === void 0 ? void 0 : _f[0],
|
|
649
|
+
updated: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.updated) === null || _h === void 0 ? void 0 : _h[0],
|
|
650
|
+
type: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.type) === null || _k === void 0 ? void 0 : _k[0],
|
|
651
|
+
cla: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.cla) === null || _m === void 0 ? void 0 : _m[0],
|
|
652
|
+
enabled: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.enabled) === null || _p === void 0 ? void 0 : _p[0],
|
|
653
|
+
name: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.name) === null || _r === void 0 ? void 0 : _r[0],
|
|
654
|
+
price: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.price) === null || _t === void 0 ? void 0 : _t[0],
|
|
655
|
+
video: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.video) === null || _v === void 0 ? void 0 : _v[0],
|
|
656
|
+
imageHomepage: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.image_homepage) === null || _x === void 0 ? void 0 : _x[0],
|
|
657
|
+
imageSectionBanner: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.image_section_banner) === null || _z === void 0 ? void 0 : _z[0],
|
|
658
|
+
};
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
function formatSectionPanels(data) {
|
|
662
|
+
return data.map(function (item) {
|
|
663
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
664
|
+
return {
|
|
665
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
666
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
667
|
+
title: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f[0],
|
|
668
|
+
created: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.created) === null || _h === void 0 ? void 0 : _h[0],
|
|
669
|
+
updated: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.updated) === null || _k === void 0 ? void 0 : _k[0],
|
|
670
|
+
weight: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.weight) === null || _m === void 0 ? void 0 : _m[0],
|
|
671
|
+
items: (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.item_uuid,
|
|
672
|
+
type: (_q = (_p = item === null || item === void 0 ? void 0 : item._source) === null || _p === void 0 ? void 0 : _p.type) === null || _q === void 0 ? void 0 : _q[0],
|
|
673
|
+
};
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
function formatSectionItems(data) {
|
|
677
|
+
return data.map(function (item) {
|
|
678
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
679
|
+
return {
|
|
680
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
681
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
682
|
+
title: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f[0],
|
|
683
|
+
created: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.created) === null || _h === void 0 ? void 0 : _h[0],
|
|
684
|
+
updated: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.updated) === null || _k === void 0 ? void 0 : _k[0],
|
|
685
|
+
type: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.type) === null || _m === void 0 ? void 0 : _m[0],
|
|
686
|
+
term: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.term) === null || _p === void 0 ? void 0 : _p[0],
|
|
687
|
+
image: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.custom_image_formatted) === null || _r === void 0 ? void 0 : _r[0],
|
|
688
|
+
bannerImage: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.banner_image_formatted) === null || _t === void 0 ? void 0 : _t[0],
|
|
689
|
+
};
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
var formatTaxonomies = function (data) {
|
|
693
|
+
return data.map(function (item) {
|
|
694
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
695
|
+
return {
|
|
696
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
697
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
698
|
+
updated: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.updated) === null || _f === void 0 ? void 0 : _f[0],
|
|
699
|
+
vocabulary: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.vocabulary) === null || _h === void 0 ? void 0 : _h[0],
|
|
700
|
+
name: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.name) === null || _k === void 0 ? void 0 : _k[0],
|
|
701
|
+
description: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.description) === null || _m === void 0 ? void 0 : _m[0],
|
|
702
|
+
image: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.image) === null || _p === void 0 ? void 0 : _p[0],
|
|
703
|
+
imageBanner: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.image_banner) === null || _r === void 0 ? void 0 : _r[0],
|
|
704
|
+
imageBannerTaxonomy: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.image_banner_taxonomy) === null || _t === void 0 ? void 0 : _t[0],
|
|
705
|
+
imageLarge: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.image_large_16_9) === null || _v === void 0 ? void 0 : _v[0],
|
|
706
|
+
weight: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.weight) === null || _x === void 0 ? void 0 : _x[0],
|
|
707
|
+
parentName: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.parent_name) === null || _z === void 0 ? void 0 : _z[0],
|
|
708
|
+
color: (_1 = (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.color) === null || _1 === void 0 ? void 0 : _1[0],
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
};
|
|
712
|
+
var formatSeries = function (data) {
|
|
713
|
+
return data.map(function (item) {
|
|
714
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
715
|
+
return {
|
|
716
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
717
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
718
|
+
created: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.created) === null || _f === void 0 ? void 0 : _f[0],
|
|
719
|
+
updated: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.updated) === null || _h === void 0 ? void 0 : _h[0],
|
|
720
|
+
title: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.display_title) === null || _k === void 0 ? void 0 : _k[0],
|
|
721
|
+
synopsis: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.synopsis) === null || _m === void 0 ? void 0 : _m[0],
|
|
722
|
+
imagePoster: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.image_style_poster) === null || _p === void 0 ? void 0 : _p[0],
|
|
723
|
+
imageThumb: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.image_style_thumb) === null || _r === void 0 ? void 0 : _r[0],
|
|
724
|
+
category: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.category) === null || _t === void 0 ? void 0 : _t[0],
|
|
725
|
+
categoryId: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.category_id) === null || _v === void 0 ? void 0 : _v[0],
|
|
726
|
+
seasons: ((_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.seasons) || [],
|
|
727
|
+
};
|
|
728
|
+
});
|
|
729
|
+
};
|
|
730
|
+
var formatSeasons = function (data) {
|
|
731
|
+
return data.map(function (item) {
|
|
732
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
733
|
+
return {
|
|
734
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
735
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
736
|
+
created: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.created) === null || _f === void 0 ? void 0 : _f[0],
|
|
737
|
+
updated: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.updated) === null || _h === void 0 ? void 0 : _h[0],
|
|
738
|
+
title: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.display_title) === null || _k === void 0 ? void 0 : _k[0],
|
|
739
|
+
synopsis: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.synopsis) === null || _m === void 0 ? void 0 : _m[0],
|
|
740
|
+
imagePoster: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.image_style_poster) === null || _p === void 0 ? void 0 : _p[0],
|
|
741
|
+
imageThumb: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.image_style_thumb) === null || _r === void 0 ? void 0 : _r[0],
|
|
742
|
+
episodes: ((_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.episodes) || [],
|
|
743
|
+
seasonNumber: (_u = (_t = item === null || item === void 0 ? void 0 : item._source) === null || _t === void 0 ? void 0 : _t.season_number) === null || _u === void 0 ? void 0 : _u[0],
|
|
744
|
+
showId: (_w = (_v = item === null || item === void 0 ? void 0 : item._source) === null || _v === void 0 ? void 0 : _v.show) === null || _w === void 0 ? void 0 : _w[0],
|
|
745
|
+
};
|
|
746
|
+
});
|
|
747
|
+
};
|
|
748
|
+
var formatLongform = function (data) {
|
|
749
|
+
return data.map(function (item) {
|
|
750
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
751
|
+
return {
|
|
752
|
+
uuid: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.uuid) === null || _b === void 0 ? void 0 : _b[0],
|
|
753
|
+
id: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.uuid) === null || _d === void 0 ? void 0 : _d[0],
|
|
754
|
+
created: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.created) === null || _f === void 0 ? void 0 : _f[0],
|
|
755
|
+
updated: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.updated) === null || _h === void 0 ? void 0 : _h[0],
|
|
756
|
+
title: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.display_title) === null || _k === void 0 ? void 0 : _k[0],
|
|
757
|
+
synopsis: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.synopsis) === null || _m === void 0 ? void 0 : _m[0],
|
|
758
|
+
image_poster: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.image_style_poster) === null || _p === void 0 ? void 0 : _p[0],
|
|
759
|
+
image_thumb: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.image_style_thumb) === null || _r === void 0 ? void 0 : _r[0],
|
|
760
|
+
duration: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.duration) === null || _t === void 0 ? void 0 : _t[0],
|
|
761
|
+
releaseDate: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.release_date) === null || _v === void 0 ? void 0 : _v[0],
|
|
762
|
+
video: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.video) === null || _x === void 0 ? void 0 : _x[0],
|
|
763
|
+
image_url: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.image_url) === null || _z === void 0 ? void 0 : _z[0],
|
|
764
|
+
episode_number: (_1 = (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.episode_number) === null || _1 === void 0 ? void 0 : _1[0],
|
|
765
|
+
};
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
var formatMediaItem = function (data) {
|
|
769
|
+
return data.map(function (item) {
|
|
770
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
771
|
+
return {
|
|
772
|
+
changed: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.changed) === null || _b === void 0 ? void 0 : _b[0],
|
|
773
|
+
created: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.created) === null || _d === void 0 ? void 0 : _d[0],
|
|
774
|
+
image: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f[0],
|
|
775
|
+
customThumbnail: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.custom_thumbnail) === null || _h === void 0 ? void 0 : _h[0],
|
|
776
|
+
price: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.price) === null || _k === void 0 ? void 0 : _k[0],
|
|
777
|
+
priceTwoYear: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.price_2_year) === null || _m === void 0 ? void 0 : _m[0],
|
|
778
|
+
revisionTimestamp: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.revision_timestamp) === null || _p === void 0 ? void 0 : _p[0],
|
|
779
|
+
sku: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.sku) === null || _r === void 0 ? void 0 : _r[0],
|
|
780
|
+
status: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.status) === null || _t === void 0 ? void 0 : _t[0],
|
|
781
|
+
uuid: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.uuid) === null || _v === void 0 ? void 0 : _v[0],
|
|
782
|
+
description: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.description) === null || _x === void 0 ? void 0 : _x[0],
|
|
783
|
+
transcript: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.transcript) === null || _z === void 0 ? void 0 : _z[0],
|
|
784
|
+
entities: (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.entities,
|
|
785
|
+
phrases: (_1 = item === null || item === void 0 ? void 0 : item._source) === null || _1 === void 0 ? void 0 : _1.phrases,
|
|
786
|
+
video: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.video) === null || _3 === void 0 ? void 0 : _3[0],
|
|
787
|
+
title: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.title) === null || _5 === void 0 ? void 0 : _5[0],
|
|
788
|
+
generatedTitle: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.generated_title) === null || _7 === void 0 ? void 0 : _7[0],
|
|
789
|
+
projectPricing: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.project_pricing) === null || _9 === void 0 ? void 0 : _9[0],
|
|
790
|
+
related_items: (_10 = item === null || item === void 0 ? void 0 : item._source) === null || _10 === void 0 ? void 0 : _10.related_uuids,
|
|
791
|
+
franchises: (_11 = item === null || item === void 0 ? void 0 : item._source) === null || _11 === void 0 ? void 0 : _11.franchise_name,
|
|
792
|
+
franchisesIds: (_12 = item === null || item === void 0 ? void 0 : item._source) === null || _12 === void 0 ? void 0 : _12.franchise_tid,
|
|
793
|
+
original: (_14 = (_13 = item === null || item === void 0 ? void 0 : item._source) === null || _13 === void 0 ? void 0 : _13.original) === null || _14 === void 0 ? void 0 : _14[0],
|
|
794
|
+
script: (_16 = (_15 = item === null || item === void 0 ? void 0 : item._source) === null || _15 === void 0 ? void 0 : _15.script) === null || _16 === void 0 ? void 0 : _16[0],
|
|
795
|
+
hideThumbnailTitle: (_18 = (_17 = item === null || item === void 0 ? void 0 : item._source) === null || _17 === void 0 ? void 0 : _17.hide_thumbnail_title) === null || _18 === void 0 ? void 0 : _18[0],
|
|
796
|
+
};
|
|
797
|
+
});
|
|
798
|
+
};
|
|
652
799
|
|
|
653
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
800
|
+
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
654
801
|
// Render the store based on the environment.
|
|
655
802
|
var isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
656
803
|
var ENV = isWeb ? process.env : require('react-native-config').default;
|
|
657
804
|
// export const ENV = process.env;
|
|
658
|
-
((_a = process.env) === null || _a === void 0 ? void 0 : _a.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
805
|
+
((_a$1 = process.env) === null || _a$1 === void 0 ? void 0 : _a$1.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
659
806
|
// Auth specific API
|
|
660
|
-
var API_AUTH_PREFIX = ((_b = process.env) === null || _b === void 0 ? void 0 : _b.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
807
|
+
var API_AUTH_PREFIX = ((_b$1 = process.env) === null || _b$1 === void 0 ? void 0 : _b$1.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
661
808
|
// Payments specific API
|
|
662
809
|
var API_PAYMENTS_PREFIX = ((_c = process.env) === null || _c === void 0 ? void 0 : _c.NEXT_PUBLIC_API_PAYMENTS_PREFIX) || ENV.API_PAYMENTS_PREFIX;
|
|
663
810
|
((_d = process.env) === null || _d === void 0 ? void 0 : _d.NEXT_PUBLIC_APP_BASE_URL) || ENV.APP_BASE_URL;
|
|
@@ -1091,6 +1238,136 @@ var paymentApi = react.createApi({
|
|
|
1091
1238
|
// Export hooks for usage in functional components.
|
|
1092
1239
|
paymentApi.useCheckUserSubscriptionQuery; paymentApi.useLazyCheckUserSubscriptionQuery; paymentApi.useGetPaymentPlansQuery; paymentApi.useLazyGetPaymentPlansQuery;
|
|
1093
1240
|
|
|
1241
|
+
function applyCoupon(coupon, netTotal) {
|
|
1242
|
+
var discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
1243
|
+
var discountedTotal = netTotal - discountedAmount;
|
|
1244
|
+
var data = __assign(__assign({}, coupon), { discountedTotal: discountedTotal, discountedAmount: discountedAmount });
|
|
1245
|
+
return data;
|
|
1246
|
+
}
|
|
1247
|
+
function applyTax(taxRate, netTotal) {
|
|
1248
|
+
var taxAmount = netTotal * (taxRate.percentage / 100);
|
|
1249
|
+
return taxAmount;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
var _a, _b;
|
|
1253
|
+
var initialState = {
|
|
1254
|
+
addedItems: [],
|
|
1255
|
+
netTotal: 0,
|
|
1256
|
+
taxRate: {
|
|
1257
|
+
country: 'none',
|
|
1258
|
+
percentage: 0,
|
|
1259
|
+
},
|
|
1260
|
+
taxAmount: 0,
|
|
1261
|
+
promoCode: {
|
|
1262
|
+
code: '',
|
|
1263
|
+
name: '',
|
|
1264
|
+
discount: '',
|
|
1265
|
+
discountedAmount: 0,
|
|
1266
|
+
},
|
|
1267
|
+
grossTotal: 0,
|
|
1268
|
+
loading: false,
|
|
1269
|
+
error: false,
|
|
1270
|
+
open: false,
|
|
1271
|
+
};
|
|
1272
|
+
var cartSlice = toolkit.createSlice({
|
|
1273
|
+
name: 'cart',
|
|
1274
|
+
initialState: initialState,
|
|
1275
|
+
reducers: {
|
|
1276
|
+
setTaxRate: function (state, action) {
|
|
1277
|
+
var netTotal = state.netTotal, promoCode = state.promoCode;
|
|
1278
|
+
var currentTotal = netTotal;
|
|
1279
|
+
if (promoCode === null || promoCode === void 0 ? void 0 : promoCode.code) {
|
|
1280
|
+
var data = applyCoupon(promoCode, currentTotal);
|
|
1281
|
+
currentTotal = data.discountedTotal;
|
|
1282
|
+
}
|
|
1283
|
+
var taxAmount = applyTax(action.payload, currentTotal);
|
|
1284
|
+
var grossTotal = currentTotal + taxAmount;
|
|
1285
|
+
return __assign(__assign({}, state), { taxRate: action.payload, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1286
|
+
},
|
|
1287
|
+
resetTaxRate: function (state, action) {
|
|
1288
|
+
console.log('resetTaxRate', action);
|
|
1289
|
+
return __assign(__assign({}, state), { taxRate: {
|
|
1290
|
+
country: 'none',
|
|
1291
|
+
percentage: 0,
|
|
1292
|
+
}, taxAmount: 0 });
|
|
1293
|
+
},
|
|
1294
|
+
setPromoCode: function (state, action) {
|
|
1295
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1296
|
+
var data = applyCoupon(action.payload, netTotal);
|
|
1297
|
+
var taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
1298
|
+
var grossTotal = data.discountedTotal + taxAmount;
|
|
1299
|
+
return __assign(__assign({}, state), { promoCode: {
|
|
1300
|
+
code: data.code,
|
|
1301
|
+
name: data.code,
|
|
1302
|
+
discount: data.discount,
|
|
1303
|
+
discountedAmount: data.discountedAmount,
|
|
1304
|
+
}, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1305
|
+
},
|
|
1306
|
+
removePromoCode: function (state, action) {
|
|
1307
|
+
console.log('removePromoCode', action);
|
|
1308
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1309
|
+
var taxAmount = applyTax(taxRate, netTotal);
|
|
1310
|
+
var grossTotal = netTotal + taxAmount;
|
|
1311
|
+
return __assign(__assign({}, state), { promoCode: initialState.promoCode, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1312
|
+
},
|
|
1313
|
+
addToCart: function (state, action) {
|
|
1314
|
+
var _a = action.payload, options = _a.options, item = _a.item;
|
|
1315
|
+
var newTotal = state.netTotal + options.selectedPrice;
|
|
1316
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1317
|
+
var grossTotal = newTotal + taxAmount;
|
|
1318
|
+
var addItem = item ? __assign(__assign({}, item), { options: options }) : null;
|
|
1319
|
+
if (!addItem) {
|
|
1320
|
+
return state;
|
|
1321
|
+
}
|
|
1322
|
+
var addedItems = __spreadArray(__spreadArray([], state.addedItems, true), [addItem], false);
|
|
1323
|
+
return __assign(__assign({}, state), { addedItems: addedItems, netTotal: newTotal, grossTotal: grossTotal });
|
|
1324
|
+
},
|
|
1325
|
+
updateCart: function (state, action) {
|
|
1326
|
+
var options = action.payload.options;
|
|
1327
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.map(function (item) {
|
|
1328
|
+
return item && __assign(__assign({}, item), { options: options });
|
|
1329
|
+
}) });
|
|
1330
|
+
},
|
|
1331
|
+
removeFromCart: function (state, action) {
|
|
1332
|
+
var _a = action.payload, id = _a.id, price = _a.price;
|
|
1333
|
+
var newTotal = state.netTotal - price;
|
|
1334
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1335
|
+
var grossTotal = newTotal + taxAmount;
|
|
1336
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.filter(function (item) { return item && item.uuid !== id; }), netTotal: newTotal, grossTotal: grossTotal });
|
|
1337
|
+
},
|
|
1338
|
+
toggleCart: function (state, action) {
|
|
1339
|
+
return __assign(__assign({}, state), { open: action.payload });
|
|
1340
|
+
},
|
|
1341
|
+
emptyCart: function () { return initialState; },
|
|
1342
|
+
},
|
|
1343
|
+
selectors: {
|
|
1344
|
+
selectMediaInCart: function (cart) { return cart.addedItems; },
|
|
1345
|
+
selectCartTotal: function (cart) { return cart.grossTotal; },
|
|
1346
|
+
selectCartNetTotal: function (cart) { return cart.netTotal; },
|
|
1347
|
+
selectCartTaxRate: function (cart) { return cart.taxRate; },
|
|
1348
|
+
selectCartTaxAmount: function (cart) { return cart.taxAmount; },
|
|
1349
|
+
selectCartCount: function (cart) { return cart.addedItems.length; },
|
|
1350
|
+
selectCartStatus: function (cart) { return cart.open; },
|
|
1351
|
+
selectPromoCode: function (cart) { return cart.promoCode; },
|
|
1352
|
+
},
|
|
1353
|
+
});
|
|
1354
|
+
var setTaxRate = (_a = cartSlice.actions, _a.setTaxRate), resetTaxRate = _a.resetTaxRate, setPromoCode = _a.setPromoCode, removePromoCode = _a.removePromoCode, addToCart = _a.addToCart, updateCart = _a.updateCart, removeFromCart = _a.removeFromCart, emptyCart = _a.emptyCart, toggleCart = _a.toggleCart;
|
|
1355
|
+
var selectMediaInCart = (_b = cartSlice.selectors, _b.selectMediaInCart), selectCartTotal = _b.selectCartTotal, selectCartNetTotal = _b.selectCartNetTotal, selectCartTaxRate = _b.selectCartTaxRate, selectCartTaxAmount = _b.selectCartTaxAmount, selectCartCount = _b.selectCartCount, selectCartStatus = _b.selectCartStatus, selectPromoCode = _b.selectPromoCode;
|
|
1356
|
+
var selectCartItems = toolkit.createSelector([selectMediaInCart], function (items) {
|
|
1357
|
+
return items.map(function (item) {
|
|
1358
|
+
return {
|
|
1359
|
+
title: item.title || item.generatedTitle,
|
|
1360
|
+
file: "".concat(item.sku, ".mp4"),
|
|
1361
|
+
options: item.options,
|
|
1362
|
+
script: item.script,
|
|
1363
|
+
};
|
|
1364
|
+
});
|
|
1365
|
+
});
|
|
1366
|
+
var selectCartItemsIds = toolkit.createSelector([selectMediaInCart], function (items) {
|
|
1367
|
+
return items.map(function (item) { return item.uuid; });
|
|
1368
|
+
});
|
|
1369
|
+
cartSlice.reducer;
|
|
1370
|
+
|
|
1094
1371
|
var useLoggedIn = function () {
|
|
1095
1372
|
var isLoggedIn = reactRedux.useSelector(isAuthenticated);
|
|
1096
1373
|
return react$1.useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
@@ -1122,13 +1399,7 @@ function createPersistStorage() {
|
|
|
1122
1399
|
}
|
|
1123
1400
|
|
|
1124
1401
|
// Infer the `RootState` type from the root reducer
|
|
1125
|
-
var rootReducer = toolkit.combineSlices(authSlice, authApi, contentApi, paymentApi);
|
|
1126
|
-
// export interface RootState {
|
|
1127
|
-
// [authSlice.name]: ReturnType<typeof authSlice.reducer>;
|
|
1128
|
-
// [authApi.reducerPath]: ReturnType<typeof authApi.reducer>;
|
|
1129
|
-
// [contentApi.reducerPath]: ReturnType<typeof contentApi.reducer>;
|
|
1130
|
-
// [paymentApi.reducerPath]: ReturnType<typeof paymentApi.reducer>;
|
|
1131
|
-
// }
|
|
1402
|
+
var rootReducer = toolkit.combineSlices(cartSlice, authSlice, authApi, contentApi, paymentApi);
|
|
1132
1403
|
// eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
|
|
1133
1404
|
// const storageWhiteList: string[] = [];
|
|
1134
1405
|
var storageBlackList = [];
|
|
@@ -1186,9 +1457,6 @@ var makeNativeStore = function () {
|
|
|
1186
1457
|
};
|
|
1187
1458
|
var makeWebStore = function () {
|
|
1188
1459
|
var storage = createPersistStorage();
|
|
1189
|
-
// if (process.env.NEXT_PUBLIC_STORE_BLACKLIST) {
|
|
1190
|
-
// storageBlackList.push(process.env.NEXT_PUBLIC_STORE_BLACKLIST);
|
|
1191
|
-
// }
|
|
1192
1460
|
storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath);
|
|
1193
1461
|
var persistConfig = {
|
|
1194
1462
|
key: 'root',
|
|
@@ -1226,26 +1494,35 @@ var makeWebStore = function () {
|
|
|
1226
1494
|
var nativeStore = !isWeb && makeNativeStore();
|
|
1227
1495
|
var webStore = isWeb && makeWebStore();
|
|
1228
1496
|
|
|
1497
|
+
exports.addToCart = addToCart;
|
|
1229
1498
|
exports.authApi = authApi;
|
|
1230
1499
|
exports.authSlice = authSlice;
|
|
1500
|
+
exports.cartSlice = cartSlice;
|
|
1231
1501
|
exports.contentApi = contentApi;
|
|
1502
|
+
exports.emptyCart = emptyCart;
|
|
1232
1503
|
exports.formatAuthSession = formatAuthSession;
|
|
1233
1504
|
exports.formatChallengeDays = formatChallengeDays;
|
|
1234
1505
|
exports.formatChallenges = formatChallenges;
|
|
1506
|
+
exports.formatConfig = formatConfig;
|
|
1235
1507
|
exports.formatFaqs = formatFaqs;
|
|
1236
1508
|
exports.formatFedaratedSession = formatFedaratedSession;
|
|
1237
1509
|
exports.formatGuests = formatGuests;
|
|
1238
1510
|
exports.formatLongform = formatLongform;
|
|
1511
|
+
exports.formatMediaItem = formatMediaItem;
|
|
1239
1512
|
exports.formatPages = formatPages;
|
|
1240
1513
|
exports.formatPress = formatPress;
|
|
1241
1514
|
exports.formatPromos = formatPromos;
|
|
1242
1515
|
exports.formatSchedule = formatSchedule;
|
|
1516
|
+
exports.formatSeasons = formatSeasons;
|
|
1243
1517
|
exports.formatSecondsToISO8601Duration = formatSecondsToISO8601Duration;
|
|
1518
|
+
exports.formatSectionItems = formatSectionItems;
|
|
1519
|
+
exports.formatSectionPanels = formatSectionPanels;
|
|
1244
1520
|
exports.formatSections = formatSections;
|
|
1245
1521
|
exports.formatSeries = formatSeries;
|
|
1246
1522
|
exports.formatSettings = formatSettings;
|
|
1247
1523
|
exports.formatShortform = formatShortform;
|
|
1248
1524
|
exports.formatSocialAuthSession = formatSocialAuthSession;
|
|
1525
|
+
exports.formatTaxonomies = formatTaxonomies;
|
|
1249
1526
|
exports.formatUserPayload = formatUserPayload;
|
|
1250
1527
|
exports.formatVideos = formatVideos;
|
|
1251
1528
|
exports.formatWorkout = formatWorkout;
|
|
@@ -1255,17 +1532,34 @@ exports.isVerifying = isVerifying;
|
|
|
1255
1532
|
exports.logout = logout;
|
|
1256
1533
|
exports.nativeStore = nativeStore;
|
|
1257
1534
|
exports.paymentApi = paymentApi;
|
|
1535
|
+
exports.removeFromCart = removeFromCart;
|
|
1536
|
+
exports.removePromoCode = removePromoCode;
|
|
1258
1537
|
exports.resetCreating = resetCreating;
|
|
1538
|
+
exports.resetTaxRate = resetTaxRate;
|
|
1259
1539
|
exports.selectAccessToken = selectAccessToken;
|
|
1540
|
+
exports.selectCartCount = selectCartCount;
|
|
1541
|
+
exports.selectCartItems = selectCartItems;
|
|
1542
|
+
exports.selectCartItemsIds = selectCartItemsIds;
|
|
1543
|
+
exports.selectCartNetTotal = selectCartNetTotal;
|
|
1544
|
+
exports.selectCartStatus = selectCartStatus;
|
|
1545
|
+
exports.selectCartTaxAmount = selectCartTaxAmount;
|
|
1546
|
+
exports.selectCartTaxRate = selectCartTaxRate;
|
|
1547
|
+
exports.selectCartTotal = selectCartTotal;
|
|
1260
1548
|
exports.selectCurrentUser = selectCurrentUser;
|
|
1261
1549
|
exports.selectCurrentUserRefreshToken = selectCurrentUserRefreshToken;
|
|
1262
1550
|
exports.selectCurrentUserSub = selectCurrentUserSub;
|
|
1551
|
+
exports.selectMediaInCart = selectMediaInCart;
|
|
1552
|
+
exports.selectPromoCode = selectPromoCode;
|
|
1263
1553
|
exports.selectRefreshToken = selectRefreshToken;
|
|
1264
1554
|
exports.selectSubscription = selectSubscription;
|
|
1265
1555
|
exports.selectSubscriptionPrice = selectSubscriptionPrice;
|
|
1266
1556
|
exports.selectUserSubscriptionStatus = selectUserSubscriptionStatus;
|
|
1267
1557
|
exports.selectUserTokens = selectUserTokens;
|
|
1268
1558
|
exports.setCredentials = setCredentials;
|
|
1559
|
+
exports.setPromoCode = setPromoCode;
|
|
1560
|
+
exports.setTaxRate = setTaxRate;
|
|
1561
|
+
exports.toggleCart = toggleCart;
|
|
1562
|
+
exports.updateCart = updateCart;
|
|
1269
1563
|
exports.updateSubscription = updateSubscription;
|
|
1270
1564
|
exports.useAppDispatch = useAppDispatch;
|
|
1271
1565
|
exports.useAppSelector = useAppSelector;
|