@techstuff-dev/foundation-api-utils 1.47.0 → 1.49.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/cjs/chunks/index-CfrYa4U_.js +9 -0
- package/dist/cjs/chunks/index-CfrYa4U_.js.map +1 -0
- package/dist/cjs/chunks/shared-2Qy1c7Qz.js +19 -0
- package/dist/cjs/chunks/shared-2Qy1c7Qz.js.map +1 -0
- package/dist/cjs/chunks/slice-CkWobkWw.js +125 -0
- package/dist/cjs/chunks/slice-CkWobkWw.js.map +1 -0
- package/dist/{index.js → cjs/chunks/slice-DsZzY7T7.js} +618 -875
- package/dist/cjs/chunks/slice-DsZzY7T7.js.map +1 -0
- package/dist/cjs/chunks/useAuth-DKhvUX_r.js +13 -0
- package/dist/cjs/chunks/useAuth-DKhvUX_r.js.map +1 -0
- package/dist/cjs/hooks/index.native.js +19 -0
- package/dist/cjs/hooks/index.native.js.map +1 -0
- package/dist/cjs/hooks/index.web.js +19 -0
- package/dist/cjs/hooks/index.web.js.map +1 -0
- package/dist/cjs/index.js +96 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/store/index.native.js +415 -0
- package/dist/cjs/store/index.native.js.map +1 -0
- package/dist/cjs/store/index.web.js +188 -0
- package/dist/cjs/store/index.web.js.map +1 -0
- package/dist/esm/chunks/index-KjhWa1AL.js +6 -0
- package/dist/esm/chunks/index-KjhWa1AL.js.map +1 -0
- package/dist/esm/chunks/shared--CrxBBZ8.js +16 -0
- package/dist/esm/chunks/shared--CrxBBZ8.js.map +1 -0
- package/dist/{index.esm.js → esm/chunks/slice-3o-PH5Gz.js} +619 -855
- package/dist/esm/chunks/slice-3o-PH5Gz.js.map +1 -0
- package/dist/esm/chunks/slice-ChJ8ZvmP.js +107 -0
- package/dist/esm/chunks/slice-ChJ8ZvmP.js.map +1 -0
- package/dist/esm/chunks/useAuth-8d6DlERn.js +11 -0
- package/dist/esm/chunks/useAuth-8d6DlERn.js.map +1 -0
- package/dist/esm/hooks/index.native.js +14 -0
- package/dist/esm/hooks/index.native.js.map +1 -0
- package/dist/esm/hooks/index.web.js +14 -0
- package/dist/esm/hooks/index.web.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/store/index.native.js +412 -0
- package/dist/esm/store/index.native.js.map +1 -0
- package/dist/esm/store/index.web.js +185 -0
- package/dist/esm/store/index.web.js.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/index-BDQnFTra.d.ts +1299 -0
- package/dist/{index.d.ts → types/index.d.ts} +64 -1301
- package/dist/types/store/index.d.ts +3 -0
- package/package.json +37 -9
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/api/index.d.ts +0 -21
- package/dist/lib/hooks/index.d.ts +0 -4
- package/dist/lib/hooks/useAuth.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -6
- package/dist/lib/services/auth/index.d.ts +0 -2027
- package/dist/lib/services/auth/slice.d.ts +0 -91
- package/dist/lib/services/cart/slice.d.ts +0 -155
- package/dist/lib/services/content/content.interfaces.d.ts +0 -801
- package/dist/lib/services/content/index.d.ts +0 -532
- package/dist/lib/services/index.d.ts +0 -7
- package/dist/lib/services/orders/index.d.ts +0 -271
- package/dist/lib/services/payment/index.d.ts +0 -1063
- package/dist/lib/store/index.d.ts +0 -2
- package/dist/lib/store/index.native.d.ts +0 -68
- package/dist/lib/store/index.web.d.ts +0 -68
- package/dist/lib/store/storage.d.ts +0 -2
- package/dist/lib/types/index.interfaces.d.ts +0 -428
- package/dist/lib/utils/dataFormat/index.d.ts +0 -86
- package/dist/lib/utils/helpers/index.d.ts +0 -14
- package/dist/node_modules/@reduxjs/toolkit/dist/uncheckedindexed.d.ts +0 -5
|
@@ -1,90 +1,9 @@
|
|
|
1
|
+
import { Auth } from 'aws-amplify';
|
|
2
|
+
import { r as resetCreating, s as setCredentials, l as logout } from './slice-ChJ8ZvmP.js';
|
|
1
3
|
import { isPlainObject as isPlainObject$1, nanoid, formatProdErrorMessage, createAction, createSelector as createSelector$1, createNextState, createAsyncThunk, createSlice, prepareAutoBatched, isAnyOf, isFulfilled, isRejectedWithValue, combineReducers, SHOULD_AUTOBATCH, isAllOf, isRejected, isPending, isAction, isAsyncThunkAction } from '@reduxjs/toolkit';
|
|
2
4
|
import { useStore, useSelector, useDispatch, batch, shallowEqual } from 'react-redux';
|
|
3
5
|
import { useCallback, useDebugValue, useMemo, useState, useEffect, useRef, useLayoutEffect } from 'react';
|
|
4
|
-
import { Auth } from 'aws-amplify';
|
|
5
6
|
import { jwtDecode } from 'jwt-decode';
|
|
6
|
-
import { NativeModules } from 'react-native';
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
Copyright (c) Microsoft Corporation.
|
|
10
|
-
|
|
11
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
-
purpose with or without fee is hereby granted.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var __assign = function() {
|
|
26
|
-
__assign = Object.assign || function __assign(t) {
|
|
27
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
28
|
-
s = arguments[i];
|
|
29
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
return __assign.apply(this, arguments);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function __generator(thisArg, body) {
|
|
47
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
48
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
49
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
50
|
-
function step(op) {
|
|
51
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
52
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
53
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
54
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
55
|
-
switch (op[0]) {
|
|
56
|
-
case 0: case 1: t = op; break;
|
|
57
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
58
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
59
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
60
|
-
default:
|
|
61
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
62
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
63
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
64
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
65
|
-
if (t[2]) _.ops.pop();
|
|
66
|
-
_.trys.pop(); continue;
|
|
67
|
-
}
|
|
68
|
-
op = body.call(thisArg, _);
|
|
69
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
70
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function __spreadArray(to, from, pack) {
|
|
75
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
76
|
-
if (ar || !(i in from)) {
|
|
77
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
78
|
-
ar[i] = from[i];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
85
|
-
var e = new Error(message);
|
|
86
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
87
|
-
};
|
|
88
7
|
|
|
89
8
|
// src/utils/env.ts
|
|
90
9
|
var NOTHING = Symbol.for("immer-nothing");
|
|
@@ -2429,7 +2348,7 @@ function updateMutationSubstateIfExists(state, id, update) {
|
|
|
2429
2348
|
update(substate);
|
|
2430
2349
|
}
|
|
2431
2350
|
}
|
|
2432
|
-
var initialState$
|
|
2351
|
+
var initialState$1 = {};
|
|
2433
2352
|
function buildSlice({
|
|
2434
2353
|
reducerPath,
|
|
2435
2354
|
queryThunk,
|
|
@@ -2505,7 +2424,7 @@ function buildSlice({
|
|
|
2505
2424
|
}
|
|
2506
2425
|
const querySlice = createSlice({
|
|
2507
2426
|
name: `${reducerPath}/queries`,
|
|
2508
|
-
initialState: initialState$
|
|
2427
|
+
initialState: initialState$1,
|
|
2509
2428
|
reducers: {
|
|
2510
2429
|
removeQueryResult: {
|
|
2511
2430
|
reducer(draft, {
|
|
@@ -2639,7 +2558,7 @@ function buildSlice({
|
|
|
2639
2558
|
});
|
|
2640
2559
|
const mutationSlice = createSlice({
|
|
2641
2560
|
name: `${reducerPath}/mutations`,
|
|
2642
|
-
initialState: initialState$
|
|
2561
|
+
initialState: initialState$1,
|
|
2643
2562
|
reducers: {
|
|
2644
2563
|
removeMutationResult: {
|
|
2645
2564
|
reducer(draft, {
|
|
@@ -2808,7 +2727,7 @@ function buildSlice({
|
|
|
2808
2727
|
}
|
|
2809
2728
|
const subscriptionSlice = createSlice({
|
|
2810
2729
|
name: `${reducerPath}/subscriptions`,
|
|
2811
|
-
initialState: initialState$
|
|
2730
|
+
initialState: initialState$1,
|
|
2812
2731
|
reducers: {
|
|
2813
2732
|
updateSubscriptionOptions(d, a) {
|
|
2814
2733
|
},
|
|
@@ -2820,7 +2739,7 @@ function buildSlice({
|
|
|
2820
2739
|
});
|
|
2821
2740
|
const internalSubscriptionsSlice = createSlice({
|
|
2822
2741
|
name: `${reducerPath}/internalSubscriptions`,
|
|
2823
|
-
initialState: initialState$
|
|
2742
|
+
initialState: initialState$1,
|
|
2824
2743
|
reducers: {
|
|
2825
2744
|
subscriptionsUpdated: {
|
|
2826
2745
|
reducer(state, action) {
|
|
@@ -4763,110 +4682,30 @@ Hook ${hookName} was either not provided or not a function.`);
|
|
|
4763
4682
|
// src/query/react/index.ts
|
|
4764
4683
|
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
|
4765
4684
|
|
|
4766
|
-
var _a$2, _b$2;
|
|
4767
|
-
var initialState$1 = {
|
|
4768
|
-
authenticated: false,
|
|
4769
|
-
verifying: false,
|
|
4770
|
-
user: {
|
|
4771
|
-
details: {
|
|
4772
|
-
userSub: '',
|
|
4773
|
-
uuid: '',
|
|
4774
|
-
subscription: '',
|
|
4775
|
-
subscriptionDetails: undefined,
|
|
4776
|
-
firstName: '',
|
|
4777
|
-
lastName: '',
|
|
4778
|
-
userEmail: '',
|
|
4779
|
-
termsAccepted: '',
|
|
4780
|
-
contactPreference: false,
|
|
4781
|
-
dateOfBirth: '',
|
|
4782
|
-
picture: '',
|
|
4783
|
-
},
|
|
4784
|
-
accessToken: '',
|
|
4785
|
-
idToken: '',
|
|
4786
|
-
accessTokenExpiry: null,
|
|
4787
|
-
refreshToken: '',
|
|
4788
|
-
email: '',
|
|
4789
|
-
sub: '',
|
|
4790
|
-
},
|
|
4791
|
-
loading: false,
|
|
4792
|
-
error: false,
|
|
4793
|
-
session: undefined,
|
|
4794
|
-
};
|
|
4795
|
-
var authSlice = createSlice({
|
|
4796
|
-
name: 'auth',
|
|
4797
|
-
initialState: initialState$1,
|
|
4798
|
-
reducers: {
|
|
4799
|
-
setCredentials: function (state, data) {
|
|
4800
|
-
return __assign(__assign({}, state), { session: data.payload.accessToken, authenticated: true, verifying: true, user: __assign(__assign({}, state.user), data.payload) });
|
|
4801
|
-
},
|
|
4802
|
-
resetCreating: function (state) {
|
|
4803
|
-
return __assign(__assign({}, state), { creating: {
|
|
4804
|
-
details: '',
|
|
4805
|
-
payment: '',
|
|
4806
|
-
} });
|
|
4807
|
-
},
|
|
4808
|
-
updateSubscription: function (state, data) {
|
|
4809
|
-
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 }) }) });
|
|
4810
|
-
},
|
|
4811
|
-
logout: function () { return initialState$1; },
|
|
4812
|
-
},
|
|
4813
|
-
selectors: {
|
|
4814
|
-
isAuthenticated: function (auth) { return auth.authenticated; },
|
|
4815
|
-
selectAccessToken: function (auth) { return auth.user.accessToken; },
|
|
4816
|
-
selectRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
4817
|
-
selectCurrentUser: function (auth) { return auth.user.details; },
|
|
4818
|
-
isVerifying: function (auth) { return auth.verifying; },
|
|
4819
|
-
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
4820
|
-
// TODO: override this selector directly in the CNBCMEDIA app.
|
|
4821
|
-
selectCurrentUserSub: function (auth) { var _a, _b, _c; return ((_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c["custom:legacySub"]) || auth.user.sub; },
|
|
4822
|
-
selectCurrentUserRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
4823
|
-
selectUserTokens: function (auth) {
|
|
4824
|
-
return {
|
|
4825
|
-
accessToken: auth.user.accessToken,
|
|
4826
|
-
refreshToken: auth.user.refreshToken,
|
|
4827
|
-
idToken: auth.user.idToken,
|
|
4828
|
-
};
|
|
4829
|
-
},
|
|
4830
|
-
selectUserSubscriptionStatus: function (auth) {
|
|
4831
|
-
var _a, _b, _c;
|
|
4832
|
-
return (_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails) === null || _c === void 0 ? void 0 : _c.status;
|
|
4833
|
-
},
|
|
4834
|
-
selectSubscription: function (auth) {
|
|
4835
|
-
var _a, _b;
|
|
4836
|
-
return (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails;
|
|
4837
|
-
},
|
|
4838
|
-
selectSubscriptionPrice: function (auth) {
|
|
4839
|
-
var _a, _b, _c;
|
|
4840
|
-
return (_c = (_b = (_a = auth === null || auth === void 0 ? void 0 : auth.user) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.subscriptionDetails) === null || _c === void 0 ? void 0 : _c.amount;
|
|
4841
|
-
},
|
|
4842
|
-
},
|
|
4843
|
-
});
|
|
4844
|
-
// Action creators are generated for each case reducer function.
|
|
4845
|
-
var setCredentials = (_a$2 = authSlice.actions, _a$2.setCredentials), resetCreating = _a$2.resetCreating, logout = _a$2.logout, updateSubscription = _a$2.updateSubscription;
|
|
4846
|
-
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
4847
|
-
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;
|
|
4848
|
-
authSlice.reducer;
|
|
4849
|
-
|
|
4850
4685
|
function applyCoupon(coupon, netTotal) {
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4686
|
+
const discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
4687
|
+
const discountedTotal = netTotal - discountedAmount;
|
|
4688
|
+
const data = {
|
|
4689
|
+
...coupon,
|
|
4690
|
+
discountedTotal,
|
|
4691
|
+
discountedAmount,
|
|
4692
|
+
};
|
|
4854
4693
|
return data;
|
|
4855
4694
|
}
|
|
4856
4695
|
function applyTax(taxRate, netTotal) {
|
|
4857
|
-
|
|
4696
|
+
const taxAmount = netTotal * (taxRate.percentage / 100);
|
|
4858
4697
|
return taxAmount;
|
|
4859
4698
|
}
|
|
4860
4699
|
function toCamelCaseObject(obj) {
|
|
4861
|
-
|
|
4862
|
-
return str.replace(/([-_][a-z])/gi,
|
|
4700
|
+
const toCamelCase = (str) => {
|
|
4701
|
+
return str.replace(/([-_][a-z])/gi, (match) => {
|
|
4863
4702
|
return match.toUpperCase().replace(/[-_]/, '');
|
|
4864
4703
|
});
|
|
4865
4704
|
};
|
|
4866
|
-
|
|
4867
|
-
for (
|
|
4705
|
+
const camelCaseObject = {};
|
|
4706
|
+
for (const key in obj) {
|
|
4868
4707
|
if (obj.hasOwnProperty(key)) {
|
|
4869
|
-
|
|
4708
|
+
const camelKey = toCamelCase(key);
|
|
4870
4709
|
camelCaseObject[camelKey] = obj[key];
|
|
4871
4710
|
}
|
|
4872
4711
|
}
|
|
@@ -4874,44 +4713,43 @@ function toCamelCaseObject(obj) {
|
|
|
4874
4713
|
}
|
|
4875
4714
|
|
|
4876
4715
|
// TODO: typing.
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4716
|
+
const formatUserPayload = (payload) => {
|
|
4717
|
+
const { email: userEmail, given_name: firstName, family_name: lastName, birthdate: dateOfBirth, picture: picture, 'cognito:username': uuid, 'custom:termsAccepted': termsAccepted, 'custom:subscriptionId': subscriptionId, 'custom:contactPreferences': contactPreference, 'custom:customerId': customerId, } = payload;
|
|
4718
|
+
const parsedTermsAccepted = termsAccepted ? JSON.parse(termsAccepted) : null;
|
|
4719
|
+
const parsedContactPreference = contactPreference
|
|
4881
4720
|
? JSON.parse(contactPreference)
|
|
4882
4721
|
: null;
|
|
4883
|
-
|
|
4884
|
-
userEmail
|
|
4885
|
-
lastName
|
|
4886
|
-
firstName
|
|
4887
|
-
dateOfBirth
|
|
4722
|
+
const data = {
|
|
4723
|
+
userEmail,
|
|
4724
|
+
lastName,
|
|
4725
|
+
firstName,
|
|
4726
|
+
dateOfBirth,
|
|
4888
4727
|
/** Handles the auth micro service/Cognito serving boolean options as a string. */
|
|
4889
4728
|
termsAccepted: parsedTermsAccepted,
|
|
4890
4729
|
contactPreference: parsedContactPreference,
|
|
4891
|
-
uuid
|
|
4730
|
+
uuid,
|
|
4892
4731
|
subscription: subscriptionId || null,
|
|
4893
|
-
customerId
|
|
4894
|
-
picture
|
|
4732
|
+
customerId,
|
|
4733
|
+
picture,
|
|
4895
4734
|
};
|
|
4896
4735
|
return data;
|
|
4897
4736
|
};
|
|
4898
4737
|
function formatPromos(data) {
|
|
4899
|
-
return data.map(
|
|
4900
|
-
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;
|
|
4738
|
+
return data.map((item) => {
|
|
4901
4739
|
return {
|
|
4902
|
-
uuid:
|
|
4903
|
-
id:
|
|
4904
|
-
title:
|
|
4905
|
-
image:
|
|
4906
|
-
imageFormatted:
|
|
4907
|
-
description:
|
|
4908
|
-
created:
|
|
4909
|
-
updated:
|
|
4910
|
-
weight:
|
|
4911
|
-
buttonText:
|
|
4912
|
-
link:
|
|
4913
|
-
linkMobile:
|
|
4914
|
-
term:
|
|
4740
|
+
uuid: item?._source?.uuid?.[0],
|
|
4741
|
+
id: item?._source?.uuid?.[0],
|
|
4742
|
+
title: item?._source?.title?.[0],
|
|
4743
|
+
image: item?._source?.image?.[0],
|
|
4744
|
+
imageFormatted: item?._source?.image_formatted?.[0],
|
|
4745
|
+
description: item?._source?.description?.[0],
|
|
4746
|
+
created: item?._source?.created?.[0],
|
|
4747
|
+
updated: item?._source?.updated?.[0],
|
|
4748
|
+
weight: item?._source?.weight?.[0],
|
|
4749
|
+
buttonText: item?._source?.button_text?.[0],
|
|
4750
|
+
link: item?._source?.link?.[0],
|
|
4751
|
+
linkMobile: item?._source?.link_mobile?.[0],
|
|
4752
|
+
term: item?._source?.term?.[0],
|
|
4915
4753
|
// video: item?._source?.video?.[0],
|
|
4916
4754
|
// align: item?._source?.align?.[0],
|
|
4917
4755
|
// section: item?._source?.section?.[0],
|
|
@@ -4924,28 +4762,27 @@ function formatPromos(data) {
|
|
|
4924
4762
|
});
|
|
4925
4763
|
}
|
|
4926
4764
|
function formatWorkout(data) {
|
|
4927
|
-
return data.map(
|
|
4928
|
-
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;
|
|
4765
|
+
return data.map((item) => {
|
|
4929
4766
|
return {
|
|
4930
|
-
changed:
|
|
4931
|
-
created:
|
|
4932
|
-
uuid:
|
|
4933
|
-
description:
|
|
4934
|
-
duration:
|
|
4767
|
+
changed: item?._source?.changed?.[0],
|
|
4768
|
+
created: item?._source?.created?.[0],
|
|
4769
|
+
uuid: item?._source?.uuid?.[0],
|
|
4770
|
+
description: item?._source?.description?.[0],
|
|
4771
|
+
duration: item?._source?.duration_filter?.[0],
|
|
4935
4772
|
// duration_filter: item?._source?.duration_filter?.[0],
|
|
4936
|
-
level:
|
|
4937
|
-
published:
|
|
4938
|
-
targeted_section:
|
|
4939
|
-
uid:
|
|
4940
|
-
imageStyled:
|
|
4941
|
-
image:
|
|
4942
|
-
title:
|
|
4943
|
-
video:
|
|
4944
|
-
videoDownload:
|
|
4945
|
-
videoPoster:
|
|
4946
|
-
workoutCategory:
|
|
4947
|
-
workoutType:
|
|
4948
|
-
livestreamSection:
|
|
4773
|
+
level: item?._source?.level?.[0],
|
|
4774
|
+
published: item?._source?.published?.[0],
|
|
4775
|
+
targeted_section: item?._source?.targeted_section?.[0],
|
|
4776
|
+
uid: item?._source?.uid?.[0],
|
|
4777
|
+
imageStyled: item?._source?.image_16_9?.[0],
|
|
4778
|
+
image: item?._source?.image?.[0],
|
|
4779
|
+
title: item?._source?.title?.[0],
|
|
4780
|
+
video: item?._source?.video_url?.[0],
|
|
4781
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
4782
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
4783
|
+
workoutCategory: item?._source?.workout_category?.[0],
|
|
4784
|
+
workoutType: item?._source?.workout_type?.[0],
|
|
4785
|
+
livestreamSection: item?._source?.livestream_section?.[0],
|
|
4949
4786
|
};
|
|
4950
4787
|
});
|
|
4951
4788
|
}
|
|
@@ -4968,8 +4805,8 @@ function formatWorkout(data) {
|
|
|
4968
4805
|
// return formattedSeriesSelection;
|
|
4969
4806
|
// }
|
|
4970
4807
|
function formatShortform(data) {
|
|
4971
|
-
return data.map(
|
|
4972
|
-
|
|
4808
|
+
return data.map((item) => {
|
|
4809
|
+
const { _source } = item;
|
|
4973
4810
|
return {
|
|
4974
4811
|
uuid: _source.uuid && _source.uuid[0],
|
|
4975
4812
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5018,8 +4855,8 @@ function formatShortform(data) {
|
|
|
5018
4855
|
// });
|
|
5019
4856
|
// }
|
|
5020
4857
|
function formatFaqs(data) {
|
|
5021
|
-
return data.map(
|
|
5022
|
-
|
|
4858
|
+
return data.map((item) => {
|
|
4859
|
+
const { _source } = item;
|
|
5023
4860
|
return {
|
|
5024
4861
|
uuid: _source.uuid && _source.uuid[0],
|
|
5025
4862
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5031,24 +4868,23 @@ function formatFaqs(data) {
|
|
|
5031
4868
|
});
|
|
5032
4869
|
}
|
|
5033
4870
|
function formatPages(data) {
|
|
5034
|
-
return data.map(
|
|
5035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
4871
|
+
return data.map((item) => {
|
|
5036
4872
|
return {
|
|
5037
|
-
uuid:
|
|
5038
|
-
id:
|
|
5039
|
-
title:
|
|
5040
|
-
body:
|
|
5041
|
-
created:
|
|
5042
|
-
updated:
|
|
5043
|
-
langcode:
|
|
5044
|
-
url:
|
|
4873
|
+
uuid: item?._source?.uuid?.[0],
|
|
4874
|
+
id: item?._source?.uuid?.[0],
|
|
4875
|
+
title: item?._source?.title?.[0],
|
|
4876
|
+
body: item?._source?.body?.[0],
|
|
4877
|
+
created: item?._source?.created?.[0],
|
|
4878
|
+
updated: item?._source?.updated?.[0],
|
|
4879
|
+
langcode: item?._source?.langcode?.[0],
|
|
4880
|
+
url: item?._source?.url?.[0],
|
|
5045
4881
|
};
|
|
5046
4882
|
});
|
|
5047
4883
|
}
|
|
5048
4884
|
function formatSettings(data) {
|
|
5049
|
-
return data.map(
|
|
5050
|
-
|
|
5051
|
-
|
|
4885
|
+
return data.map((item) => {
|
|
4886
|
+
const { _source } = item;
|
|
4887
|
+
const fieldset = _source.fieldset && _source.fieldset[0].toLowerCase();
|
|
5052
4888
|
return {
|
|
5053
4889
|
uuid: _source.uuid && _source.uuid[0],
|
|
5054
4890
|
created: _source.created && _source.created[0],
|
|
@@ -5058,13 +4894,13 @@ function formatSettings(data) {
|
|
|
5058
4894
|
video: _source.video && _source.video[0],
|
|
5059
4895
|
number: _source.number && _source.number[0],
|
|
5060
4896
|
pass: _source.pass && _source.pass[0],
|
|
5061
|
-
fieldset
|
|
4897
|
+
fieldset,
|
|
5062
4898
|
};
|
|
5063
4899
|
});
|
|
5064
4900
|
}
|
|
5065
4901
|
function formatPress(data) {
|
|
5066
|
-
return data.map(
|
|
5067
|
-
|
|
4902
|
+
return data.map((item) => {
|
|
4903
|
+
const { _source } = item;
|
|
5068
4904
|
return {
|
|
5069
4905
|
uuid: _source.uuid && _source.uuid[0],
|
|
5070
4906
|
created: _source.created && _source.created[0],
|
|
@@ -5075,8 +4911,8 @@ function formatPress(data) {
|
|
|
5075
4911
|
});
|
|
5076
4912
|
}
|
|
5077
4913
|
function formatGuests(data) {
|
|
5078
|
-
return data.map(
|
|
5079
|
-
|
|
4914
|
+
return data.map((item) => {
|
|
4915
|
+
const { _source } = item;
|
|
5080
4916
|
return {
|
|
5081
4917
|
uuid: _source.uuid && _source.uuid[0],
|
|
5082
4918
|
id: _source.id && _source.id[0],
|
|
@@ -5089,27 +4925,26 @@ function formatGuests(data) {
|
|
|
5089
4925
|
});
|
|
5090
4926
|
}
|
|
5091
4927
|
function formatVideos(data) {
|
|
5092
|
-
return data.map(
|
|
5093
|
-
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;
|
|
4928
|
+
return data.map((item) => {
|
|
5094
4929
|
return {
|
|
5095
|
-
uuid:
|
|
5096
|
-
title:
|
|
5097
|
-
created:
|
|
5098
|
-
updated:
|
|
5099
|
-
description:
|
|
5100
|
-
image:
|
|
5101
|
-
duration:
|
|
5102
|
-
section:
|
|
5103
|
-
videoPoster:
|
|
5104
|
-
video:
|
|
5105
|
-
videoDownload:
|
|
5106
|
-
sectionId:
|
|
4930
|
+
uuid: item?._source?.uuid?.[0],
|
|
4931
|
+
title: item?._source?.title?.[0],
|
|
4932
|
+
created: item?._source?.created?.[0],
|
|
4933
|
+
updated: item?._source?.updated?.[0],
|
|
4934
|
+
description: item?._source?.description?.[0],
|
|
4935
|
+
image: item?._source?.image?.[0],
|
|
4936
|
+
duration: item?._source?.duration?.[0],
|
|
4937
|
+
section: item?._source?.section?.[0],
|
|
4938
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
4939
|
+
video: item?._source?.video_url?.[0],
|
|
4940
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
4941
|
+
sectionId: item?._source?.section_id?.[0],
|
|
5107
4942
|
};
|
|
5108
4943
|
});
|
|
5109
4944
|
}
|
|
5110
4945
|
function formatSections(data) {
|
|
5111
|
-
return data.map(
|
|
5112
|
-
|
|
4946
|
+
return data.map((item) => {
|
|
4947
|
+
const { _source } = item;
|
|
5113
4948
|
return {
|
|
5114
4949
|
uuid: _source.uuid && _source.uuid[0],
|
|
5115
4950
|
title: _source.title && _source.title[0],
|
|
@@ -5122,95 +4957,87 @@ function formatSections(data) {
|
|
|
5122
4957
|
});
|
|
5123
4958
|
}
|
|
5124
4959
|
function formatSchedule(data) {
|
|
5125
|
-
return data.map(
|
|
5126
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
4960
|
+
return data.map((item) => {
|
|
5127
4961
|
return {
|
|
5128
|
-
uuid:
|
|
5129
|
-
created:
|
|
5130
|
-
langcode:
|
|
5131
|
-
updated:
|
|
4962
|
+
uuid: item?._source?.uuid?.[0],
|
|
4963
|
+
created: item?._source?.created?.[0],
|
|
4964
|
+
langcode: item?._source?.langcode?.[0],
|
|
4965
|
+
updated: item?._source?.updated?.[0],
|
|
5132
4966
|
days: [
|
|
5133
4967
|
{
|
|
5134
|
-
monday:
|
|
5135
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4968
|
+
monday: item?._source?.monday_title?.map((title, index) => {
|
|
5136
4969
|
return {
|
|
5137
|
-
end:
|
|
5138
|
-
start:
|
|
4970
|
+
end: item?._source?.monday_end?.[index],
|
|
4971
|
+
start: item?._source?.monday_start?.[index],
|
|
5139
4972
|
title: title,
|
|
5140
|
-
video:
|
|
5141
|
-
live:
|
|
4973
|
+
video: item?._source?.monday_video?.[index],
|
|
4974
|
+
live: item?._source?.monday_live?.[index],
|
|
5142
4975
|
};
|
|
5143
4976
|
}),
|
|
5144
4977
|
},
|
|
5145
4978
|
{
|
|
5146
|
-
tuesday:
|
|
5147
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4979
|
+
tuesday: item?._source?.tuesday_title?.map((title, index) => {
|
|
5148
4980
|
return {
|
|
5149
|
-
end:
|
|
5150
|
-
start:
|
|
4981
|
+
end: item?._source?.tuesday_end?.[index],
|
|
4982
|
+
start: item?._source?.tuesday_start?.[index],
|
|
5151
4983
|
title: title,
|
|
5152
|
-
video:
|
|
5153
|
-
live:
|
|
4984
|
+
video: item?._source?.tuesday_video?.[index],
|
|
4985
|
+
live: item?._source?.tuesday_live?.[index],
|
|
5154
4986
|
};
|
|
5155
4987
|
}),
|
|
5156
4988
|
},
|
|
5157
4989
|
{
|
|
5158
|
-
wednesday:
|
|
5159
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4990
|
+
wednesday: item?._source?.wednesday_title?.map((title, index) => {
|
|
5160
4991
|
return {
|
|
5161
|
-
end:
|
|
5162
|
-
start:
|
|
4992
|
+
end: item?._source?.wednesday_end?.[index],
|
|
4993
|
+
start: item?._source?.wednesday_start?.[index],
|
|
5163
4994
|
title: title,
|
|
5164
|
-
video:
|
|
5165
|
-
live:
|
|
4995
|
+
video: item?._source?.wednesday_video?.[index],
|
|
4996
|
+
live: item?._source?.wednesday_live?.[index],
|
|
5166
4997
|
};
|
|
5167
4998
|
}),
|
|
5168
4999
|
},
|
|
5169
5000
|
{
|
|
5170
|
-
thursday:
|
|
5171
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5001
|
+
thursday: item?._source?.thursday_title?.map((title, index) => {
|
|
5172
5002
|
return {
|
|
5173
|
-
end:
|
|
5174
|
-
start:
|
|
5003
|
+
end: item?._source?.thursday_end?.[index],
|
|
5004
|
+
start: item?._source?.thursday_start?.[index],
|
|
5175
5005
|
title: title,
|
|
5176
|
-
video:
|
|
5177
|
-
live:
|
|
5006
|
+
video: item?._source?.thursday_video?.[index],
|
|
5007
|
+
live: item?._source?.thursday_live?.[index],
|
|
5178
5008
|
};
|
|
5179
5009
|
}),
|
|
5180
5010
|
},
|
|
5181
5011
|
{
|
|
5182
|
-
friday:
|
|
5183
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5012
|
+
friday: item?._source?.friday_title?.map((title, index) => {
|
|
5184
5013
|
return {
|
|
5185
|
-
end:
|
|
5186
|
-
start:
|
|
5014
|
+
end: item?._source?.friday_end?.[index],
|
|
5015
|
+
start: item?._source?.friday_start?.[index],
|
|
5187
5016
|
title: title,
|
|
5188
|
-
video:
|
|
5189
|
-
live:
|
|
5017
|
+
video: item?._source?.friday_video?.[index],
|
|
5018
|
+
live: item?._source?.friday_live?.[index],
|
|
5190
5019
|
};
|
|
5191
5020
|
}),
|
|
5192
5021
|
},
|
|
5193
5022
|
{
|
|
5194
|
-
saturday:
|
|
5195
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5023
|
+
saturday: item?._source?.saturday_title?.map((title, index) => {
|
|
5196
5024
|
return {
|
|
5197
|
-
end:
|
|
5198
|
-
start:
|
|
5025
|
+
end: item?._source?.saturday_end?.[index],
|
|
5026
|
+
start: item?._source?.saturday_start?.[index],
|
|
5199
5027
|
title: title,
|
|
5200
|
-
video:
|
|
5201
|
-
live:
|
|
5028
|
+
video: item?._source?.saturday_video?.[index],
|
|
5029
|
+
live: item?._source?.saturday_live?.[index],
|
|
5202
5030
|
};
|
|
5203
5031
|
}),
|
|
5204
5032
|
},
|
|
5205
5033
|
{
|
|
5206
|
-
sunday:
|
|
5207
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5034
|
+
sunday: item?._source?.sunday_title?.map((title, index) => {
|
|
5208
5035
|
return {
|
|
5209
|
-
end:
|
|
5210
|
-
start:
|
|
5036
|
+
end: item?._source?.sunday_end?.[index],
|
|
5037
|
+
start: item?._source?.sunday_start?.[index],
|
|
5211
5038
|
title: title,
|
|
5212
|
-
video:
|
|
5213
|
-
live:
|
|
5039
|
+
video: item?._source?.sunday_video?.[index],
|
|
5040
|
+
live: item?._source?.sunday_live?.[index],
|
|
5214
5041
|
};
|
|
5215
5042
|
}),
|
|
5216
5043
|
},
|
|
@@ -5219,11 +5046,10 @@ function formatSchedule(data) {
|
|
|
5219
5046
|
});
|
|
5220
5047
|
}
|
|
5221
5048
|
function formatChallenges(data) {
|
|
5222
|
-
return data.map(
|
|
5223
|
-
|
|
5224
|
-
var _source = item._source;
|
|
5049
|
+
return data.map((item) => {
|
|
5050
|
+
const { _source } = item;
|
|
5225
5051
|
return {
|
|
5226
|
-
uuid:
|
|
5052
|
+
uuid: _source?.uuid?.[0],
|
|
5227
5053
|
title: _source.title && _source.title[0],
|
|
5228
5054
|
body: _source.body && _source.body[0],
|
|
5229
5055
|
image: _source.image && _source.image[0],
|
|
@@ -5237,17 +5063,16 @@ function formatChallenges(data) {
|
|
|
5237
5063
|
});
|
|
5238
5064
|
}
|
|
5239
5065
|
function formatChallengeDays(data) {
|
|
5240
|
-
return data.map(
|
|
5241
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
5066
|
+
return data.map((item) => {
|
|
5242
5067
|
return {
|
|
5243
|
-
uuid:
|
|
5244
|
-
title:
|
|
5245
|
-
body:
|
|
5246
|
-
image:
|
|
5247
|
-
created:
|
|
5248
|
-
updated:
|
|
5249
|
-
video:
|
|
5250
|
-
workout:
|
|
5068
|
+
uuid: item?._source?.uuid?.[0],
|
|
5069
|
+
title: item?._source?.title?.[0],
|
|
5070
|
+
body: item?._source?.body?.[0],
|
|
5071
|
+
image: item?._source?.image?.[0],
|
|
5072
|
+
created: item?._source?.created?.[0],
|
|
5073
|
+
updated: item?._source?.updated?.[0],
|
|
5074
|
+
video: item?._source?.video?.[0],
|
|
5075
|
+
workout: item?._source?.workout?.[0],
|
|
5251
5076
|
};
|
|
5252
5077
|
});
|
|
5253
5078
|
}
|
|
@@ -5255,360 +5080,328 @@ function formatSecondsToISO8601Duration(seconds) {
|
|
|
5255
5080
|
if (!seconds)
|
|
5256
5081
|
return '';
|
|
5257
5082
|
// Calculate hours, minutes, and remaining seconds
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5083
|
+
const hours = Math.floor(seconds / 3600);
|
|
5084
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
5085
|
+
const remainingSeconds = seconds % 60;
|
|
5261
5086
|
// Build the ISO 8601 duration string
|
|
5262
|
-
|
|
5087
|
+
let duration = 'PT';
|
|
5263
5088
|
if (hours > 0) {
|
|
5264
|
-
duration +=
|
|
5089
|
+
duration += `${hours}H`;
|
|
5265
5090
|
}
|
|
5266
5091
|
if (minutes > 0) {
|
|
5267
|
-
duration +=
|
|
5092
|
+
duration += `${minutes}M`;
|
|
5268
5093
|
}
|
|
5269
5094
|
if (remainingSeconds > 0 || duration === 'PT') {
|
|
5270
|
-
duration +=
|
|
5095
|
+
duration += `${remainingSeconds}S`;
|
|
5271
5096
|
}
|
|
5272
5097
|
return duration;
|
|
5273
5098
|
}
|
|
5274
5099
|
function formatAuthSession(session) {
|
|
5275
|
-
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, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
|
|
5276
5100
|
return {
|
|
5277
|
-
accessToken:
|
|
5278
|
-
idToken:
|
|
5101
|
+
accessToken: session?.tokens?.accessToken.toString(),
|
|
5102
|
+
idToken: session?.tokens?.idToken?.toString(),
|
|
5279
5103
|
refreshToken: undefined,
|
|
5280
|
-
accessTokenExpiry:
|
|
5281
|
-
expires:
|
|
5282
|
-
sub:
|
|
5104
|
+
accessTokenExpiry: session?.tokens?.idToken?.payload?.exp,
|
|
5105
|
+
expires: session?.tokens?.idToken?.payload?.exp,
|
|
5106
|
+
sub: session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5283
5107
|
details: {
|
|
5284
|
-
userEmail:
|
|
5285
|
-
firstName:
|
|
5286
|
-
lastName:
|
|
5287
|
-
dateOfBirth:
|
|
5288
|
-
'cognito:username':
|
|
5289
|
-
'custom:termsAccepted':
|
|
5290
|
-
'custom:subscriptionId':
|
|
5291
|
-
'custom:contactPreferences':
|
|
5292
|
-
'custom:customerId':
|
|
5293
|
-
picture:
|
|
5108
|
+
userEmail: session?.tokens?.idToken?.payload?.email?.toString(),
|
|
5109
|
+
firstName: session?.tokens?.idToken?.payload?.given_name?.toString(),
|
|
5110
|
+
lastName: session?.tokens?.idToken?.payload?.family_name?.toString(),
|
|
5111
|
+
dateOfBirth: session?.tokens?.idToken?.payload?.birthdate?.toString(),
|
|
5112
|
+
'cognito:username': session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5113
|
+
'custom:termsAccepted': session?.tokens?.idToken?.payload?.['custom:termsAccepted']?.toString(),
|
|
5114
|
+
'custom:subscriptionId': session?.tokens?.idToken?.payload?.['custom:subscriptionId']?.toString(),
|
|
5115
|
+
'custom:contactPreferences': session?.tokens?.idToken?.payload?.['custom:contactPreferences']?.toString(),
|
|
5116
|
+
'custom:customerId': session?.tokens?.idToken?.payload?.['custom:customerId']?.toString(),
|
|
5117
|
+
picture: session?.tokens?.idToken?.payload?.picture?.toString(),
|
|
5294
5118
|
},
|
|
5295
5119
|
};
|
|
5296
5120
|
}
|
|
5297
5121
|
function formatFedaratedSession(session) {
|
|
5298
|
-
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;
|
|
5299
5122
|
return {
|
|
5300
|
-
accessToken:
|
|
5301
|
-
idToken:
|
|
5302
|
-
refreshToken:
|
|
5303
|
-
accessTokenExpiry:
|
|
5304
|
-
expires:
|
|
5305
|
-
sub:
|
|
5123
|
+
accessToken: session?.accessToken?.jwtToken,
|
|
5124
|
+
idToken: session?.idToken?.jwtToken,
|
|
5125
|
+
refreshToken: session?.refreshToken?.token,
|
|
5126
|
+
accessTokenExpiry: session?.accessToken?.payload?.exp,
|
|
5127
|
+
expires: session?.accessToken?.payload?.exp,
|
|
5128
|
+
sub: session?.idToken?.payload?.sub,
|
|
5306
5129
|
details: {
|
|
5307
|
-
userEmail:
|
|
5308
|
-
firstName:
|
|
5309
|
-
lastName:
|
|
5310
|
-
dateOfBirth:
|
|
5311
|
-
'cognito:username':
|
|
5312
|
-
'custom:termsAccepted':
|
|
5313
|
-
'custom:subscriptionId':
|
|
5314
|
-
'custom:contactPreferences':
|
|
5315
|
-
'custom:customerId':
|
|
5316
|
-
picture:
|
|
5317
|
-
id: toCamelCaseObject(
|
|
5130
|
+
userEmail: session?.idToken?.payload?.email,
|
|
5131
|
+
firstName: session?.idToken?.payload?.given_name,
|
|
5132
|
+
lastName: session?.idToken?.payload?.family_name,
|
|
5133
|
+
dateOfBirth: session?.idToken?.payload?.birthdate,
|
|
5134
|
+
'cognito:username': session?.idToken?.payload?.sub,
|
|
5135
|
+
'custom:termsAccepted': session?.idToken?.payload?.['custom:termsAccepted'],
|
|
5136
|
+
'custom:subscriptionId': session?.idToken?.payload?.['custom:subscriptionId'],
|
|
5137
|
+
'custom:contactPreferences': session?.idToken?.payload?.['custom:contactPreferences'],
|
|
5138
|
+
'custom:customerId': session?.idToken?.payload?.['custom:customerId'],
|
|
5139
|
+
picture: session?.idToken?.payload?.picture,
|
|
5140
|
+
id: toCamelCaseObject(session?.idToken?.payload),
|
|
5318
5141
|
},
|
|
5319
5142
|
};
|
|
5320
5143
|
}
|
|
5321
5144
|
function formatSocialAuthSession(tokens) {
|
|
5322
|
-
|
|
5145
|
+
const idToken = jwtDecode(tokens.idToken);
|
|
5323
5146
|
return {
|
|
5324
5147
|
socialSignin: true,
|
|
5325
5148
|
accessToken: tokens.accessToken,
|
|
5326
5149
|
idToken: tokens.idToken,
|
|
5327
5150
|
refreshToken: tokens.refreshToken,
|
|
5328
|
-
accessTokenExpiry: idToken
|
|
5329
|
-
expires: idToken
|
|
5151
|
+
accessTokenExpiry: idToken?.exp,
|
|
5152
|
+
expires: idToken?.exp,
|
|
5330
5153
|
sub: idToken.sub,
|
|
5331
5154
|
details: {
|
|
5332
5155
|
userEmail: idToken.email,
|
|
5333
5156
|
firstName: idToken.given_name,
|
|
5334
5157
|
lastName: idToken.family_name,
|
|
5335
|
-
dateOfBirth: idToken
|
|
5336
|
-
'cognito:username': idToken
|
|
5337
|
-
'custom:termsAccepted': idToken
|
|
5338
|
-
'custom:subscriptionId': idToken
|
|
5339
|
-
'custom:contactPreferences': idToken
|
|
5340
|
-
'custom:customerId': idToken
|
|
5341
|
-
picture: idToken
|
|
5158
|
+
dateOfBirth: idToken?.birthdate,
|
|
5159
|
+
'cognito:username': idToken?.['cognito:username'],
|
|
5160
|
+
'custom:termsAccepted': idToken?.['custom:termsAccepted'],
|
|
5161
|
+
'custom:subscriptionId': idToken?.['custom:subscriptionId'],
|
|
5162
|
+
'custom:contactPreferences': idToken?.['custom:contactPreferences'],
|
|
5163
|
+
'custom:customerId': idToken?.['custom:customerId'],
|
|
5164
|
+
picture: idToken?.picture,
|
|
5342
5165
|
},
|
|
5343
5166
|
};
|
|
5344
5167
|
}
|
|
5345
5168
|
function formatConfig(data) {
|
|
5346
|
-
return data.map(
|
|
5347
|
-
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;
|
|
5169
|
+
return data.map((item) => {
|
|
5348
5170
|
return {
|
|
5349
|
-
uuid:
|
|
5350
|
-
id:
|
|
5351
|
-
created:
|
|
5352
|
-
updated:
|
|
5353
|
-
type:
|
|
5354
|
-
cla:
|
|
5355
|
-
enabled:
|
|
5356
|
-
name:
|
|
5357
|
-
price:
|
|
5358
|
-
video:
|
|
5359
|
-
imageHomepage:
|
|
5360
|
-
imageSectionBanner:
|
|
5171
|
+
uuid: item?._source?.uuid?.[0],
|
|
5172
|
+
id: item?._source?.uuid?.[0],
|
|
5173
|
+
created: item?._source?.created?.[0],
|
|
5174
|
+
updated: item?._source?.updated?.[0],
|
|
5175
|
+
type: item?._source?.type?.[0],
|
|
5176
|
+
cla: item?._source?.cla?.[0],
|
|
5177
|
+
enabled: item?._source?.enabled?.[0],
|
|
5178
|
+
name: item?._source?.name?.[0],
|
|
5179
|
+
price: item?._source?.price?.[0],
|
|
5180
|
+
video: item?._source?.video?.[0],
|
|
5181
|
+
imageHomepage: item?._source?.image_homepage?.[0],
|
|
5182
|
+
imageSectionBanner: item?._source?.image_section_banner?.[0],
|
|
5361
5183
|
};
|
|
5362
5184
|
});
|
|
5363
5185
|
}
|
|
5364
5186
|
function formatSectionPanels(data) {
|
|
5365
|
-
return data.map(
|
|
5366
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5187
|
+
return data.map((item) => {
|
|
5367
5188
|
return {
|
|
5368
|
-
uuid:
|
|
5369
|
-
id:
|
|
5370
|
-
title:
|
|
5371
|
-
created:
|
|
5372
|
-
updated:
|
|
5373
|
-
weight:
|
|
5374
|
-
items:
|
|
5375
|
-
type:
|
|
5189
|
+
uuid: item?._source?.uuid?.[0],
|
|
5190
|
+
id: item?._source?.uuid?.[0],
|
|
5191
|
+
title: item?._source?.title?.[0],
|
|
5192
|
+
created: item?._source?.created?.[0],
|
|
5193
|
+
updated: item?._source?.updated?.[0],
|
|
5194
|
+
weight: item?._source?.weight?.[0],
|
|
5195
|
+
items: item?._source?.item_uuid,
|
|
5196
|
+
type: item?._source?.type?.[0],
|
|
5376
5197
|
};
|
|
5377
5198
|
});
|
|
5378
5199
|
}
|
|
5379
5200
|
function formatSectionItems(data) {
|
|
5380
|
-
return data.map(
|
|
5381
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
5201
|
+
return data.map((item) => {
|
|
5382
5202
|
return {
|
|
5383
|
-
uuid:
|
|
5384
|
-
id:
|
|
5385
|
-
title:
|
|
5386
|
-
created:
|
|
5387
|
-
updated:
|
|
5388
|
-
type:
|
|
5389
|
-
term:
|
|
5390
|
-
image:
|
|
5391
|
-
bannerImage:
|
|
5203
|
+
uuid: item?._source?.uuid?.[0],
|
|
5204
|
+
id: item?._source?.uuid?.[0],
|
|
5205
|
+
title: item?._source?.title?.[0],
|
|
5206
|
+
created: item?._source?.created?.[0],
|
|
5207
|
+
updated: item?._source?.updated?.[0],
|
|
5208
|
+
type: item?._source?.type?.[0],
|
|
5209
|
+
term: item?._source?.term?.[0],
|
|
5210
|
+
image: item?._source?.custom_image_formatted?.[0],
|
|
5211
|
+
bannerImage: item?._source?.banner_image_formatted?.[0],
|
|
5392
5212
|
};
|
|
5393
5213
|
});
|
|
5394
5214
|
}
|
|
5395
|
-
|
|
5396
|
-
return data.map(
|
|
5397
|
-
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;
|
|
5215
|
+
const formatTaxonomies = (data) => {
|
|
5216
|
+
return data.map((item) => {
|
|
5398
5217
|
return {
|
|
5399
|
-
uuid:
|
|
5400
|
-
id:
|
|
5401
|
-
updated:
|
|
5402
|
-
vocabulary:
|
|
5403
|
-
name:
|
|
5404
|
-
description:
|
|
5405
|
-
image:
|
|
5406
|
-
imageBanner:
|
|
5407
|
-
imageBannerTaxonomy:
|
|
5408
|
-
imageLarge:
|
|
5409
|
-
weight:
|
|
5410
|
-
parentName:
|
|
5411
|
-
color:
|
|
5218
|
+
uuid: item?._source?.uuid?.[0],
|
|
5219
|
+
id: item?._source?.uuid?.[0],
|
|
5220
|
+
updated: item?._source?.updated?.[0],
|
|
5221
|
+
vocabulary: item?._source?.vocabulary?.[0],
|
|
5222
|
+
name: item?._source?.name?.[0],
|
|
5223
|
+
description: item?._source?.description?.[0],
|
|
5224
|
+
image: item?._source?.image?.[0],
|
|
5225
|
+
imageBanner: item?._source?.image_banner?.[0],
|
|
5226
|
+
imageBannerTaxonomy: item?._source?.image_banner_taxonomy?.[0],
|
|
5227
|
+
imageLarge: item?._source?.image_large_16_9?.[0],
|
|
5228
|
+
weight: item?._source?.weight?.[0],
|
|
5229
|
+
parentName: item?._source?.parent_name?.[0],
|
|
5230
|
+
color: item?._source?.color?.[0],
|
|
5412
5231
|
};
|
|
5413
5232
|
});
|
|
5414
5233
|
};
|
|
5415
|
-
|
|
5416
|
-
return data.map(
|
|
5417
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5234
|
+
const formatSeries = (data) => {
|
|
5235
|
+
return data.map((item) => {
|
|
5418
5236
|
return {
|
|
5419
|
-
uuid:
|
|
5420
|
-
id:
|
|
5421
|
-
created:
|
|
5422
|
-
updated:
|
|
5423
|
-
title:
|
|
5424
|
-
synopsis:
|
|
5425
|
-
imagePoster:
|
|
5426
|
-
imageThumb:
|
|
5427
|
-
category:
|
|
5428
|
-
categoryId:
|
|
5429
|
-
seasons:
|
|
5237
|
+
uuid: item?._source?.uuid?.[0],
|
|
5238
|
+
id: item?._source?.uuid?.[0],
|
|
5239
|
+
created: item?._source?.created?.[0],
|
|
5240
|
+
updated: item?._source?.updated?.[0],
|
|
5241
|
+
title: item?._source?.display_title?.[0],
|
|
5242
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5243
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5244
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5245
|
+
category: item?._source?.category?.[0],
|
|
5246
|
+
categoryId: item?._source?.category_id?.[0],
|
|
5247
|
+
seasons: item?._source?.seasons || [],
|
|
5430
5248
|
};
|
|
5431
5249
|
});
|
|
5432
5250
|
};
|
|
5433
|
-
|
|
5434
|
-
return data.map(
|
|
5435
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5251
|
+
const formatSeasons = (data) => {
|
|
5252
|
+
return data.map((item) => {
|
|
5436
5253
|
return {
|
|
5437
|
-
uuid:
|
|
5438
|
-
id:
|
|
5439
|
-
created:
|
|
5440
|
-
updated:
|
|
5441
|
-
title:
|
|
5442
|
-
synopsis:
|
|
5443
|
-
imagePoster:
|
|
5444
|
-
imageThumb:
|
|
5445
|
-
episodes:
|
|
5446
|
-
seasonNumber:
|
|
5447
|
-
showId:
|
|
5254
|
+
uuid: item?._source?.uuid?.[0],
|
|
5255
|
+
id: item?._source?.uuid?.[0],
|
|
5256
|
+
created: item?._source?.created?.[0],
|
|
5257
|
+
updated: item?._source?.updated?.[0],
|
|
5258
|
+
title: item?._source?.display_title?.[0],
|
|
5259
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5260
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5261
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5262
|
+
episodes: item?._source?.episodes || [],
|
|
5263
|
+
seasonNumber: item?._source?.season_number?.[0],
|
|
5264
|
+
showId: item?._source?.show?.[0],
|
|
5448
5265
|
};
|
|
5449
5266
|
});
|
|
5450
5267
|
};
|
|
5451
|
-
|
|
5452
|
-
return data.map(
|
|
5453
|
-
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;
|
|
5268
|
+
const formatLongform = (data) => {
|
|
5269
|
+
return data.map((item) => {
|
|
5454
5270
|
return {
|
|
5455
|
-
uuid:
|
|
5456
|
-
id:
|
|
5457
|
-
created:
|
|
5458
|
-
updated:
|
|
5459
|
-
title:
|
|
5460
|
-
synopsis:
|
|
5461
|
-
imagePoster:
|
|
5462
|
-
imageThumb:
|
|
5463
|
-
duration:
|
|
5464
|
-
releaseDate:
|
|
5465
|
-
video:
|
|
5466
|
-
imageUrl:
|
|
5467
|
-
episodeNumber:
|
|
5271
|
+
uuid: item?._source?.uuid?.[0],
|
|
5272
|
+
id: item?._source?.uuid?.[0],
|
|
5273
|
+
created: item?._source?.created?.[0],
|
|
5274
|
+
updated: item?._source?.updated?.[0],
|
|
5275
|
+
title: item?._source?.display_title?.[0],
|
|
5276
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5277
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5278
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5279
|
+
duration: item?._source?.duration?.[0],
|
|
5280
|
+
releaseDate: item?._source?.release_date?.[0],
|
|
5281
|
+
video: item?._source?.video?.[0],
|
|
5282
|
+
imageUrl: item?._source?.image_url?.[0],
|
|
5283
|
+
episodeNumber: item?._source?.episode_number?.[0],
|
|
5468
5284
|
};
|
|
5469
5285
|
});
|
|
5470
5286
|
};
|
|
5471
|
-
|
|
5472
|
-
return data.map(
|
|
5473
|
-
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;
|
|
5287
|
+
const formatMediaItem = (data) => {
|
|
5288
|
+
return data.map((item) => {
|
|
5474
5289
|
return {
|
|
5475
|
-
changed:
|
|
5476
|
-
created:
|
|
5477
|
-
image:
|
|
5478
|
-
customThumbnail:
|
|
5479
|
-
price:
|
|
5480
|
-
priceTwoYear:
|
|
5481
|
-
revisionTimestamp:
|
|
5482
|
-
sku:
|
|
5483
|
-
status:
|
|
5484
|
-
uuid:
|
|
5485
|
-
description:
|
|
5486
|
-
transcript:
|
|
5487
|
-
entities:
|
|
5488
|
-
phrases:
|
|
5489
|
-
video:
|
|
5490
|
-
title:
|
|
5491
|
-
generatedTitle:
|
|
5492
|
-
projectPricing:
|
|
5493
|
-
related_items:
|
|
5494
|
-
franchises:
|
|
5495
|
-
franchisesIds:
|
|
5496
|
-
original:
|
|
5497
|
-
script:
|
|
5498
|
-
hideThumbnailTitle:
|
|
5290
|
+
changed: item?._source?.changed?.[0],
|
|
5291
|
+
created: item?._source?.created?.[0],
|
|
5292
|
+
image: item?._source?.image?.[0],
|
|
5293
|
+
customThumbnail: item?._source?.custom_thumbnail?.[0],
|
|
5294
|
+
price: item?._source?.price?.[0],
|
|
5295
|
+
priceTwoYear: item?._source?.price_2_year?.[0],
|
|
5296
|
+
revisionTimestamp: item?._source?.revision_timestamp?.[0],
|
|
5297
|
+
sku: item?._source?.sku?.[0],
|
|
5298
|
+
status: item?._source?.status?.[0],
|
|
5299
|
+
uuid: item?._source?.uuid?.[0],
|
|
5300
|
+
description: item?._source?.description?.[0],
|
|
5301
|
+
transcript: item?._source?.transcript?.[0],
|
|
5302
|
+
entities: item?._source?.entities,
|
|
5303
|
+
phrases: item?._source?.phrases,
|
|
5304
|
+
video: item?._source?.video?.[0],
|
|
5305
|
+
title: item?._source?.title?.[0],
|
|
5306
|
+
generatedTitle: item?._source?.generated_title?.[0],
|
|
5307
|
+
projectPricing: item?._source?.project_pricing?.[0],
|
|
5308
|
+
related_items: item?._source?.related_uuids,
|
|
5309
|
+
franchises: item?._source?.franchise_name,
|
|
5310
|
+
franchisesIds: item?._source?.franchise_tid,
|
|
5311
|
+
original: item?._source?.original?.[0],
|
|
5312
|
+
script: item?._source?.script?.[0],
|
|
5313
|
+
hideThumbnailTitle: item?._source?.hide_thumbnail_title?.[0],
|
|
5499
5314
|
};
|
|
5500
5315
|
});
|
|
5501
5316
|
};
|
|
5502
5317
|
|
|
5503
|
-
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
5504
5318
|
// Render the store based on the environment.
|
|
5505
|
-
|
|
5506
|
-
|
|
5319
|
+
const isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
5320
|
+
const ENV = isWeb ? process.env : import('./index-KjhWa1AL.js').then((mod) => mod.default).catch(() => ({}));
|
|
5507
5321
|
// export const ENV = process.env;
|
|
5508
|
-
|
|
5322
|
+
process.env?.NEXT_PUBLIC_API_PREFIX || ENV.API_PREFIX;
|
|
5509
5323
|
// Auth specific API
|
|
5510
|
-
|
|
5324
|
+
const API_AUTH_PREFIX = process.env?.NEXT_PUBLIC_API_AUTH_PREFIX || ENV.API_AUTH_PREFIX;
|
|
5511
5325
|
// Payments specific API
|
|
5512
|
-
|
|
5326
|
+
const API_PAYMENTS_PREFIX = process.env?.NEXT_PUBLIC_API_PAYMENTS_PREFIX || ENV.API_PAYMENTS_PREFIX;
|
|
5513
5327
|
// Orders specific API
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5328
|
+
const API_ORDERS_PREFIX = process.env?.NEXT_PUBLIC_API_ORDERS_PREFIX || ENV.API_ORDERS_PREFIX;
|
|
5329
|
+
process.env?.NEXT_PUBLIC_APP_BASE_URL || ENV.APP_BASE_URL;
|
|
5330
|
+
const APP_ES_INSTANCE = process.env?.NEXT_PUBLIC_APP_ES_INSTANCE || ENV.APP_ES_INSTANCE;
|
|
5331
|
+
const APP_ES_AUTH = process.env?.NEXT_PUBLIC_APP_ES_AUTH || ENV.APP_ES_AUTH;
|
|
5332
|
+
process.env?.NEXT_PUBLIC_APP_ES_PROMO_PANEL_INDEX ||
|
|
5519
5333
|
ENV.APP_ES_PROMO_PANEL_INDEX;
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5334
|
+
process.env?.NEXT_PUBLIC_APP_ES_FAQ_INDEX || ENV.APP_ES_FAQ_INDEX;
|
|
5335
|
+
process.env?.NEXT_PUBLIC_APP_ES_PAGES_INDEX || ENV.APP_ES_PAGES_INDEX;
|
|
5336
|
+
process.env?.NEXT_PUBLIC_APP_ES_SETTINGS_INDEX || ENV.APP_ES_SETTINGS_INDEX;
|
|
5337
|
+
process.env?.NEXT_PUBLIC_APP_ES_PRESS_INDEX || ENV.APP_ES_PRESS_INDEX;
|
|
5338
|
+
process.env?.NEXT_PUBLIC_APP_ES_GUESTS_INDEX || ENV.APP_ES_GUESTS_INDEX;
|
|
5339
|
+
process.env?.NEXT_PUBLIC_APP_ES_VIDEOS_INDEX || ENV.APP_ES_VIDEOS_INDEX;
|
|
5340
|
+
process.env?.NEXT_PUBLIC_APP_ES_SECTIONS_INDEX || ENV.APP_ES_SECTIONS_INDEX;
|
|
5341
|
+
process.env?.NEXT_PUBLIC_APP_ES_WORKOUTS_INDEX || ENV.APP_ES_WORKOUTS_INDEX;
|
|
5342
|
+
process.env?.NEXT_PUBLIC_APP_ES_SCHEDULE_INDEX || ENV.APP_ES_SCHEDULE_INDEX;
|
|
5343
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGES_INDEX ||
|
|
5530
5344
|
ENV.APP_ES_CHALLENGES_INDEX;
|
|
5531
|
-
|
|
5345
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX ||
|
|
5532
5346
|
ENV.APP_ES_CHALLENGE_DAYS_INDEX;
|
|
5533
5347
|
|
|
5534
|
-
|
|
5348
|
+
const authDataBaseQuery = fetchBaseQuery({
|
|
5535
5349
|
baseUrl: API_AUTH_PREFIX,
|
|
5536
|
-
prepareHeaders:
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
session = _c.sent();
|
|
5548
|
-
idToken = session.getIdToken().getJwtToken();
|
|
5549
|
-
accessToken = session.getAccessToken().getJwtToken();
|
|
5550
|
-
if (accessToken && idToken) {
|
|
5551
|
-
headers.set('accesstoken', accessToken);
|
|
5552
|
-
headers.set('idtoken', idToken);
|
|
5553
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5554
|
-
}
|
|
5555
|
-
return [2 /*return*/, headers];
|
|
5556
|
-
case 3:
|
|
5557
|
-
error_1 = _c.sent();
|
|
5558
|
-
console.error('authDataBaseQuery: ', error_1);
|
|
5559
|
-
return [2 /*return*/, headers];
|
|
5560
|
-
case 4: return [2 /*return*/];
|
|
5350
|
+
prepareHeaders: async (headers, {}) => {
|
|
5351
|
+
headers.set('Content-Type', 'application/json');
|
|
5352
|
+
try {
|
|
5353
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5354
|
+
const session = await Auth.currentSession();
|
|
5355
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5356
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5357
|
+
if (accessToken && idToken) {
|
|
5358
|
+
headers.set('accesstoken', accessToken);
|
|
5359
|
+
headers.set('idtoken', idToken);
|
|
5360
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5561
5361
|
}
|
|
5562
|
-
|
|
5563
|
-
|
|
5362
|
+
return headers;
|
|
5363
|
+
}
|
|
5364
|
+
catch (error) {
|
|
5365
|
+
console.error('authDataBaseQuery: ', error);
|
|
5366
|
+
return headers;
|
|
5367
|
+
}
|
|
5368
|
+
},
|
|
5564
5369
|
credentials: 'include',
|
|
5565
5370
|
});
|
|
5566
5371
|
/**
|
|
5567
5372
|
* This function is used to retry a request if we get a 401 error.
|
|
5568
5373
|
*/
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
user = formatAuthSession(authSession);
|
|
5584
|
-
api.dispatch(setCredentials(user));
|
|
5585
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5586
|
-
return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
|
|
5587
|
-
case 3:
|
|
5588
|
-
// If we get a new access token, retry the original request.
|
|
5589
|
-
result = _b.sent();
|
|
5590
|
-
return [3 /*break*/, 6];
|
|
5591
|
-
case 4:
|
|
5374
|
+
const authDataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5375
|
+
let result = await authDataBaseQuery(args, api, extraOptions);
|
|
5376
|
+
// If we get a 401 error
|
|
5377
|
+
if (result?.error?.status === 401) {
|
|
5378
|
+
const authSession = await Auth.currentAuthenticatedUser({
|
|
5379
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5380
|
+
});
|
|
5381
|
+
const user = formatAuthSession(authSession);
|
|
5382
|
+
api.dispatch(setCredentials(user));
|
|
5383
|
+
if (authSession?.tokens) {
|
|
5384
|
+
// If we get a new access token, retry the original request.
|
|
5385
|
+
result = await authDataBaseQuery(args, api, extraOptions);
|
|
5386
|
+
}
|
|
5387
|
+
else {
|
|
5592
5388
|
// TODO; require full data reset?
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
api.dispatch(logout());
|
|
5598
|
-
// If no access token throw error.
|
|
5599
|
-
throw new Error('No access token found');
|
|
5600
|
-
case 6: return [2 /*return*/, result];
|
|
5389
|
+
await Auth.signOut();
|
|
5390
|
+
api.dispatch(logout());
|
|
5391
|
+
// If no access token throw error.
|
|
5392
|
+
throw new Error('No access token found');
|
|
5601
5393
|
}
|
|
5602
|
-
}
|
|
5603
|
-
|
|
5604
|
-
|
|
5394
|
+
}
|
|
5395
|
+
return result;
|
|
5396
|
+
};
|
|
5397
|
+
const authApi = createApi({
|
|
5605
5398
|
reducerPath: 'authApi',
|
|
5606
5399
|
baseQuery: authDataBaseQueryWithReauth,
|
|
5607
5400
|
tagTypes: ['UserToken', 'UserData'],
|
|
5608
5401
|
// keepUnusedDataFor: 300,
|
|
5609
|
-
endpoints:
|
|
5402
|
+
endpoints: (builder) => ({
|
|
5610
5403
|
resetPassword: builder.mutation({
|
|
5611
|
-
query:
|
|
5404
|
+
query: (data) => ({
|
|
5612
5405
|
url: '/user/password/reset',
|
|
5613
5406
|
method: 'POST',
|
|
5614
5407
|
body: {
|
|
@@ -5617,10 +5410,10 @@ var authApi = createApi({
|
|
|
5617
5410
|
currentPassword: data.currentPassword,
|
|
5618
5411
|
newPassword: data.newPassword,
|
|
5619
5412
|
},
|
|
5620
|
-
})
|
|
5413
|
+
}),
|
|
5621
5414
|
}),
|
|
5622
5415
|
resetPasswordAuth: builder.mutation({
|
|
5623
|
-
query:
|
|
5416
|
+
query: (data) => ({
|
|
5624
5417
|
url: '/user/password/reset-auth',
|
|
5625
5418
|
method: 'POST',
|
|
5626
5419
|
body: {
|
|
@@ -5628,54 +5421,41 @@ var authApi = createApi({
|
|
|
5628
5421
|
currentPassword: data.currentPassword,
|
|
5629
5422
|
newPassword: data.newPassword,
|
|
5630
5423
|
},
|
|
5631
|
-
})
|
|
5424
|
+
}),
|
|
5632
5425
|
}),
|
|
5633
5426
|
forgottenPassword: builder.mutation({
|
|
5634
|
-
query:
|
|
5427
|
+
query: (data) => ({
|
|
5635
5428
|
url: '/user/password/forgot',
|
|
5636
5429
|
method: 'POST',
|
|
5637
5430
|
body: {
|
|
5638
5431
|
email: data.email,
|
|
5639
5432
|
},
|
|
5640
|
-
})
|
|
5433
|
+
}),
|
|
5641
5434
|
}),
|
|
5642
5435
|
register: builder.mutation({
|
|
5643
|
-
query:
|
|
5436
|
+
query: (data) => ({
|
|
5644
5437
|
url: '/user/register',
|
|
5645
5438
|
method: 'POST',
|
|
5646
5439
|
body: data,
|
|
5647
|
-
})
|
|
5648
|
-
onQueryStarted
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
return [4 /*yield*/, queryFulfilled];
|
|
5657
|
-
case 1:
|
|
5658
|
-
_c.sent();
|
|
5659
|
-
dispatch(resetCreating());
|
|
5660
|
-
return [3 /*break*/, 3];
|
|
5661
|
-
case 2:
|
|
5662
|
-
err_1 = _c.sent();
|
|
5663
|
-
console.error('REGISTER: ', err_1);
|
|
5664
|
-
return [3 /*break*/, 3];
|
|
5665
|
-
case 3: return [2 /*return*/];
|
|
5666
|
-
}
|
|
5667
|
-
});
|
|
5668
|
-
});
|
|
5440
|
+
}),
|
|
5441
|
+
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
5442
|
+
try {
|
|
5443
|
+
await queryFulfilled;
|
|
5444
|
+
dispatch(resetCreating());
|
|
5445
|
+
}
|
|
5446
|
+
catch (err) {
|
|
5447
|
+
console.error('REGISTER: ', err);
|
|
5448
|
+
}
|
|
5669
5449
|
},
|
|
5670
5450
|
}),
|
|
5671
5451
|
verifyUser: builder.query({
|
|
5672
|
-
query:
|
|
5452
|
+
query: (data) => ({
|
|
5673
5453
|
url: '/user/verify',
|
|
5674
5454
|
method: 'POST',
|
|
5675
5455
|
body: data,
|
|
5676
|
-
})
|
|
5677
|
-
transformErrorResponse:
|
|
5678
|
-
|
|
5456
|
+
}),
|
|
5457
|
+
transformErrorResponse: (rawResult) => {
|
|
5458
|
+
const { status, data, message } = rawResult;
|
|
5679
5459
|
switch (status) {
|
|
5680
5460
|
case 429:
|
|
5681
5461
|
// Toast.info(TOO_MANY_REQUESTS_MESSAGE);
|
|
@@ -5687,7 +5467,7 @@ var authApi = createApi({
|
|
|
5687
5467
|
*/
|
|
5688
5468
|
return {
|
|
5689
5469
|
route: 'resend',
|
|
5690
|
-
message:
|
|
5470
|
+
message: data?.message || message,
|
|
5691
5471
|
};
|
|
5692
5472
|
case 404:
|
|
5693
5473
|
/**
|
|
@@ -5695,7 +5475,7 @@ var authApi = createApi({
|
|
|
5695
5475
|
*/
|
|
5696
5476
|
return {
|
|
5697
5477
|
route: 'failed',
|
|
5698
|
-
message:
|
|
5478
|
+
message: data?.message || message,
|
|
5699
5479
|
};
|
|
5700
5480
|
case 401:
|
|
5701
5481
|
/**
|
|
@@ -5703,159 +5483,146 @@ var authApi = createApi({
|
|
|
5703
5483
|
*/
|
|
5704
5484
|
return {
|
|
5705
5485
|
route: 'error',
|
|
5706
|
-
message:
|
|
5486
|
+
message: data?.message || message,
|
|
5707
5487
|
};
|
|
5708
5488
|
default:
|
|
5709
5489
|
return {
|
|
5710
5490
|
route: 'error',
|
|
5711
|
-
message:
|
|
5491
|
+
message: data?.message || message,
|
|
5712
5492
|
};
|
|
5713
5493
|
}
|
|
5714
5494
|
},
|
|
5715
|
-
transformResponse:
|
|
5716
|
-
|
|
5717
|
-
return { route: 'success', message: data
|
|
5495
|
+
transformResponse: (rawResult) => {
|
|
5496
|
+
const { data } = rawResult;
|
|
5497
|
+
return { route: 'success', message: data?.message };
|
|
5718
5498
|
},
|
|
5719
5499
|
}),
|
|
5720
5500
|
verifyUserAttributes: builder.query({
|
|
5721
|
-
query:
|
|
5501
|
+
query: (data) => ({
|
|
5722
5502
|
url: '/user/verify/email',
|
|
5723
5503
|
method: 'POST',
|
|
5724
5504
|
body: data,
|
|
5725
|
-
})
|
|
5505
|
+
}),
|
|
5726
5506
|
}),
|
|
5727
5507
|
verifyUserResend: builder.query({
|
|
5728
|
-
query:
|
|
5508
|
+
query: (data) => ({
|
|
5729
5509
|
url: '/user/verify/resend',
|
|
5730
5510
|
method: 'POST',
|
|
5731
5511
|
body: data,
|
|
5732
|
-
})
|
|
5512
|
+
}),
|
|
5733
5513
|
}),
|
|
5734
5514
|
getUserInfo: builder.query({
|
|
5735
|
-
query:
|
|
5736
|
-
url:
|
|
5515
|
+
query: (uuid) => ({
|
|
5516
|
+
url: `/data/user/${uuid}`,
|
|
5737
5517
|
method: 'GET',
|
|
5738
|
-
})
|
|
5518
|
+
}),
|
|
5739
5519
|
providesTags: ['UserData'],
|
|
5740
5520
|
}),
|
|
5741
5521
|
updateUserInfo: builder.mutation({
|
|
5742
|
-
query:
|
|
5522
|
+
query: (expressions) => ({
|
|
5743
5523
|
url: '/data/user',
|
|
5744
5524
|
method: 'PATCH',
|
|
5745
5525
|
body: expressions,
|
|
5746
|
-
})
|
|
5526
|
+
}),
|
|
5747
5527
|
invalidatesTags: ['UserData'],
|
|
5748
5528
|
}),
|
|
5749
5529
|
updateUser: builder.mutation({
|
|
5750
|
-
query:
|
|
5530
|
+
query: (data) => ({
|
|
5751
5531
|
url: '/user',
|
|
5752
5532
|
method: 'PATCH',
|
|
5753
5533
|
body: data,
|
|
5754
|
-
})
|
|
5534
|
+
}),
|
|
5755
5535
|
invalidatesTags: ['UserData'],
|
|
5756
5536
|
}),
|
|
5757
|
-
})
|
|
5537
|
+
}),
|
|
5758
5538
|
});
|
|
5759
5539
|
// Export hooks for usage in functional components.
|
|
5760
|
-
|
|
5540
|
+
const {
|
|
5541
|
+
// useLoginQuery,
|
|
5761
5542
|
// useLazyLoginQuery,
|
|
5762
5543
|
// useRefreshTokenQuery,
|
|
5763
5544
|
// useLazyRefreshTokenQuery,
|
|
5764
5545
|
// useLogoutQuery,
|
|
5765
5546
|
// useLazyLogoutQuery,
|
|
5766
|
-
useResetPasswordMutation
|
|
5767
|
-
useResetPasswordAuthMutation
|
|
5547
|
+
useResetPasswordMutation, // Use this for mobile app.
|
|
5548
|
+
useResetPasswordAuthMutation, useRegisterMutation, useVerifyUserQuery, useLazyVerifyUserQuery, useGetUserInfoQuery, useLazyGetUserInfoQuery, useUpdateUserInfoMutation, useForgottenPasswordMutation, useVerifyUserAttributesQuery, useLazyVerifyUserAttributesQuery, useVerifyUserResendQuery, useLazyVerifyUserResendQuery, useUpdateUserMutation, } = authApi;
|
|
5768
5549
|
|
|
5769
|
-
|
|
5550
|
+
const contentApi = createApi({
|
|
5770
5551
|
reducerPath: 'contentApi',
|
|
5771
5552
|
baseQuery: fetchBaseQuery({
|
|
5772
5553
|
baseUrl: APP_ES_INSTANCE,
|
|
5773
|
-
prepareHeaders:
|
|
5554
|
+
prepareHeaders: (headers) => {
|
|
5774
5555
|
headers.set('Authorization', APP_ES_AUTH);
|
|
5775
5556
|
return headers;
|
|
5776
5557
|
},
|
|
5777
5558
|
}),
|
|
5778
5559
|
tagTypes: ['Data', 'Workout'],
|
|
5779
5560
|
// keepUnusedDataFor: 300,
|
|
5780
|
-
endpoints:
|
|
5561
|
+
endpoints: (builder) => ({
|
|
5781
5562
|
getData: builder.query({
|
|
5782
|
-
query:
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
query: options.query || {
|
|
5792
|
-
match_all: {},
|
|
5793
|
-
},
|
|
5563
|
+
query: ({ index, options = {} }) => ({
|
|
5564
|
+
url: `${index}/_search`,
|
|
5565
|
+
method: 'POST',
|
|
5566
|
+
body: {
|
|
5567
|
+
from: 0,
|
|
5568
|
+
size: options.size || 1000,
|
|
5569
|
+
sort: options.sort || [{ created: { order: 'desc' } }],
|
|
5570
|
+
query: options.query || {
|
|
5571
|
+
match_all: {},
|
|
5794
5572
|
},
|
|
5795
|
-
}
|
|
5796
|
-
},
|
|
5797
|
-
transformResponse:
|
|
5573
|
+
},
|
|
5574
|
+
}),
|
|
5575
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5798
5576
|
providesTags: ['Data'],
|
|
5799
5577
|
}),
|
|
5800
5578
|
getDataById: builder.query({
|
|
5801
|
-
query:
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
query: {
|
|
5811
|
-
terms: (_b = {},
|
|
5812
|
-
_b['uuid.keyword'] = ids,
|
|
5813
|
-
_b),
|
|
5579
|
+
query: ({ index, ids }) => ({
|
|
5580
|
+
url: `${index}/_search`,
|
|
5581
|
+
method: 'POST',
|
|
5582
|
+
body: {
|
|
5583
|
+
from: 0,
|
|
5584
|
+
size: ids.length,
|
|
5585
|
+
query: {
|
|
5586
|
+
terms: {
|
|
5587
|
+
['uuid.keyword']: ids,
|
|
5814
5588
|
},
|
|
5815
5589
|
},
|
|
5816
|
-
}
|
|
5817
|
-
},
|
|
5818
|
-
transformResponse:
|
|
5590
|
+
},
|
|
5591
|
+
}),
|
|
5592
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5819
5593
|
providesTags: ['Workout'],
|
|
5820
5594
|
}),
|
|
5821
|
-
})
|
|
5595
|
+
}),
|
|
5822
5596
|
});
|
|
5823
|
-
|
|
5597
|
+
const { useGetDataQuery, useLazyGetDataQuery, useGetDataByIdQuery, useLazyGetDataByIdQuery, } = contentApi;
|
|
5824
5598
|
|
|
5825
|
-
|
|
5599
|
+
const paymentApi = createApi({
|
|
5826
5600
|
reducerPath: 'paymentApi',
|
|
5827
5601
|
baseQuery: fetchBaseQuery({
|
|
5828
5602
|
baseUrl: API_PAYMENTS_PREFIX,
|
|
5829
|
-
prepareHeaders:
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
headers.set('idtoken', idToken);
|
|
5843
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5844
|
-
}
|
|
5845
|
-
return [2 /*return*/, headers];
|
|
5846
|
-
}
|
|
5847
|
-
});
|
|
5848
|
-
}); },
|
|
5603
|
+
prepareHeaders: async (headers, {}) => {
|
|
5604
|
+
headers.set('Content-Type', 'application/json');
|
|
5605
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5606
|
+
const session = await Auth.currentSession();
|
|
5607
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5608
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5609
|
+
if (accessToken && idToken) {
|
|
5610
|
+
headers.set('accesstoken', accessToken);
|
|
5611
|
+
headers.set('idtoken', idToken);
|
|
5612
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5613
|
+
}
|
|
5614
|
+
return headers;
|
|
5615
|
+
},
|
|
5849
5616
|
credentials: 'include',
|
|
5850
5617
|
}),
|
|
5851
5618
|
tagTypes: ['UserSubscription', 'Plans', 'TaxRates', 'PromoCodes'],
|
|
5852
5619
|
// keepUnusedDataFor: 300,
|
|
5853
|
-
endpoints:
|
|
5620
|
+
endpoints: (builder) => ({
|
|
5854
5621
|
/**
|
|
5855
5622
|
* USER API.
|
|
5856
5623
|
*/
|
|
5857
5624
|
checkUserSubscription: builder.query({
|
|
5858
|
-
query:
|
|
5625
|
+
query: (data) => ({
|
|
5859
5626
|
url: '/payment/subscriber',
|
|
5860
5627
|
method: 'POST',
|
|
5861
5628
|
body: {
|
|
@@ -5863,119 +5630,99 @@ var paymentApi = createApi({
|
|
|
5863
5630
|
email: data.email,
|
|
5864
5631
|
sub: data.sub,
|
|
5865
5632
|
},
|
|
5866
|
-
})
|
|
5633
|
+
}),
|
|
5867
5634
|
providesTags: ['UserSubscription'],
|
|
5868
5635
|
}),
|
|
5869
5636
|
getPaymentPlans: builder.query({
|
|
5870
|
-
query:
|
|
5637
|
+
query: () => '/payment/plans',
|
|
5871
5638
|
providesTags: ['Plans'],
|
|
5872
5639
|
}),
|
|
5873
5640
|
getTaxRates: builder.query({
|
|
5874
|
-
query:
|
|
5641
|
+
query: () => ({
|
|
5875
5642
|
url: '/payment/tax-rates',
|
|
5876
5643
|
method: 'GET',
|
|
5877
|
-
})
|
|
5644
|
+
}),
|
|
5878
5645
|
providesTags: ['TaxRates'],
|
|
5879
5646
|
}),
|
|
5880
5647
|
checkPromoCode: builder.query({
|
|
5881
|
-
query:
|
|
5882
|
-
url:
|
|
5648
|
+
query: (promoCode) => ({
|
|
5649
|
+
url: `/payment/coupon/${promoCode}`,
|
|
5883
5650
|
method: 'GET',
|
|
5884
|
-
})
|
|
5651
|
+
}),
|
|
5885
5652
|
providesTags: ['PromoCodes'],
|
|
5886
5653
|
}),
|
|
5887
|
-
})
|
|
5654
|
+
}),
|
|
5888
5655
|
});
|
|
5889
5656
|
// Export hooks for usage in functional components.
|
|
5890
|
-
|
|
5657
|
+
const { useCheckUserSubscriptionQuery, useLazyCheckUserSubscriptionQuery, useGetPaymentPlansQuery, useLazyGetPaymentPlansQuery, useGetTaxRatesQuery, useLazyGetTaxRatesQuery, useCheckPromoCodeQuery, useLazyCheckPromoCodeQuery, } = paymentApi;
|
|
5891
5658
|
|
|
5892
|
-
|
|
5659
|
+
const dataBaseQuery = fetchBaseQuery({
|
|
5893
5660
|
baseUrl: API_ORDERS_PREFIX,
|
|
5894
|
-
prepareHeaders:
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
headers.set('idtoken', idToken);
|
|
5908
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5909
|
-
}
|
|
5910
|
-
return [2 /*return*/, headers];
|
|
5911
|
-
}
|
|
5912
|
-
});
|
|
5913
|
-
}); },
|
|
5661
|
+
prepareHeaders: async (headers, {}) => {
|
|
5662
|
+
headers.set('Content-Type', 'application/json');
|
|
5663
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5664
|
+
const session = await Auth.currentSession();
|
|
5665
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5666
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5667
|
+
if (accessToken && idToken) {
|
|
5668
|
+
headers.set('accesstoken', accessToken);
|
|
5669
|
+
headers.set('idtoken', idToken);
|
|
5670
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5671
|
+
}
|
|
5672
|
+
return headers;
|
|
5673
|
+
},
|
|
5914
5674
|
credentials: 'include',
|
|
5915
5675
|
});
|
|
5916
5676
|
/**
|
|
5917
5677
|
* This function is used to retry a request if we get a 401 error.
|
|
5918
5678
|
*/
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
user = formatAuthSession(authSession);
|
|
5934
|
-
api.dispatch(setCredentials(user));
|
|
5935
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5936
|
-
return [4 /*yield*/, dataBaseQuery(args, api, extraOptions)];
|
|
5937
|
-
case 3:
|
|
5938
|
-
// If we get a new access token, retry the original request.
|
|
5939
|
-
result = _b.sent();
|
|
5940
|
-
return [3 /*break*/, 6];
|
|
5941
|
-
case 4:
|
|
5679
|
+
const dataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5680
|
+
let result = await dataBaseQuery(args, api, extraOptions);
|
|
5681
|
+
// If we get a 401 error
|
|
5682
|
+
if (result?.error?.status === 401) {
|
|
5683
|
+
const authSession = await Auth.currentAuthenticatedUser({
|
|
5684
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5685
|
+
});
|
|
5686
|
+
const user = formatAuthSession(authSession);
|
|
5687
|
+
api.dispatch(setCredentials(user));
|
|
5688
|
+
if (authSession?.tokens) {
|
|
5689
|
+
// If we get a new access token, retry the original request.
|
|
5690
|
+
result = await dataBaseQuery(args, api, extraOptions);
|
|
5691
|
+
}
|
|
5692
|
+
else {
|
|
5942
5693
|
// TODO; require full data reset?
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
api.dispatch(logout());
|
|
5948
|
-
// If no access token throw error.
|
|
5949
|
-
throw new Error('No access token found');
|
|
5950
|
-
case 6: return [2 /*return*/, result];
|
|
5694
|
+
await Auth.signOut();
|
|
5695
|
+
api.dispatch(logout());
|
|
5696
|
+
// If no access token throw error.
|
|
5697
|
+
throw new Error('No access token found');
|
|
5951
5698
|
}
|
|
5952
|
-
}
|
|
5953
|
-
|
|
5954
|
-
|
|
5699
|
+
}
|
|
5700
|
+
return result;
|
|
5701
|
+
};
|
|
5702
|
+
const ordersApi = createApi({
|
|
5955
5703
|
reducerPath: 'ordersApi',
|
|
5956
5704
|
baseQuery: dataBaseQueryWithReauth,
|
|
5957
5705
|
tagTypes: ['Orders'],
|
|
5958
5706
|
// keepUnusedDataFor: 300,
|
|
5959
|
-
endpoints:
|
|
5707
|
+
endpoints: (builder) => ({
|
|
5960
5708
|
/**
|
|
5961
5709
|
* USER API.
|
|
5962
5710
|
*/
|
|
5963
5711
|
fetchOrders: builder.query({
|
|
5964
|
-
query:
|
|
5712
|
+
query: (ids) => ({
|
|
5965
5713
|
url: '/order/search',
|
|
5966
5714
|
method: 'POST',
|
|
5967
5715
|
body: {
|
|
5968
|
-
ids
|
|
5716
|
+
ids,
|
|
5969
5717
|
},
|
|
5970
|
-
})
|
|
5718
|
+
}),
|
|
5971
5719
|
}),
|
|
5972
|
-
})
|
|
5720
|
+
}),
|
|
5973
5721
|
});
|
|
5974
5722
|
// Export hooks for usage in functional components.
|
|
5975
|
-
|
|
5723
|
+
const { useFetchOrdersQuery, useLazyFetchOrdersQuery } = ordersApi;
|
|
5976
5724
|
|
|
5977
|
-
|
|
5978
|
-
var initialState = {
|
|
5725
|
+
const initialState = {
|
|
5979
5726
|
addedItems: [],
|
|
5980
5727
|
netTotal: 0,
|
|
5981
5728
|
taxRate: {
|
|
@@ -5994,121 +5741,138 @@ var initialState = {
|
|
|
5994
5741
|
error: false,
|
|
5995
5742
|
open: false,
|
|
5996
5743
|
};
|
|
5997
|
-
|
|
5744
|
+
const cartSlice = createSlice({
|
|
5998
5745
|
name: 'cart',
|
|
5999
|
-
initialState
|
|
5746
|
+
initialState,
|
|
6000
5747
|
reducers: {
|
|
6001
|
-
setTaxRate:
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
if (promoCode
|
|
6005
|
-
|
|
5748
|
+
setTaxRate: (state, action) => {
|
|
5749
|
+
const { netTotal, promoCode } = state;
|
|
5750
|
+
let currentTotal = netTotal;
|
|
5751
|
+
if (promoCode?.code) {
|
|
5752
|
+
const data = applyCoupon(promoCode, currentTotal);
|
|
6006
5753
|
currentTotal = data.discountedTotal;
|
|
6007
5754
|
}
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
return
|
|
5755
|
+
const taxAmount = applyTax(action.payload, currentTotal);
|
|
5756
|
+
const grossTotal = currentTotal + taxAmount;
|
|
5757
|
+
return {
|
|
5758
|
+
...state,
|
|
5759
|
+
taxRate: action.payload,
|
|
5760
|
+
taxAmount,
|
|
5761
|
+
grossTotal,
|
|
5762
|
+
};
|
|
6011
5763
|
},
|
|
6012
|
-
resetTaxRate:
|
|
6013
|
-
return
|
|
5764
|
+
resetTaxRate: (state, action) => {
|
|
5765
|
+
return {
|
|
5766
|
+
...state,
|
|
5767
|
+
taxRate: {
|
|
6014
5768
|
country: 'none',
|
|
6015
5769
|
percentage: 0,
|
|
6016
|
-
},
|
|
5770
|
+
},
|
|
5771
|
+
taxAmount: 0,
|
|
5772
|
+
};
|
|
6017
5773
|
},
|
|
6018
|
-
setPromoCode:
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
return
|
|
5774
|
+
setPromoCode: (state, action) => {
|
|
5775
|
+
const { netTotal, taxRate } = state;
|
|
5776
|
+
const data = applyCoupon(action.payload, netTotal);
|
|
5777
|
+
const taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
5778
|
+
const grossTotal = data.discountedTotal + taxAmount;
|
|
5779
|
+
return {
|
|
5780
|
+
...state,
|
|
5781
|
+
promoCode: {
|
|
6024
5782
|
code: data.code,
|
|
6025
5783
|
name: data.code,
|
|
6026
5784
|
discount: data.discount,
|
|
6027
5785
|
discountedAmount: data.discountedAmount,
|
|
6028
|
-
},
|
|
5786
|
+
},
|
|
5787
|
+
taxAmount,
|
|
5788
|
+
grossTotal,
|
|
5789
|
+
};
|
|
6029
5790
|
},
|
|
6030
|
-
removePromoCode:
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
return
|
|
5791
|
+
removePromoCode: (state, action) => {
|
|
5792
|
+
const { netTotal, taxRate } = state;
|
|
5793
|
+
const taxAmount = applyTax(taxRate, netTotal);
|
|
5794
|
+
const grossTotal = netTotal + taxAmount;
|
|
5795
|
+
return {
|
|
5796
|
+
...state,
|
|
5797
|
+
promoCode: initialState.promoCode,
|
|
5798
|
+
taxAmount,
|
|
5799
|
+
grossTotal,
|
|
5800
|
+
};
|
|
6035
5801
|
},
|
|
6036
|
-
addToCart:
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
5802
|
+
addToCart: (state, action) => {
|
|
5803
|
+
const { options, item } = action.payload;
|
|
5804
|
+
const newTotal = state.netTotal + options.selectedPrice;
|
|
5805
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5806
|
+
const grossTotal = newTotal + taxAmount;
|
|
5807
|
+
const addItem = item ? { ...item, options } : null;
|
|
6042
5808
|
if (!addItem) {
|
|
6043
5809
|
return state;
|
|
6044
5810
|
}
|
|
6045
|
-
|
|
6046
|
-
return
|
|
5811
|
+
const addedItems = [...state.addedItems, addItem];
|
|
5812
|
+
return {
|
|
5813
|
+
...state,
|
|
5814
|
+
addedItems: addedItems,
|
|
5815
|
+
netTotal: newTotal,
|
|
5816
|
+
grossTotal: grossTotal,
|
|
5817
|
+
};
|
|
6047
5818
|
},
|
|
6048
|
-
updateCart:
|
|
6049
|
-
|
|
6050
|
-
return
|
|
6051
|
-
|
|
6052
|
-
|
|
5819
|
+
updateCart: (state, action) => {
|
|
5820
|
+
const { options } = action.payload;
|
|
5821
|
+
return {
|
|
5822
|
+
...state,
|
|
5823
|
+
addedItems: state.addedItems.map((item) => item && {
|
|
5824
|
+
...item,
|
|
5825
|
+
options: options,
|
|
5826
|
+
}),
|
|
5827
|
+
};
|
|
6053
5828
|
},
|
|
6054
|
-
removeFromCart:
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
return
|
|
5829
|
+
removeFromCart: (state, action) => {
|
|
5830
|
+
const { id, price } = action.payload;
|
|
5831
|
+
const newTotal = state.netTotal - price;
|
|
5832
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5833
|
+
const grossTotal = newTotal + taxAmount;
|
|
5834
|
+
return {
|
|
5835
|
+
...state,
|
|
5836
|
+
addedItems: state.addedItems.filter((item) => item && item.uuid !== id),
|
|
5837
|
+
netTotal: newTotal,
|
|
5838
|
+
grossTotal: grossTotal,
|
|
5839
|
+
};
|
|
6060
5840
|
},
|
|
6061
|
-
toggleCart:
|
|
6062
|
-
return
|
|
5841
|
+
toggleCart: (state, action) => {
|
|
5842
|
+
return {
|
|
5843
|
+
...state,
|
|
5844
|
+
open: action.payload,
|
|
5845
|
+
};
|
|
6063
5846
|
},
|
|
6064
|
-
emptyCart:
|
|
5847
|
+
emptyCart: () => initialState,
|
|
6065
5848
|
},
|
|
6066
5849
|
selectors: {
|
|
6067
|
-
selectMediaInCart:
|
|
6068
|
-
selectCartTotal:
|
|
6069
|
-
selectCartNetTotal:
|
|
6070
|
-
selectCartTaxRate:
|
|
6071
|
-
selectCartTaxAmount:
|
|
6072
|
-
selectCartCount:
|
|
6073
|
-
selectCartStatus:
|
|
6074
|
-
selectPromoCode:
|
|
5850
|
+
selectMediaInCart: (cart) => cart.addedItems,
|
|
5851
|
+
selectCartTotal: (cart) => cart.grossTotal,
|
|
5852
|
+
selectCartNetTotal: (cart) => cart.netTotal,
|
|
5853
|
+
selectCartTaxRate: (cart) => cart.taxRate,
|
|
5854
|
+
selectCartTaxAmount: (cart) => cart.taxAmount,
|
|
5855
|
+
selectCartCount: (cart) => cart.addedItems.length,
|
|
5856
|
+
selectCartStatus: (cart) => cart.open,
|
|
5857
|
+
selectPromoCode: (cart) => cart.promoCode,
|
|
6075
5858
|
},
|
|
6076
5859
|
});
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
return items.map(
|
|
5860
|
+
const { setTaxRate, resetTaxRate, setPromoCode, removePromoCode, addToCart, updateCart, removeFromCart, emptyCart, toggleCart, } = cartSlice.actions;
|
|
5861
|
+
const { selectMediaInCart, selectCartTotal, selectCartNetTotal, selectCartTaxRate, selectCartTaxAmount, selectCartCount, selectCartStatus, selectPromoCode, } = cartSlice.selectors;
|
|
5862
|
+
const selectCartItems = createSelector$1([selectMediaInCart], (items) => {
|
|
5863
|
+
return items.map((item) => {
|
|
6081
5864
|
return {
|
|
6082
5865
|
title: item.title || item.generatedTitle,
|
|
6083
|
-
file:
|
|
5866
|
+
file: `${item.sku}.mp4`,
|
|
6084
5867
|
options: item.options,
|
|
6085
5868
|
script: item.script,
|
|
6086
5869
|
};
|
|
6087
5870
|
});
|
|
6088
5871
|
});
|
|
6089
|
-
|
|
6090
|
-
return items.map(
|
|
5872
|
+
const selectCartItemsIds = createSelector$1([selectMediaInCart], (items) => {
|
|
5873
|
+
return items.map((item) => item.uuid);
|
|
6091
5874
|
});
|
|
6092
5875
|
cartSlice.reducer;
|
|
6093
5876
|
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
return useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
6097
|
-
};
|
|
6098
|
-
|
|
6099
|
-
// This file serves as a central hub for re-exporting pre-typed Redux hooks.
|
|
6100
|
-
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
|
6101
|
-
var useAppDispatch = isWeb ? useDispatch.withTypes() : useDispatch.withTypes();
|
|
6102
|
-
var useAppSelector = isWeb ? useSelector.withTypes() : useSelector.withTypes();
|
|
6103
|
-
var useAppStore = isWeb ? useStore.withTypes() : useStore.withTypes();
|
|
6104
|
-
|
|
6105
|
-
const Config = NativeModules.RNCConfigModule || {};
|
|
6106
|
-
|
|
6107
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
6108
|
-
__proto__: null,
|
|
6109
|
-
Config: Config,
|
|
6110
|
-
default: Config
|
|
6111
|
-
});
|
|
6112
|
-
|
|
6113
|
-
export { addToCart, authApi, authSlice, cartSlice, contentApi, emptyCart, formatAuthSession, formatChallengeDays, formatChallenges, formatConfig, formatFaqs, formatFedaratedSession, formatGuests, formatLongform, formatMediaItem, formatPages, formatPress, formatPromos, formatSchedule, formatSeasons, formatSecondsToISO8601Duration, formatSectionItems, formatSectionPanels, formatSections, formatSeries, formatSettings, formatShortform, formatSocialAuthSession, formatTaxonomies, formatUserPayload, formatVideos, formatWorkout, getUserSession, isAuthenticated, isVerifying, logout, ordersApi, paymentApi, removeFromCart, removePromoCode, resetCreating, resetTaxRate, selectAccessToken, selectCartCount, selectCartItems, selectCartItemsIds, selectCartNetTotal, selectCartStatus, selectCartTaxAmount, selectCartTaxRate, selectCartTotal, selectCurrentUser, selectCurrentUserRefreshToken, selectCurrentUserSub, selectMediaInCart, selectPromoCode, selectRefreshToken, selectSubscription, selectSubscriptionPrice, selectUserSubscriptionStatus, selectUserTokens, setCredentials, setPromoCode, setTaxRate, toggleCart, updateCart, updateSubscription, useAppDispatch, useAppSelector, useAppStore, useForgottenPasswordMutation, useGetUserInfoQuery, useLazyGetUserInfoQuery, useLazyVerifyUserAttributesQuery, useLazyVerifyUserQuery, useLazyVerifyUserResendQuery, useLoggedIn, useRegisterMutation, useResetPasswordAuthMutation, useResetPasswordMutation, useUpdateUserInfoMutation, useUpdateUserMutation, useVerifyUserAttributesQuery, useVerifyUserQuery, useVerifyUserResendQuery };
|
|
6114
|
-
//# sourceMappingURL=index.esm.js.map
|
|
5877
|
+
export { formatAuthSession as $, emptyCart as A, toggleCart as B, selectMediaInCart as C, selectCartTotal as D, selectCartNetTotal as E, selectCartTaxRate as F, selectCartTaxAmount as G, selectCartCount as H, selectCartStatus as I, selectPromoCode as J, selectCartItems as K, selectCartItemsIds as L, formatUserPayload as M, formatPromos as N, formatWorkout as O, formatShortform as P, formatFaqs as Q, formatPages as R, formatSettings as S, formatPress as T, formatGuests as U, formatVideos as V, formatSections as W, formatSchedule as X, formatChallenges as Y, formatChallengeDays as Z, formatSecondsToISO8601Duration as _, authApi as a, formatFedaratedSession as a0, formatSocialAuthSession as a1, formatConfig as a2, formatSectionPanels as a3, formatSectionItems as a4, formatTaxonomies as a5, formatSeries as a6, formatSeasons as a7, formatLongform as a8, formatMediaItem as a9, useResetPasswordAuthMutation as b, contentApi as c, useRegisterMutation as d, useVerifyUserQuery as e, useLazyVerifyUserQuery as f, useGetUserInfoQuery as g, useLazyGetUserInfoQuery as h, useUpdateUserInfoMutation as i, useForgottenPasswordMutation as j, useVerifyUserAttributesQuery as k, useLazyVerifyUserAttributesQuery as l, useVerifyUserResendQuery as m, useLazyVerifyUserResendQuery as n, ordersApi as o, paymentApi as p, useUpdateUserMutation as q, cartSlice as r, setTaxRate as s, resetTaxRate as t, useResetPasswordMutation as u, setPromoCode as v, removePromoCode as w, addToCart as x, updateCart as y, removeFromCart as z };
|
|
5878
|
+
//# sourceMappingURL=slice-3o-PH5Gz.js.map
|