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