@storepecker/storefront-core 2.2.2 → 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/api/index.cjs +78 -74
- package/dist/api/index.d.cts +6 -1
- package/dist/api/index.d.ts +6 -1
- package/dist/api/index.js +6 -6
- package/dist/checkout/index.cjs +23 -23
- package/dist/checkout/index.js +3 -3
- package/dist/{chunk-BHOXJGIE.js → chunk-27MTKBJL.js} +1 -1
- package/dist/chunk-3SYYP3XV.js +121 -0
- package/dist/{chunk-XLQAALMU.cjs → chunk-65Z7I5UP.cjs} +10 -10
- package/dist/{chunk-N3ZCCKXV.cjs → chunk-665CNTEX.cjs} +5 -5
- package/dist/{chunk-A67PCF55.cjs → chunk-6BVTMDR2.cjs} +17 -17
- package/dist/{chunk-7R2V4C7Q.js → chunk-AFM4IJVE.js} +1 -1
- package/dist/{chunk-FMHR5ABF.cjs → chunk-CV6DWPYF.cjs} +28 -28
- package/dist/chunk-ECHV2JSY.cjs +130 -0
- package/dist/{chunk-G3R7ZVAG.cjs → chunk-RDUT4W3B.cjs} +7 -7
- package/dist/{chunk-GHABOHLA.js → chunk-VWFZZFZL.js} +1 -1
- package/dist/{chunk-C7ZJZEEN.js → chunk-WYXT5AAG.js} +1 -1
- package/dist/{chunk-ZKHQPHT5.js → chunk-X35IATPX.js} +55 -7
- package/dist/{chunk-KKQKHG26.cjs → chunk-Y46EHRJQ.cjs} +3 -3
- package/dist/{chunk-ERLBPVFK.js → chunk-YEJZYH55.js} +1 -1
- package/dist/{chunk-JVSR6THX.cjs → chunk-Z4DBCDAH.cjs} +57 -9
- package/dist/{chunk-YY77CUWX.js → chunk-ZGMLOLTC.js} +1 -1
- package/dist/components/index.cjs +4 -4
- package/dist/components/index.js +3 -3
- package/dist/hooks/index.cjs +32 -31
- package/dist/hooks/index.js +9 -8
- package/dist/store/index.cjs +8 -8
- package/dist/store/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-JWKDXFS4.js +0 -61
- package/dist/chunk-ZO2HREQL.cjs +0 -69
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
|
|
4
4
|
|
|
5
5
|
// src/api/address.ts
|
|
6
6
|
async function getAddresses(url) {
|
|
7
|
-
const response = await
|
|
7
|
+
const response = await chunkECHV2JSY_cjs.http_service_default.get(url);
|
|
8
8
|
return response.data;
|
|
9
9
|
}
|
|
10
10
|
async function addAddress(addressDetails) {
|
|
11
|
-
return
|
|
11
|
+
return chunkECHV2JSY_cjs.http_service_default.post("/store/customer_address/", addressDetails);
|
|
12
12
|
}
|
|
13
13
|
async function updateAddress(addressDetails) {
|
|
14
|
-
return
|
|
14
|
+
return chunkECHV2JSY_cjs.http_service_default.patch("/store/customer_address/", addressDetails);
|
|
15
15
|
}
|
|
16
16
|
async function deleteAddress(address_id) {
|
|
17
|
-
return
|
|
17
|
+
return chunkECHV2JSY_cjs.http_service_default.delete("/store/customer_address/", {
|
|
18
18
|
params: { address_id }
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// src/api/countries.ts
|
|
23
23
|
var getCountries = async () => {
|
|
24
|
-
return
|
|
24
|
+
return chunkECHV2JSY_cjs.http_service_default.get("utils/countries/");
|
|
25
25
|
};
|
|
26
26
|
var getSubdivisions = async (countryId) => {
|
|
27
|
-
return
|
|
27
|
+
return chunkECHV2JSY_cjs.http_service_default.get(`utils/subdivisions/`, {
|
|
28
28
|
params: { country_id: countryId }
|
|
29
29
|
});
|
|
30
30
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { updateCart, removeFromCart, addToCart, getCart } from './chunk-
|
|
1
|
+
import { updateCart, removeFromCart, addToCart, getCart } from './chunk-YEJZYH55.js';
|
|
2
2
|
import { cart_default } from './chunk-QAC72HKO.js';
|
|
3
3
|
import { auth_default } from './chunk-WEMNXIRS.js';
|
|
4
4
|
import { USER_CRED_TOKEN, USER_CREDENTIALS } from './chunk-BQ256JKN.js';
|
|
@@ -42,8 +42,24 @@ var useCartStore = create((set) => ({
|
|
|
42
42
|
addToCart: async (items, customizationInputs, addressId) => {
|
|
43
43
|
set({ status: "loading" /* LOADING */ });
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (auth_default.getUserDetails()) {
|
|
46
|
+
await addToCart(items, customizationInputs);
|
|
47
|
+
await useCartStore.getState().syncCart(addressId);
|
|
48
|
+
} else {
|
|
49
|
+
const cart = cart_default.get();
|
|
50
|
+
if (cart) {
|
|
51
|
+
items.forEach((item) => {
|
|
52
|
+
const product = cart.product_variants.find(
|
|
53
|
+
(p) => p.id === item.variant_id
|
|
54
|
+
);
|
|
55
|
+
if (product) {
|
|
56
|
+
cart_default.add(product);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const updatedCart = cart_default.get();
|
|
61
|
+
if (updatedCart) set({ cart: updatedCart });
|
|
62
|
+
}
|
|
47
63
|
} catch {
|
|
48
64
|
} finally {
|
|
49
65
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -52,8 +68,26 @@ var useCartStore = create((set) => ({
|
|
|
52
68
|
removeFromCart: async (items, addressId) => {
|
|
53
69
|
set({ status: "loading" /* LOADING */ });
|
|
54
70
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
if (auth_default.getUserDetails()) {
|
|
72
|
+
await removeFromCart(items);
|
|
73
|
+
await useCartStore.getState().syncCart(addressId);
|
|
74
|
+
} else {
|
|
75
|
+
const cart = cart_default.get();
|
|
76
|
+
if (cart) {
|
|
77
|
+
items.forEach((item) => {
|
|
78
|
+
const product = cart.product_variants.find(
|
|
79
|
+
(p) => p.id === item.variant_id
|
|
80
|
+
);
|
|
81
|
+
if (product) cart_default.remove(product);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const updatedCart = cart_default.get();
|
|
85
|
+
if (updatedCart) {
|
|
86
|
+
set({ cart: updatedCart });
|
|
87
|
+
} else {
|
|
88
|
+
set(initialState);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
57
91
|
} catch {
|
|
58
92
|
} finally {
|
|
59
93
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -62,8 +96,22 @@ var useCartStore = create((set) => ({
|
|
|
62
96
|
updateCart: async (items, addressId) => {
|
|
63
97
|
set({ status: "loading" /* LOADING */ });
|
|
64
98
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
99
|
+
if (auth_default.getUserDetails()) {
|
|
100
|
+
await updateCart(items);
|
|
101
|
+
await useCartStore.getState().syncCart(addressId);
|
|
102
|
+
} else {
|
|
103
|
+
const cart = cart_default.get();
|
|
104
|
+
if (cart) {
|
|
105
|
+
items.forEach((item) => {
|
|
106
|
+
const product = cart.product_variants.find(
|
|
107
|
+
(p) => p.id === item.variant_id
|
|
108
|
+
);
|
|
109
|
+
if (product) cart_default.updateQuantity(product, item.quantity);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const updatedCart = cart_default.get();
|
|
113
|
+
if (updatedCart) set({ cart: updatedCart });
|
|
114
|
+
}
|
|
67
115
|
} catch {
|
|
68
116
|
} finally {
|
|
69
117
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
|
|
4
4
|
|
|
5
5
|
// src/api/user.ts
|
|
6
6
|
async function getUserDetails(url) {
|
|
7
|
-
const response = await
|
|
7
|
+
const response = await chunkECHV2JSY_cjs.http_service_default.get(url);
|
|
8
8
|
return response.data;
|
|
9
9
|
}
|
|
10
10
|
async function updateUserDetails(userDetails) {
|
|
11
|
-
return
|
|
11
|
+
return chunkECHV2JSY_cjs.http_service_default.patch("/users/store/profile/", { ...userDetails });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
exports.getUserDetails = getUserDetails;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6BVTMDR2_cjs = require('./chunk-6BVTMDR2.cjs');
|
|
4
4
|
var chunkSMHJRNCR_cjs = require('./chunk-SMHJRNCR.cjs');
|
|
5
5
|
var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
|
|
6
6
|
var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
|
|
@@ -22,7 +22,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
22
22
|
syncCart: async (addressId) => {
|
|
23
23
|
set({ status: "loading" /* LOADING */ });
|
|
24
24
|
try {
|
|
25
|
-
const response = await
|
|
25
|
+
const response = await chunk6BVTMDR2_cjs.getCart("/customer/cart/", addressId);
|
|
26
26
|
if (response) {
|
|
27
27
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
28
28
|
}
|
|
@@ -33,7 +33,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
33
33
|
fetchCart: async (addressId) => {
|
|
34
34
|
set({ status: "loading" /* LOADING */ });
|
|
35
35
|
try {
|
|
36
|
-
const response = await
|
|
36
|
+
const response = await chunk6BVTMDR2_cjs.getCart("/customer/cart/", addressId);
|
|
37
37
|
if (response) {
|
|
38
38
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
39
39
|
}
|
|
@@ -44,8 +44,24 @@ var useCartStore = zustand.create((set) => ({
|
|
|
44
44
|
addToCart: async (items, customizationInputs, addressId) => {
|
|
45
45
|
set({ status: "loading" /* LOADING */ });
|
|
46
46
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
48
|
+
await chunk6BVTMDR2_cjs.addToCart(items, customizationInputs);
|
|
49
|
+
await useCartStore.getState().syncCart(addressId);
|
|
50
|
+
} else {
|
|
51
|
+
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
52
|
+
if (cart) {
|
|
53
|
+
items.forEach((item) => {
|
|
54
|
+
const product = cart.product_variants.find(
|
|
55
|
+
(p) => p.id === item.variant_id
|
|
56
|
+
);
|
|
57
|
+
if (product) {
|
|
58
|
+
chunkSMHJRNCR_cjs.cart_default.add(product);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
63
|
+
if (updatedCart) set({ cart: updatedCart });
|
|
64
|
+
}
|
|
49
65
|
} catch {
|
|
50
66
|
} finally {
|
|
51
67
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -54,8 +70,26 @@ var useCartStore = zustand.create((set) => ({
|
|
|
54
70
|
removeFromCart: async (items, addressId) => {
|
|
55
71
|
set({ status: "loading" /* LOADING */ });
|
|
56
72
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
74
|
+
await chunk6BVTMDR2_cjs.removeFromCart(items);
|
|
75
|
+
await useCartStore.getState().syncCart(addressId);
|
|
76
|
+
} else {
|
|
77
|
+
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
78
|
+
if (cart) {
|
|
79
|
+
items.forEach((item) => {
|
|
80
|
+
const product = cart.product_variants.find(
|
|
81
|
+
(p) => p.id === item.variant_id
|
|
82
|
+
);
|
|
83
|
+
if (product) chunkSMHJRNCR_cjs.cart_default.remove(product);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
87
|
+
if (updatedCart) {
|
|
88
|
+
set({ cart: updatedCart });
|
|
89
|
+
} else {
|
|
90
|
+
set(initialState);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
59
93
|
} catch {
|
|
60
94
|
} finally {
|
|
61
95
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -64,8 +98,22 @@ var useCartStore = zustand.create((set) => ({
|
|
|
64
98
|
updateCart: async (items, addressId) => {
|
|
65
99
|
set({ status: "loading" /* LOADING */ });
|
|
66
100
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
101
|
+
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
102
|
+
await chunk6BVTMDR2_cjs.updateCart(items);
|
|
103
|
+
await useCartStore.getState().syncCart(addressId);
|
|
104
|
+
} else {
|
|
105
|
+
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
106
|
+
if (cart) {
|
|
107
|
+
items.forEach((item) => {
|
|
108
|
+
const product = cart.product_variants.find(
|
|
109
|
+
(p) => p.id === item.variant_id
|
|
110
|
+
);
|
|
111
|
+
if (product) chunkSMHJRNCR_cjs.cart_default.updateQuantity(product, item.quantity);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
115
|
+
if (updatedCart) set({ cart: updatedCart });
|
|
116
|
+
}
|
|
69
117
|
} catch {
|
|
70
118
|
} finally {
|
|
71
119
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkBBRB475I_cjs = require('../chunk-BBRB475I.cjs');
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
4
|
+
var chunk665CNTEX_cjs = require('../chunk-665CNTEX.cjs');
|
|
5
|
+
require('../chunk-RDUT4W3B.cjs');
|
|
6
6
|
var chunk4CVKE6CC_cjs = require('../chunk-4CVKE6CC.cjs');
|
|
7
7
|
require('../chunk-47XTPPII.cjs');
|
|
8
|
-
require('../chunk-
|
|
8
|
+
require('../chunk-ECHV2JSY.cjs');
|
|
9
9
|
require('../chunk-BBRXE57K.cjs');
|
|
10
10
|
require('../chunk-NE3ZHELZ.cjs');
|
|
11
11
|
require('../chunk-N3CTXRFT.cjs');
|
|
@@ -343,7 +343,7 @@ var AddressForm = react.forwardRef(
|
|
|
343
343
|
handlePhoneChange,
|
|
344
344
|
isSubmitting,
|
|
345
345
|
isEditing
|
|
346
|
-
} =
|
|
346
|
+
} = chunk665CNTEX_cjs.useAddressForm({
|
|
347
347
|
address,
|
|
348
348
|
onSuccess,
|
|
349
349
|
onError,
|
package/dist/components/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { timeFromNow, isExpired } from '../chunk-HSF2D56O.js';
|
|
2
|
-
import { useAddressForm } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
import { useAddressForm } from '../chunk-AFM4IJVE.js';
|
|
3
|
+
import '../chunk-ZGMLOLTC.js';
|
|
4
4
|
import { shareLink, convertToCurrency } from '../chunk-YUPBTD4M.js';
|
|
5
5
|
import '../chunk-B7FOXIZN.js';
|
|
6
|
-
import '../chunk-
|
|
6
|
+
import '../chunk-3SYYP3XV.js';
|
|
7
7
|
import '../chunk-WEMNXIRS.js';
|
|
8
8
|
import '../chunk-BQ256JKN.js';
|
|
9
9
|
import '../chunk-JQMLHRWL.js';
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkY46EHRJQ_cjs = require('../chunk-Y46EHRJQ.cjs');
|
|
4
4
|
var chunk2AHH3XBW_cjs = require('../chunk-2AHH3XBW.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkZ4DBCDAH_cjs = require('../chunk-Z4DBCDAH.cjs');
|
|
6
|
+
var chunk6BVTMDR2_cjs = require('../chunk-6BVTMDR2.cjs');
|
|
7
7
|
var chunkSMHJRNCR_cjs = require('../chunk-SMHJRNCR.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var chunk65Z7I5UP_cjs = require('../chunk-65Z7I5UP.cjs');
|
|
9
|
+
var chunkCV6DWPYF_cjs = require('../chunk-CV6DWPYF.cjs');
|
|
10
10
|
require('../chunk-K44JZ5NL.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var chunk665CNTEX_cjs = require('../chunk-665CNTEX.cjs');
|
|
12
|
+
var chunkRDUT4W3B_cjs = require('../chunk-RDUT4W3B.cjs');
|
|
13
13
|
var chunk4CVKE6CC_cjs = require('../chunk-4CVKE6CC.cjs');
|
|
14
14
|
require('../chunk-47XTPPII.cjs');
|
|
15
|
-
require('../chunk-
|
|
15
|
+
require('../chunk-ECHV2JSY.cjs');
|
|
16
16
|
require('../chunk-BBRXE57K.cjs');
|
|
17
17
|
require('../chunk-NE3ZHELZ.cjs');
|
|
18
18
|
require('../chunk-N3CTXRFT.cjs');
|
|
@@ -27,11 +27,12 @@ var useAddress = () => {
|
|
|
27
27
|
const fetchData = react.useCallback(async () => {
|
|
28
28
|
try {
|
|
29
29
|
setIsLoading(true);
|
|
30
|
-
const result = await
|
|
30
|
+
const result = await chunkRDUT4W3B_cjs.getAddresses("/store/customer_address/");
|
|
31
31
|
setData(result || []);
|
|
32
32
|
setError(null);
|
|
33
33
|
} catch (err) {
|
|
34
34
|
setError(err);
|
|
35
|
+
setData([]);
|
|
35
36
|
} finally {
|
|
36
37
|
setIsLoading(false);
|
|
37
38
|
}
|
|
@@ -52,7 +53,7 @@ var useCart = (addressId) => {
|
|
|
52
53
|
async (addrId) => {
|
|
53
54
|
try {
|
|
54
55
|
setIsLoading(true);
|
|
55
|
-
const result = await
|
|
56
|
+
const result = await chunk6BVTMDR2_cjs.getCart("/customer/cart/", addrId ?? addressId);
|
|
56
57
|
setData(result);
|
|
57
58
|
setError(null);
|
|
58
59
|
} catch (err) {
|
|
@@ -87,7 +88,7 @@ var useOrders = (filters) => {
|
|
|
87
88
|
try {
|
|
88
89
|
setIsLoading(true);
|
|
89
90
|
const url = `/customer/order/?${queryString}`;
|
|
90
|
-
const result = await
|
|
91
|
+
const result = await chunkCV6DWPYF_cjs.getOrders(url);
|
|
91
92
|
setData(result);
|
|
92
93
|
setError(null);
|
|
93
94
|
} catch (err) {
|
|
@@ -124,7 +125,7 @@ function useGetProducts(initialFilter, options) {
|
|
|
124
125
|
apiParams[key] = value;
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
|
-
const result = await
|
|
128
|
+
const result = await chunk6BVTMDR2_cjs.getProductList(endpoint, apiParams);
|
|
128
129
|
setData(result);
|
|
129
130
|
if (modeRef.current === "append" && isLoadMoreRef.current) {
|
|
130
131
|
setProducts((prev) => [...prev, ...result.results || []]);
|
|
@@ -192,7 +193,7 @@ var useGetProductDetails = (slug) => {
|
|
|
192
193
|
const fetchData = react.useCallback(async () => {
|
|
193
194
|
try {
|
|
194
195
|
setIsLoading(true);
|
|
195
|
-
const result = await
|
|
196
|
+
const result = await chunk6BVTMDR2_cjs.getProductDetail("/inventory/products/", slug);
|
|
196
197
|
setData(result);
|
|
197
198
|
} catch (err) {
|
|
198
199
|
} finally {
|
|
@@ -215,7 +216,7 @@ var useGetProductCategories = () => {
|
|
|
215
216
|
const fetchData = async () => {
|
|
216
217
|
try {
|
|
217
218
|
setIsLoading(true);
|
|
218
|
-
const result = await
|
|
219
|
+
const result = await chunk6BVTMDR2_cjs.getProductCategories("/store/categories");
|
|
219
220
|
setData(result || []);
|
|
220
221
|
} catch (err) {
|
|
221
222
|
setError(err);
|
|
@@ -235,7 +236,7 @@ var useUserDetails = () => {
|
|
|
235
236
|
const fetchData = react.useCallback(async () => {
|
|
236
237
|
try {
|
|
237
238
|
setIsLoading(true);
|
|
238
|
-
const result = await
|
|
239
|
+
const result = await chunkY46EHRJQ_cjs.getUserDetails("/users/store/profile/");
|
|
239
240
|
setData(result);
|
|
240
241
|
setError(null);
|
|
241
242
|
} catch (err) {
|
|
@@ -260,7 +261,7 @@ var useWishlist = () => {
|
|
|
260
261
|
const fetchData = react.useCallback(async () => {
|
|
261
262
|
try {
|
|
262
263
|
setIsLoading(true);
|
|
263
|
-
const response = await
|
|
264
|
+
const response = await chunk6BVTMDR2_cjs.getWishlist("/customer/wishlist/");
|
|
264
265
|
if (response.data) setData(response.data);
|
|
265
266
|
setError(null);
|
|
266
267
|
} catch (err) {
|
|
@@ -318,7 +319,7 @@ function useCheckoutPayment(options) {
|
|
|
318
319
|
const [isConfirmingPayment, setIsConfirmingPayment] = react.useState(false);
|
|
319
320
|
const [showSuccessModal, setShowSuccessModal] = react.useState(false);
|
|
320
321
|
const [showFailureModal, setShowFailureModal] = react.useState(false);
|
|
321
|
-
const resetCartCount =
|
|
322
|
+
const resetCartCount = chunkZ4DBCDAH_cjs.useCartStore((s) => s.resetCartCount);
|
|
322
323
|
const callbacks = {
|
|
323
324
|
onSuccess: (order) => {
|
|
324
325
|
setOrderSummary(order);
|
|
@@ -341,7 +342,7 @@ function useCheckoutPayment(options) {
|
|
|
341
342
|
try {
|
|
342
343
|
setIsPlacingOrder(true);
|
|
343
344
|
const isCod = paymentMethod === "cod";
|
|
344
|
-
const response = await
|
|
345
|
+
const response = await chunkCV6DWPYF_cjs.placeOrder(
|
|
345
346
|
addressId,
|
|
346
347
|
options.phonepeRedirectUrl,
|
|
347
348
|
isCod,
|
|
@@ -350,7 +351,7 @@ function useCheckoutPayment(options) {
|
|
|
350
351
|
);
|
|
351
352
|
const order = response.data;
|
|
352
353
|
setOrderSummary(order);
|
|
353
|
-
|
|
354
|
+
chunk65Z7I5UP_cjs.processPayment(order, paymentMethod, callbacks);
|
|
354
355
|
} catch {
|
|
355
356
|
setShowFailureModal(true);
|
|
356
357
|
} finally {
|
|
@@ -380,7 +381,7 @@ function useCheckoutCoupon(options) {
|
|
|
380
381
|
const refreshCoupons = react.useCallback(async () => {
|
|
381
382
|
setIsLoading(true);
|
|
382
383
|
try {
|
|
383
|
-
const coupons = await
|
|
384
|
+
const coupons = await chunk65Z7I5UP_cjs.fetchAvailableCoupons();
|
|
384
385
|
setAvailableCoupons(coupons);
|
|
385
386
|
} catch {
|
|
386
387
|
} finally {
|
|
@@ -392,7 +393,7 @@ function useCheckoutCoupon(options) {
|
|
|
392
393
|
setError(null);
|
|
393
394
|
setIsApplying(true);
|
|
394
395
|
try {
|
|
395
|
-
const coupon = await
|
|
396
|
+
const coupon = await chunk65Z7I5UP_cjs.applyCheckoutCoupon(code, callbacks);
|
|
396
397
|
setAppliedCoupon(coupon);
|
|
397
398
|
} catch (err) {
|
|
398
399
|
setError(err instanceof Error ? err.message : "Failed to apply coupon");
|
|
@@ -405,7 +406,7 @@ function useCheckoutCoupon(options) {
|
|
|
405
406
|
const removeCouponHandler = react.useCallback(async () => {
|
|
406
407
|
if (!appliedCoupon) return;
|
|
407
408
|
try {
|
|
408
|
-
await
|
|
409
|
+
await chunk65Z7I5UP_cjs.removeCheckoutCoupon(appliedCoupon.coupon_code, callbacks);
|
|
409
410
|
setAppliedCoupon(null);
|
|
410
411
|
setError(null);
|
|
411
412
|
} catch {
|
|
@@ -504,8 +505,8 @@ function useVariantSelector(options) {
|
|
|
504
505
|
}
|
|
505
506
|
function useShopCheckout(options) {
|
|
506
507
|
const { product, onNavigateToCart, onToast } = options;
|
|
507
|
-
const { addToCart, setCart } =
|
|
508
|
-
const isUserAuthenticated =
|
|
508
|
+
const { addToCart, setCart } = chunkZ4DBCDAH_cjs.useCartStore();
|
|
509
|
+
const isUserAuthenticated = chunkZ4DBCDAH_cjs.useAuthStore((s) => s.isAuthenticated);
|
|
509
510
|
const [isWishlisted, setIsWishlisted] = react.useState(product.is_wishlisted);
|
|
510
511
|
const [isAddedToCart, setIsAddedToCart] = react.useState(false);
|
|
511
512
|
const [loading, setLoading] = react.useState(false);
|
|
@@ -516,7 +517,7 @@ function useShopCheckout(options) {
|
|
|
516
517
|
react.useEffect(() => {
|
|
517
518
|
const fetchCategories = async () => {
|
|
518
519
|
try {
|
|
519
|
-
const response = await
|
|
520
|
+
const response = await chunk6BVTMDR2_cjs.getCategories();
|
|
520
521
|
setCategories(response.data);
|
|
521
522
|
} catch (error) {
|
|
522
523
|
console.log(error);
|
|
@@ -630,7 +631,7 @@ function useShopCheckout(options) {
|
|
|
630
631
|
const handleNotifyMeFormSubmit = react.useCallback(
|
|
631
632
|
async (values) => {
|
|
632
633
|
try {
|
|
633
|
-
const response = await
|
|
634
|
+
const response = await chunk6BVTMDR2_cjs.notifyProductStock({
|
|
634
635
|
...values,
|
|
635
636
|
variant_slug: product.slug
|
|
636
637
|
});
|
|
@@ -693,7 +694,7 @@ function useCoupon(options = {}) {
|
|
|
693
694
|
react.useEffect(() => {
|
|
694
695
|
const fetchCoupons = async () => {
|
|
695
696
|
try {
|
|
696
|
-
const response = await
|
|
697
|
+
const response = await chunkCV6DWPYF_cjs.getCoupons();
|
|
697
698
|
if (response.data) {
|
|
698
699
|
setAvailableCoupons(response.data);
|
|
699
700
|
}
|
|
@@ -702,7 +703,7 @@ function useCoupon(options = {}) {
|
|
|
702
703
|
};
|
|
703
704
|
const fetchAppliedCoupon2 = async () => {
|
|
704
705
|
try {
|
|
705
|
-
const response = await
|
|
706
|
+
const response = await chunkCV6DWPYF_cjs.getAppliedCoupon();
|
|
706
707
|
if (response.data) {
|
|
707
708
|
setAppliedCoupon(response.data);
|
|
708
709
|
}
|
|
@@ -723,7 +724,7 @@ function useCoupon(options = {}) {
|
|
|
723
724
|
try {
|
|
724
725
|
setCouponApplyingLoading(true);
|
|
725
726
|
setCouponApplyingError(null);
|
|
726
|
-
const response = await
|
|
727
|
+
const response = await chunkCV6DWPYF_cjs.applyCoupon(code);
|
|
727
728
|
if (response.data) {
|
|
728
729
|
onCouponStatusChange?.(response.data.coupon);
|
|
729
730
|
setAppliedCoupon(response.data.coupon);
|
|
@@ -741,7 +742,7 @@ function useCoupon(options = {}) {
|
|
|
741
742
|
const handleRemoveCoupon = react.useCallback(async () => {
|
|
742
743
|
if (!appliedCoupon) return;
|
|
743
744
|
try {
|
|
744
|
-
const response = await
|
|
745
|
+
const response = await chunkCV6DWPYF_cjs.removeCoupon(appliedCoupon.coupon_code);
|
|
745
746
|
if (response.data) {
|
|
746
747
|
setAppliedCoupon(null);
|
|
747
748
|
onCouponStatusChange?.(null);
|
|
@@ -765,7 +766,7 @@ function useCoupon(options = {}) {
|
|
|
765
766
|
|
|
766
767
|
Object.defineProperty(exports, "useAddressForm", {
|
|
767
768
|
enumerable: true,
|
|
768
|
-
get: function () { return
|
|
769
|
+
get: function () { return chunk665CNTEX_cjs.useAddressForm; }
|
|
769
770
|
});
|
|
770
771
|
exports.useAddress = useAddress;
|
|
771
772
|
exports.useCart = useCart;
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getUserDetails } from '../chunk-
|
|
1
|
+
import { getUserDetails } from '../chunk-WYXT5AAG.js';
|
|
2
2
|
import { findMatchingVariant, findSimilarVariant, isVariantCombinationAvailable, isColorVariantType } from '../chunk-HEFA67WK.js';
|
|
3
|
-
import { useCartStore, useAuthStore } from '../chunk-
|
|
4
|
-
import { getCart, getProductList, getProductDetail, getWishlist, notifyProductStock, getProductCategories, getCategories } from '../chunk-
|
|
3
|
+
import { useCartStore, useAuthStore } from '../chunk-X35IATPX.js';
|
|
4
|
+
import { getCart, getProductList, getProductDetail, getWishlist, notifyProductStock, getProductCategories, getCategories } from '../chunk-YEJZYH55.js';
|
|
5
5
|
import { cart_default } from '../chunk-QAC72HKO.js';
|
|
6
|
-
import { processPayment, fetchAvailableCoupons, applyCheckoutCoupon, removeCheckoutCoupon } from '../chunk-
|
|
7
|
-
import { getOrders, placeOrder, applyCoupon, removeCoupon, getCoupons, getAppliedCoupon } from '../chunk-
|
|
6
|
+
import { processPayment, fetchAvailableCoupons, applyCheckoutCoupon, removeCheckoutCoupon } from '../chunk-27MTKBJL.js';
|
|
7
|
+
import { getOrders, placeOrder, applyCoupon, removeCoupon, getCoupons, getAppliedCoupon } from '../chunk-VWFZZFZL.js';
|
|
8
8
|
import '../chunk-WFDKKOO7.js';
|
|
9
|
-
export { useAddressForm } from '../chunk-
|
|
10
|
-
import { getAddresses } from '../chunk-
|
|
9
|
+
export { useAddressForm } from '../chunk-AFM4IJVE.js';
|
|
10
|
+
import { getAddresses } from '../chunk-ZGMLOLTC.js';
|
|
11
11
|
import { shareLink, convertToCurrency } from '../chunk-YUPBTD4M.js';
|
|
12
12
|
import '../chunk-B7FOXIZN.js';
|
|
13
|
-
import '../chunk-
|
|
13
|
+
import '../chunk-3SYYP3XV.js';
|
|
14
14
|
import '../chunk-WEMNXIRS.js';
|
|
15
15
|
import '../chunk-BQ256JKN.js';
|
|
16
16
|
import '../chunk-JQMLHRWL.js';
|
|
@@ -30,6 +30,7 @@ var useAddress = () => {
|
|
|
30
30
|
setError(null);
|
|
31
31
|
} catch (err) {
|
|
32
32
|
setError(err);
|
|
33
|
+
setData([]);
|
|
33
34
|
} finally {
|
|
34
35
|
setIsLoading(false);
|
|
35
36
|
}
|
package/dist/store/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZ4DBCDAH_cjs = require('../chunk-Z4DBCDAH.cjs');
|
|
4
|
+
var chunk6BVTMDR2_cjs = require('../chunk-6BVTMDR2.cjs');
|
|
5
5
|
require('../chunk-SMHJRNCR.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-ECHV2JSY.cjs');
|
|
7
7
|
require('../chunk-BBRXE57K.cjs');
|
|
8
8
|
require('../chunk-NE3ZHELZ.cjs');
|
|
9
9
|
require('../chunk-N3CTXRFT.cjs');
|
|
@@ -19,7 +19,7 @@ var useWishlistStore = zustand.create((set) => ({
|
|
|
19
19
|
resetWishlist: () => set(initialState),
|
|
20
20
|
syncWishlist: async () => {
|
|
21
21
|
try {
|
|
22
|
-
const response = await
|
|
22
|
+
const response = await chunk6BVTMDR2_cjs.getWishlist("/customer/wishlist/");
|
|
23
23
|
if (response.data) {
|
|
24
24
|
set({
|
|
25
25
|
wishlist_count: response.data.wishlist_count,
|
|
@@ -47,7 +47,7 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
47
47
|
data: filter.page === 1 ? [] : state.data
|
|
48
48
|
}));
|
|
49
49
|
try {
|
|
50
|
-
const response = await
|
|
50
|
+
const response = await chunk6BVTMDR2_cjs.getProducts({ ...filter });
|
|
51
51
|
if (response.data) {
|
|
52
52
|
const { results, ...meta } = response.data;
|
|
53
53
|
set((state) => ({
|
|
@@ -67,15 +67,15 @@ var useProductStore = zustand.create((set, get) => ({
|
|
|
67
67
|
|
|
68
68
|
Object.defineProperty(exports, "loginUser", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkZ4DBCDAH_cjs.loginUser; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "useAuthStore", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkZ4DBCDAH_cjs.useAuthStore; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "useCartStore", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkZ4DBCDAH_cjs.useCartStore; }
|
|
79
79
|
});
|
|
80
80
|
exports.useProductStore = useProductStore;
|
|
81
81
|
exports.useWishlistStore = useWishlistStore;
|
package/dist/store/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { loginUser, useAuthStore, useCartStore } from '../chunk-
|
|
2
|
-
import { getWishlist, getProducts } from '../chunk-
|
|
1
|
+
export { loginUser, useAuthStore, useCartStore } from '../chunk-X35IATPX.js';
|
|
2
|
+
import { getWishlist, getProducts } from '../chunk-YEJZYH55.js';
|
|
3
3
|
import '../chunk-QAC72HKO.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-3SYYP3XV.js';
|
|
5
5
|
import '../chunk-WEMNXIRS.js';
|
|
6
6
|
import '../chunk-BQ256JKN.js';
|
|
7
7
|
import '../chunk-JQMLHRWL.js';
|