@techstuff-dev/foundation-api-utils 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/lib/hooks/index.d.ts +4 -4
- package/dist/@types/lib/services/cart/slice.d.ts +155 -0
- package/dist/@types/lib/services/content/content.interfaces.d.ts +59 -3
- package/dist/@types/lib/services/index.d.ts +1 -0
- package/dist/@types/lib/store/index.d.ts +10 -10
- package/dist/@types/lib/utils/dataFormat/index.d.ts +2 -1
- package/dist/@types/lib/utils/helpers/index.d.ts +12 -0
- package/dist/index.esm.js +185 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +204 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fetchBaseQuery, createApi } from '@reduxjs/toolkit/query/react';
|
|
2
2
|
import { Auth } from 'aws-amplify';
|
|
3
|
-
import { createSlice, combineSlices, configureStore } from '@reduxjs/toolkit';
|
|
3
|
+
import { createSlice, createSelector, combineSlices, configureStore } from '@reduxjs/toolkit';
|
|
4
4
|
import { jwtDecode } from 'jwt-decode';
|
|
5
5
|
import { useSelector, useDispatch, useStore } from 'react-redux';
|
|
6
6
|
import { useMemo } from 'react';
|
|
@@ -73,13 +73,23 @@ function __generator(thisArg, body) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
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
|
+
|
|
76
86
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
77
87
|
var e = new Error(message);
|
|
78
88
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
var _a$
|
|
82
|
-
var initialState = {
|
|
91
|
+
var _a$2, _b$2;
|
|
92
|
+
var initialState$1 = {
|
|
83
93
|
authenticated: false,
|
|
84
94
|
verifying: false,
|
|
85
95
|
user: {
|
|
@@ -103,29 +113,13 @@ var initialState = {
|
|
|
103
113
|
email: '',
|
|
104
114
|
sub: '',
|
|
105
115
|
},
|
|
106
|
-
// creating: {
|
|
107
|
-
// details: '',
|
|
108
|
-
// payment: '',
|
|
109
|
-
// },
|
|
110
116
|
loading: false,
|
|
111
117
|
error: false,
|
|
112
118
|
session: undefined,
|
|
113
119
|
};
|
|
114
|
-
// interface AuthReducers {
|
|
115
|
-
// setCredentials: (
|
|
116
|
-
// state: AuthState,
|
|
117
|
-
// data: {
|
|
118
|
-
// payload: any;
|
|
119
|
-
// type: string;
|
|
120
|
-
// },
|
|
121
|
-
// ) => AuthState;
|
|
122
|
-
// resetCreating: (state: AuthState) => void;
|
|
123
|
-
// updateSubscription: (state: AuthState, data: any) => void;
|
|
124
|
-
// logout: () => void;
|
|
125
|
-
// }
|
|
126
120
|
var authSlice = createSlice({
|
|
127
121
|
name: 'auth',
|
|
128
|
-
initialState: initialState,
|
|
122
|
+
initialState: initialState$1,
|
|
129
123
|
reducers: {
|
|
130
124
|
setCredentials: function (state, data) {
|
|
131
125
|
return __assign(__assign({}, state), { session: data.payload.accessToken, authenticated: true, verifying: true, user: __assign(__assign({}, state.user), data.payload) });
|
|
@@ -139,15 +133,13 @@ var authSlice = createSlice({
|
|
|
139
133
|
updateSubscription: function (state, data) {
|
|
140
134
|
return __assign(__assign({}, state), { user: __assign(__assign({}, state.user), { details: __assign(__assign({}, state.user.details), { customerId: data.payload.customerId, subscription: data.payload.subscription, subscriptionDetails: data.payload.subscriptionDetails }) }) });
|
|
141
135
|
},
|
|
142
|
-
logout: function () { return initialState; },
|
|
136
|
+
logout: function () { return initialState$1; },
|
|
143
137
|
},
|
|
144
138
|
selectors: {
|
|
145
139
|
isAuthenticated: function (auth) { return auth.authenticated; },
|
|
146
140
|
selectAccessToken: function (auth) { return auth.user.accessToken; },
|
|
147
141
|
selectRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
148
142
|
selectCurrentUser: function (auth) { return auth.user.details; },
|
|
149
|
-
// selectUserCreating: (auth) => auth.creating,
|
|
150
|
-
// selectUserCreatingDetails: (auth) => auth.creating.details,
|
|
151
143
|
isVerifying: function (auth) { return auth.verifying; },
|
|
152
144
|
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
153
145
|
selectCurrentUserSub: function (auth) { return auth.user.sub; },
|
|
@@ -174,12 +166,9 @@ var authSlice = createSlice({
|
|
|
174
166
|
},
|
|
175
167
|
});
|
|
176
168
|
// Action creators are generated for each case reducer function.
|
|
177
|
-
var setCredentials = (_a$
|
|
169
|
+
var setCredentials = (_a$2 = authSlice.actions, _a$2.setCredentials), resetCreating = _a$2.resetCreating, logout = _a$2.logout, updateSubscription = _a$2.updateSubscription;
|
|
178
170
|
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
179
|
-
var isAuthenticated = (_b$
|
|
180
|
-
// selectUserCreating,
|
|
181
|
-
// selectUserCreatingDetails,
|
|
182
|
-
isVerifying = _b$1.isVerifying, getUserSession = _b$1.getUserSession, selectCurrentUserSub = _b$1.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$1.selectCurrentUserRefreshToken, selectUserTokens = _b$1.selectUserTokens, selectUserSubscriptionStatus = _b$1.selectUserSubscriptionStatus, selectSubscription = _b$1.selectSubscription, selectSubscriptionPrice = _b$1.selectSubscriptionPrice;
|
|
171
|
+
var isAuthenticated = (_b$2 = authSlice.selectors, _b$2.isAuthenticated), selectAccessToken = _b$2.selectAccessToken, selectRefreshToken = _b$2.selectRefreshToken, selectCurrentUser = _b$2.selectCurrentUser, isVerifying = _b$2.isVerifying, getUserSession = _b$2.getUserSession, selectCurrentUserSub = _b$2.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$2.selectCurrentUserRefreshToken, selectUserTokens = _b$2.selectUserTokens, selectUserSubscriptionStatus = _b$2.selectUserSubscriptionStatus, selectSubscription = _b$2.selectSubscription, selectSubscriptionPrice = _b$2.selectSubscriptionPrice;
|
|
183
172
|
authSlice.reducer;
|
|
184
173
|
|
|
185
174
|
// TODO: typing.
|
|
@@ -662,8 +651,8 @@ function formatConfig(data) {
|
|
|
662
651
|
name: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.name) === null || _r === void 0 ? void 0 : _r[0],
|
|
663
652
|
price: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.price) === null || _t === void 0 ? void 0 : _t[0],
|
|
664
653
|
video: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.video) === null || _v === void 0 ? void 0 : _v[0],
|
|
665
|
-
|
|
666
|
-
|
|
654
|
+
imageHomepage: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.image_homepage) === null || _x === void 0 ? void 0 : _x[0],
|
|
655
|
+
imageSectionBanner: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.image_section_banner) === null || _z === void 0 ? void 0 : _z[0],
|
|
667
656
|
};
|
|
668
657
|
});
|
|
669
658
|
}
|
|
@@ -774,15 +763,46 @@ var formatLongform = function (data) {
|
|
|
774
763
|
};
|
|
775
764
|
});
|
|
776
765
|
};
|
|
766
|
+
var formatMediaItem = function (data) {
|
|
767
|
+
return data.map(function (item) {
|
|
768
|
+
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;
|
|
769
|
+
return {
|
|
770
|
+
changed: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.changed) === null || _b === void 0 ? void 0 : _b[0],
|
|
771
|
+
created: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.created) === null || _d === void 0 ? void 0 : _d[0],
|
|
772
|
+
image: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f[0],
|
|
773
|
+
customThumbnail: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.custom_thumbnail) === null || _h === void 0 ? void 0 : _h[0],
|
|
774
|
+
price: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.price) === null || _k === void 0 ? void 0 : _k[0],
|
|
775
|
+
priceTwoYear: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.price_2_year) === null || _m === void 0 ? void 0 : _m[0],
|
|
776
|
+
revisionTimestamp: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.revision_timestamp) === null || _p === void 0 ? void 0 : _p[0],
|
|
777
|
+
sku: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.sku) === null || _r === void 0 ? void 0 : _r[0],
|
|
778
|
+
status: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.status) === null || _t === void 0 ? void 0 : _t[0],
|
|
779
|
+
uuid: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.uuid) === null || _v === void 0 ? void 0 : _v[0],
|
|
780
|
+
description: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.description) === null || _x === void 0 ? void 0 : _x[0],
|
|
781
|
+
transcript: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.transcript) === null || _z === void 0 ? void 0 : _z[0],
|
|
782
|
+
entities: (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.entities,
|
|
783
|
+
phrases: (_1 = item === null || item === void 0 ? void 0 : item._source) === null || _1 === void 0 ? void 0 : _1.phrases,
|
|
784
|
+
video: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.video) === null || _3 === void 0 ? void 0 : _3[0],
|
|
785
|
+
title: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.title) === null || _5 === void 0 ? void 0 : _5[0],
|
|
786
|
+
generatedTitle: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.generated_title) === null || _7 === void 0 ? void 0 : _7[0],
|
|
787
|
+
projectPricing: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.project_pricing) === null || _9 === void 0 ? void 0 : _9[0],
|
|
788
|
+
related_items: (_10 = item === null || item === void 0 ? void 0 : item._source) === null || _10 === void 0 ? void 0 : _10.related_uuids,
|
|
789
|
+
franchises: (_11 = item === null || item === void 0 ? void 0 : item._source) === null || _11 === void 0 ? void 0 : _11.franchise_name,
|
|
790
|
+
franchisesIds: (_12 = item === null || item === void 0 ? void 0 : item._source) === null || _12 === void 0 ? void 0 : _12.franchise_tid,
|
|
791
|
+
original: (_14 = (_13 = item === null || item === void 0 ? void 0 : item._source) === null || _13 === void 0 ? void 0 : _13.original) === null || _14 === void 0 ? void 0 : _14[0],
|
|
792
|
+
script: (_16 = (_15 = item === null || item === void 0 ? void 0 : item._source) === null || _15 === void 0 ? void 0 : _15.script) === null || _16 === void 0 ? void 0 : _16[0],
|
|
793
|
+
hideThumbnailTitle: (_18 = (_17 = item === null || item === void 0 ? void 0 : item._source) === null || _17 === void 0 ? void 0 : _17.hide_thumbnail_title) === null || _18 === void 0 ? void 0 : _18[0],
|
|
794
|
+
};
|
|
795
|
+
});
|
|
796
|
+
};
|
|
777
797
|
|
|
778
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
798
|
+
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
779
799
|
// Render the store based on the environment.
|
|
780
800
|
var isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
781
801
|
var ENV = isWeb ? process.env : require('react-native-config').default;
|
|
782
802
|
// export const ENV = process.env;
|
|
783
|
-
((_a = process.env) === null || _a === void 0 ? void 0 : _a.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
803
|
+
((_a$1 = process.env) === null || _a$1 === void 0 ? void 0 : _a$1.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
784
804
|
// Auth specific API
|
|
785
|
-
var API_AUTH_PREFIX = ((_b = process.env) === null || _b === void 0 ? void 0 : _b.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
805
|
+
var API_AUTH_PREFIX = ((_b$1 = process.env) === null || _b$1 === void 0 ? void 0 : _b$1.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
786
806
|
// Payments specific API
|
|
787
807
|
var API_PAYMENTS_PREFIX = ((_c = process.env) === null || _c === void 0 ? void 0 : _c.NEXT_PUBLIC_API_PAYMENTS_PREFIX) || ENV.API_PAYMENTS_PREFIX;
|
|
788
808
|
((_d = process.env) === null || _d === void 0 ? void 0 : _d.NEXT_PUBLIC_APP_BASE_URL) || ENV.APP_BASE_URL;
|
|
@@ -1216,6 +1236,136 @@ var paymentApi = createApi({
|
|
|
1216
1236
|
// Export hooks for usage in functional components.
|
|
1217
1237
|
paymentApi.useCheckUserSubscriptionQuery; paymentApi.useLazyCheckUserSubscriptionQuery; paymentApi.useGetPaymentPlansQuery; paymentApi.useLazyGetPaymentPlansQuery;
|
|
1218
1238
|
|
|
1239
|
+
function applyCoupon(coupon, netTotal) {
|
|
1240
|
+
var discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
1241
|
+
var discountedTotal = netTotal - discountedAmount;
|
|
1242
|
+
var data = __assign(__assign({}, coupon), { discountedTotal: discountedTotal, discountedAmount: discountedAmount });
|
|
1243
|
+
return data;
|
|
1244
|
+
}
|
|
1245
|
+
function applyTax(taxRate, netTotal) {
|
|
1246
|
+
var taxAmount = netTotal * (taxRate.percentage / 100);
|
|
1247
|
+
return taxAmount;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
var _a, _b;
|
|
1251
|
+
var initialState = {
|
|
1252
|
+
addedItems: [],
|
|
1253
|
+
netTotal: 0,
|
|
1254
|
+
taxRate: {
|
|
1255
|
+
country: 'none',
|
|
1256
|
+
percentage: 0,
|
|
1257
|
+
},
|
|
1258
|
+
taxAmount: 0,
|
|
1259
|
+
promoCode: {
|
|
1260
|
+
code: '',
|
|
1261
|
+
name: '',
|
|
1262
|
+
discount: '',
|
|
1263
|
+
discountedAmount: 0,
|
|
1264
|
+
},
|
|
1265
|
+
grossTotal: 0,
|
|
1266
|
+
loading: false,
|
|
1267
|
+
error: false,
|
|
1268
|
+
open: false,
|
|
1269
|
+
};
|
|
1270
|
+
var cartSlice = createSlice({
|
|
1271
|
+
name: 'cart',
|
|
1272
|
+
initialState: initialState,
|
|
1273
|
+
reducers: {
|
|
1274
|
+
setTaxRate: function (state, action) {
|
|
1275
|
+
var netTotal = state.netTotal, promoCode = state.promoCode;
|
|
1276
|
+
var currentTotal = netTotal;
|
|
1277
|
+
if (promoCode === null || promoCode === void 0 ? void 0 : promoCode.code) {
|
|
1278
|
+
var data = applyCoupon(promoCode, currentTotal);
|
|
1279
|
+
currentTotal = data.discountedTotal;
|
|
1280
|
+
}
|
|
1281
|
+
var taxAmount = applyTax(action.payload, currentTotal);
|
|
1282
|
+
var grossTotal = currentTotal + taxAmount;
|
|
1283
|
+
return __assign(__assign({}, state), { taxRate: action.payload, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1284
|
+
},
|
|
1285
|
+
resetTaxRate: function (state, action) {
|
|
1286
|
+
console.log('resetTaxRate', action);
|
|
1287
|
+
return __assign(__assign({}, state), { taxRate: {
|
|
1288
|
+
country: 'none',
|
|
1289
|
+
percentage: 0,
|
|
1290
|
+
}, taxAmount: 0 });
|
|
1291
|
+
},
|
|
1292
|
+
setPromoCode: function (state, action) {
|
|
1293
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1294
|
+
var data = applyCoupon(action.payload, netTotal);
|
|
1295
|
+
var taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
1296
|
+
var grossTotal = data.discountedTotal + taxAmount;
|
|
1297
|
+
return __assign(__assign({}, state), { promoCode: {
|
|
1298
|
+
code: data.code,
|
|
1299
|
+
name: data.code,
|
|
1300
|
+
discount: data.discount,
|
|
1301
|
+
discountedAmount: data.discountedAmount,
|
|
1302
|
+
}, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1303
|
+
},
|
|
1304
|
+
removePromoCode: function (state, action) {
|
|
1305
|
+
console.log('removePromoCode', action);
|
|
1306
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1307
|
+
var taxAmount = applyTax(taxRate, netTotal);
|
|
1308
|
+
var grossTotal = netTotal + taxAmount;
|
|
1309
|
+
return __assign(__assign({}, state), { promoCode: initialState.promoCode, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1310
|
+
},
|
|
1311
|
+
addToCart: function (state, action) {
|
|
1312
|
+
var _a = action.payload, options = _a.options, item = _a.item;
|
|
1313
|
+
var newTotal = state.netTotal + options.selectedPrice;
|
|
1314
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1315
|
+
var grossTotal = newTotal + taxAmount;
|
|
1316
|
+
var addItem = item ? __assign(__assign({}, item), { options: options }) : null;
|
|
1317
|
+
if (!addItem) {
|
|
1318
|
+
return state;
|
|
1319
|
+
}
|
|
1320
|
+
var addedItems = __spreadArray(__spreadArray([], state.addedItems, true), [addItem], false);
|
|
1321
|
+
return __assign(__assign({}, state), { addedItems: addedItems, netTotal: newTotal, grossTotal: grossTotal });
|
|
1322
|
+
},
|
|
1323
|
+
updateCart: function (state, action) {
|
|
1324
|
+
var options = action.payload.options;
|
|
1325
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.map(function (item) {
|
|
1326
|
+
return item && __assign(__assign({}, item), { options: options });
|
|
1327
|
+
}) });
|
|
1328
|
+
},
|
|
1329
|
+
removeFromCart: function (state, action) {
|
|
1330
|
+
var _a = action.payload, id = _a.id, price = _a.price;
|
|
1331
|
+
var newTotal = state.netTotal - price;
|
|
1332
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1333
|
+
var grossTotal = newTotal + taxAmount;
|
|
1334
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.filter(function (item) { return item && item.uuid !== id; }), netTotal: newTotal, grossTotal: grossTotal });
|
|
1335
|
+
},
|
|
1336
|
+
toggleCart: function (state, action) {
|
|
1337
|
+
return __assign(__assign({}, state), { open: action.payload });
|
|
1338
|
+
},
|
|
1339
|
+
emptyCart: function () { return initialState; },
|
|
1340
|
+
},
|
|
1341
|
+
selectors: {
|
|
1342
|
+
selectMediaInCart: function (cart) { return cart.addedItems; },
|
|
1343
|
+
selectCartTotal: function (cart) { return cart.grossTotal; },
|
|
1344
|
+
selectCartNetTotal: function (cart) { return cart.netTotal; },
|
|
1345
|
+
selectCartTaxRate: function (cart) { return cart.taxRate; },
|
|
1346
|
+
selectCartTaxAmount: function (cart) { return cart.taxAmount; },
|
|
1347
|
+
selectCartCount: function (cart) { return cart.addedItems.length; },
|
|
1348
|
+
selectCartStatus: function (cart) { return cart.open; },
|
|
1349
|
+
selectPromoCode: function (cart) { return cart.promoCode; },
|
|
1350
|
+
},
|
|
1351
|
+
});
|
|
1352
|
+
var setTaxRate = (_a = cartSlice.actions, _a.setTaxRate), resetTaxRate = _a.resetTaxRate, setPromoCode = _a.setPromoCode, removePromoCode = _a.removePromoCode, addToCart = _a.addToCart, updateCart = _a.updateCart, removeFromCart = _a.removeFromCart, emptyCart = _a.emptyCart, toggleCart = _a.toggleCart;
|
|
1353
|
+
var selectMediaInCart = (_b = cartSlice.selectors, _b.selectMediaInCart), selectCartTotal = _b.selectCartTotal, selectCartNetTotal = _b.selectCartNetTotal, selectCartTaxRate = _b.selectCartTaxRate, selectCartTaxAmount = _b.selectCartTaxAmount, selectCartCount = _b.selectCartCount, selectCartStatus = _b.selectCartStatus, selectPromoCode = _b.selectPromoCode;
|
|
1354
|
+
var selectCartItems = createSelector([selectMediaInCart], function (items) {
|
|
1355
|
+
return items.map(function (item) {
|
|
1356
|
+
return {
|
|
1357
|
+
title: item.title || item.generatedTitle,
|
|
1358
|
+
file: "".concat(item.sku, ".mp4"),
|
|
1359
|
+
options: item.options,
|
|
1360
|
+
script: item.script,
|
|
1361
|
+
};
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
var selectCartItemsIds = createSelector([selectMediaInCart], function (items) {
|
|
1365
|
+
return items.map(function (item) { return item.uuid; });
|
|
1366
|
+
});
|
|
1367
|
+
cartSlice.reducer;
|
|
1368
|
+
|
|
1219
1369
|
var useLoggedIn = function () {
|
|
1220
1370
|
var isLoggedIn = useSelector(isAuthenticated);
|
|
1221
1371
|
return useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
@@ -1247,13 +1397,7 @@ function createPersistStorage() {
|
|
|
1247
1397
|
}
|
|
1248
1398
|
|
|
1249
1399
|
// Infer the `RootState` type from the root reducer
|
|
1250
|
-
var rootReducer = combineSlices(authSlice, authApi, contentApi, paymentApi);
|
|
1251
|
-
// export interface RootState {
|
|
1252
|
-
// [authSlice.name]: ReturnType<typeof authSlice.reducer>;
|
|
1253
|
-
// [authApi.reducerPath]: ReturnType<typeof authApi.reducer>;
|
|
1254
|
-
// [contentApi.reducerPath]: ReturnType<typeof contentApi.reducer>;
|
|
1255
|
-
// [paymentApi.reducerPath]: ReturnType<typeof paymentApi.reducer>;
|
|
1256
|
-
// }
|
|
1400
|
+
var rootReducer = combineSlices(cartSlice, authSlice, authApi, contentApi, paymentApi);
|
|
1257
1401
|
// eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
|
|
1258
1402
|
// const storageWhiteList: string[] = [];
|
|
1259
1403
|
var storageBlackList = [];
|
|
@@ -1311,9 +1455,6 @@ var makeNativeStore = function () {
|
|
|
1311
1455
|
};
|
|
1312
1456
|
var makeWebStore = function () {
|
|
1313
1457
|
var storage = createPersistStorage();
|
|
1314
|
-
// if (process.env.NEXT_PUBLIC_STORE_BLACKLIST) {
|
|
1315
|
-
// storageBlackList.push(process.env.NEXT_PUBLIC_STORE_BLACKLIST);
|
|
1316
|
-
// }
|
|
1317
1458
|
storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath);
|
|
1318
1459
|
var persistConfig = {
|
|
1319
1460
|
key: 'root',
|
|
@@ -1351,5 +1492,5 @@ var makeWebStore = function () {
|
|
|
1351
1492
|
var nativeStore = !isWeb && makeNativeStore();
|
|
1352
1493
|
var webStore = isWeb && makeWebStore();
|
|
1353
1494
|
|
|
1354
|
-
export { authApi, authSlice, contentApi, formatAuthSession, formatChallengeDays, formatChallenges, formatConfig, formatFaqs, formatFedaratedSession, formatGuests, formatLongform, formatPages, formatPress, formatPromos, formatSchedule, formatSeasons, formatSecondsToISO8601Duration, formatSectionItems, formatSectionPanels, formatSections, formatSeries, formatSettings, formatShortform, formatSocialAuthSession, formatTaxonomies, formatUserPayload, formatVideos, formatWorkout, getUserSession, isAuthenticated, isVerifying, logout, nativeStore, paymentApi, resetCreating, selectAccessToken, selectCurrentUser, selectCurrentUserRefreshToken, selectCurrentUserSub, selectRefreshToken, selectSubscription, selectSubscriptionPrice, selectUserSubscriptionStatus, selectUserTokens, setCredentials, updateSubscription, useAppDispatch, useAppSelector, useAppStore, useForgottenPasswordMutation, useGetUserInfoQuery, useLazyGetUserInfoQuery, useLazyVerifyUserAttributesQuery, useLazyVerifyUserQuery, useLazyVerifyUserResendQuery, useLoggedIn, useRegisterMutation, useResetPasswordAuthMutation, useResetPasswordMutation, useUpdateUserInfoMutation, useUpdateUserMutation, useVerifyUserAttributesQuery, useVerifyUserQuery, useVerifyUserResendQuery, webStore };
|
|
1495
|
+
export { addToCart, authApi, authSlice, cartSlice, contentApi, emptyCart, formatAuthSession, formatChallengeDays, formatChallenges, formatConfig, formatFaqs, formatFedaratedSession, formatGuests, formatLongform, formatMediaItem, formatPages, formatPress, formatPromos, formatSchedule, formatSeasons, formatSecondsToISO8601Duration, formatSectionItems, formatSectionPanels, formatSections, formatSeries, formatSettings, formatShortform, formatSocialAuthSession, formatTaxonomies, formatUserPayload, formatVideos, formatWorkout, getUserSession, isAuthenticated, isVerifying, logout, nativeStore, paymentApi, removeFromCart, removePromoCode, resetCreating, resetTaxRate, selectAccessToken, selectCartCount, selectCartItems, selectCartItemsIds, selectCartNetTotal, selectCartStatus, selectCartTaxAmount, selectCartTaxRate, selectCartTotal, selectCurrentUser, selectCurrentUserRefreshToken, selectCurrentUserSub, selectMediaInCart, selectPromoCode, selectRefreshToken, selectSubscription, selectSubscriptionPrice, selectUserSubscriptionStatus, selectUserTokens, setCredentials, setPromoCode, setTaxRate, toggleCart, updateCart, updateSubscription, useAppDispatch, useAppSelector, useAppStore, useForgottenPasswordMutation, useGetUserInfoQuery, useLazyGetUserInfoQuery, useLazyVerifyUserAttributesQuery, useLazyVerifyUserQuery, useLazyVerifyUserResendQuery, useLoggedIn, useRegisterMutation, useResetPasswordAuthMutation, useResetPasswordMutation, useUpdateUserInfoMutation, useUpdateUserMutation, useVerifyUserAttributesQuery, useVerifyUserQuery, useVerifyUserResendQuery, webStore };
|
|
1355
1496
|
//# sourceMappingURL=index.esm.js.map
|