@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.js
CHANGED
|
@@ -75,13 +75,23 @@ function __generator(thisArg, body) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
function __spreadArray(to, from, pack) {
|
|
79
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
80
|
+
if (ar || !(i in from)) {
|
|
81
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
82
|
+
ar[i] = from[i];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
79
89
|
var e = new Error(message);
|
|
80
90
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
var _a$
|
|
84
|
-
var initialState = {
|
|
93
|
+
var _a$2, _b$2;
|
|
94
|
+
var initialState$1 = {
|
|
85
95
|
authenticated: false,
|
|
86
96
|
verifying: false,
|
|
87
97
|
user: {
|
|
@@ -105,29 +115,13 @@ var initialState = {
|
|
|
105
115
|
email: '',
|
|
106
116
|
sub: '',
|
|
107
117
|
},
|
|
108
|
-
// creating: {
|
|
109
|
-
// details: '',
|
|
110
|
-
// payment: '',
|
|
111
|
-
// },
|
|
112
118
|
loading: false,
|
|
113
119
|
error: false,
|
|
114
120
|
session: undefined,
|
|
115
121
|
};
|
|
116
|
-
// interface AuthReducers {
|
|
117
|
-
// setCredentials: (
|
|
118
|
-
// state: AuthState,
|
|
119
|
-
// data: {
|
|
120
|
-
// payload: any;
|
|
121
|
-
// type: string;
|
|
122
|
-
// },
|
|
123
|
-
// ) => AuthState;
|
|
124
|
-
// resetCreating: (state: AuthState) => void;
|
|
125
|
-
// updateSubscription: (state: AuthState, data: any) => void;
|
|
126
|
-
// logout: () => void;
|
|
127
|
-
// }
|
|
128
122
|
var authSlice = toolkit.createSlice({
|
|
129
123
|
name: 'auth',
|
|
130
|
-
initialState: initialState,
|
|
124
|
+
initialState: initialState$1,
|
|
131
125
|
reducers: {
|
|
132
126
|
setCredentials: function (state, data) {
|
|
133
127
|
return __assign(__assign({}, state), { session: data.payload.accessToken, authenticated: true, verifying: true, user: __assign(__assign({}, state.user), data.payload) });
|
|
@@ -141,15 +135,13 @@ var authSlice = toolkit.createSlice({
|
|
|
141
135
|
updateSubscription: function (state, data) {
|
|
142
136
|
return __assign(__assign({}, state), { user: __assign(__assign({}, state.user), { details: __assign(__assign({}, state.user.details), { customerId: data.payload.customerId, subscription: data.payload.subscription, subscriptionDetails: data.payload.subscriptionDetails }) }) });
|
|
143
137
|
},
|
|
144
|
-
logout: function () { return initialState; },
|
|
138
|
+
logout: function () { return initialState$1; },
|
|
145
139
|
},
|
|
146
140
|
selectors: {
|
|
147
141
|
isAuthenticated: function (auth) { return auth.authenticated; },
|
|
148
142
|
selectAccessToken: function (auth) { return auth.user.accessToken; },
|
|
149
143
|
selectRefreshToken: function (auth) { return auth.user.refreshToken; },
|
|
150
144
|
selectCurrentUser: function (auth) { return auth.user.details; },
|
|
151
|
-
// selectUserCreating: (auth) => auth.creating,
|
|
152
|
-
// selectUserCreatingDetails: (auth) => auth.creating.details,
|
|
153
145
|
isVerifying: function (auth) { return auth.verifying; },
|
|
154
146
|
getUserSession: function (auth) { return (auth.authenticated ? auth.session : false); },
|
|
155
147
|
selectCurrentUserSub: function (auth) { return auth.user.sub; },
|
|
@@ -176,12 +168,9 @@ var authSlice = toolkit.createSlice({
|
|
|
176
168
|
},
|
|
177
169
|
});
|
|
178
170
|
// Action creators are generated for each case reducer function.
|
|
179
|
-
var setCredentials = (_a$
|
|
171
|
+
var setCredentials = (_a$2 = authSlice.actions, _a$2.setCredentials), resetCreating = _a$2.resetCreating, logout = _a$2.logout, updateSubscription = _a$2.updateSubscription;
|
|
180
172
|
// Selectors returned by `slice.selectors` take the root state as their first argument.
|
|
181
|
-
var isAuthenticated = (_b$
|
|
182
|
-
// selectUserCreating,
|
|
183
|
-
// selectUserCreatingDetails,
|
|
184
|
-
isVerifying = _b$1.isVerifying, getUserSession = _b$1.getUserSession, selectCurrentUserSub = _b$1.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$1.selectCurrentUserRefreshToken, selectUserTokens = _b$1.selectUserTokens, selectUserSubscriptionStatus = _b$1.selectUserSubscriptionStatus, selectSubscription = _b$1.selectSubscription, selectSubscriptionPrice = _b$1.selectSubscriptionPrice;
|
|
173
|
+
var isAuthenticated = (_b$2 = authSlice.selectors, _b$2.isAuthenticated), selectAccessToken = _b$2.selectAccessToken, selectRefreshToken = _b$2.selectRefreshToken, selectCurrentUser = _b$2.selectCurrentUser, isVerifying = _b$2.isVerifying, getUserSession = _b$2.getUserSession, selectCurrentUserSub = _b$2.selectCurrentUserSub, selectCurrentUserRefreshToken = _b$2.selectCurrentUserRefreshToken, selectUserTokens = _b$2.selectUserTokens, selectUserSubscriptionStatus = _b$2.selectUserSubscriptionStatus, selectSubscription = _b$2.selectSubscription, selectSubscriptionPrice = _b$2.selectSubscriptionPrice;
|
|
185
174
|
authSlice.reducer;
|
|
186
175
|
|
|
187
176
|
// TODO: typing.
|
|
@@ -664,8 +653,8 @@ function formatConfig(data) {
|
|
|
664
653
|
name: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.name) === null || _r === void 0 ? void 0 : _r[0],
|
|
665
654
|
price: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.price) === null || _t === void 0 ? void 0 : _t[0],
|
|
666
655
|
video: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.video) === null || _v === void 0 ? void 0 : _v[0],
|
|
667
|
-
|
|
668
|
-
|
|
656
|
+
imageHomepage: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.image_homepage) === null || _x === void 0 ? void 0 : _x[0],
|
|
657
|
+
imageSectionBanner: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.image_section_banner) === null || _z === void 0 ? void 0 : _z[0],
|
|
669
658
|
};
|
|
670
659
|
});
|
|
671
660
|
}
|
|
@@ -776,15 +765,46 @@ var formatLongform = function (data) {
|
|
|
776
765
|
};
|
|
777
766
|
});
|
|
778
767
|
};
|
|
768
|
+
var formatMediaItem = function (data) {
|
|
769
|
+
return data.map(function (item) {
|
|
770
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
771
|
+
return {
|
|
772
|
+
changed: (_b = (_a = item === null || item === void 0 ? void 0 : item._source) === null || _a === void 0 ? void 0 : _a.changed) === null || _b === void 0 ? void 0 : _b[0],
|
|
773
|
+
created: (_d = (_c = item === null || item === void 0 ? void 0 : item._source) === null || _c === void 0 ? void 0 : _c.created) === null || _d === void 0 ? void 0 : _d[0],
|
|
774
|
+
image: (_f = (_e = item === null || item === void 0 ? void 0 : item._source) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f[0],
|
|
775
|
+
customThumbnail: (_h = (_g = item === null || item === void 0 ? void 0 : item._source) === null || _g === void 0 ? void 0 : _g.custom_thumbnail) === null || _h === void 0 ? void 0 : _h[0],
|
|
776
|
+
price: (_k = (_j = item === null || item === void 0 ? void 0 : item._source) === null || _j === void 0 ? void 0 : _j.price) === null || _k === void 0 ? void 0 : _k[0],
|
|
777
|
+
priceTwoYear: (_m = (_l = item === null || item === void 0 ? void 0 : item._source) === null || _l === void 0 ? void 0 : _l.price_2_year) === null || _m === void 0 ? void 0 : _m[0],
|
|
778
|
+
revisionTimestamp: (_p = (_o = item === null || item === void 0 ? void 0 : item._source) === null || _o === void 0 ? void 0 : _o.revision_timestamp) === null || _p === void 0 ? void 0 : _p[0],
|
|
779
|
+
sku: (_r = (_q = item === null || item === void 0 ? void 0 : item._source) === null || _q === void 0 ? void 0 : _q.sku) === null || _r === void 0 ? void 0 : _r[0],
|
|
780
|
+
status: (_t = (_s = item === null || item === void 0 ? void 0 : item._source) === null || _s === void 0 ? void 0 : _s.status) === null || _t === void 0 ? void 0 : _t[0],
|
|
781
|
+
uuid: (_v = (_u = item === null || item === void 0 ? void 0 : item._source) === null || _u === void 0 ? void 0 : _u.uuid) === null || _v === void 0 ? void 0 : _v[0],
|
|
782
|
+
description: (_x = (_w = item === null || item === void 0 ? void 0 : item._source) === null || _w === void 0 ? void 0 : _w.description) === null || _x === void 0 ? void 0 : _x[0],
|
|
783
|
+
transcript: (_z = (_y = item === null || item === void 0 ? void 0 : item._source) === null || _y === void 0 ? void 0 : _y.transcript) === null || _z === void 0 ? void 0 : _z[0],
|
|
784
|
+
entities: (_0 = item === null || item === void 0 ? void 0 : item._source) === null || _0 === void 0 ? void 0 : _0.entities,
|
|
785
|
+
phrases: (_1 = item === null || item === void 0 ? void 0 : item._source) === null || _1 === void 0 ? void 0 : _1.phrases,
|
|
786
|
+
video: (_3 = (_2 = item === null || item === void 0 ? void 0 : item._source) === null || _2 === void 0 ? void 0 : _2.video) === null || _3 === void 0 ? void 0 : _3[0],
|
|
787
|
+
title: (_5 = (_4 = item === null || item === void 0 ? void 0 : item._source) === null || _4 === void 0 ? void 0 : _4.title) === null || _5 === void 0 ? void 0 : _5[0],
|
|
788
|
+
generatedTitle: (_7 = (_6 = item === null || item === void 0 ? void 0 : item._source) === null || _6 === void 0 ? void 0 : _6.generated_title) === null || _7 === void 0 ? void 0 : _7[0],
|
|
789
|
+
projectPricing: (_9 = (_8 = item === null || item === void 0 ? void 0 : item._source) === null || _8 === void 0 ? void 0 : _8.project_pricing) === null || _9 === void 0 ? void 0 : _9[0],
|
|
790
|
+
related_items: (_10 = item === null || item === void 0 ? void 0 : item._source) === null || _10 === void 0 ? void 0 : _10.related_uuids,
|
|
791
|
+
franchises: (_11 = item === null || item === void 0 ? void 0 : item._source) === null || _11 === void 0 ? void 0 : _11.franchise_name,
|
|
792
|
+
franchisesIds: (_12 = item === null || item === void 0 ? void 0 : item._source) === null || _12 === void 0 ? void 0 : _12.franchise_tid,
|
|
793
|
+
original: (_14 = (_13 = item === null || item === void 0 ? void 0 : item._source) === null || _13 === void 0 ? void 0 : _13.original) === null || _14 === void 0 ? void 0 : _14[0],
|
|
794
|
+
script: (_16 = (_15 = item === null || item === void 0 ? void 0 : item._source) === null || _15 === void 0 ? void 0 : _15.script) === null || _16 === void 0 ? void 0 : _16[0],
|
|
795
|
+
hideThumbnailTitle: (_18 = (_17 = item === null || item === void 0 ? void 0 : item._source) === null || _17 === void 0 ? void 0 : _17.hide_thumbnail_title) === null || _18 === void 0 ? void 0 : _18[0],
|
|
796
|
+
};
|
|
797
|
+
});
|
|
798
|
+
};
|
|
779
799
|
|
|
780
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
800
|
+
var _a$1, _b$1, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
781
801
|
// Render the store based on the environment.
|
|
782
802
|
var isWeb = process.env.NEXT_PUBLIC_WEB_APP;
|
|
783
803
|
var ENV = isWeb ? process.env : require('react-native-config').default;
|
|
784
804
|
// export const ENV = process.env;
|
|
785
|
-
((_a = process.env) === null || _a === void 0 ? void 0 : _a.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
805
|
+
((_a$1 = process.env) === null || _a$1 === void 0 ? void 0 : _a$1.NEXT_PUBLIC_API_PREFIX) || ENV.API_PREFIX;
|
|
786
806
|
// Auth specific API
|
|
787
|
-
var API_AUTH_PREFIX = ((_b = process.env) === null || _b === void 0 ? void 0 : _b.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
807
|
+
var API_AUTH_PREFIX = ((_b$1 = process.env) === null || _b$1 === void 0 ? void 0 : _b$1.NEXT_PUBLIC_API_AUTH_PREFIX) || ENV.API_AUTH_PREFIX;
|
|
788
808
|
// Payments specific API
|
|
789
809
|
var API_PAYMENTS_PREFIX = ((_c = process.env) === null || _c === void 0 ? void 0 : _c.NEXT_PUBLIC_API_PAYMENTS_PREFIX) || ENV.API_PAYMENTS_PREFIX;
|
|
790
810
|
((_d = process.env) === null || _d === void 0 ? void 0 : _d.NEXT_PUBLIC_APP_BASE_URL) || ENV.APP_BASE_URL;
|
|
@@ -1218,6 +1238,136 @@ var paymentApi = react.createApi({
|
|
|
1218
1238
|
// Export hooks for usage in functional components.
|
|
1219
1239
|
paymentApi.useCheckUserSubscriptionQuery; paymentApi.useLazyCheckUserSubscriptionQuery; paymentApi.useGetPaymentPlansQuery; paymentApi.useLazyGetPaymentPlansQuery;
|
|
1220
1240
|
|
|
1241
|
+
function applyCoupon(coupon, netTotal) {
|
|
1242
|
+
var discountedAmount = netTotal * (Number(coupon.discount) / 100);
|
|
1243
|
+
var discountedTotal = netTotal - discountedAmount;
|
|
1244
|
+
var data = __assign(__assign({}, coupon), { discountedTotal: discountedTotal, discountedAmount: discountedAmount });
|
|
1245
|
+
return data;
|
|
1246
|
+
}
|
|
1247
|
+
function applyTax(taxRate, netTotal) {
|
|
1248
|
+
var taxAmount = netTotal * (taxRate.percentage / 100);
|
|
1249
|
+
return taxAmount;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
var _a, _b;
|
|
1253
|
+
var initialState = {
|
|
1254
|
+
addedItems: [],
|
|
1255
|
+
netTotal: 0,
|
|
1256
|
+
taxRate: {
|
|
1257
|
+
country: 'none',
|
|
1258
|
+
percentage: 0,
|
|
1259
|
+
},
|
|
1260
|
+
taxAmount: 0,
|
|
1261
|
+
promoCode: {
|
|
1262
|
+
code: '',
|
|
1263
|
+
name: '',
|
|
1264
|
+
discount: '',
|
|
1265
|
+
discountedAmount: 0,
|
|
1266
|
+
},
|
|
1267
|
+
grossTotal: 0,
|
|
1268
|
+
loading: false,
|
|
1269
|
+
error: false,
|
|
1270
|
+
open: false,
|
|
1271
|
+
};
|
|
1272
|
+
var cartSlice = toolkit.createSlice({
|
|
1273
|
+
name: 'cart',
|
|
1274
|
+
initialState: initialState,
|
|
1275
|
+
reducers: {
|
|
1276
|
+
setTaxRate: function (state, action) {
|
|
1277
|
+
var netTotal = state.netTotal, promoCode = state.promoCode;
|
|
1278
|
+
var currentTotal = netTotal;
|
|
1279
|
+
if (promoCode === null || promoCode === void 0 ? void 0 : promoCode.code) {
|
|
1280
|
+
var data = applyCoupon(promoCode, currentTotal);
|
|
1281
|
+
currentTotal = data.discountedTotal;
|
|
1282
|
+
}
|
|
1283
|
+
var taxAmount = applyTax(action.payload, currentTotal);
|
|
1284
|
+
var grossTotal = currentTotal + taxAmount;
|
|
1285
|
+
return __assign(__assign({}, state), { taxRate: action.payload, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1286
|
+
},
|
|
1287
|
+
resetTaxRate: function (state, action) {
|
|
1288
|
+
console.log('resetTaxRate', action);
|
|
1289
|
+
return __assign(__assign({}, state), { taxRate: {
|
|
1290
|
+
country: 'none',
|
|
1291
|
+
percentage: 0,
|
|
1292
|
+
}, taxAmount: 0 });
|
|
1293
|
+
},
|
|
1294
|
+
setPromoCode: function (state, action) {
|
|
1295
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1296
|
+
var data = applyCoupon(action.payload, netTotal);
|
|
1297
|
+
var taxAmount = applyTax(taxRate, data.discountedTotal);
|
|
1298
|
+
var grossTotal = data.discountedTotal + taxAmount;
|
|
1299
|
+
return __assign(__assign({}, state), { promoCode: {
|
|
1300
|
+
code: data.code,
|
|
1301
|
+
name: data.code,
|
|
1302
|
+
discount: data.discount,
|
|
1303
|
+
discountedAmount: data.discountedAmount,
|
|
1304
|
+
}, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1305
|
+
},
|
|
1306
|
+
removePromoCode: function (state, action) {
|
|
1307
|
+
console.log('removePromoCode', action);
|
|
1308
|
+
var netTotal = state.netTotal, taxRate = state.taxRate;
|
|
1309
|
+
var taxAmount = applyTax(taxRate, netTotal);
|
|
1310
|
+
var grossTotal = netTotal + taxAmount;
|
|
1311
|
+
return __assign(__assign({}, state), { promoCode: initialState.promoCode, taxAmount: taxAmount, grossTotal: grossTotal });
|
|
1312
|
+
},
|
|
1313
|
+
addToCart: function (state, action) {
|
|
1314
|
+
var _a = action.payload, options = _a.options, item = _a.item;
|
|
1315
|
+
var newTotal = state.netTotal + options.selectedPrice;
|
|
1316
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1317
|
+
var grossTotal = newTotal + taxAmount;
|
|
1318
|
+
var addItem = item ? __assign(__assign({}, item), { options: options }) : null;
|
|
1319
|
+
if (!addItem) {
|
|
1320
|
+
return state;
|
|
1321
|
+
}
|
|
1322
|
+
var addedItems = __spreadArray(__spreadArray([], state.addedItems, true), [addItem], false);
|
|
1323
|
+
return __assign(__assign({}, state), { addedItems: addedItems, netTotal: newTotal, grossTotal: grossTotal });
|
|
1324
|
+
},
|
|
1325
|
+
updateCart: function (state, action) {
|
|
1326
|
+
var options = action.payload.options;
|
|
1327
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.map(function (item) {
|
|
1328
|
+
return item && __assign(__assign({}, item), { options: options });
|
|
1329
|
+
}) });
|
|
1330
|
+
},
|
|
1331
|
+
removeFromCart: function (state, action) {
|
|
1332
|
+
var _a = action.payload, id = _a.id, price = _a.price;
|
|
1333
|
+
var newTotal = state.netTotal - price;
|
|
1334
|
+
var taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
1335
|
+
var grossTotal = newTotal + taxAmount;
|
|
1336
|
+
return __assign(__assign({}, state), { addedItems: state.addedItems.filter(function (item) { return item && item.uuid !== id; }), netTotal: newTotal, grossTotal: grossTotal });
|
|
1337
|
+
},
|
|
1338
|
+
toggleCart: function (state, action) {
|
|
1339
|
+
return __assign(__assign({}, state), { open: action.payload });
|
|
1340
|
+
},
|
|
1341
|
+
emptyCart: function () { return initialState; },
|
|
1342
|
+
},
|
|
1343
|
+
selectors: {
|
|
1344
|
+
selectMediaInCart: function (cart) { return cart.addedItems; },
|
|
1345
|
+
selectCartTotal: function (cart) { return cart.grossTotal; },
|
|
1346
|
+
selectCartNetTotal: function (cart) { return cart.netTotal; },
|
|
1347
|
+
selectCartTaxRate: function (cart) { return cart.taxRate; },
|
|
1348
|
+
selectCartTaxAmount: function (cart) { return cart.taxAmount; },
|
|
1349
|
+
selectCartCount: function (cart) { return cart.addedItems.length; },
|
|
1350
|
+
selectCartStatus: function (cart) { return cart.open; },
|
|
1351
|
+
selectPromoCode: function (cart) { return cart.promoCode; },
|
|
1352
|
+
},
|
|
1353
|
+
});
|
|
1354
|
+
var setTaxRate = (_a = cartSlice.actions, _a.setTaxRate), resetTaxRate = _a.resetTaxRate, setPromoCode = _a.setPromoCode, removePromoCode = _a.removePromoCode, addToCart = _a.addToCart, updateCart = _a.updateCart, removeFromCart = _a.removeFromCart, emptyCart = _a.emptyCart, toggleCart = _a.toggleCart;
|
|
1355
|
+
var selectMediaInCart = (_b = cartSlice.selectors, _b.selectMediaInCart), selectCartTotal = _b.selectCartTotal, selectCartNetTotal = _b.selectCartNetTotal, selectCartTaxRate = _b.selectCartTaxRate, selectCartTaxAmount = _b.selectCartTaxAmount, selectCartCount = _b.selectCartCount, selectCartStatus = _b.selectCartStatus, selectPromoCode = _b.selectPromoCode;
|
|
1356
|
+
var selectCartItems = toolkit.createSelector([selectMediaInCart], function (items) {
|
|
1357
|
+
return items.map(function (item) {
|
|
1358
|
+
return {
|
|
1359
|
+
title: item.title || item.generatedTitle,
|
|
1360
|
+
file: "".concat(item.sku, ".mp4"),
|
|
1361
|
+
options: item.options,
|
|
1362
|
+
script: item.script,
|
|
1363
|
+
};
|
|
1364
|
+
});
|
|
1365
|
+
});
|
|
1366
|
+
var selectCartItemsIds = toolkit.createSelector([selectMediaInCart], function (items) {
|
|
1367
|
+
return items.map(function (item) { return item.uuid; });
|
|
1368
|
+
});
|
|
1369
|
+
cartSlice.reducer;
|
|
1370
|
+
|
|
1221
1371
|
var useLoggedIn = function () {
|
|
1222
1372
|
var isLoggedIn = reactRedux.useSelector(isAuthenticated);
|
|
1223
1373
|
return react$1.useMemo(function () { return isLoggedIn; }, [isLoggedIn]);
|
|
@@ -1249,13 +1399,7 @@ function createPersistStorage() {
|
|
|
1249
1399
|
}
|
|
1250
1400
|
|
|
1251
1401
|
// Infer the `RootState` type from the root reducer
|
|
1252
|
-
var rootReducer = toolkit.combineSlices(authSlice, authApi, contentApi, paymentApi);
|
|
1253
|
-
// export interface RootState {
|
|
1254
|
-
// [authSlice.name]: ReturnType<typeof authSlice.reducer>;
|
|
1255
|
-
// [authApi.reducerPath]: ReturnType<typeof authApi.reducer>;
|
|
1256
|
-
// [contentApi.reducerPath]: ReturnType<typeof contentApi.reducer>;
|
|
1257
|
-
// [paymentApi.reducerPath]: ReturnType<typeof paymentApi.reducer>;
|
|
1258
|
-
// }
|
|
1402
|
+
var rootReducer = toolkit.combineSlices(cartSlice, authSlice, authApi, contentApi, paymentApi);
|
|
1259
1403
|
// eg. ['auth', 'creating'], or an empty array if you don't want to whitelist any.
|
|
1260
1404
|
// const storageWhiteList: string[] = [];
|
|
1261
1405
|
var storageBlackList = [];
|
|
@@ -1313,9 +1457,6 @@ var makeNativeStore = function () {
|
|
|
1313
1457
|
};
|
|
1314
1458
|
var makeWebStore = function () {
|
|
1315
1459
|
var storage = createPersistStorage();
|
|
1316
|
-
// if (process.env.NEXT_PUBLIC_STORE_BLACKLIST) {
|
|
1317
|
-
// storageBlackList.push(process.env.NEXT_PUBLIC_STORE_BLACKLIST);
|
|
1318
|
-
// }
|
|
1319
1460
|
storageBlackList.push(paymentApi.reducerPath, authApi.reducerPath, contentApi.reducerPath);
|
|
1320
1461
|
var persistConfig = {
|
|
1321
1462
|
key: 'root',
|
|
@@ -1353,9 +1494,12 @@ var makeWebStore = function () {
|
|
|
1353
1494
|
var nativeStore = !isWeb && makeNativeStore();
|
|
1354
1495
|
var webStore = isWeb && makeWebStore();
|
|
1355
1496
|
|
|
1497
|
+
exports.addToCart = addToCart;
|
|
1356
1498
|
exports.authApi = authApi;
|
|
1357
1499
|
exports.authSlice = authSlice;
|
|
1500
|
+
exports.cartSlice = cartSlice;
|
|
1358
1501
|
exports.contentApi = contentApi;
|
|
1502
|
+
exports.emptyCart = emptyCart;
|
|
1359
1503
|
exports.formatAuthSession = formatAuthSession;
|
|
1360
1504
|
exports.formatChallengeDays = formatChallengeDays;
|
|
1361
1505
|
exports.formatChallenges = formatChallenges;
|
|
@@ -1364,6 +1508,7 @@ exports.formatFaqs = formatFaqs;
|
|
|
1364
1508
|
exports.formatFedaratedSession = formatFedaratedSession;
|
|
1365
1509
|
exports.formatGuests = formatGuests;
|
|
1366
1510
|
exports.formatLongform = formatLongform;
|
|
1511
|
+
exports.formatMediaItem = formatMediaItem;
|
|
1367
1512
|
exports.formatPages = formatPages;
|
|
1368
1513
|
exports.formatPress = formatPress;
|
|
1369
1514
|
exports.formatPromos = formatPromos;
|
|
@@ -1387,17 +1532,34 @@ exports.isVerifying = isVerifying;
|
|
|
1387
1532
|
exports.logout = logout;
|
|
1388
1533
|
exports.nativeStore = nativeStore;
|
|
1389
1534
|
exports.paymentApi = paymentApi;
|
|
1535
|
+
exports.removeFromCart = removeFromCart;
|
|
1536
|
+
exports.removePromoCode = removePromoCode;
|
|
1390
1537
|
exports.resetCreating = resetCreating;
|
|
1538
|
+
exports.resetTaxRate = resetTaxRate;
|
|
1391
1539
|
exports.selectAccessToken = selectAccessToken;
|
|
1540
|
+
exports.selectCartCount = selectCartCount;
|
|
1541
|
+
exports.selectCartItems = selectCartItems;
|
|
1542
|
+
exports.selectCartItemsIds = selectCartItemsIds;
|
|
1543
|
+
exports.selectCartNetTotal = selectCartNetTotal;
|
|
1544
|
+
exports.selectCartStatus = selectCartStatus;
|
|
1545
|
+
exports.selectCartTaxAmount = selectCartTaxAmount;
|
|
1546
|
+
exports.selectCartTaxRate = selectCartTaxRate;
|
|
1547
|
+
exports.selectCartTotal = selectCartTotal;
|
|
1392
1548
|
exports.selectCurrentUser = selectCurrentUser;
|
|
1393
1549
|
exports.selectCurrentUserRefreshToken = selectCurrentUserRefreshToken;
|
|
1394
1550
|
exports.selectCurrentUserSub = selectCurrentUserSub;
|
|
1551
|
+
exports.selectMediaInCart = selectMediaInCart;
|
|
1552
|
+
exports.selectPromoCode = selectPromoCode;
|
|
1395
1553
|
exports.selectRefreshToken = selectRefreshToken;
|
|
1396
1554
|
exports.selectSubscription = selectSubscription;
|
|
1397
1555
|
exports.selectSubscriptionPrice = selectSubscriptionPrice;
|
|
1398
1556
|
exports.selectUserSubscriptionStatus = selectUserSubscriptionStatus;
|
|
1399
1557
|
exports.selectUserTokens = selectUserTokens;
|
|
1400
1558
|
exports.setCredentials = setCredentials;
|
|
1559
|
+
exports.setPromoCode = setPromoCode;
|
|
1560
|
+
exports.setTaxRate = setTaxRate;
|
|
1561
|
+
exports.toggleCart = toggleCart;
|
|
1562
|
+
exports.updateCart = updateCart;
|
|
1401
1563
|
exports.updateSubscription = updateSubscription;
|
|
1402
1564
|
exports.useAppDispatch = useAppDispatch;
|
|
1403
1565
|
exports.useAppSelector = useAppSelector;
|