@techstuff-dev/foundation-api-utils 1.46.1 → 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 -1377
- 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} +664 -1373
- 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} +64 -1404
- 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 -33
- 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 -76
- 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,92 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var awsAmplify = require('aws-amplify');
|
|
3
4
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
5
|
var reactRedux = require('react-redux');
|
|
5
6
|
var React = require('react');
|
|
6
|
-
var awsAmplify = require('aws-amplify');
|
|
7
7
|
var jwtDecode = require('jwt-decode');
|
|
8
|
-
var reactNative = require('react-native');
|
|
9
|
-
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var __assign = function() {
|
|
28
|
-
__assign = Object.assign || function __assign(t) {
|
|
29
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
30
|
-
s = arguments[i];
|
|
31
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
32
|
-
}
|
|
33
|
-
return t;
|
|
34
|
-
};
|
|
35
|
-
return __assign.apply(this, arguments);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
39
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function __generator(thisArg, body) {
|
|
49
|
-
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);
|
|
50
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
51
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
52
|
-
function step(op) {
|
|
53
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
54
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
55
|
-
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;
|
|
56
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
57
|
-
switch (op[0]) {
|
|
58
|
-
case 0: case 1: t = op; break;
|
|
59
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
60
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
61
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
62
|
-
default:
|
|
63
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
64
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
65
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
66
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
67
|
-
if (t[2]) _.ops.pop();
|
|
68
|
-
_.trys.pop(); continue;
|
|
69
|
-
}
|
|
70
|
-
op = body.call(thisArg, _);
|
|
71
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
72
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function __spreadArray(to, from, pack) {
|
|
77
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
78
|
-
if (ar || !(i in from)) {
|
|
79
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
80
|
-
ar[i] = from[i];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
87
|
-
var e = new Error(message);
|
|
88
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
89
|
-
};
|
|
90
8
|
|
|
91
9
|
// src/utils/env.ts
|
|
92
10
|
var NOTHING = Symbol.for("immer-nothing");
|
|
@@ -4765,8 +4683,7 @@ Hook ${hookName} was either not provided or not a function.`);
|
|
|
4765
4683
|
// src/query/react/index.ts
|
|
4766
4684
|
var createApi = /* @__PURE__ */ buildCreateApi(coreModule(), reactHooksModule());
|
|
4767
4685
|
|
|
4768
|
-
|
|
4769
|
-
var initialState$1 = {
|
|
4686
|
+
const initialState$1 = {
|
|
4770
4687
|
authenticated: false,
|
|
4771
4688
|
verifying: false,
|
|
4772
4689
|
user: {
|
|
@@ -4794,81 +4711,105 @@ var initialState$1 = {
|
|
|
4794
4711
|
error: false,
|
|
4795
4712
|
session: undefined,
|
|
4796
4713
|
};
|
|
4797
|
-
|
|
4714
|
+
const authSlice = toolkit.createSlice({
|
|
4798
4715
|
name: 'auth',
|
|
4799
4716
|
initialState: initialState$1,
|
|
4800
4717
|
reducers: {
|
|
4801
|
-
setCredentials:
|
|
4802
|
-
return
|
|
4718
|
+
setCredentials: (state, data) => {
|
|
4719
|
+
return {
|
|
4720
|
+
...state,
|
|
4721
|
+
session: data.payload.accessToken,
|
|
4722
|
+
authenticated: true,
|
|
4723
|
+
verifying: true,
|
|
4724
|
+
user: {
|
|
4725
|
+
...state.user,
|
|
4726
|
+
...data.payload,
|
|
4727
|
+
},
|
|
4728
|
+
};
|
|
4803
4729
|
},
|
|
4804
|
-
resetCreating:
|
|
4805
|
-
return
|
|
4730
|
+
resetCreating: (state) => {
|
|
4731
|
+
return {
|
|
4732
|
+
...state,
|
|
4733
|
+
creating: {
|
|
4806
4734
|
details: '',
|
|
4807
4735
|
payment: '',
|
|
4808
|
-
}
|
|
4736
|
+
},
|
|
4737
|
+
};
|
|
4809
4738
|
},
|
|
4810
|
-
updateSubscription:
|
|
4811
|
-
return
|
|
4739
|
+
updateSubscription: (state, data) => {
|
|
4740
|
+
return {
|
|
4741
|
+
...state,
|
|
4742
|
+
user: {
|
|
4743
|
+
...state.user,
|
|
4744
|
+
details: {
|
|
4745
|
+
...state.user.details,
|
|
4746
|
+
customerId: data.payload.customerId,
|
|
4747
|
+
subscription: data.payload.subscription,
|
|
4748
|
+
subscriptionDetails: data.payload.subscriptionDetails,
|
|
4749
|
+
},
|
|
4750
|
+
},
|
|
4751
|
+
};
|
|
4812
4752
|
},
|
|
4813
|
-
logout:
|
|
4753
|
+
logout: () => initialState$1,
|
|
4814
4754
|
},
|
|
4815
4755
|
selectors: {
|
|
4816
|
-
isAuthenticated:
|
|
4817
|
-
selectAccessToken:
|
|
4818
|
-
selectRefreshToken:
|
|
4819
|
-
selectCurrentUser:
|
|
4820
|
-
isVerifying:
|
|
4821
|
-
getUserSession:
|
|
4756
|
+
isAuthenticated: (auth) => auth.authenticated,
|
|
4757
|
+
selectAccessToken: (auth) => auth.user.accessToken,
|
|
4758
|
+
selectRefreshToken: (auth) => auth.user.refreshToken,
|
|
4759
|
+
selectCurrentUser: (auth) => auth.user.details,
|
|
4760
|
+
isVerifying: (auth) => auth.verifying,
|
|
4761
|
+
getUserSession: (auth) => (auth.authenticated ? auth.session : false),
|
|
4822
4762
|
// TODO: override this selector directly in the CNBCMEDIA app.
|
|
4823
|
-
selectCurrentUserSub:
|
|
4824
|
-
selectCurrentUserRefreshToken:
|
|
4825
|
-
selectUserTokens:
|
|
4763
|
+
selectCurrentUserSub: (auth) => auth?.user?.details?.id?.["custom:legacySub"] || auth.user.sub,
|
|
4764
|
+
selectCurrentUserRefreshToken: (auth) => auth.user.refreshToken,
|
|
4765
|
+
selectUserTokens: (auth) => {
|
|
4826
4766
|
return {
|
|
4827
4767
|
accessToken: auth.user.accessToken,
|
|
4828
4768
|
refreshToken: auth.user.refreshToken,
|
|
4829
4769
|
idToken: auth.user.idToken,
|
|
4830
4770
|
};
|
|
4831
4771
|
},
|
|
4832
|
-
selectUserSubscriptionStatus:
|
|
4833
|
-
|
|
4834
|
-
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;
|
|
4772
|
+
selectUserSubscriptionStatus: (auth) => {
|
|
4773
|
+
return auth?.user?.details?.subscriptionDetails?.status;
|
|
4835
4774
|
},
|
|
4836
|
-
selectSubscription:
|
|
4837
|
-
|
|
4838
|
-
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;
|
|
4775
|
+
selectSubscription: (auth) => {
|
|
4776
|
+
return auth?.user?.details?.subscriptionDetails;
|
|
4839
4777
|
},
|
|
4840
|
-
selectSubscriptionPrice:
|
|
4841
|
-
|
|
4842
|
-
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;
|
|
4778
|
+
selectSubscriptionPrice: (auth) => {
|
|
4779
|
+
return auth?.user?.details?.subscriptionDetails?.amount;
|
|
4843
4780
|
},
|
|
4844
4781
|
},
|
|
4845
4782
|
});
|
|
4846
4783
|
// Action creators are generated for each case reducer function.
|
|
4847
|
-
|
|
4784
|
+
const { setCredentials, resetCreating, logout, updateSubscription } = authSlice.actions;
|
|
4848
4785
|
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
4849
|
-
|
|
4786
|
+
const { isAuthenticated, selectAccessToken, selectRefreshToken, selectCurrentUser, isVerifying, getUserSession, selectCurrentUserSub, selectCurrentUserRefreshToken, selectUserTokens, selectUserSubscriptionStatus, selectSubscription, selectSubscriptionPrice, } = authSlice.selectors;
|
|
4850
4787
|
authSlice.reducer;
|
|
4851
4788
|
|
|
4852
4789
|
function applyCoupon(coupon, netTotal) {
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4790
|
+
const discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
4791
|
+
const discountedTotal = netTotal - discountedAmount;
|
|
4792
|
+
const data = {
|
|
4793
|
+
...coupon,
|
|
4794
|
+
discountedTotal,
|
|
4795
|
+
discountedAmount,
|
|
4796
|
+
};
|
|
4856
4797
|
return data;
|
|
4857
4798
|
}
|
|
4858
4799
|
function applyTax(taxRate, netTotal) {
|
|
4859
|
-
|
|
4800
|
+
const taxAmount = netTotal * (taxRate.percentage / 100);
|
|
4860
4801
|
return taxAmount;
|
|
4861
4802
|
}
|
|
4862
4803
|
function toCamelCaseObject(obj) {
|
|
4863
|
-
|
|
4864
|
-
return str.replace(/([-_][a-z])/gi,
|
|
4804
|
+
const toCamelCase = (str) => {
|
|
4805
|
+
return str.replace(/([-_][a-z])/gi, (match) => {
|
|
4865
4806
|
return match.toUpperCase().replace(/[-_]/, '');
|
|
4866
4807
|
});
|
|
4867
4808
|
};
|
|
4868
|
-
|
|
4869
|
-
for (
|
|
4809
|
+
const camelCaseObject = {};
|
|
4810
|
+
for (const key in obj) {
|
|
4870
4811
|
if (obj.hasOwnProperty(key)) {
|
|
4871
|
-
|
|
4812
|
+
const camelKey = toCamelCase(key);
|
|
4872
4813
|
camelCaseObject[camelKey] = obj[key];
|
|
4873
4814
|
}
|
|
4874
4815
|
}
|
|
@@ -4876,44 +4817,43 @@ function toCamelCaseObject(obj) {
|
|
|
4876
4817
|
}
|
|
4877
4818
|
|
|
4878
4819
|
// TODO: typing.
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4820
|
+
const formatUserPayload = (payload) => {
|
|
4821
|
+
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;
|
|
4822
|
+
const parsedTermsAccepted = termsAccepted ? JSON.parse(termsAccepted) : null;
|
|
4823
|
+
const parsedContactPreference = contactPreference
|
|
4883
4824
|
? JSON.parse(contactPreference)
|
|
4884
4825
|
: null;
|
|
4885
|
-
|
|
4886
|
-
userEmail
|
|
4887
|
-
lastName
|
|
4888
|
-
firstName
|
|
4889
|
-
dateOfBirth
|
|
4826
|
+
const data = {
|
|
4827
|
+
userEmail,
|
|
4828
|
+
lastName,
|
|
4829
|
+
firstName,
|
|
4830
|
+
dateOfBirth,
|
|
4890
4831
|
/** Handles the auth micro service/Cognito serving boolean options as a string. */
|
|
4891
4832
|
termsAccepted: parsedTermsAccepted,
|
|
4892
4833
|
contactPreference: parsedContactPreference,
|
|
4893
|
-
uuid
|
|
4834
|
+
uuid,
|
|
4894
4835
|
subscription: subscriptionId || null,
|
|
4895
|
-
customerId
|
|
4896
|
-
picture
|
|
4836
|
+
customerId,
|
|
4837
|
+
picture,
|
|
4897
4838
|
};
|
|
4898
4839
|
return data;
|
|
4899
4840
|
};
|
|
4900
4841
|
function formatPromos(data) {
|
|
4901
|
-
return data.map(
|
|
4902
|
-
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;
|
|
4842
|
+
return data.map((item) => {
|
|
4903
4843
|
return {
|
|
4904
|
-
uuid:
|
|
4905
|
-
id:
|
|
4906
|
-
title:
|
|
4907
|
-
image:
|
|
4908
|
-
imageFormatted:
|
|
4909
|
-
description:
|
|
4910
|
-
created:
|
|
4911
|
-
updated:
|
|
4912
|
-
weight:
|
|
4913
|
-
buttonText:
|
|
4914
|
-
link:
|
|
4915
|
-
linkMobile:
|
|
4916
|
-
term:
|
|
4844
|
+
uuid: item?._source?.uuid?.[0],
|
|
4845
|
+
id: item?._source?.uuid?.[0],
|
|
4846
|
+
title: item?._source?.title?.[0],
|
|
4847
|
+
image: item?._source?.image?.[0],
|
|
4848
|
+
imageFormatted: item?._source?.image_formatted?.[0],
|
|
4849
|
+
description: item?._source?.description?.[0],
|
|
4850
|
+
created: item?._source?.created?.[0],
|
|
4851
|
+
updated: item?._source?.updated?.[0],
|
|
4852
|
+
weight: item?._source?.weight?.[0],
|
|
4853
|
+
buttonText: item?._source?.button_text?.[0],
|
|
4854
|
+
link: item?._source?.link?.[0],
|
|
4855
|
+
linkMobile: item?._source?.link_mobile?.[0],
|
|
4856
|
+
term: item?._source?.term?.[0],
|
|
4917
4857
|
// video: item?._source?.video?.[0],
|
|
4918
4858
|
// align: item?._source?.align?.[0],
|
|
4919
4859
|
// section: item?._source?.section?.[0],
|
|
@@ -4926,28 +4866,27 @@ function formatPromos(data) {
|
|
|
4926
4866
|
});
|
|
4927
4867
|
}
|
|
4928
4868
|
function formatWorkout(data) {
|
|
4929
|
-
return data.map(
|
|
4930
|
-
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;
|
|
4869
|
+
return data.map((item) => {
|
|
4931
4870
|
return {
|
|
4932
|
-
changed:
|
|
4933
|
-
created:
|
|
4934
|
-
uuid:
|
|
4935
|
-
description:
|
|
4936
|
-
duration:
|
|
4871
|
+
changed: item?._source?.changed?.[0],
|
|
4872
|
+
created: item?._source?.created?.[0],
|
|
4873
|
+
uuid: item?._source?.uuid?.[0],
|
|
4874
|
+
description: item?._source?.description?.[0],
|
|
4875
|
+
duration: item?._source?.duration_filter?.[0],
|
|
4937
4876
|
// duration_filter: item?._source?.duration_filter?.[0],
|
|
4938
|
-
level:
|
|
4939
|
-
published:
|
|
4940
|
-
targeted_section:
|
|
4941
|
-
uid:
|
|
4942
|
-
imageStyled:
|
|
4943
|
-
image:
|
|
4944
|
-
title:
|
|
4945
|
-
video:
|
|
4946
|
-
videoDownload:
|
|
4947
|
-
videoPoster:
|
|
4948
|
-
workoutCategory:
|
|
4949
|
-
workoutType:
|
|
4950
|
-
livestreamSection:
|
|
4877
|
+
level: item?._source?.level?.[0],
|
|
4878
|
+
published: item?._source?.published?.[0],
|
|
4879
|
+
targeted_section: item?._source?.targeted_section?.[0],
|
|
4880
|
+
uid: item?._source?.uid?.[0],
|
|
4881
|
+
imageStyled: item?._source?.image_16_9?.[0],
|
|
4882
|
+
image: item?._source?.image?.[0],
|
|
4883
|
+
title: item?._source?.title?.[0],
|
|
4884
|
+
video: item?._source?.video_url?.[0],
|
|
4885
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
4886
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
4887
|
+
workoutCategory: item?._source?.workout_category?.[0],
|
|
4888
|
+
workoutType: item?._source?.workout_type?.[0],
|
|
4889
|
+
livestreamSection: item?._source?.livestream_section?.[0],
|
|
4951
4890
|
};
|
|
4952
4891
|
});
|
|
4953
4892
|
}
|
|
@@ -4970,8 +4909,8 @@ function formatWorkout(data) {
|
|
|
4970
4909
|
// return formattedSeriesSelection;
|
|
4971
4910
|
// }
|
|
4972
4911
|
function formatShortform(data) {
|
|
4973
|
-
return data.map(
|
|
4974
|
-
|
|
4912
|
+
return data.map((item) => {
|
|
4913
|
+
const { _source } = item;
|
|
4975
4914
|
return {
|
|
4976
4915
|
uuid: _source.uuid && _source.uuid[0],
|
|
4977
4916
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5020,8 +4959,8 @@ function formatShortform(data) {
|
|
|
5020
4959
|
// });
|
|
5021
4960
|
// }
|
|
5022
4961
|
function formatFaqs(data) {
|
|
5023
|
-
return data.map(
|
|
5024
|
-
|
|
4962
|
+
return data.map((item) => {
|
|
4963
|
+
const { _source } = item;
|
|
5025
4964
|
return {
|
|
5026
4965
|
uuid: _source.uuid && _source.uuid[0],
|
|
5027
4966
|
id: _source.uuid && _source.uuid[0],
|
|
@@ -5033,24 +4972,23 @@ function formatFaqs(data) {
|
|
|
5033
4972
|
});
|
|
5034
4973
|
}
|
|
5035
4974
|
function formatPages(data) {
|
|
5036
|
-
return data.map(
|
|
5037
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
4975
|
+
return data.map((item) => {
|
|
5038
4976
|
return {
|
|
5039
|
-
uuid:
|
|
5040
|
-
id:
|
|
5041
|
-
title:
|
|
5042
|
-
body:
|
|
5043
|
-
created:
|
|
5044
|
-
updated:
|
|
5045
|
-
langcode:
|
|
5046
|
-
url:
|
|
4977
|
+
uuid: item?._source?.uuid?.[0],
|
|
4978
|
+
id: item?._source?.uuid?.[0],
|
|
4979
|
+
title: item?._source?.title?.[0],
|
|
4980
|
+
body: item?._source?.body?.[0],
|
|
4981
|
+
created: item?._source?.created?.[0],
|
|
4982
|
+
updated: item?._source?.updated?.[0],
|
|
4983
|
+
langcode: item?._source?.langcode?.[0],
|
|
4984
|
+
url: item?._source?.url?.[0],
|
|
5047
4985
|
};
|
|
5048
4986
|
});
|
|
5049
4987
|
}
|
|
5050
4988
|
function formatSettings(data) {
|
|
5051
|
-
return data.map(
|
|
5052
|
-
|
|
5053
|
-
|
|
4989
|
+
return data.map((item) => {
|
|
4990
|
+
const { _source } = item;
|
|
4991
|
+
const fieldset = _source.fieldset && _source.fieldset[0].toLowerCase();
|
|
5054
4992
|
return {
|
|
5055
4993
|
uuid: _source.uuid && _source.uuid[0],
|
|
5056
4994
|
created: _source.created && _source.created[0],
|
|
@@ -5060,13 +4998,13 @@ function formatSettings(data) {
|
|
|
5060
4998
|
video: _source.video && _source.video[0],
|
|
5061
4999
|
number: _source.number && _source.number[0],
|
|
5062
5000
|
pass: _source.pass && _source.pass[0],
|
|
5063
|
-
fieldset
|
|
5001
|
+
fieldset,
|
|
5064
5002
|
};
|
|
5065
5003
|
});
|
|
5066
5004
|
}
|
|
5067
5005
|
function formatPress(data) {
|
|
5068
|
-
return data.map(
|
|
5069
|
-
|
|
5006
|
+
return data.map((item) => {
|
|
5007
|
+
const { _source } = item;
|
|
5070
5008
|
return {
|
|
5071
5009
|
uuid: _source.uuid && _source.uuid[0],
|
|
5072
5010
|
created: _source.created && _source.created[0],
|
|
@@ -5077,8 +5015,8 @@ function formatPress(data) {
|
|
|
5077
5015
|
});
|
|
5078
5016
|
}
|
|
5079
5017
|
function formatGuests(data) {
|
|
5080
|
-
return data.map(
|
|
5081
|
-
|
|
5018
|
+
return data.map((item) => {
|
|
5019
|
+
const { _source } = item;
|
|
5082
5020
|
return {
|
|
5083
5021
|
uuid: _source.uuid && _source.uuid[0],
|
|
5084
5022
|
id: _source.id && _source.id[0],
|
|
@@ -5091,27 +5029,26 @@ function formatGuests(data) {
|
|
|
5091
5029
|
});
|
|
5092
5030
|
}
|
|
5093
5031
|
function formatVideos(data) {
|
|
5094
|
-
return data.map(
|
|
5095
|
-
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;
|
|
5032
|
+
return data.map((item) => {
|
|
5096
5033
|
return {
|
|
5097
|
-
uuid:
|
|
5098
|
-
title:
|
|
5099
|
-
created:
|
|
5100
|
-
updated:
|
|
5101
|
-
description:
|
|
5102
|
-
image:
|
|
5103
|
-
duration:
|
|
5104
|
-
section:
|
|
5105
|
-
videoPoster:
|
|
5106
|
-
video:
|
|
5107
|
-
videoDownload:
|
|
5108
|
-
sectionId:
|
|
5034
|
+
uuid: item?._source?.uuid?.[0],
|
|
5035
|
+
title: item?._source?.title?.[0],
|
|
5036
|
+
created: item?._source?.created?.[0],
|
|
5037
|
+
updated: item?._source?.updated?.[0],
|
|
5038
|
+
description: item?._source?.description?.[0],
|
|
5039
|
+
image: item?._source?.image?.[0],
|
|
5040
|
+
duration: item?._source?.duration?.[0],
|
|
5041
|
+
section: item?._source?.section?.[0],
|
|
5042
|
+
videoPoster: item?._source?.video_poster?.[0],
|
|
5043
|
+
video: item?._source?.video_url?.[0],
|
|
5044
|
+
videoDownload: item?._source?.video_download?.[0],
|
|
5045
|
+
sectionId: item?._source?.section_id?.[0],
|
|
5109
5046
|
};
|
|
5110
5047
|
});
|
|
5111
5048
|
}
|
|
5112
5049
|
function formatSections(data) {
|
|
5113
|
-
return data.map(
|
|
5114
|
-
|
|
5050
|
+
return data.map((item) => {
|
|
5051
|
+
const { _source } = item;
|
|
5115
5052
|
return {
|
|
5116
5053
|
uuid: _source.uuid && _source.uuid[0],
|
|
5117
5054
|
title: _source.title && _source.title[0],
|
|
@@ -5124,95 +5061,87 @@ function formatSections(data) {
|
|
|
5124
5061
|
});
|
|
5125
5062
|
}
|
|
5126
5063
|
function formatSchedule(data) {
|
|
5127
|
-
return data.map(
|
|
5128
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
5064
|
+
return data.map((item) => {
|
|
5129
5065
|
return {
|
|
5130
|
-
uuid:
|
|
5131
|
-
created:
|
|
5132
|
-
langcode:
|
|
5133
|
-
updated:
|
|
5066
|
+
uuid: item?._source?.uuid?.[0],
|
|
5067
|
+
created: item?._source?.created?.[0],
|
|
5068
|
+
langcode: item?._source?.langcode?.[0],
|
|
5069
|
+
updated: item?._source?.updated?.[0],
|
|
5134
5070
|
days: [
|
|
5135
5071
|
{
|
|
5136
|
-
monday:
|
|
5137
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5072
|
+
monday: item?._source?.monday_title?.map((title, index) => {
|
|
5138
5073
|
return {
|
|
5139
|
-
end:
|
|
5140
|
-
start:
|
|
5074
|
+
end: item?._source?.monday_end?.[index],
|
|
5075
|
+
start: item?._source?.monday_start?.[index],
|
|
5141
5076
|
title: title,
|
|
5142
|
-
video:
|
|
5143
|
-
live:
|
|
5077
|
+
video: item?._source?.monday_video?.[index],
|
|
5078
|
+
live: item?._source?.monday_live?.[index],
|
|
5144
5079
|
};
|
|
5145
5080
|
}),
|
|
5146
5081
|
},
|
|
5147
5082
|
{
|
|
5148
|
-
tuesday:
|
|
5149
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5083
|
+
tuesday: item?._source?.tuesday_title?.map((title, index) => {
|
|
5150
5084
|
return {
|
|
5151
|
-
end:
|
|
5152
|
-
start:
|
|
5085
|
+
end: item?._source?.tuesday_end?.[index],
|
|
5086
|
+
start: item?._source?.tuesday_start?.[index],
|
|
5153
5087
|
title: title,
|
|
5154
|
-
video:
|
|
5155
|
-
live:
|
|
5088
|
+
video: item?._source?.tuesday_video?.[index],
|
|
5089
|
+
live: item?._source?.tuesday_live?.[index],
|
|
5156
5090
|
};
|
|
5157
5091
|
}),
|
|
5158
5092
|
},
|
|
5159
5093
|
{
|
|
5160
|
-
wednesday:
|
|
5161
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5094
|
+
wednesday: item?._source?.wednesday_title?.map((title, index) => {
|
|
5162
5095
|
return {
|
|
5163
|
-
end:
|
|
5164
|
-
start:
|
|
5096
|
+
end: item?._source?.wednesday_end?.[index],
|
|
5097
|
+
start: item?._source?.wednesday_start?.[index],
|
|
5165
5098
|
title: title,
|
|
5166
|
-
video:
|
|
5167
|
-
live:
|
|
5099
|
+
video: item?._source?.wednesday_video?.[index],
|
|
5100
|
+
live: item?._source?.wednesday_live?.[index],
|
|
5168
5101
|
};
|
|
5169
5102
|
}),
|
|
5170
5103
|
},
|
|
5171
5104
|
{
|
|
5172
|
-
thursday:
|
|
5173
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5105
|
+
thursday: item?._source?.thursday_title?.map((title, index) => {
|
|
5174
5106
|
return {
|
|
5175
|
-
end:
|
|
5176
|
-
start:
|
|
5107
|
+
end: item?._source?.thursday_end?.[index],
|
|
5108
|
+
start: item?._source?.thursday_start?.[index],
|
|
5177
5109
|
title: title,
|
|
5178
|
-
video:
|
|
5179
|
-
live:
|
|
5110
|
+
video: item?._source?.thursday_video?.[index],
|
|
5111
|
+
live: item?._source?.thursday_live?.[index],
|
|
5180
5112
|
};
|
|
5181
5113
|
}),
|
|
5182
5114
|
},
|
|
5183
5115
|
{
|
|
5184
|
-
friday:
|
|
5185
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5116
|
+
friday: item?._source?.friday_title?.map((title, index) => {
|
|
5186
5117
|
return {
|
|
5187
|
-
end:
|
|
5188
|
-
start:
|
|
5118
|
+
end: item?._source?.friday_end?.[index],
|
|
5119
|
+
start: item?._source?.friday_start?.[index],
|
|
5189
5120
|
title: title,
|
|
5190
|
-
video:
|
|
5191
|
-
live:
|
|
5121
|
+
video: item?._source?.friday_video?.[index],
|
|
5122
|
+
live: item?._source?.friday_live?.[index],
|
|
5192
5123
|
};
|
|
5193
5124
|
}),
|
|
5194
5125
|
},
|
|
5195
5126
|
{
|
|
5196
|
-
saturday:
|
|
5197
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5127
|
+
saturday: item?._source?.saturday_title?.map((title, index) => {
|
|
5198
5128
|
return {
|
|
5199
|
-
end:
|
|
5200
|
-
start:
|
|
5129
|
+
end: item?._source?.saturday_end?.[index],
|
|
5130
|
+
start: item?._source?.saturday_start?.[index],
|
|
5201
5131
|
title: title,
|
|
5202
|
-
video:
|
|
5203
|
-
live:
|
|
5132
|
+
video: item?._source?.saturday_video?.[index],
|
|
5133
|
+
live: item?._source?.saturday_live?.[index],
|
|
5204
5134
|
};
|
|
5205
5135
|
}),
|
|
5206
5136
|
},
|
|
5207
5137
|
{
|
|
5208
|
-
sunday:
|
|
5209
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5138
|
+
sunday: item?._source?.sunday_title?.map((title, index) => {
|
|
5210
5139
|
return {
|
|
5211
|
-
end:
|
|
5212
|
-
start:
|
|
5140
|
+
end: item?._source?.sunday_end?.[index],
|
|
5141
|
+
start: item?._source?.sunday_start?.[index],
|
|
5213
5142
|
title: title,
|
|
5214
|
-
video:
|
|
5215
|
-
live:
|
|
5143
|
+
video: item?._source?.sunday_video?.[index],
|
|
5144
|
+
live: item?._source?.sunday_live?.[index],
|
|
5216
5145
|
};
|
|
5217
5146
|
}),
|
|
5218
5147
|
},
|
|
@@ -5221,11 +5150,10 @@ function formatSchedule(data) {
|
|
|
5221
5150
|
});
|
|
5222
5151
|
}
|
|
5223
5152
|
function formatChallenges(data) {
|
|
5224
|
-
return data.map(
|
|
5225
|
-
|
|
5226
|
-
var _source = item._source;
|
|
5153
|
+
return data.map((item) => {
|
|
5154
|
+
const { _source } = item;
|
|
5227
5155
|
return {
|
|
5228
|
-
uuid:
|
|
5156
|
+
uuid: _source?.uuid?.[0],
|
|
5229
5157
|
title: _source.title && _source.title[0],
|
|
5230
5158
|
body: _source.body && _source.body[0],
|
|
5231
5159
|
image: _source.image && _source.image[0],
|
|
@@ -5239,17 +5167,16 @@ function formatChallenges(data) {
|
|
|
5239
5167
|
});
|
|
5240
5168
|
}
|
|
5241
5169
|
function formatChallengeDays(data) {
|
|
5242
|
-
return data.map(
|
|
5243
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
5170
|
+
return data.map((item) => {
|
|
5244
5171
|
return {
|
|
5245
|
-
uuid:
|
|
5246
|
-
title:
|
|
5247
|
-
body:
|
|
5248
|
-
image:
|
|
5249
|
-
created:
|
|
5250
|
-
updated:
|
|
5251
|
-
video:
|
|
5252
|
-
workout:
|
|
5172
|
+
uuid: item?._source?.uuid?.[0],
|
|
5173
|
+
title: item?._source?.title?.[0],
|
|
5174
|
+
body: item?._source?.body?.[0],
|
|
5175
|
+
image: item?._source?.image?.[0],
|
|
5176
|
+
created: item?._source?.created?.[0],
|
|
5177
|
+
updated: item?._source?.updated?.[0],
|
|
5178
|
+
video: item?._source?.video?.[0],
|
|
5179
|
+
workout: item?._source?.workout?.[0],
|
|
5253
5180
|
};
|
|
5254
5181
|
});
|
|
5255
5182
|
}
|
|
@@ -5257,360 +5184,328 @@ function formatSecondsToISO8601Duration(seconds) {
|
|
|
5257
5184
|
if (!seconds)
|
|
5258
5185
|
return '';
|
|
5259
5186
|
// Calculate hours, minutes, and remaining seconds
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5187
|
+
const hours = Math.floor(seconds / 3600);
|
|
5188
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
5189
|
+
const remainingSeconds = seconds % 60;
|
|
5263
5190
|
// Build the ISO 8601 duration string
|
|
5264
|
-
|
|
5191
|
+
let duration = 'PT';
|
|
5265
5192
|
if (hours > 0) {
|
|
5266
|
-
duration +=
|
|
5193
|
+
duration += `${hours}H`;
|
|
5267
5194
|
}
|
|
5268
5195
|
if (minutes > 0) {
|
|
5269
|
-
duration +=
|
|
5196
|
+
duration += `${minutes}M`;
|
|
5270
5197
|
}
|
|
5271
5198
|
if (remainingSeconds > 0 || duration === 'PT') {
|
|
5272
|
-
duration +=
|
|
5199
|
+
duration += `${remainingSeconds}S`;
|
|
5273
5200
|
}
|
|
5274
5201
|
return duration;
|
|
5275
5202
|
}
|
|
5276
5203
|
function formatAuthSession(session) {
|
|
5277
|
-
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;
|
|
5278
5204
|
return {
|
|
5279
|
-
accessToken:
|
|
5280
|
-
idToken:
|
|
5205
|
+
accessToken: session?.tokens?.accessToken.toString(),
|
|
5206
|
+
idToken: session?.tokens?.idToken?.toString(),
|
|
5281
5207
|
refreshToken: undefined,
|
|
5282
|
-
accessTokenExpiry:
|
|
5283
|
-
expires:
|
|
5284
|
-
sub:
|
|
5208
|
+
accessTokenExpiry: session?.tokens?.idToken?.payload?.exp,
|
|
5209
|
+
expires: session?.tokens?.idToken?.payload?.exp,
|
|
5210
|
+
sub: session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5285
5211
|
details: {
|
|
5286
|
-
userEmail:
|
|
5287
|
-
firstName:
|
|
5288
|
-
lastName:
|
|
5289
|
-
dateOfBirth:
|
|
5290
|
-
'cognito:username':
|
|
5291
|
-
'custom:termsAccepted':
|
|
5292
|
-
'custom:subscriptionId':
|
|
5293
|
-
'custom:contactPreferences':
|
|
5294
|
-
'custom:customerId':
|
|
5295
|
-
picture:
|
|
5212
|
+
userEmail: session?.tokens?.idToken?.payload?.email?.toString(),
|
|
5213
|
+
firstName: session?.tokens?.idToken?.payload?.given_name?.toString(),
|
|
5214
|
+
lastName: session?.tokens?.idToken?.payload?.family_name?.toString(),
|
|
5215
|
+
dateOfBirth: session?.tokens?.idToken?.payload?.birthdate?.toString(),
|
|
5216
|
+
'cognito:username': session?.tokens?.idToken?.payload?.['cognito:username']?.toString(),
|
|
5217
|
+
'custom:termsAccepted': session?.tokens?.idToken?.payload?.['custom:termsAccepted']?.toString(),
|
|
5218
|
+
'custom:subscriptionId': session?.tokens?.idToken?.payload?.['custom:subscriptionId']?.toString(),
|
|
5219
|
+
'custom:contactPreferences': session?.tokens?.idToken?.payload?.['custom:contactPreferences']?.toString(),
|
|
5220
|
+
'custom:customerId': session?.tokens?.idToken?.payload?.['custom:customerId']?.toString(),
|
|
5221
|
+
picture: session?.tokens?.idToken?.payload?.picture?.toString(),
|
|
5296
5222
|
},
|
|
5297
5223
|
};
|
|
5298
5224
|
}
|
|
5299
5225
|
function formatFedaratedSession(session) {
|
|
5300
|
-
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;
|
|
5301
5226
|
return {
|
|
5302
|
-
accessToken:
|
|
5303
|
-
idToken:
|
|
5304
|
-
refreshToken:
|
|
5305
|
-
accessTokenExpiry:
|
|
5306
|
-
expires:
|
|
5307
|
-
sub:
|
|
5227
|
+
accessToken: session?.accessToken?.jwtToken,
|
|
5228
|
+
idToken: session?.idToken?.jwtToken,
|
|
5229
|
+
refreshToken: session?.refreshToken?.token,
|
|
5230
|
+
accessTokenExpiry: session?.accessToken?.payload?.exp,
|
|
5231
|
+
expires: session?.accessToken?.payload?.exp,
|
|
5232
|
+
sub: session?.idToken?.payload?.sub,
|
|
5308
5233
|
details: {
|
|
5309
|
-
userEmail:
|
|
5310
|
-
firstName:
|
|
5311
|
-
lastName:
|
|
5312
|
-
dateOfBirth:
|
|
5313
|
-
'cognito:username':
|
|
5314
|
-
'custom:termsAccepted':
|
|
5315
|
-
'custom:subscriptionId':
|
|
5316
|
-
'custom:contactPreferences':
|
|
5317
|
-
'custom:customerId':
|
|
5318
|
-
picture:
|
|
5319
|
-
id: toCamelCaseObject(
|
|
5234
|
+
userEmail: session?.idToken?.payload?.email,
|
|
5235
|
+
firstName: session?.idToken?.payload?.given_name,
|
|
5236
|
+
lastName: session?.idToken?.payload?.family_name,
|
|
5237
|
+
dateOfBirth: session?.idToken?.payload?.birthdate,
|
|
5238
|
+
'cognito:username': session?.idToken?.payload?.sub,
|
|
5239
|
+
'custom:termsAccepted': session?.idToken?.payload?.['custom:termsAccepted'],
|
|
5240
|
+
'custom:subscriptionId': session?.idToken?.payload?.['custom:subscriptionId'],
|
|
5241
|
+
'custom:contactPreferences': session?.idToken?.payload?.['custom:contactPreferences'],
|
|
5242
|
+
'custom:customerId': session?.idToken?.payload?.['custom:customerId'],
|
|
5243
|
+
picture: session?.idToken?.payload?.picture,
|
|
5244
|
+
id: toCamelCaseObject(session?.idToken?.payload),
|
|
5320
5245
|
},
|
|
5321
5246
|
};
|
|
5322
5247
|
}
|
|
5323
5248
|
function formatSocialAuthSession(tokens) {
|
|
5324
|
-
|
|
5249
|
+
const idToken = jwtDecode.jwtDecode(tokens.idToken);
|
|
5325
5250
|
return {
|
|
5326
5251
|
socialSignin: true,
|
|
5327
5252
|
accessToken: tokens.accessToken,
|
|
5328
5253
|
idToken: tokens.idToken,
|
|
5329
5254
|
refreshToken: tokens.refreshToken,
|
|
5330
|
-
accessTokenExpiry: idToken
|
|
5331
|
-
expires: idToken
|
|
5255
|
+
accessTokenExpiry: idToken?.exp,
|
|
5256
|
+
expires: idToken?.exp,
|
|
5332
5257
|
sub: idToken.sub,
|
|
5333
5258
|
details: {
|
|
5334
5259
|
userEmail: idToken.email,
|
|
5335
5260
|
firstName: idToken.given_name,
|
|
5336
5261
|
lastName: idToken.family_name,
|
|
5337
|
-
dateOfBirth: idToken
|
|
5338
|
-
'cognito:username': idToken
|
|
5339
|
-
'custom:termsAccepted': idToken
|
|
5340
|
-
'custom:subscriptionId': idToken
|
|
5341
|
-
'custom:contactPreferences': idToken
|
|
5342
|
-
'custom:customerId': idToken
|
|
5343
|
-
picture: idToken
|
|
5262
|
+
dateOfBirth: idToken?.birthdate,
|
|
5263
|
+
'cognito:username': idToken?.['cognito:username'],
|
|
5264
|
+
'custom:termsAccepted': idToken?.['custom:termsAccepted'],
|
|
5265
|
+
'custom:subscriptionId': idToken?.['custom:subscriptionId'],
|
|
5266
|
+
'custom:contactPreferences': idToken?.['custom:contactPreferences'],
|
|
5267
|
+
'custom:customerId': idToken?.['custom:customerId'],
|
|
5268
|
+
picture: idToken?.picture,
|
|
5344
5269
|
},
|
|
5345
5270
|
};
|
|
5346
5271
|
}
|
|
5347
5272
|
function formatConfig(data) {
|
|
5348
|
-
return data.map(
|
|
5349
|
-
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;
|
|
5273
|
+
return data.map((item) => {
|
|
5350
5274
|
return {
|
|
5351
|
-
uuid:
|
|
5352
|
-
id:
|
|
5353
|
-
created:
|
|
5354
|
-
updated:
|
|
5355
|
-
type:
|
|
5356
|
-
cla:
|
|
5357
|
-
enabled:
|
|
5358
|
-
name:
|
|
5359
|
-
price:
|
|
5360
|
-
video:
|
|
5361
|
-
imageHomepage:
|
|
5362
|
-
imageSectionBanner:
|
|
5275
|
+
uuid: item?._source?.uuid?.[0],
|
|
5276
|
+
id: item?._source?.uuid?.[0],
|
|
5277
|
+
created: item?._source?.created?.[0],
|
|
5278
|
+
updated: item?._source?.updated?.[0],
|
|
5279
|
+
type: item?._source?.type?.[0],
|
|
5280
|
+
cla: item?._source?.cla?.[0],
|
|
5281
|
+
enabled: item?._source?.enabled?.[0],
|
|
5282
|
+
name: item?._source?.name?.[0],
|
|
5283
|
+
price: item?._source?.price?.[0],
|
|
5284
|
+
video: item?._source?.video?.[0],
|
|
5285
|
+
imageHomepage: item?._source?.image_homepage?.[0],
|
|
5286
|
+
imageSectionBanner: item?._source?.image_section_banner?.[0],
|
|
5363
5287
|
};
|
|
5364
5288
|
});
|
|
5365
5289
|
}
|
|
5366
5290
|
function formatSectionPanels(data) {
|
|
5367
|
-
return data.map(
|
|
5368
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
5291
|
+
return data.map((item) => {
|
|
5369
5292
|
return {
|
|
5370
|
-
uuid:
|
|
5371
|
-
id:
|
|
5372
|
-
title:
|
|
5373
|
-
created:
|
|
5374
|
-
updated:
|
|
5375
|
-
weight:
|
|
5376
|
-
items:
|
|
5377
|
-
type:
|
|
5293
|
+
uuid: item?._source?.uuid?.[0],
|
|
5294
|
+
id: item?._source?.uuid?.[0],
|
|
5295
|
+
title: item?._source?.title?.[0],
|
|
5296
|
+
created: item?._source?.created?.[0],
|
|
5297
|
+
updated: item?._source?.updated?.[0],
|
|
5298
|
+
weight: item?._source?.weight?.[0],
|
|
5299
|
+
items: item?._source?.item_uuid,
|
|
5300
|
+
type: item?._source?.type?.[0],
|
|
5378
5301
|
};
|
|
5379
5302
|
});
|
|
5380
5303
|
}
|
|
5381
5304
|
function formatSectionItems(data) {
|
|
5382
|
-
return data.map(
|
|
5383
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
5305
|
+
return data.map((item) => {
|
|
5384
5306
|
return {
|
|
5385
|
-
uuid:
|
|
5386
|
-
id:
|
|
5387
|
-
title:
|
|
5388
|
-
created:
|
|
5389
|
-
updated:
|
|
5390
|
-
type:
|
|
5391
|
-
term:
|
|
5392
|
-
image:
|
|
5393
|
-
bannerImage:
|
|
5307
|
+
uuid: item?._source?.uuid?.[0],
|
|
5308
|
+
id: item?._source?.uuid?.[0],
|
|
5309
|
+
title: item?._source?.title?.[0],
|
|
5310
|
+
created: item?._source?.created?.[0],
|
|
5311
|
+
updated: item?._source?.updated?.[0],
|
|
5312
|
+
type: item?._source?.type?.[0],
|
|
5313
|
+
term: item?._source?.term?.[0],
|
|
5314
|
+
image: item?._source?.custom_image_formatted?.[0],
|
|
5315
|
+
bannerImage: item?._source?.banner_image_formatted?.[0],
|
|
5394
5316
|
};
|
|
5395
5317
|
});
|
|
5396
5318
|
}
|
|
5397
|
-
|
|
5398
|
-
return data.map(
|
|
5399
|
-
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;
|
|
5319
|
+
const formatTaxonomies = (data) => {
|
|
5320
|
+
return data.map((item) => {
|
|
5400
5321
|
return {
|
|
5401
|
-
uuid:
|
|
5402
|
-
id:
|
|
5403
|
-
updated:
|
|
5404
|
-
vocabulary:
|
|
5405
|
-
name:
|
|
5406
|
-
description:
|
|
5407
|
-
image:
|
|
5408
|
-
imageBanner:
|
|
5409
|
-
imageBannerTaxonomy:
|
|
5410
|
-
imageLarge:
|
|
5411
|
-
weight:
|
|
5412
|
-
parentName:
|
|
5413
|
-
color:
|
|
5322
|
+
uuid: item?._source?.uuid?.[0],
|
|
5323
|
+
id: item?._source?.uuid?.[0],
|
|
5324
|
+
updated: item?._source?.updated?.[0],
|
|
5325
|
+
vocabulary: item?._source?.vocabulary?.[0],
|
|
5326
|
+
name: item?._source?.name?.[0],
|
|
5327
|
+
description: item?._source?.description?.[0],
|
|
5328
|
+
image: item?._source?.image?.[0],
|
|
5329
|
+
imageBanner: item?._source?.image_banner?.[0],
|
|
5330
|
+
imageBannerTaxonomy: item?._source?.image_banner_taxonomy?.[0],
|
|
5331
|
+
imageLarge: item?._source?.image_large_16_9?.[0],
|
|
5332
|
+
weight: item?._source?.weight?.[0],
|
|
5333
|
+
parentName: item?._source?.parent_name?.[0],
|
|
5334
|
+
color: item?._source?.color?.[0],
|
|
5414
5335
|
};
|
|
5415
5336
|
});
|
|
5416
5337
|
};
|
|
5417
|
-
|
|
5418
|
-
return data.map(
|
|
5419
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5338
|
+
const formatSeries = (data) => {
|
|
5339
|
+
return data.map((item) => {
|
|
5420
5340
|
return {
|
|
5421
|
-
uuid:
|
|
5422
|
-
id:
|
|
5423
|
-
created:
|
|
5424
|
-
updated:
|
|
5425
|
-
title:
|
|
5426
|
-
synopsis:
|
|
5427
|
-
imagePoster:
|
|
5428
|
-
imageThumb:
|
|
5429
|
-
category:
|
|
5430
|
-
categoryId:
|
|
5431
|
-
seasons:
|
|
5341
|
+
uuid: item?._source?.uuid?.[0],
|
|
5342
|
+
id: item?._source?.uuid?.[0],
|
|
5343
|
+
created: item?._source?.created?.[0],
|
|
5344
|
+
updated: item?._source?.updated?.[0],
|
|
5345
|
+
title: item?._source?.display_title?.[0],
|
|
5346
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5347
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5348
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5349
|
+
category: item?._source?.category?.[0],
|
|
5350
|
+
categoryId: item?._source?.category_id?.[0],
|
|
5351
|
+
seasons: item?._source?.seasons || [],
|
|
5432
5352
|
};
|
|
5433
5353
|
});
|
|
5434
5354
|
};
|
|
5435
|
-
|
|
5436
|
-
return data.map(
|
|
5437
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5355
|
+
const formatSeasons = (data) => {
|
|
5356
|
+
return data.map((item) => {
|
|
5438
5357
|
return {
|
|
5439
|
-
uuid:
|
|
5440
|
-
id:
|
|
5441
|
-
created:
|
|
5442
|
-
updated:
|
|
5443
|
-
title:
|
|
5444
|
-
synopsis:
|
|
5445
|
-
imagePoster:
|
|
5446
|
-
imageThumb:
|
|
5447
|
-
episodes:
|
|
5448
|
-
seasonNumber:
|
|
5449
|
-
showId:
|
|
5358
|
+
uuid: item?._source?.uuid?.[0],
|
|
5359
|
+
id: item?._source?.uuid?.[0],
|
|
5360
|
+
created: item?._source?.created?.[0],
|
|
5361
|
+
updated: item?._source?.updated?.[0],
|
|
5362
|
+
title: item?._source?.display_title?.[0],
|
|
5363
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5364
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5365
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5366
|
+
episodes: item?._source?.episodes || [],
|
|
5367
|
+
seasonNumber: item?._source?.season_number?.[0],
|
|
5368
|
+
showId: item?._source?.show?.[0],
|
|
5450
5369
|
};
|
|
5451
5370
|
});
|
|
5452
5371
|
};
|
|
5453
|
-
|
|
5454
|
-
return data.map(
|
|
5455
|
-
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;
|
|
5372
|
+
const formatLongform = (data) => {
|
|
5373
|
+
return data.map((item) => {
|
|
5456
5374
|
return {
|
|
5457
|
-
uuid:
|
|
5458
|
-
id:
|
|
5459
|
-
created:
|
|
5460
|
-
updated:
|
|
5461
|
-
title:
|
|
5462
|
-
synopsis:
|
|
5463
|
-
imagePoster:
|
|
5464
|
-
imageThumb:
|
|
5465
|
-
duration:
|
|
5466
|
-
releaseDate:
|
|
5467
|
-
video:
|
|
5468
|
-
imageUrl:
|
|
5469
|
-
episodeNumber:
|
|
5375
|
+
uuid: item?._source?.uuid?.[0],
|
|
5376
|
+
id: item?._source?.uuid?.[0],
|
|
5377
|
+
created: item?._source?.created?.[0],
|
|
5378
|
+
updated: item?._source?.updated?.[0],
|
|
5379
|
+
title: item?._source?.display_title?.[0],
|
|
5380
|
+
synopsis: item?._source?.synopsis?.[0],
|
|
5381
|
+
imagePoster: item?._source?.image_style_poster?.[0],
|
|
5382
|
+
imageThumb: item?._source?.image_style_thumb?.[0],
|
|
5383
|
+
duration: item?._source?.duration?.[0],
|
|
5384
|
+
releaseDate: item?._source?.release_date?.[0],
|
|
5385
|
+
video: item?._source?.video?.[0],
|
|
5386
|
+
imageUrl: item?._source?.image_url?.[0],
|
|
5387
|
+
episodeNumber: item?._source?.episode_number?.[0],
|
|
5470
5388
|
};
|
|
5471
5389
|
});
|
|
5472
5390
|
};
|
|
5473
|
-
|
|
5474
|
-
return data.map(
|
|
5475
|
-
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;
|
|
5391
|
+
const formatMediaItem = (data) => {
|
|
5392
|
+
return data.map((item) => {
|
|
5476
5393
|
return {
|
|
5477
|
-
changed:
|
|
5478
|
-
created:
|
|
5479
|
-
image:
|
|
5480
|
-
customThumbnail:
|
|
5481
|
-
price:
|
|
5482
|
-
priceTwoYear:
|
|
5483
|
-
revisionTimestamp:
|
|
5484
|
-
sku:
|
|
5485
|
-
status:
|
|
5486
|
-
uuid:
|
|
5487
|
-
description:
|
|
5488
|
-
transcript:
|
|
5489
|
-
entities:
|
|
5490
|
-
phrases:
|
|
5491
|
-
video:
|
|
5492
|
-
title:
|
|
5493
|
-
generatedTitle:
|
|
5494
|
-
projectPricing:
|
|
5495
|
-
related_items:
|
|
5496
|
-
franchises:
|
|
5497
|
-
franchisesIds:
|
|
5498
|
-
original:
|
|
5499
|
-
script:
|
|
5500
|
-
hideThumbnailTitle:
|
|
5394
|
+
changed: item?._source?.changed?.[0],
|
|
5395
|
+
created: item?._source?.created?.[0],
|
|
5396
|
+
image: item?._source?.image?.[0],
|
|
5397
|
+
customThumbnail: item?._source?.custom_thumbnail?.[0],
|
|
5398
|
+
price: item?._source?.price?.[0],
|
|
5399
|
+
priceTwoYear: item?._source?.price_2_year?.[0],
|
|
5400
|
+
revisionTimestamp: item?._source?.revision_timestamp?.[0],
|
|
5401
|
+
sku: item?._source?.sku?.[0],
|
|
5402
|
+
status: item?._source?.status?.[0],
|
|
5403
|
+
uuid: item?._source?.uuid?.[0],
|
|
5404
|
+
description: item?._source?.description?.[0],
|
|
5405
|
+
transcript: item?._source?.transcript?.[0],
|
|
5406
|
+
entities: item?._source?.entities,
|
|
5407
|
+
phrases: item?._source?.phrases,
|
|
5408
|
+
video: item?._source?.video?.[0],
|
|
5409
|
+
title: item?._source?.title?.[0],
|
|
5410
|
+
generatedTitle: item?._source?.generated_title?.[0],
|
|
5411
|
+
projectPricing: item?._source?.project_pricing?.[0],
|
|
5412
|
+
related_items: item?._source?.related_uuids,
|
|
5413
|
+
franchises: item?._source?.franchise_name,
|
|
5414
|
+
franchisesIds: item?._source?.franchise_tid,
|
|
5415
|
+
original: item?._source?.original?.[0],
|
|
5416
|
+
script: item?._source?.script?.[0],
|
|
5417
|
+
hideThumbnailTitle: item?._source?.hide_thumbnail_title?.[0],
|
|
5501
5418
|
};
|
|
5502
5419
|
});
|
|
5503
5420
|
};
|
|
5504
5421
|
|
|
5505
|
-
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
5506
5422
|
// Render the store based on the environment.
|
|
5507
|
-
|
|
5508
|
-
|
|
5423
|
+
const isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
5424
|
+
const ENV = isWeb ? process.env : Promise.resolve().then(function () { return require('./index-CfrYa4U_.js'); }).then((mod) => mod.default).catch(() => ({}));
|
|
5509
5425
|
// export const ENV = process.env;
|
|
5510
|
-
|
|
5426
|
+
process.env?.NEXT_PUBLIC_API_PREFIX || ENV.API_PREFIX;
|
|
5511
5427
|
// Auth specific API
|
|
5512
|
-
|
|
5428
|
+
const API_AUTH_PREFIX = process.env?.NEXT_PUBLIC_API_AUTH_PREFIX || ENV.API_AUTH_PREFIX;
|
|
5513
5429
|
// Payments specific API
|
|
5514
|
-
|
|
5430
|
+
const API_PAYMENTS_PREFIX = process.env?.NEXT_PUBLIC_API_PAYMENTS_PREFIX || ENV.API_PAYMENTS_PREFIX;
|
|
5515
5431
|
// Orders specific API
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5432
|
+
const API_ORDERS_PREFIX = process.env?.NEXT_PUBLIC_API_ORDERS_PREFIX || ENV.API_ORDERS_PREFIX;
|
|
5433
|
+
process.env?.NEXT_PUBLIC_APP_BASE_URL || ENV.APP_BASE_URL;
|
|
5434
|
+
const APP_ES_INSTANCE = process.env?.NEXT_PUBLIC_APP_ES_INSTANCE || ENV.APP_ES_INSTANCE;
|
|
5435
|
+
const APP_ES_AUTH = process.env?.NEXT_PUBLIC_APP_ES_AUTH || ENV.APP_ES_AUTH;
|
|
5436
|
+
process.env?.NEXT_PUBLIC_APP_ES_PROMO_PANEL_INDEX ||
|
|
5521
5437
|
ENV.APP_ES_PROMO_PANEL_INDEX;
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5438
|
+
process.env?.NEXT_PUBLIC_APP_ES_FAQ_INDEX || ENV.APP_ES_FAQ_INDEX;
|
|
5439
|
+
process.env?.NEXT_PUBLIC_APP_ES_PAGES_INDEX || ENV.APP_ES_PAGES_INDEX;
|
|
5440
|
+
process.env?.NEXT_PUBLIC_APP_ES_SETTINGS_INDEX || ENV.APP_ES_SETTINGS_INDEX;
|
|
5441
|
+
process.env?.NEXT_PUBLIC_APP_ES_PRESS_INDEX || ENV.APP_ES_PRESS_INDEX;
|
|
5442
|
+
process.env?.NEXT_PUBLIC_APP_ES_GUESTS_INDEX || ENV.APP_ES_GUESTS_INDEX;
|
|
5443
|
+
process.env?.NEXT_PUBLIC_APP_ES_VIDEOS_INDEX || ENV.APP_ES_VIDEOS_INDEX;
|
|
5444
|
+
process.env?.NEXT_PUBLIC_APP_ES_SECTIONS_INDEX || ENV.APP_ES_SECTIONS_INDEX;
|
|
5445
|
+
process.env?.NEXT_PUBLIC_APP_ES_WORKOUTS_INDEX || ENV.APP_ES_WORKOUTS_INDEX;
|
|
5446
|
+
process.env?.NEXT_PUBLIC_APP_ES_SCHEDULE_INDEX || ENV.APP_ES_SCHEDULE_INDEX;
|
|
5447
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGES_INDEX ||
|
|
5532
5448
|
ENV.APP_ES_CHALLENGES_INDEX;
|
|
5533
|
-
|
|
5449
|
+
process.env?.NEXT_PUBLIC_APP_ES_CHALLENGE_DAYS_INDEX ||
|
|
5534
5450
|
ENV.APP_ES_CHALLENGE_DAYS_INDEX;
|
|
5535
5451
|
|
|
5536
|
-
|
|
5452
|
+
const authDataBaseQuery = fetchBaseQuery({
|
|
5537
5453
|
baseUrl: API_AUTH_PREFIX,
|
|
5538
|
-
prepareHeaders:
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
session = _c.sent();
|
|
5550
|
-
idToken = session.getIdToken().getJwtToken();
|
|
5551
|
-
accessToken = session.getAccessToken().getJwtToken();
|
|
5552
|
-
if (accessToken && idToken) {
|
|
5553
|
-
headers.set('accesstoken', accessToken);
|
|
5554
|
-
headers.set('idtoken', idToken);
|
|
5555
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5556
|
-
}
|
|
5557
|
-
return [2 /*return*/, headers];
|
|
5558
|
-
case 3:
|
|
5559
|
-
error_1 = _c.sent();
|
|
5560
|
-
console.error('authDataBaseQuery: ', error_1);
|
|
5561
|
-
return [2 /*return*/, headers];
|
|
5562
|
-
case 4: return [2 /*return*/];
|
|
5454
|
+
prepareHeaders: async (headers, {}) => {
|
|
5455
|
+
headers.set('Content-Type', 'application/json');
|
|
5456
|
+
try {
|
|
5457
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5458
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5459
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5460
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5461
|
+
if (accessToken && idToken) {
|
|
5462
|
+
headers.set('accesstoken', accessToken);
|
|
5463
|
+
headers.set('idtoken', idToken);
|
|
5464
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5563
5465
|
}
|
|
5564
|
-
|
|
5565
|
-
|
|
5466
|
+
return headers;
|
|
5467
|
+
}
|
|
5468
|
+
catch (error) {
|
|
5469
|
+
console.error('authDataBaseQuery: ', error);
|
|
5470
|
+
return headers;
|
|
5471
|
+
}
|
|
5472
|
+
},
|
|
5566
5473
|
credentials: 'include',
|
|
5567
5474
|
});
|
|
5568
5475
|
/**
|
|
5569
5476
|
* This function is used to retry a request if we get a 401 error.
|
|
5570
5477
|
*/
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
user = formatAuthSession(authSession);
|
|
5586
|
-
api.dispatch(setCredentials(user));
|
|
5587
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5588
|
-
return [4 /*yield*/, authDataBaseQuery(args, api, extraOptions)];
|
|
5589
|
-
case 3:
|
|
5590
|
-
// If we get a new access token, retry the original request.
|
|
5591
|
-
result = _b.sent();
|
|
5592
|
-
return [3 /*break*/, 6];
|
|
5593
|
-
case 4:
|
|
5478
|
+
const authDataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5479
|
+
let result = await authDataBaseQuery(args, api, extraOptions);
|
|
5480
|
+
// If we get a 401 error
|
|
5481
|
+
if (result?.error?.status === 401) {
|
|
5482
|
+
const authSession = await awsAmplify.Auth.currentAuthenticatedUser({
|
|
5483
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5484
|
+
});
|
|
5485
|
+
const user = formatAuthSession(authSession);
|
|
5486
|
+
api.dispatch(setCredentials(user));
|
|
5487
|
+
if (authSession?.tokens) {
|
|
5488
|
+
// If we get a new access token, retry the original request.
|
|
5489
|
+
result = await authDataBaseQuery(args, api, extraOptions);
|
|
5490
|
+
}
|
|
5491
|
+
else {
|
|
5594
5492
|
// TODO; require full data reset?
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
api.dispatch(logout());
|
|
5600
|
-
// If no access token throw error.
|
|
5601
|
-
throw new Error('No access token found');
|
|
5602
|
-
case 6: return [2 /*return*/, result];
|
|
5493
|
+
await awsAmplify.Auth.signOut();
|
|
5494
|
+
api.dispatch(logout());
|
|
5495
|
+
// If no access token throw error.
|
|
5496
|
+
throw new Error('No access token found');
|
|
5603
5497
|
}
|
|
5604
|
-
}
|
|
5605
|
-
|
|
5606
|
-
|
|
5498
|
+
}
|
|
5499
|
+
return result;
|
|
5500
|
+
};
|
|
5501
|
+
const authApi = createApi({
|
|
5607
5502
|
reducerPath: 'authApi',
|
|
5608
5503
|
baseQuery: authDataBaseQueryWithReauth,
|
|
5609
5504
|
tagTypes: ['UserToken', 'UserData'],
|
|
5610
5505
|
// keepUnusedDataFor: 300,
|
|
5611
|
-
endpoints:
|
|
5506
|
+
endpoints: (builder) => ({
|
|
5612
5507
|
resetPassword: builder.mutation({
|
|
5613
|
-
query:
|
|
5508
|
+
query: (data) => ({
|
|
5614
5509
|
url: '/user/password/reset',
|
|
5615
5510
|
method: 'POST',
|
|
5616
5511
|
body: {
|
|
@@ -5619,10 +5514,10 @@ var authApi = createApi({
|
|
|
5619
5514
|
currentPassword: data.currentPassword,
|
|
5620
5515
|
newPassword: data.newPassword,
|
|
5621
5516
|
},
|
|
5622
|
-
})
|
|
5517
|
+
}),
|
|
5623
5518
|
}),
|
|
5624
5519
|
resetPasswordAuth: builder.mutation({
|
|
5625
|
-
query:
|
|
5520
|
+
query: (data) => ({
|
|
5626
5521
|
url: '/user/password/reset-auth',
|
|
5627
5522
|
method: 'POST',
|
|
5628
5523
|
body: {
|
|
@@ -5630,54 +5525,41 @@ var authApi = createApi({
|
|
|
5630
5525
|
currentPassword: data.currentPassword,
|
|
5631
5526
|
newPassword: data.newPassword,
|
|
5632
5527
|
},
|
|
5633
|
-
})
|
|
5528
|
+
}),
|
|
5634
5529
|
}),
|
|
5635
5530
|
forgottenPassword: builder.mutation({
|
|
5636
|
-
query:
|
|
5531
|
+
query: (data) => ({
|
|
5637
5532
|
url: '/user/password/forgot',
|
|
5638
5533
|
method: 'POST',
|
|
5639
5534
|
body: {
|
|
5640
5535
|
email: data.email,
|
|
5641
5536
|
},
|
|
5642
|
-
})
|
|
5537
|
+
}),
|
|
5643
5538
|
}),
|
|
5644
5539
|
register: builder.mutation({
|
|
5645
|
-
query:
|
|
5540
|
+
query: (data) => ({
|
|
5646
5541
|
url: '/user/register',
|
|
5647
5542
|
method: 'POST',
|
|
5648
5543
|
body: data,
|
|
5649
|
-
})
|
|
5650
|
-
onQueryStarted
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
return [4 /*yield*/, queryFulfilled];
|
|
5659
|
-
case 1:
|
|
5660
|
-
_c.sent();
|
|
5661
|
-
dispatch(resetCreating());
|
|
5662
|
-
return [3 /*break*/, 3];
|
|
5663
|
-
case 2:
|
|
5664
|
-
err_1 = _c.sent();
|
|
5665
|
-
console.error('REGISTER: ', err_1);
|
|
5666
|
-
return [3 /*break*/, 3];
|
|
5667
|
-
case 3: return [2 /*return*/];
|
|
5668
|
-
}
|
|
5669
|
-
});
|
|
5670
|
-
});
|
|
5544
|
+
}),
|
|
5545
|
+
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
5546
|
+
try {
|
|
5547
|
+
await queryFulfilled;
|
|
5548
|
+
dispatch(resetCreating());
|
|
5549
|
+
}
|
|
5550
|
+
catch (err) {
|
|
5551
|
+
console.error('REGISTER: ', err);
|
|
5552
|
+
}
|
|
5671
5553
|
},
|
|
5672
5554
|
}),
|
|
5673
5555
|
verifyUser: builder.query({
|
|
5674
|
-
query:
|
|
5556
|
+
query: (data) => ({
|
|
5675
5557
|
url: '/user/verify',
|
|
5676
5558
|
method: 'POST',
|
|
5677
5559
|
body: data,
|
|
5678
|
-
})
|
|
5679
|
-
transformErrorResponse:
|
|
5680
|
-
|
|
5560
|
+
}),
|
|
5561
|
+
transformErrorResponse: (rawResult) => {
|
|
5562
|
+
const { status, data, message } = rawResult;
|
|
5681
5563
|
switch (status) {
|
|
5682
5564
|
case 429:
|
|
5683
5565
|
// Toast.info(TOO_MANY_REQUESTS_MESSAGE);
|
|
@@ -5689,7 +5571,7 @@ var authApi = createApi({
|
|
|
5689
5571
|
*/
|
|
5690
5572
|
return {
|
|
5691
5573
|
route: 'resend',
|
|
5692
|
-
message:
|
|
5574
|
+
message: data?.message || message,
|
|
5693
5575
|
};
|
|
5694
5576
|
case 404:
|
|
5695
5577
|
/**
|
|
@@ -5697,7 +5579,7 @@ var authApi = createApi({
|
|
|
5697
5579
|
*/
|
|
5698
5580
|
return {
|
|
5699
5581
|
route: 'failed',
|
|
5700
|
-
message:
|
|
5582
|
+
message: data?.message || message,
|
|
5701
5583
|
};
|
|
5702
5584
|
case 401:
|
|
5703
5585
|
/**
|
|
@@ -5705,159 +5587,146 @@ var authApi = createApi({
|
|
|
5705
5587
|
*/
|
|
5706
5588
|
return {
|
|
5707
5589
|
route: 'error',
|
|
5708
|
-
message:
|
|
5590
|
+
message: data?.message || message,
|
|
5709
5591
|
};
|
|
5710
5592
|
default:
|
|
5711
5593
|
return {
|
|
5712
5594
|
route: 'error',
|
|
5713
|
-
message:
|
|
5595
|
+
message: data?.message || message,
|
|
5714
5596
|
};
|
|
5715
5597
|
}
|
|
5716
5598
|
},
|
|
5717
|
-
transformResponse:
|
|
5718
|
-
|
|
5719
|
-
return { route: 'success', message: data
|
|
5599
|
+
transformResponse: (rawResult) => {
|
|
5600
|
+
const { data } = rawResult;
|
|
5601
|
+
return { route: 'success', message: data?.message };
|
|
5720
5602
|
},
|
|
5721
5603
|
}),
|
|
5722
5604
|
verifyUserAttributes: builder.query({
|
|
5723
|
-
query:
|
|
5605
|
+
query: (data) => ({
|
|
5724
5606
|
url: '/user/verify/email',
|
|
5725
5607
|
method: 'POST',
|
|
5726
5608
|
body: data,
|
|
5727
|
-
})
|
|
5609
|
+
}),
|
|
5728
5610
|
}),
|
|
5729
5611
|
verifyUserResend: builder.query({
|
|
5730
|
-
query:
|
|
5612
|
+
query: (data) => ({
|
|
5731
5613
|
url: '/user/verify/resend',
|
|
5732
5614
|
method: 'POST',
|
|
5733
5615
|
body: data,
|
|
5734
|
-
})
|
|
5616
|
+
}),
|
|
5735
5617
|
}),
|
|
5736
5618
|
getUserInfo: builder.query({
|
|
5737
|
-
query:
|
|
5738
|
-
url:
|
|
5619
|
+
query: (uuid) => ({
|
|
5620
|
+
url: `/data/user/${uuid}`,
|
|
5739
5621
|
method: 'GET',
|
|
5740
|
-
})
|
|
5622
|
+
}),
|
|
5741
5623
|
providesTags: ['UserData'],
|
|
5742
5624
|
}),
|
|
5743
5625
|
updateUserInfo: builder.mutation({
|
|
5744
|
-
query:
|
|
5626
|
+
query: (expressions) => ({
|
|
5745
5627
|
url: '/data/user',
|
|
5746
5628
|
method: 'PATCH',
|
|
5747
5629
|
body: expressions,
|
|
5748
|
-
})
|
|
5630
|
+
}),
|
|
5749
5631
|
invalidatesTags: ['UserData'],
|
|
5750
5632
|
}),
|
|
5751
5633
|
updateUser: builder.mutation({
|
|
5752
|
-
query:
|
|
5634
|
+
query: (data) => ({
|
|
5753
5635
|
url: '/user',
|
|
5754
5636
|
method: 'PATCH',
|
|
5755
5637
|
body: data,
|
|
5756
|
-
})
|
|
5638
|
+
}),
|
|
5757
5639
|
invalidatesTags: ['UserData'],
|
|
5758
5640
|
}),
|
|
5759
|
-
})
|
|
5641
|
+
}),
|
|
5760
5642
|
});
|
|
5761
5643
|
// Export hooks for usage in functional components.
|
|
5762
|
-
|
|
5644
|
+
const {
|
|
5645
|
+
// useLoginQuery,
|
|
5763
5646
|
// useLazyLoginQuery,
|
|
5764
5647
|
// useRefreshTokenQuery,
|
|
5765
5648
|
// useLazyRefreshTokenQuery,
|
|
5766
5649
|
// useLogoutQuery,
|
|
5767
5650
|
// useLazyLogoutQuery,
|
|
5768
|
-
useResetPasswordMutation
|
|
5769
|
-
useResetPasswordAuthMutation
|
|
5651
|
+
useResetPasswordMutation, // Use this for mobile app.
|
|
5652
|
+
useResetPasswordAuthMutation, useRegisterMutation, useVerifyUserQuery, useLazyVerifyUserQuery, useGetUserInfoQuery, useLazyGetUserInfoQuery, useUpdateUserInfoMutation, useForgottenPasswordMutation, useVerifyUserAttributesQuery, useLazyVerifyUserAttributesQuery, useVerifyUserResendQuery, useLazyVerifyUserResendQuery, useUpdateUserMutation, } = authApi;
|
|
5770
5653
|
|
|
5771
|
-
|
|
5654
|
+
const contentApi = createApi({
|
|
5772
5655
|
reducerPath: 'contentApi',
|
|
5773
5656
|
baseQuery: fetchBaseQuery({
|
|
5774
5657
|
baseUrl: APP_ES_INSTANCE,
|
|
5775
|
-
prepareHeaders:
|
|
5658
|
+
prepareHeaders: (headers) => {
|
|
5776
5659
|
headers.set('Authorization', APP_ES_AUTH);
|
|
5777
5660
|
return headers;
|
|
5778
5661
|
},
|
|
5779
5662
|
}),
|
|
5780
5663
|
tagTypes: ['Data', 'Workout'],
|
|
5781
5664
|
// keepUnusedDataFor: 300,
|
|
5782
|
-
endpoints:
|
|
5665
|
+
endpoints: (builder) => ({
|
|
5783
5666
|
getData: builder.query({
|
|
5784
|
-
query:
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
query: options.query || {
|
|
5794
|
-
match_all: {},
|
|
5795
|
-
},
|
|
5667
|
+
query: ({ index, options = {} }) => ({
|
|
5668
|
+
url: `${index}/_search`,
|
|
5669
|
+
method: 'POST',
|
|
5670
|
+
body: {
|
|
5671
|
+
from: 0,
|
|
5672
|
+
size: options.size || 1000,
|
|
5673
|
+
sort: options.sort || [{ created: { order: 'desc' } }],
|
|
5674
|
+
query: options.query || {
|
|
5675
|
+
match_all: {},
|
|
5796
5676
|
},
|
|
5797
|
-
}
|
|
5798
|
-
},
|
|
5799
|
-
transformResponse:
|
|
5677
|
+
},
|
|
5678
|
+
}),
|
|
5679
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5800
5680
|
providesTags: ['Data'],
|
|
5801
5681
|
}),
|
|
5802
5682
|
getDataById: builder.query({
|
|
5803
|
-
query:
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
query: {
|
|
5813
|
-
terms: (_b = {},
|
|
5814
|
-
_b['uuid.keyword'] = ids,
|
|
5815
|
-
_b),
|
|
5683
|
+
query: ({ index, ids }) => ({
|
|
5684
|
+
url: `${index}/_search`,
|
|
5685
|
+
method: 'POST',
|
|
5686
|
+
body: {
|
|
5687
|
+
from: 0,
|
|
5688
|
+
size: ids.length,
|
|
5689
|
+
query: {
|
|
5690
|
+
terms: {
|
|
5691
|
+
['uuid.keyword']: ids,
|
|
5816
5692
|
},
|
|
5817
5693
|
},
|
|
5818
|
-
}
|
|
5819
|
-
},
|
|
5820
|
-
transformResponse:
|
|
5694
|
+
},
|
|
5695
|
+
}),
|
|
5696
|
+
transformResponse: (response) => response?.hits?.hits,
|
|
5821
5697
|
providesTags: ['Workout'],
|
|
5822
5698
|
}),
|
|
5823
|
-
})
|
|
5699
|
+
}),
|
|
5824
5700
|
});
|
|
5825
|
-
|
|
5701
|
+
const { useGetDataQuery, useLazyGetDataQuery, useGetDataByIdQuery, useLazyGetDataByIdQuery, } = contentApi;
|
|
5826
5702
|
|
|
5827
|
-
|
|
5703
|
+
const paymentApi = createApi({
|
|
5828
5704
|
reducerPath: 'paymentApi',
|
|
5829
5705
|
baseQuery: fetchBaseQuery({
|
|
5830
5706
|
baseUrl: API_PAYMENTS_PREFIX,
|
|
5831
|
-
prepareHeaders:
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
headers.set('idtoken', idToken);
|
|
5845
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5846
|
-
}
|
|
5847
|
-
return [2 /*return*/, headers];
|
|
5848
|
-
}
|
|
5849
|
-
});
|
|
5850
|
-
}); },
|
|
5707
|
+
prepareHeaders: async (headers, {}) => {
|
|
5708
|
+
headers.set('Content-Type', 'application/json');
|
|
5709
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5710
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5711
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5712
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5713
|
+
if (accessToken && idToken) {
|
|
5714
|
+
headers.set('accesstoken', accessToken);
|
|
5715
|
+
headers.set('idtoken', idToken);
|
|
5716
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5717
|
+
}
|
|
5718
|
+
return headers;
|
|
5719
|
+
},
|
|
5851
5720
|
credentials: 'include',
|
|
5852
5721
|
}),
|
|
5853
5722
|
tagTypes: ['UserSubscription', 'Plans', 'TaxRates', 'PromoCodes'],
|
|
5854
5723
|
// keepUnusedDataFor: 300,
|
|
5855
|
-
endpoints:
|
|
5724
|
+
endpoints: (builder) => ({
|
|
5856
5725
|
/**
|
|
5857
5726
|
* USER API.
|
|
5858
5727
|
*/
|
|
5859
5728
|
checkUserSubscription: builder.query({
|
|
5860
|
-
query:
|
|
5729
|
+
query: (data) => ({
|
|
5861
5730
|
url: '/payment/subscriber',
|
|
5862
5731
|
method: 'POST',
|
|
5863
5732
|
body: {
|
|
@@ -5865,119 +5734,99 @@ var paymentApi = createApi({
|
|
|
5865
5734
|
email: data.email,
|
|
5866
5735
|
sub: data.sub,
|
|
5867
5736
|
},
|
|
5868
|
-
})
|
|
5737
|
+
}),
|
|
5869
5738
|
providesTags: ['UserSubscription'],
|
|
5870
5739
|
}),
|
|
5871
5740
|
getPaymentPlans: builder.query({
|
|
5872
|
-
query:
|
|
5741
|
+
query: () => '/payment/plans',
|
|
5873
5742
|
providesTags: ['Plans'],
|
|
5874
5743
|
}),
|
|
5875
5744
|
getTaxRates: builder.query({
|
|
5876
|
-
query:
|
|
5745
|
+
query: () => ({
|
|
5877
5746
|
url: '/payment/tax-rates',
|
|
5878
5747
|
method: 'GET',
|
|
5879
|
-
})
|
|
5748
|
+
}),
|
|
5880
5749
|
providesTags: ['TaxRates'],
|
|
5881
5750
|
}),
|
|
5882
5751
|
checkPromoCode: builder.query({
|
|
5883
|
-
query:
|
|
5884
|
-
url:
|
|
5752
|
+
query: (promoCode) => ({
|
|
5753
|
+
url: `/payment/coupon/${promoCode}`,
|
|
5885
5754
|
method: 'GET',
|
|
5886
|
-
})
|
|
5755
|
+
}),
|
|
5887
5756
|
providesTags: ['PromoCodes'],
|
|
5888
5757
|
}),
|
|
5889
|
-
})
|
|
5758
|
+
}),
|
|
5890
5759
|
});
|
|
5891
5760
|
// Export hooks for usage in functional components.
|
|
5892
|
-
|
|
5761
|
+
const { useCheckUserSubscriptionQuery, useLazyCheckUserSubscriptionQuery, useGetPaymentPlansQuery, useLazyGetPaymentPlansQuery, useGetTaxRatesQuery, useLazyGetTaxRatesQuery, useCheckPromoCodeQuery, useLazyCheckPromoCodeQuery, } = paymentApi;
|
|
5893
5762
|
|
|
5894
|
-
|
|
5763
|
+
const dataBaseQuery = fetchBaseQuery({
|
|
5895
5764
|
baseUrl: API_ORDERS_PREFIX,
|
|
5896
|
-
prepareHeaders:
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
headers.set('idtoken', idToken);
|
|
5910
|
-
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5911
|
-
}
|
|
5912
|
-
return [2 /*return*/, headers];
|
|
5913
|
-
}
|
|
5914
|
-
});
|
|
5915
|
-
}); },
|
|
5765
|
+
prepareHeaders: async (headers, {}) => {
|
|
5766
|
+
headers.set('Content-Type', 'application/json');
|
|
5767
|
+
// add accessToken to headers from slice using selectAccessToken selector
|
|
5768
|
+
const session = await awsAmplify.Auth.currentSession();
|
|
5769
|
+
const idToken = session.getIdToken().getJwtToken(); // ID token
|
|
5770
|
+
const accessToken = session.getAccessToken().getJwtToken(); // Access token
|
|
5771
|
+
if (accessToken && idToken) {
|
|
5772
|
+
headers.set('accesstoken', accessToken);
|
|
5773
|
+
headers.set('idtoken', idToken);
|
|
5774
|
+
// headers.set('refreshtoken', tokens.refreshToken);
|
|
5775
|
+
}
|
|
5776
|
+
return headers;
|
|
5777
|
+
},
|
|
5916
5778
|
credentials: 'include',
|
|
5917
5779
|
});
|
|
5918
5780
|
/**
|
|
5919
5781
|
* This function is used to retry a request if we get a 401 error.
|
|
5920
5782
|
*/
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
user = formatAuthSession(authSession);
|
|
5936
|
-
api.dispatch(setCredentials(user));
|
|
5937
|
-
if (!(authSession === null || authSession === void 0 ? void 0 : authSession.tokens)) return [3 /*break*/, 4];
|
|
5938
|
-
return [4 /*yield*/, dataBaseQuery(args, api, extraOptions)];
|
|
5939
|
-
case 3:
|
|
5940
|
-
// If we get a new access token, retry the original request.
|
|
5941
|
-
result = _b.sent();
|
|
5942
|
-
return [3 /*break*/, 6];
|
|
5943
|
-
case 4:
|
|
5783
|
+
const dataBaseQueryWithReauth = async (args, api, extraOptions) => {
|
|
5784
|
+
let result = await dataBaseQuery(args, api, extraOptions);
|
|
5785
|
+
// If we get a 401 error
|
|
5786
|
+
if (result?.error?.status === 401) {
|
|
5787
|
+
const authSession = await awsAmplify.Auth.currentAuthenticatedUser({
|
|
5788
|
+
bypassCache: true, // Ensures that the user is refreshed from the server
|
|
5789
|
+
});
|
|
5790
|
+
const user = formatAuthSession(authSession);
|
|
5791
|
+
api.dispatch(setCredentials(user));
|
|
5792
|
+
if (authSession?.tokens) {
|
|
5793
|
+
// If we get a new access token, retry the original request.
|
|
5794
|
+
result = await dataBaseQuery(args, api, extraOptions);
|
|
5795
|
+
}
|
|
5796
|
+
else {
|
|
5944
5797
|
// TODO; require full data reset?
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
api.dispatch(logout());
|
|
5950
|
-
// If no access token throw error.
|
|
5951
|
-
throw new Error('No access token found');
|
|
5952
|
-
case 6: return [2 /*return*/, result];
|
|
5798
|
+
await awsAmplify.Auth.signOut();
|
|
5799
|
+
api.dispatch(logout());
|
|
5800
|
+
// If no access token throw error.
|
|
5801
|
+
throw new Error('No access token found');
|
|
5953
5802
|
}
|
|
5954
|
-
}
|
|
5955
|
-
|
|
5956
|
-
|
|
5803
|
+
}
|
|
5804
|
+
return result;
|
|
5805
|
+
};
|
|
5806
|
+
const ordersApi = createApi({
|
|
5957
5807
|
reducerPath: 'ordersApi',
|
|
5958
5808
|
baseQuery: dataBaseQueryWithReauth,
|
|
5959
5809
|
tagTypes: ['Orders'],
|
|
5960
5810
|
// keepUnusedDataFor: 300,
|
|
5961
|
-
endpoints:
|
|
5811
|
+
endpoints: (builder) => ({
|
|
5962
5812
|
/**
|
|
5963
5813
|
* USER API.
|
|
5964
5814
|
*/
|
|
5965
5815
|
fetchOrders: builder.query({
|
|
5966
|
-
query:
|
|
5816
|
+
query: (ids) => ({
|
|
5967
5817
|
url: '/order/search',
|
|
5968
5818
|
method: 'POST',
|
|
5969
5819
|
body: {
|
|
5970
|
-
ids
|
|
5820
|
+
ids,
|
|
5971
5821
|
},
|
|
5972
|
-
})
|
|
5822
|
+
}),
|
|
5973
5823
|
}),
|
|
5974
|
-
})
|
|
5824
|
+
}),
|
|
5975
5825
|
});
|
|
5976
5826
|
// Export hooks for usage in functional components.
|
|
5977
|
-
|
|
5827
|
+
const { useFetchOrdersQuery, useLazyFetchOrdersQuery } = ordersApi;
|
|
5978
5828
|
|
|
5979
|
-
|
|
5980
|
-
var initialState = {
|
|
5829
|
+
const initialState = {
|
|
5981
5830
|
addedItems: [],
|
|
5982
5831
|
netTotal: 0,
|
|
5983
5832
|
taxRate: {
|
|
@@ -5996,697 +5845,139 @@ var initialState = {
|
|
|
5996
5845
|
error: false,
|
|
5997
5846
|
open: false,
|
|
5998
5847
|
};
|
|
5999
|
-
|
|
5848
|
+
const cartSlice = toolkit.createSlice({
|
|
6000
5849
|
name: 'cart',
|
|
6001
|
-
initialState
|
|
5850
|
+
initialState,
|
|
6002
5851
|
reducers: {
|
|
6003
|
-
setTaxRate:
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
if (promoCode
|
|
6007
|
-
|
|
5852
|
+
setTaxRate: (state, action) => {
|
|
5853
|
+
const { netTotal, promoCode } = state;
|
|
5854
|
+
let currentTotal = netTotal;
|
|
5855
|
+
if (promoCode?.code) {
|
|
5856
|
+
const data = applyCoupon(promoCode, currentTotal);
|
|
6008
5857
|
currentTotal = data.discountedTotal;
|
|
6009
5858
|
}
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
return
|
|
5859
|
+
const taxAmount = applyTax(action.payload, currentTotal);
|
|
5860
|
+
const grossTotal = currentTotal + taxAmount;
|
|
5861
|
+
return {
|
|
5862
|
+
...state,
|
|
5863
|
+
taxRate: action.payload,
|
|
5864
|
+
taxAmount,
|
|
5865
|
+
grossTotal,
|
|
5866
|
+
};
|
|
6013
5867
|
},
|
|
6014
|
-
resetTaxRate:
|
|
6015
|
-
return
|
|
5868
|
+
resetTaxRate: (state, action) => {
|
|
5869
|
+
return {
|
|
5870
|
+
...state,
|
|
5871
|
+
taxRate: {
|
|
6016
5872
|
country: 'none',
|
|
6017
5873
|
percentage: 0,
|
|
6018
|
-
},
|
|
5874
|
+
},
|
|
5875
|
+
taxAmount: 0,
|
|
5876
|
+
};
|
|
6019
5877
|
},
|
|
6020
|
-
setPromoCode:
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
return
|
|
5878
|
+
setPromoCode: (state, action) => {
|
|
5879
|
+
const { netTotal, taxRate } = state;
|
|
5880
|
+
const data = applyCoupon(action.payload, netTotal);
|
|
5881
|
+
const taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
5882
|
+
const grossTotal = data.discountedTotal + taxAmount;
|
|
5883
|
+
return {
|
|
5884
|
+
...state,
|
|
5885
|
+
promoCode: {
|
|
6026
5886
|
code: data.code,
|
|
6027
5887
|
name: data.code,
|
|
6028
5888
|
discount: data.discount,
|
|
6029
5889
|
discountedAmount: data.discountedAmount,
|
|
6030
|
-
},
|
|
5890
|
+
},
|
|
5891
|
+
taxAmount,
|
|
5892
|
+
grossTotal,
|
|
5893
|
+
};
|
|
6031
5894
|
},
|
|
6032
|
-
removePromoCode:
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
return
|
|
5895
|
+
removePromoCode: (state, action) => {
|
|
5896
|
+
const { netTotal, taxRate } = state;
|
|
5897
|
+
const taxAmount = applyTax(taxRate, netTotal);
|
|
5898
|
+
const grossTotal = netTotal + taxAmount;
|
|
5899
|
+
return {
|
|
5900
|
+
...state,
|
|
5901
|
+
promoCode: initialState.promoCode,
|
|
5902
|
+
taxAmount,
|
|
5903
|
+
grossTotal,
|
|
5904
|
+
};
|
|
6037
5905
|
},
|
|
6038
|
-
addToCart:
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
5906
|
+
addToCart: (state, action) => {
|
|
5907
|
+
const { options, item } = action.payload;
|
|
5908
|
+
const newTotal = state.netTotal + options.selectedPrice;
|
|
5909
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5910
|
+
const grossTotal = newTotal + taxAmount;
|
|
5911
|
+
const addItem = item ? { ...item, options } : null;
|
|
6044
5912
|
if (!addItem) {
|
|
6045
5913
|
return state;
|
|
6046
5914
|
}
|
|
6047
|
-
|
|
6048
|
-
return
|
|
5915
|
+
const addedItems = [...state.addedItems, addItem];
|
|
5916
|
+
return {
|
|
5917
|
+
...state,
|
|
5918
|
+
addedItems: addedItems,
|
|
5919
|
+
netTotal: newTotal,
|
|
5920
|
+
grossTotal: grossTotal,
|
|
5921
|
+
};
|
|
6049
5922
|
},
|
|
6050
|
-
updateCart:
|
|
6051
|
-
|
|
6052
|
-
return
|
|
6053
|
-
|
|
6054
|
-
|
|
5923
|
+
updateCart: (state, action) => {
|
|
5924
|
+
const { options } = action.payload;
|
|
5925
|
+
return {
|
|
5926
|
+
...state,
|
|
5927
|
+
addedItems: state.addedItems.map((item) => item && {
|
|
5928
|
+
...item,
|
|
5929
|
+
options: options,
|
|
5930
|
+
}),
|
|
5931
|
+
};
|
|
6055
5932
|
},
|
|
6056
|
-
removeFromCart:
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
return
|
|
5933
|
+
removeFromCart: (state, action) => {
|
|
5934
|
+
const { id, price } = action.payload;
|
|
5935
|
+
const newTotal = state.netTotal - price;
|
|
5936
|
+
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
5937
|
+
const grossTotal = newTotal + taxAmount;
|
|
5938
|
+
return {
|
|
5939
|
+
...state,
|
|
5940
|
+
addedItems: state.addedItems.filter((item) => item && item.uuid !== id),
|
|
5941
|
+
netTotal: newTotal,
|
|
5942
|
+
grossTotal: grossTotal,
|
|
5943
|
+
};
|
|
6062
5944
|
},
|
|
6063
|
-
toggleCart:
|
|
6064
|
-
return
|
|
5945
|
+
toggleCart: (state, action) => {
|
|
5946
|
+
return {
|
|
5947
|
+
...state,
|
|
5948
|
+
open: action.payload,
|
|
5949
|
+
};
|
|
6065
5950
|
},
|
|
6066
|
-
emptyCart:
|
|
5951
|
+
emptyCart: () => initialState,
|
|
6067
5952
|
},
|
|
6068
5953
|
selectors: {
|
|
6069
|
-
selectMediaInCart:
|
|
6070
|
-
selectCartTotal:
|
|
6071
|
-
selectCartNetTotal:
|
|
6072
|
-
selectCartTaxRate:
|
|
6073
|
-
selectCartTaxAmount:
|
|
6074
|
-
selectCartCount:
|
|
6075
|
-
selectCartStatus:
|
|
6076
|
-
selectPromoCode:
|
|
5954
|
+
selectMediaInCart: (cart) => cart.addedItems,
|
|
5955
|
+
selectCartTotal: (cart) => cart.grossTotal,
|
|
5956
|
+
selectCartNetTotal: (cart) => cart.netTotal,
|
|
5957
|
+
selectCartTaxRate: (cart) => cart.taxRate,
|
|
5958
|
+
selectCartTaxAmount: (cart) => cart.taxAmount,
|
|
5959
|
+
selectCartCount: (cart) => cart.addedItems.length,
|
|
5960
|
+
selectCartStatus: (cart) => cart.open,
|
|
5961
|
+
selectPromoCode: (cart) => cart.promoCode,
|
|
6077
5962
|
},
|
|
6078
5963
|
});
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
return items.map(
|
|
5964
|
+
const { setTaxRate, resetTaxRate, setPromoCode, removePromoCode, addToCart, updateCart, removeFromCart, emptyCart, toggleCart, } = cartSlice.actions;
|
|
5965
|
+
const { selectMediaInCart, selectCartTotal, selectCartNetTotal, selectCartTaxRate, selectCartTaxAmount, selectCartCount, selectCartStatus, selectPromoCode, } = cartSlice.selectors;
|
|
5966
|
+
const selectCartItems = toolkit.createSelector([selectMediaInCart], (items) => {
|
|
5967
|
+
return items.map((item) => {
|
|
6083
5968
|
return {
|
|
6084
5969
|
title: item.title || item.generatedTitle,
|
|
6085
|
-
file:
|
|
5970
|
+
file: `${item.sku}.mp4`,
|
|
6086
5971
|
options: item.options,
|
|
6087
5972
|
script: item.script,
|
|
6088
5973
|
};
|
|
6089
5974
|
});
|
|
6090
5975
|
});
|
|
6091
|
-
|
|
6092
|
-
return items.map(
|
|
5976
|
+
const selectCartItemsIds = toolkit.createSelector([selectMediaInCart], (items) => {
|
|
5977
|
+
return items.map((item) => item.uuid);
|
|
6093
5978
|
});
|
|
6094
5979
|
cartSlice.reducer;
|
|
6095
5980
|
|
|
6096
|
-
var useLoggedIn = function () {
|
|
6097
|
-
var isLoggedIn = reactRedux.useSelector(isAuthenticated);
|
|
6098
|
-
return React.useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
6099
|
-
};
|
|
6100
|
-
|
|
6101
|
-
// This file serves as a central hub for re-exporting pre-typed Redux hooks.
|
|
6102
|
-
// Use throughout your app instead of plain `useDispatch` and `useSelector`
|
|
6103
|
-
var useAppDispatch = isWeb ? reactRedux.useDispatch.withTypes() : reactRedux.useDispatch.withTypes();
|
|
6104
|
-
var useAppSelector = isWeb ? reactRedux.useSelector.withTypes() : reactRedux.useSelector.withTypes();
|
|
6105
|
-
var useAppStore = isWeb ? reactRedux.useStore.withTypes() : reactRedux.useStore.withTypes();
|
|
6106
|
-
|
|
6107
|
-
function getDefaultExportFromCjs (x) {
|
|
6108
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
6109
|
-
}
|
|
6110
|
-
|
|
6111
|
-
var createWebStorage$1 = {};
|
|
6112
|
-
|
|
6113
|
-
var getStorage = {};
|
|
6114
|
-
|
|
6115
|
-
var hasRequiredGetStorage;
|
|
6116
|
-
|
|
6117
|
-
function requireGetStorage () {
|
|
6118
|
-
if (hasRequiredGetStorage) return getStorage;
|
|
6119
|
-
hasRequiredGetStorage = 1;
|
|
6120
|
-
|
|
6121
|
-
getStorage.__esModule = true;
|
|
6122
|
-
getStorage.default = getStorage$1;
|
|
6123
|
-
|
|
6124
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
6125
|
-
|
|
6126
|
-
function noop() {}
|
|
6127
|
-
|
|
6128
|
-
var noopStorage = {
|
|
6129
|
-
getItem: noop,
|
|
6130
|
-
setItem: noop,
|
|
6131
|
-
removeItem: noop
|
|
6132
|
-
};
|
|
6133
|
-
|
|
6134
|
-
function hasStorage(storageType) {
|
|
6135
|
-
if ((typeof self === "undefined" ? "undefined" : _typeof(self)) !== 'object' || !(storageType in self)) {
|
|
6136
|
-
return false;
|
|
6137
|
-
}
|
|
6138
|
-
|
|
6139
|
-
try {
|
|
6140
|
-
var storage = self[storageType];
|
|
6141
|
-
var testKey = "redux-persist ".concat(storageType, " test");
|
|
6142
|
-
storage.setItem(testKey, 'test');
|
|
6143
|
-
storage.getItem(testKey);
|
|
6144
|
-
storage.removeItem(testKey);
|
|
6145
|
-
} catch (e) {
|
|
6146
|
-
if (process.env.NODE_ENV !== 'production') console.warn("redux-persist ".concat(storageType, " test failed, persistence will be disabled."));
|
|
6147
|
-
return false;
|
|
6148
|
-
}
|
|
6149
|
-
|
|
6150
|
-
return true;
|
|
6151
|
-
}
|
|
6152
|
-
|
|
6153
|
-
function getStorage$1(type) {
|
|
6154
|
-
var storageType = "".concat(type, "Storage");
|
|
6155
|
-
if (hasStorage(storageType)) return self[storageType];else {
|
|
6156
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
6157
|
-
console.error("redux-persist failed to create sync storage. falling back to noop storage.");
|
|
6158
|
-
}
|
|
6159
|
-
|
|
6160
|
-
return noopStorage;
|
|
6161
|
-
}
|
|
6162
|
-
}
|
|
6163
|
-
return getStorage;
|
|
6164
|
-
}
|
|
6165
|
-
|
|
6166
|
-
var hasRequiredCreateWebStorage;
|
|
6167
|
-
|
|
6168
|
-
function requireCreateWebStorage () {
|
|
6169
|
-
if (hasRequiredCreateWebStorage) return createWebStorage$1;
|
|
6170
|
-
hasRequiredCreateWebStorage = 1;
|
|
6171
|
-
|
|
6172
|
-
createWebStorage$1.__esModule = true;
|
|
6173
|
-
createWebStorage$1.default = createWebStorage;
|
|
6174
|
-
|
|
6175
|
-
var _getStorage = _interopRequireDefault(requireGetStorage());
|
|
6176
|
-
|
|
6177
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6178
|
-
|
|
6179
|
-
function createWebStorage(type) {
|
|
6180
|
-
var storage = (0, _getStorage.default)(type);
|
|
6181
|
-
return {
|
|
6182
|
-
getItem: function getItem(key) {
|
|
6183
|
-
return new Promise(function (resolve, reject) {
|
|
6184
|
-
resolve(storage.getItem(key));
|
|
6185
|
-
});
|
|
6186
|
-
},
|
|
6187
|
-
setItem: function setItem(key, item) {
|
|
6188
|
-
return new Promise(function (resolve, reject) {
|
|
6189
|
-
resolve(storage.setItem(key, item));
|
|
6190
|
-
});
|
|
6191
|
-
},
|
|
6192
|
-
removeItem: function removeItem(key) {
|
|
6193
|
-
return new Promise(function (resolve, reject) {
|
|
6194
|
-
resolve(storage.removeItem(key));
|
|
6195
|
-
});
|
|
6196
|
-
}
|
|
6197
|
-
};
|
|
6198
|
-
}
|
|
6199
|
-
return createWebStorage$1;
|
|
6200
|
-
}
|
|
6201
|
-
|
|
6202
|
-
var createWebStorageExports = requireCreateWebStorage();
|
|
6203
|
-
var createWebStorage = /*@__PURE__*/getDefaultExportFromCjs(createWebStorageExports);
|
|
6204
|
-
|
|
6205
|
-
// @ts-expect-error - required for module alias
|
|
6206
|
-
function createPersistStorage() {
|
|
6207
|
-
var isServer = typeof window === 'undefined';
|
|
6208
|
-
// Returns noop (dummy) storage.
|
|
6209
|
-
if (isServer) {
|
|
6210
|
-
return {
|
|
6211
|
-
getItem: function () {
|
|
6212
|
-
return Promise.resolve(null);
|
|
6213
|
-
},
|
|
6214
|
-
setItem: function () {
|
|
6215
|
-
return Promise.resolve();
|
|
6216
|
-
},
|
|
6217
|
-
removeItem: function () {
|
|
6218
|
-
return Promise.resolve();
|
|
6219
|
-
},
|
|
6220
|
-
};
|
|
6221
|
-
}
|
|
6222
|
-
return createWebStorage('local');
|
|
6223
|
-
}
|
|
6224
|
-
|
|
6225
|
-
// Infer the `RootState` type from the root reducer
|
|
6226
|
-
var rootReducer = toolkit.combineSlices(cartSlice, authSlice, authApi, contentApi, paymentApi, ordersApi);
|
|
6227
|
-
// eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
|
|
6228
|
-
// const storageWhiteList: string[] = [];
|
|
6229
|
-
var storageBlackList = [];
|
|
6230
|
-
// `makeStore` encapsulates the store configuration to allow
|
|
6231
|
-
// creating unique store instances, which is particularly important for
|
|
6232
|
-
// server-side rendering (SSR) scenarios. In SSR, separate store instances
|
|
6233
|
-
// are needed for each request to prevent cross-request state pollution.
|
|
6234
|
-
var makeNativeStore = function () {
|
|
6235
|
-
var customEnhancers = [];
|
|
6236
|
-
// const Platform = require('react-native').Platform;
|
|
6237
|
-
var Platform = import('react-native').then(function (mod) { return mod.Platform; }).catch(function () { return ({}); });
|
|
6238
|
-
console.log('makeNativeStore Platform', Platform);
|
|
6239
|
-
var reducer;
|
|
6240
|
-
var FLUSH;
|
|
6241
|
-
var REHYDRATE;
|
|
6242
|
-
var PAUSE;
|
|
6243
|
-
var PERSIST;
|
|
6244
|
-
var PURGE;
|
|
6245
|
-
var REGISTER;
|
|
6246
|
-
if (Platform.OS !== 'web' && !Platform.isTV) {
|
|
6247
|
-
var reduxPersist = require('redux-persist');
|
|
6248
|
-
var persistReducer = require('redux-persist').persistReducer;
|
|
6249
|
-
FLUSH = reduxPersist.FLUSH;
|
|
6250
|
-
REHYDRATE = reduxPersist.REHYDRATE;
|
|
6251
|
-
PAUSE = reduxPersist.PAUSE;
|
|
6252
|
-
PERSIST = reduxPersist.PERSIST;
|
|
6253
|
-
PURGE = reduxPersist.PURGE;
|
|
6254
|
-
REGISTER = reduxPersist.REGISTER;
|
|
6255
|
-
storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath, ordersApi.reducerPath);
|
|
6256
|
-
// const storage =
|
|
6257
|
-
// require('@react-native-async-storage/async-storage').default;
|
|
6258
|
-
var storage = Promise.resolve().then(function () { return index; }).then(function (mod) { return mod.default; }).catch(function () { return ({}); });
|
|
6259
|
-
var persistConfig = {
|
|
6260
|
-
key: 'root',
|
|
6261
|
-
storage: storage,
|
|
6262
|
-
// whitelist: storageWhiteList,
|
|
6263
|
-
blacklist: storageBlackList,
|
|
6264
|
-
};
|
|
6265
|
-
var persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
6266
|
-
reducer = persistedReducer;
|
|
6267
|
-
}
|
|
6268
|
-
else {
|
|
6269
|
-
reducer = rootReducer;
|
|
6270
|
-
}
|
|
6271
|
-
var middlewares = [
|
|
6272
|
-
authApi.middleware,
|
|
6273
|
-
contentApi.middleware,
|
|
6274
|
-
paymentApi.middleware,
|
|
6275
|
-
ordersApi.middleware,
|
|
6276
|
-
];
|
|
6277
|
-
return toolkit.configureStore({
|
|
6278
|
-
reducer: reducer,
|
|
6279
|
-
// Adding the api middleware enables caching, invalidation, polling,
|
|
6280
|
-
// and other useful features of `rtk-query`.
|
|
6281
|
-
middleware: function (getDefaultMiddleware) {
|
|
6282
|
-
return getDefaultMiddleware({
|
|
6283
|
-
immutableCheck: { warnAfter: 256 },
|
|
6284
|
-
serializableCheck: {
|
|
6285
|
-
warnAfter: 256,
|
|
6286
|
-
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
|
6287
|
-
},
|
|
6288
|
-
}).concat(middlewares);
|
|
6289
|
-
},
|
|
6290
|
-
enhancers: function (getDefaultEnhancers) {
|
|
6291
|
-
return getDefaultEnhancers().concat(customEnhancers);
|
|
6292
|
-
},
|
|
6293
|
-
});
|
|
6294
|
-
};
|
|
6295
|
-
var makeWebStore = function () {
|
|
6296
|
-
var reduxPersist = require('redux-persist');
|
|
6297
|
-
var persistReducer = require('redux-persist').persistReducer;
|
|
6298
|
-
var FLUSH = reduxPersist.FLUSH;
|
|
6299
|
-
var REHYDRATE = reduxPersist.REHYDRATE;
|
|
6300
|
-
var PAUSE = reduxPersist.PAUSE;
|
|
6301
|
-
var PERSIST = reduxPersist.PERSIST;
|
|
6302
|
-
var PURGE = reduxPersist.PURGE;
|
|
6303
|
-
var REGISTER = reduxPersist.REGISTER;
|
|
6304
|
-
var storage = createPersistStorage();
|
|
6305
|
-
storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath, ordersApi.reducerPath);
|
|
6306
|
-
var persistConfig = {
|
|
6307
|
-
key: 'root',
|
|
6308
|
-
storage: storage,
|
|
6309
|
-
// whitelist: storageWhiteList,
|
|
6310
|
-
blacklist: storageBlackList,
|
|
6311
|
-
};
|
|
6312
|
-
var middlewares = [
|
|
6313
|
-
authApi.middleware,
|
|
6314
|
-
contentApi.middleware,
|
|
6315
|
-
paymentApi.middleware,
|
|
6316
|
-
ordersApi.middleware,
|
|
6317
|
-
];
|
|
6318
|
-
// `combineSlices` automatically combines the reducers using
|
|
6319
|
-
// their `reducerPath`s, therefore we no longer need to call `combineReducers`.
|
|
6320
|
-
var persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
6321
|
-
var customEnhancers = [];
|
|
6322
|
-
return toolkit.configureStore({
|
|
6323
|
-
reducer: persistedReducer,
|
|
6324
|
-
// Adding the api middleware enables caching, invalidation, polling,
|
|
6325
|
-
// and other useful features of `rtk-query`.
|
|
6326
|
-
middleware: function (getDefaultMiddleware) {
|
|
6327
|
-
return getDefaultMiddleware({
|
|
6328
|
-
immutableCheck: { warnAfter: 256 },
|
|
6329
|
-
serializableCheck: {
|
|
6330
|
-
warnAfter: 256,
|
|
6331
|
-
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
|
6332
|
-
},
|
|
6333
|
-
}).concat(middlewares);
|
|
6334
|
-
},
|
|
6335
|
-
enhancers: function (getDefaultEnhancers) {
|
|
6336
|
-
return getDefaultEnhancers().concat(customEnhancers);
|
|
6337
|
-
},
|
|
6338
|
-
});
|
|
6339
|
-
};
|
|
6340
|
-
var nativeStore = !isWeb ? makeNativeStore() : undefined;
|
|
6341
|
-
var webStore = isWeb ? makeWebStore() : undefined;
|
|
6342
|
-
|
|
6343
|
-
const Config = reactNative.NativeModules.RNCConfigModule || {};
|
|
6344
|
-
|
|
6345
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
6346
|
-
__proto__: null,
|
|
6347
|
-
Config: Config,
|
|
6348
|
-
default: Config
|
|
6349
|
-
});
|
|
6350
|
-
|
|
6351
|
-
var isPlainObj;
|
|
6352
|
-
var hasRequiredIsPlainObj;
|
|
6353
|
-
|
|
6354
|
-
function requireIsPlainObj () {
|
|
6355
|
-
if (hasRequiredIsPlainObj) return isPlainObj;
|
|
6356
|
-
hasRequiredIsPlainObj = 1;
|
|
6357
|
-
|
|
6358
|
-
isPlainObj = value => {
|
|
6359
|
-
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
6360
|
-
return false;
|
|
6361
|
-
}
|
|
6362
|
-
|
|
6363
|
-
const prototype = Object.getPrototypeOf(value);
|
|
6364
|
-
return prototype === null || prototype === Object.prototype;
|
|
6365
|
-
};
|
|
6366
|
-
return isPlainObj;
|
|
6367
|
-
}
|
|
6368
|
-
|
|
6369
|
-
var mergeOptions$1;
|
|
6370
|
-
var hasRequiredMergeOptions;
|
|
6371
|
-
|
|
6372
|
-
function requireMergeOptions () {
|
|
6373
|
-
if (hasRequiredMergeOptions) return mergeOptions$1;
|
|
6374
|
-
hasRequiredMergeOptions = 1;
|
|
6375
|
-
const isOptionObject = requireIsPlainObj();
|
|
6376
|
-
|
|
6377
|
-
const {hasOwnProperty} = Object.prototype;
|
|
6378
|
-
const {propertyIsEnumerable} = Object;
|
|
6379
|
-
const defineProperty = (object, name, value) => Object.defineProperty(object, name, {
|
|
6380
|
-
value,
|
|
6381
|
-
writable: true,
|
|
6382
|
-
enumerable: true,
|
|
6383
|
-
configurable: true
|
|
6384
|
-
});
|
|
6385
|
-
|
|
6386
|
-
const globalThis = mergeOptions$1;
|
|
6387
|
-
const defaultMergeOptions = {
|
|
6388
|
-
concatArrays: false,
|
|
6389
|
-
ignoreUndefined: false
|
|
6390
|
-
};
|
|
6391
|
-
|
|
6392
|
-
const getEnumerableOwnPropertyKeys = value => {
|
|
6393
|
-
const keys = [];
|
|
6394
|
-
|
|
6395
|
-
for (const key in value) {
|
|
6396
|
-
if (hasOwnProperty.call(value, key)) {
|
|
6397
|
-
keys.push(key);
|
|
6398
|
-
}
|
|
6399
|
-
}
|
|
6400
|
-
|
|
6401
|
-
/* istanbul ignore else */
|
|
6402
|
-
if (Object.getOwnPropertySymbols) {
|
|
6403
|
-
const symbols = Object.getOwnPropertySymbols(value);
|
|
6404
|
-
|
|
6405
|
-
for (const symbol of symbols) {
|
|
6406
|
-
if (propertyIsEnumerable.call(value, symbol)) {
|
|
6407
|
-
keys.push(symbol);
|
|
6408
|
-
}
|
|
6409
|
-
}
|
|
6410
|
-
}
|
|
6411
|
-
|
|
6412
|
-
return keys;
|
|
6413
|
-
};
|
|
6414
|
-
|
|
6415
|
-
function clone(value) {
|
|
6416
|
-
if (Array.isArray(value)) {
|
|
6417
|
-
return cloneArray(value);
|
|
6418
|
-
}
|
|
6419
|
-
|
|
6420
|
-
if (isOptionObject(value)) {
|
|
6421
|
-
return cloneOptionObject(value);
|
|
6422
|
-
}
|
|
6423
|
-
|
|
6424
|
-
return value;
|
|
6425
|
-
}
|
|
6426
|
-
|
|
6427
|
-
function cloneArray(array) {
|
|
6428
|
-
const result = array.slice(0, 0);
|
|
6429
|
-
|
|
6430
|
-
getEnumerableOwnPropertyKeys(array).forEach(key => {
|
|
6431
|
-
defineProperty(result, key, clone(array[key]));
|
|
6432
|
-
});
|
|
6433
|
-
|
|
6434
|
-
return result;
|
|
6435
|
-
}
|
|
6436
|
-
|
|
6437
|
-
function cloneOptionObject(object) {
|
|
6438
|
-
const result = Object.getPrototypeOf(object) === null ? Object.create(null) : {};
|
|
6439
|
-
|
|
6440
|
-
getEnumerableOwnPropertyKeys(object).forEach(key => {
|
|
6441
|
-
defineProperty(result, key, clone(object[key]));
|
|
6442
|
-
});
|
|
6443
|
-
|
|
6444
|
-
return result;
|
|
6445
|
-
}
|
|
6446
|
-
|
|
6447
|
-
/**
|
|
6448
|
-
* @param {*} merged already cloned
|
|
6449
|
-
* @param {*} source something to merge
|
|
6450
|
-
* @param {string[]} keys keys to merge
|
|
6451
|
-
* @param {Object} config Config Object
|
|
6452
|
-
* @returns {*} cloned Object
|
|
6453
|
-
*/
|
|
6454
|
-
const mergeKeys = (merged, source, keys, config) => {
|
|
6455
|
-
keys.forEach(key => {
|
|
6456
|
-
if (typeof source[key] === 'undefined' && config.ignoreUndefined) {
|
|
6457
|
-
return;
|
|
6458
|
-
}
|
|
6459
|
-
|
|
6460
|
-
// Do not recurse into prototype chain of merged
|
|
6461
|
-
if (key in merged && merged[key] !== Object.getPrototypeOf(merged)) {
|
|
6462
|
-
defineProperty(merged, key, merge(merged[key], source[key], config));
|
|
6463
|
-
} else {
|
|
6464
|
-
defineProperty(merged, key, clone(source[key]));
|
|
6465
|
-
}
|
|
6466
|
-
});
|
|
6467
|
-
|
|
6468
|
-
return merged;
|
|
6469
|
-
};
|
|
6470
|
-
|
|
6471
|
-
/**
|
|
6472
|
-
* @param {*} merged already cloned
|
|
6473
|
-
* @param {*} source something to merge
|
|
6474
|
-
* @param {Object} config Config Object
|
|
6475
|
-
* @returns {*} cloned Object
|
|
6476
|
-
*
|
|
6477
|
-
* see [Array.prototype.concat ( ...arguments )](http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat)
|
|
6478
|
-
*/
|
|
6479
|
-
const concatArrays = (merged, source, config) => {
|
|
6480
|
-
let result = merged.slice(0, 0);
|
|
6481
|
-
let resultIndex = 0;
|
|
6482
|
-
|
|
6483
|
-
[merged, source].forEach(array => {
|
|
6484
|
-
const indices = [];
|
|
6485
|
-
|
|
6486
|
-
// `result.concat(array)` with cloning
|
|
6487
|
-
for (let k = 0; k < array.length; k++) {
|
|
6488
|
-
if (!hasOwnProperty.call(array, k)) {
|
|
6489
|
-
continue;
|
|
6490
|
-
}
|
|
6491
|
-
|
|
6492
|
-
indices.push(String(k));
|
|
6493
|
-
|
|
6494
|
-
if (array === merged) {
|
|
6495
|
-
// Already cloned
|
|
6496
|
-
defineProperty(result, resultIndex++, array[k]);
|
|
6497
|
-
} else {
|
|
6498
|
-
defineProperty(result, resultIndex++, clone(array[k]));
|
|
6499
|
-
}
|
|
6500
|
-
}
|
|
6501
|
-
|
|
6502
|
-
// Merge non-index keys
|
|
6503
|
-
result = mergeKeys(result, array, getEnumerableOwnPropertyKeys(array).filter(key => !indices.includes(key)), config);
|
|
6504
|
-
});
|
|
6505
|
-
|
|
6506
|
-
return result;
|
|
6507
|
-
};
|
|
6508
|
-
|
|
6509
|
-
/**
|
|
6510
|
-
* @param {*} merged already cloned
|
|
6511
|
-
* @param {*} source something to merge
|
|
6512
|
-
* @param {Object} config Config Object
|
|
6513
|
-
* @returns {*} cloned Object
|
|
6514
|
-
*/
|
|
6515
|
-
function merge(merged, source, config) {
|
|
6516
|
-
if (config.concatArrays && Array.isArray(merged) && Array.isArray(source)) {
|
|
6517
|
-
return concatArrays(merged, source, config);
|
|
6518
|
-
}
|
|
6519
|
-
|
|
6520
|
-
if (!isOptionObject(source) || !isOptionObject(merged)) {
|
|
6521
|
-
return clone(source);
|
|
6522
|
-
}
|
|
6523
|
-
|
|
6524
|
-
return mergeKeys(merged, source, getEnumerableOwnPropertyKeys(source), config);
|
|
6525
|
-
}
|
|
6526
|
-
|
|
6527
|
-
mergeOptions$1 = function (...options) {
|
|
6528
|
-
const config = merge(clone(defaultMergeOptions), (this !== globalThis && this) || {}, defaultMergeOptions);
|
|
6529
|
-
let merged = {_: {}};
|
|
6530
|
-
|
|
6531
|
-
for (const option of options) {
|
|
6532
|
-
if (option === undefined) {
|
|
6533
|
-
continue;
|
|
6534
|
-
}
|
|
6535
|
-
|
|
6536
|
-
if (!isOptionObject(option)) {
|
|
6537
|
-
throw new TypeError('`' + option + '` is not an Option Object');
|
|
6538
|
-
}
|
|
6539
|
-
|
|
6540
|
-
merged = merge(merged, {_: option}, config);
|
|
6541
|
-
}
|
|
6542
|
-
|
|
6543
|
-
return merged._;
|
|
6544
|
-
};
|
|
6545
|
-
return mergeOptions$1;
|
|
6546
|
-
}
|
|
6547
|
-
|
|
6548
|
-
var mergeOptionsExports = requireMergeOptions();
|
|
6549
|
-
var mergeOptions = /*@__PURE__*/getDefaultExportFromCjs(mergeOptionsExports);
|
|
6550
|
-
|
|
6551
|
-
/**
|
|
6552
|
-
* Thin ESM wrapper for CJS named exports.
|
|
6553
|
-
*
|
|
6554
|
-
* Ref: https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1
|
|
6555
|
-
*/
|
|
6556
|
-
|
|
6557
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6558
|
-
|
|
6559
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6560
|
-
|
|
6561
|
-
const merge = mergeOptions.bind({
|
|
6562
|
-
concatArrays: true,
|
|
6563
|
-
ignoreUndefined: true
|
|
6564
|
-
});
|
|
6565
|
-
function mergeLocalStorageItem(key, value) {
|
|
6566
|
-
const oldValue = window.localStorage.getItem(key);
|
|
6567
|
-
if (oldValue) {
|
|
6568
|
-
const oldObject = JSON.parse(oldValue);
|
|
6569
|
-
const newObject = JSON.parse(value);
|
|
6570
|
-
const nextValue = JSON.stringify(merge(oldObject, newObject));
|
|
6571
|
-
window.localStorage.setItem(key, nextValue);
|
|
6572
|
-
} else {
|
|
6573
|
-
window.localStorage.setItem(key, value);
|
|
6574
|
-
}
|
|
6575
|
-
}
|
|
6576
|
-
function createPromise(getValue, callback) {
|
|
6577
|
-
return new Promise((resolve, reject) => {
|
|
6578
|
-
try {
|
|
6579
|
-
const value = getValue();
|
|
6580
|
-
callback?.(null, value);
|
|
6581
|
-
resolve(value);
|
|
6582
|
-
} catch (err) {
|
|
6583
|
-
callback?.(err);
|
|
6584
|
-
reject(err);
|
|
6585
|
-
}
|
|
6586
|
-
});
|
|
6587
|
-
}
|
|
6588
|
-
function createPromiseAll(promises, callback, processResult) {
|
|
6589
|
-
return Promise.all(promises).then(result => {
|
|
6590
|
-
const value = processResult?.(result) ?? null;
|
|
6591
|
-
callback?.(null, value);
|
|
6592
|
-
return Promise.resolve(value);
|
|
6593
|
-
}, errors => {
|
|
6594
|
-
callback?.(errors);
|
|
6595
|
-
return Promise.reject(errors);
|
|
6596
|
-
});
|
|
6597
|
-
}
|
|
6598
|
-
const AsyncStorage = {
|
|
6599
|
-
/**
|
|
6600
|
-
* Fetches `key` value.
|
|
6601
|
-
*/
|
|
6602
|
-
getItem: (key, callback) => {
|
|
6603
|
-
return createPromise(() => window.localStorage.getItem(key), callback);
|
|
6604
|
-
},
|
|
6605
|
-
/**
|
|
6606
|
-
* Sets `value` for `key`.
|
|
6607
|
-
*/
|
|
6608
|
-
setItem: (key, value, callback) => {
|
|
6609
|
-
return createPromise(() => window.localStorage.setItem(key, value), callback);
|
|
6610
|
-
},
|
|
6611
|
-
/**
|
|
6612
|
-
* Removes a `key`
|
|
6613
|
-
*/
|
|
6614
|
-
removeItem: (key, callback) => {
|
|
6615
|
-
return createPromise(() => window.localStorage.removeItem(key), callback);
|
|
6616
|
-
},
|
|
6617
|
-
/**
|
|
6618
|
-
* Merges existing value with input value, assuming they are stringified JSON.
|
|
6619
|
-
*/
|
|
6620
|
-
mergeItem: (key, value, callback) => {
|
|
6621
|
-
return createPromise(() => mergeLocalStorageItem(key, value), callback);
|
|
6622
|
-
},
|
|
6623
|
-
/**
|
|
6624
|
-
* Erases *all* AsyncStorage for the domain.
|
|
6625
|
-
*/
|
|
6626
|
-
clear: callback => {
|
|
6627
|
-
return createPromise(() => window.localStorage.clear(), callback);
|
|
6628
|
-
},
|
|
6629
|
-
/**
|
|
6630
|
-
* Gets *all* keys known to the app, for all callers, libraries, etc.
|
|
6631
|
-
*/
|
|
6632
|
-
getAllKeys: callback => {
|
|
6633
|
-
return createPromise(() => {
|
|
6634
|
-
const numberOfKeys = window.localStorage.length;
|
|
6635
|
-
const keys = [];
|
|
6636
|
-
for (let i = 0; i < numberOfKeys; i += 1) {
|
|
6637
|
-
const key = window.localStorage.key(i) || "";
|
|
6638
|
-
keys.push(key);
|
|
6639
|
-
}
|
|
6640
|
-
return keys;
|
|
6641
|
-
}, callback);
|
|
6642
|
-
},
|
|
6643
|
-
/**
|
|
6644
|
-
* (stub) Flushes any pending requests using a single batch call to get the data.
|
|
6645
|
-
*/
|
|
6646
|
-
flushGetRequests: () => undefined,
|
|
6647
|
-
/**
|
|
6648
|
-
* multiGet resolves to an array of key-value pair arrays that matches the
|
|
6649
|
-
* input format of multiSet.
|
|
6650
|
-
*
|
|
6651
|
-
* multiGet(['k1', 'k2']) -> [['k1', 'val1'], ['k2', 'val2']]
|
|
6652
|
-
*/
|
|
6653
|
-
multiGet: (keys, callback) => {
|
|
6654
|
-
const promises = keys.map(key => AsyncStorage.getItem(key));
|
|
6655
|
-
const processResult = result => result.map((value, i) => [keys[i], value]);
|
|
6656
|
-
return createPromiseAll(promises, callback, processResult);
|
|
6657
|
-
},
|
|
6658
|
-
/**
|
|
6659
|
-
* Takes an array of key-value array pairs.
|
|
6660
|
-
* multiSet([['k1', 'val1'], ['k2', 'val2']])
|
|
6661
|
-
*/
|
|
6662
|
-
multiSet: (keyValuePairs, callback) => {
|
|
6663
|
-
const promises = keyValuePairs.map(item => AsyncStorage.setItem(item[0], item[1]));
|
|
6664
|
-
return createPromiseAll(promises, callback);
|
|
6665
|
-
},
|
|
6666
|
-
/**
|
|
6667
|
-
* Delete all the keys in the `keys` array.
|
|
6668
|
-
*/
|
|
6669
|
-
multiRemove: (keys, callback) => {
|
|
6670
|
-
const promises = keys.map(key => AsyncStorage.removeItem(key));
|
|
6671
|
-
return createPromiseAll(promises, callback);
|
|
6672
|
-
},
|
|
6673
|
-
/**
|
|
6674
|
-
* Takes an array of key-value array pairs and merges them with existing
|
|
6675
|
-
* values, assuming they are stringified JSON.
|
|
6676
|
-
*
|
|
6677
|
-
* multiMerge([['k1', 'val1'], ['k2', 'val2']])
|
|
6678
|
-
*/
|
|
6679
|
-
multiMerge: (keyValuePairs, callback) => {
|
|
6680
|
-
const promises = keyValuePairs.map(item => AsyncStorage.mergeItem(item[0], item[1]));
|
|
6681
|
-
return createPromiseAll(promises, callback);
|
|
6682
|
-
}
|
|
6683
|
-
};
|
|
6684
|
-
|
|
6685
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
6686
|
-
__proto__: null,
|
|
6687
|
-
default: AsyncStorage
|
|
6688
|
-
});
|
|
6689
|
-
|
|
6690
5981
|
exports.addToCart = addToCart;
|
|
6691
5982
|
exports.authApi = authApi;
|
|
6692
5983
|
exports.authSlice = authSlice;
|
|
@@ -6723,7 +6014,6 @@ exports.getUserSession = getUserSession;
|
|
|
6723
6014
|
exports.isAuthenticated = isAuthenticated;
|
|
6724
6015
|
exports.isVerifying = isVerifying;
|
|
6725
6016
|
exports.logout = logout;
|
|
6726
|
-
exports.nativeStore = nativeStore;
|
|
6727
6017
|
exports.ordersApi = ordersApi;
|
|
6728
6018
|
exports.paymentApi = paymentApi;
|
|
6729
6019
|
exports.removeFromCart = removeFromCart;
|
|
@@ -6755,16 +6045,12 @@ exports.setTaxRate = setTaxRate;
|
|
|
6755
6045
|
exports.toggleCart = toggleCart;
|
|
6756
6046
|
exports.updateCart = updateCart;
|
|
6757
6047
|
exports.updateSubscription = updateSubscription;
|
|
6758
|
-
exports.useAppDispatch = useAppDispatch;
|
|
6759
|
-
exports.useAppSelector = useAppSelector;
|
|
6760
|
-
exports.useAppStore = useAppStore;
|
|
6761
6048
|
exports.useForgottenPasswordMutation = useForgottenPasswordMutation;
|
|
6762
6049
|
exports.useGetUserInfoQuery = useGetUserInfoQuery;
|
|
6763
6050
|
exports.useLazyGetUserInfoQuery = useLazyGetUserInfoQuery;
|
|
6764
6051
|
exports.useLazyVerifyUserAttributesQuery = useLazyVerifyUserAttributesQuery;
|
|
6765
6052
|
exports.useLazyVerifyUserQuery = useLazyVerifyUserQuery;
|
|
6766
6053
|
exports.useLazyVerifyUserResendQuery = useLazyVerifyUserResendQuery;
|
|
6767
|
-
exports.useLoggedIn = useLoggedIn;
|
|
6768
6054
|
exports.useRegisterMutation = useRegisterMutation;
|
|
6769
6055
|
exports.useResetPasswordAuthMutation = useResetPasswordAuthMutation;
|
|
6770
6056
|
exports.useResetPasswordMutation = useResetPasswordMutation;
|
|
@@ -6773,5 +6059,4 @@ exports.useUpdateUserMutation = useUpdateUserMutation;
|
|
|
6773
6059
|
exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
|
|
6774
6060
|
exports.useVerifyUserQuery = useVerifyUserQuery;
|
|
6775
6061
|
exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
|
|
6776
|
-
|
|
6777
|
-
//# sourceMappingURL=index.js.map
|
|
6062
|
+
//# sourceMappingURL=slice-CAWa47E3.js.map
|