@techstuff-dev/foundation-api-utils 2.2.0 → 2.3.1
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/{shared-DhKGyfxw.js → shared-Dg7JQIWA.js} +2 -2
- package/dist/cjs/chunks/{shared-DhKGyfxw.js.map → shared-Dg7JQIWA.js.map} +1 -1
- package/dist/cjs/chunks/{slice-CUaXwIIK.js → slice-CJ4WSj5p.js} +32 -6
- package/dist/cjs/chunks/{slice-CUaXwIIK.js.map → slice-CJ4WSj5p.js.map} +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/store/index.native.js +2 -2
- package/dist/cjs/store/index.web.js +2 -2
- package/dist/esm/chunks/{shared-UVgGR-tG.js → shared-CztMTb2m.js} +2 -2
- package/dist/esm/chunks/{shared-UVgGR-tG.js.map → shared-CztMTb2m.js.map} +1 -1
- package/dist/esm/chunks/{slice-B4QZ6txZ.js → slice-_b4ee7tw.js} +29 -7
- package/dist/esm/chunks/{slice-B4QZ6txZ.js.map → slice-_b4ee7tw.js.map} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/store/index.native.js +2 -2
- package/dist/esm/store/index.web.js +2 -2
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/{index-Cc1emcVx.d.ts → index-CNDW7aai.d.ts} +836 -2
- package/dist/types/index.d.ts +4 -11
- package/dist/types/store/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var toolkit = require('@reduxjs/toolkit');
|
|
4
|
-
var slice = require('./slice-
|
|
4
|
+
var slice = require('./slice-CJ4WSj5p.js');
|
|
5
5
|
var slice$1 = require('./slice-CkWobkWw.js');
|
|
6
6
|
|
|
7
7
|
// This file exists just so TypeScript has a module at ./store for IDEs/build.
|
|
@@ -11,4 +11,4 @@ var slice$1 = require('./slice-CkWobkWw.js');
|
|
|
11
11
|
const rootReducer = toolkit.combineSlices(slice.cartSlice, slice$1.authSlice, slice.authApi, slice.contentApi, slice.paymentApi, slice.productsApi, slice.ordersApi);
|
|
12
12
|
|
|
13
13
|
exports.rootReducer = rootReducer;
|
|
14
|
-
//# sourceMappingURL=shared-
|
|
14
|
+
//# sourceMappingURL=shared-Dg7JQIWA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-Dg7JQIWA.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
|
|
@@ -6437,7 +6437,7 @@ const ordersApi = createApi({
|
|
|
6437
6437
|
// keepUnusedDataFor: 300,
|
|
6438
6438
|
endpoints: (builder) => ({
|
|
6439
6439
|
/**
|
|
6440
|
-
*
|
|
6440
|
+
* Legacy order search endpoint.
|
|
6441
6441
|
*/
|
|
6442
6442
|
fetchOrders: builder.query({
|
|
6443
6443
|
query: (ids) => ({
|
|
@@ -6448,10 +6448,27 @@ const ordersApi = createApi({
|
|
|
6448
6448
|
},
|
|
6449
6449
|
}),
|
|
6450
6450
|
}),
|
|
6451
|
+
/**
|
|
6452
|
+
* Get all partnership orders for a customer from Stripe.
|
|
6453
|
+
*/
|
|
6454
|
+
getOrders: builder.query({
|
|
6455
|
+
query: ({ customerId }) => ({
|
|
6456
|
+
url: `${process.env.NEXT_PUBLIC_PAYMENTS_URL}/v1/payment/orders`,
|
|
6457
|
+
params: { customerId },
|
|
6458
|
+
}),
|
|
6459
|
+
providesTags: ['Orders'],
|
|
6460
|
+
}),
|
|
6461
|
+
/**
|
|
6462
|
+
* Get a single partnership order by ID from Stripe.
|
|
6463
|
+
*/
|
|
6464
|
+
getOrder: builder.query({
|
|
6465
|
+
query: (orderId) => `${process.env.NEXT_PUBLIC_PAYMENTS_URL}/v1/payment/orders/${orderId}`,
|
|
6466
|
+
providesTags: (_result, _error, orderId) => [{ type: 'Orders', id: orderId }],
|
|
6467
|
+
}),
|
|
6451
6468
|
}),
|
|
6452
6469
|
});
|
|
6453
6470
|
// Export hooks for usage in functional components.
|
|
6454
|
-
const { useFetchOrdersQuery, useLazyFetchOrdersQuery } = ordersApi;
|
|
6471
|
+
const { useFetchOrdersQuery, useLazyFetchOrdersQuery, useGetOrdersQuery, useGetOrderQuery, } = ordersApi;
|
|
6455
6472
|
|
|
6456
6473
|
const initialState = {
|
|
6457
6474
|
addedItems: [],
|
|
@@ -6532,10 +6549,13 @@ const cartSlice = toolkit.createSlice({
|
|
|
6532
6549
|
},
|
|
6533
6550
|
addToCart: (state, action) => {
|
|
6534
6551
|
const { options, item } = action.payload;
|
|
6535
|
-
const
|
|
6552
|
+
const price = Number(options?.selectedPrice) || 0;
|
|
6553
|
+
const currentNetTotal = Number(state.netTotal) || 0;
|
|
6554
|
+
const newTotal = currentNetTotal + price;
|
|
6536
6555
|
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
6537
6556
|
const grossTotal = newTotal + taxAmount;
|
|
6538
|
-
const
|
|
6557
|
+
const sanitizedOptions = { ...options, selectedPrice: price };
|
|
6558
|
+
const addItem = item ? { ...item, options: sanitizedOptions } : null;
|
|
6539
6559
|
if (!addItem) {
|
|
6540
6560
|
return state;
|
|
6541
6561
|
}
|
|
@@ -6559,7 +6579,9 @@ const cartSlice = toolkit.createSlice({
|
|
|
6559
6579
|
},
|
|
6560
6580
|
removeFromCart: (state, action) => {
|
|
6561
6581
|
const { id, price } = action.payload;
|
|
6562
|
-
const
|
|
6582
|
+
const sanitizedPrice = Number(price) || 0;
|
|
6583
|
+
const currentNetTotal = Number(state.netTotal) || 0;
|
|
6584
|
+
const newTotal = currentNetTotal - sanitizedPrice;
|
|
6563
6585
|
const taxAmount = newTotal * (state.taxRate.percentage / 100);
|
|
6564
6586
|
const grossTotal = newTotal + taxAmount;
|
|
6565
6587
|
return {
|
|
@@ -6665,9 +6687,13 @@ exports.setTaxRate = setTaxRate;
|
|
|
6665
6687
|
exports.toCamelCaseObject = toCamelCaseObject;
|
|
6666
6688
|
exports.toggleCart = toggleCart;
|
|
6667
6689
|
exports.updateCart = updateCart;
|
|
6690
|
+
exports.useFetchOrdersQuery = useFetchOrdersQuery;
|
|
6668
6691
|
exports.useForgottenPasswordMutation = useForgottenPasswordMutation;
|
|
6692
|
+
exports.useGetOrderQuery = useGetOrderQuery;
|
|
6693
|
+
exports.useGetOrdersQuery = useGetOrdersQuery;
|
|
6669
6694
|
exports.useGetProductsQuery = useGetProductsQuery;
|
|
6670
6695
|
exports.useGetUserInfoQuery = useGetUserInfoQuery;
|
|
6696
|
+
exports.useLazyFetchOrdersQuery = useLazyFetchOrdersQuery;
|
|
6671
6697
|
exports.useLazyGetProductsQuery = useLazyGetProductsQuery;
|
|
6672
6698
|
exports.useLazyGetUserInfoQuery = useLazyGetUserInfoQuery;
|
|
6673
6699
|
exports.useLazyVerifyUserAttributesQuery = useLazyVerifyUserAttributesQuery;
|
|
@@ -6682,4 +6708,4 @@ exports.useUpdateUserMutation = useUpdateUserMutation;
|
|
|
6682
6708
|
exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
|
|
6683
6709
|
exports.useVerifyUserQuery = useVerifyUserQuery;
|
|
6684
6710
|
exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
|
|
6685
|
-
//# sourceMappingURL=slice-
|
|
6711
|
+
//# sourceMappingURL=slice-CJ4WSj5p.js.map
|