@storepecker/storefront-core 2.3.1 → 2.3.3
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 +52 -51
- package/dist/api/index.d.cts +6 -6
- package/dist/api/index.d.ts +6 -6
- package/dist/api/index.js +3 -2
- package/dist/{booking-BSZ6NP-e.d.ts → booking-BVWe8HHh.d.ts} +1 -1
- package/dist/{booking-BGvxHd-t.d.cts → booking-DX9SU_qm.d.cts} +1 -1
- package/dist/{cart-XumsY-y0.d.cts → cart-kJoawc_Z.d.cts} +4 -1
- package/dist/{cart-CfsntcpS.d.ts → cart-y-7RPmnQ.d.ts} +4 -1
- package/dist/checkout/index.cjs +40 -35
- package/dist/checkout/index.d.cts +9 -4
- package/dist/checkout/index.d.ts +9 -4
- package/dist/checkout/index.js +4 -3
- package/dist/chunk-7M5CVYZJ.js +17 -0
- package/dist/{chunk-X35IATPX.js → chunk-ANTJLYQD.js} +12 -1
- package/dist/{chunk-65Z7I5UP.cjs → chunk-BTT3XQ32.cjs} +11 -10
- package/dist/{chunk-B7FOXIZN.js → chunk-ELP23UGF.js} +27 -2
- package/dist/{chunk-CV6DWPYF.cjs → chunk-HTFVROIV.cjs} +0 -18
- package/dist/{chunk-AFM4IJVE.js → chunk-ILVGYHNI.js} +1 -1
- package/dist/{chunk-665CNTEX.cjs → chunk-JCOOINQF.cjs} +5 -5
- package/dist/{chunk-VWFZZFZL.js → chunk-LW3V53WJ.js} +1 -15
- package/dist/{chunk-47XTPPII.cjs → chunk-TB72NPRM.cjs} +27 -1
- package/dist/{chunk-YEJZYH55.js → chunk-U25T7M6S.js} +2 -1
- package/dist/{chunk-Z4DBCDAH.cjs → chunk-WZ6I3N4O.cjs} +17 -6
- package/dist/chunk-XFOUNOKO.cjs +22 -0
- package/dist/{chunk-6BVTMDR2.cjs → chunk-Y2CPMT34.cjs} +2 -1
- package/dist/{chunk-27MTKBJL.js → chunk-Y4NGR42Z.js} +2 -1
- package/dist/{collections-D4tvWcZp.d.ts → collections-BDSVfRNo.d.ts} +1 -1
- package/dist/{collections-dCr3VEJo.d.cts → collections-WzvTO0OQ.d.cts} +1 -1
- package/dist/components/index.cjs +3 -3
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/hooks/index.cjs +28 -27
- package/dist/hooks/index.d.cts +4 -4
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.js +7 -6
- package/dist/models/index.d.cts +6 -6
- package/dist/models/index.d.ts +6 -6
- package/dist/{orders-Dm5Dq02y.d.cts → orders-CjNmCY5I.d.cts} +1 -1
- package/dist/{orders-CvCa7XWm.d.ts → orders-L_8eIkUS.d.ts} +1 -1
- package/dist/{product-Daxj09p9.d.cts → product-DJMdi4D4.d.cts} +4 -0
- package/dist/{product-Daxj09p9.d.ts → product-DJMdi4D4.d.ts} +4 -0
- package/dist/store/index.cjs +8 -7
- package/dist/store/index.d.cts +8 -3
- package/dist/store/index.d.ts +8 -3
- package/dist/store/index.js +3 -2
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.ts +5 -5
- package/dist/{wishlist-Cow1wVqf.d.cts → wishlist-CUuCTSVJ.d.cts} +1 -1
- package/dist/{wishlist-gamNg0T1.d.ts → wishlist-DKYFZR0s.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { updateCart, removeFromCart, addToCart, getCart } from './chunk-
|
|
1
|
+
import { updateCart, removeFromCart, addToCart, getCart } from './chunk-U25T7M6S.js';
|
|
2
2
|
import { cart_default } from './chunk-QAC72HKO.js';
|
|
3
|
+
import { updateOrderCustomization } from './chunk-LW3V53WJ.js';
|
|
3
4
|
import { auth_default } from './chunk-WEMNXIRS.js';
|
|
4
5
|
import { USER_CRED_TOKEN, USER_CREDENTIALS } from './chunk-BQ256JKN.js';
|
|
5
6
|
import { create } from 'zustand';
|
|
@@ -116,6 +117,16 @@ var useCartStore = create((set) => ({
|
|
|
116
117
|
} finally {
|
|
117
118
|
set({ status: "idle" /* IDLE */ });
|
|
118
119
|
}
|
|
120
|
+
},
|
|
121
|
+
updateCustomization: async (customizationInput) => {
|
|
122
|
+
set({ status: "loading" /* LOADING */ });
|
|
123
|
+
try {
|
|
124
|
+
await updateOrderCustomization(customizationInput);
|
|
125
|
+
await useCartStore.getState().syncCart();
|
|
126
|
+
} catch {
|
|
127
|
+
} finally {
|
|
128
|
+
set({ status: "idle" /* IDLE */ });
|
|
129
|
+
}
|
|
119
130
|
}
|
|
120
131
|
}));
|
|
121
132
|
var getInitialState = () => ({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXFOUNOKO_cjs = require('./chunk-XFOUNOKO.cjs');
|
|
4
4
|
var chunkK44JZ5NL_cjs = require('./chunk-K44JZ5NL.cjs');
|
|
5
|
+
var chunkHTFVROIV_cjs = require('./chunk-HTFVROIV.cjs');
|
|
5
6
|
var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
|
|
6
7
|
var axios = require('axios');
|
|
7
8
|
|
|
@@ -65,7 +66,7 @@ function openRazorpayCheckout(order, callbacks) {
|
|
|
65
66
|
async function handleRazorpaySuccess(data, order, callbacks) {
|
|
66
67
|
try {
|
|
67
68
|
callbacks.onPaymentStart?.();
|
|
68
|
-
await
|
|
69
|
+
await chunkHTFVROIV_cjs.razorpayOrderSuccess(data);
|
|
69
70
|
chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
|
|
70
71
|
chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
|
|
71
72
|
callbacks.onCartReset();
|
|
@@ -78,7 +79,7 @@ async function handleRazorpaySuccess(data, order, callbacks) {
|
|
|
78
79
|
}
|
|
79
80
|
async function handleRazorpayFail(order, callbacks) {
|
|
80
81
|
try {
|
|
81
|
-
await
|
|
82
|
+
await chunkHTFVROIV_cjs.razorpayOrderFail({
|
|
82
83
|
order_id: order.id,
|
|
83
84
|
razorpay_order_id: order.razorpay_order_id
|
|
84
85
|
});
|
|
@@ -110,9 +111,9 @@ async function handleCODPayment(order, callbacks, options) {
|
|
|
110
111
|
callbacks.onPaymentStart?.();
|
|
111
112
|
chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "cod");
|
|
112
113
|
if (options?.isPublic) {
|
|
113
|
-
await
|
|
114
|
+
await chunkHTFVROIV_cjs.publicMakeCODOrder(order.order_number);
|
|
114
115
|
} else {
|
|
115
|
-
await
|
|
116
|
+
await chunkHTFVROIV_cjs.makeCODOrder(order.id);
|
|
116
117
|
}
|
|
117
118
|
chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
|
|
118
119
|
chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
|
|
@@ -140,7 +141,7 @@ function handleStripePayment(order, callbacks) {
|
|
|
140
141
|
async function handleStripeSuccess(order, paymentIntentId, callbacks) {
|
|
141
142
|
try {
|
|
142
143
|
callbacks.onPaymentStart?.();
|
|
143
|
-
await
|
|
144
|
+
await chunkHTFVROIV_cjs.stripeOrderSuccess({
|
|
144
145
|
order_id: order.id,
|
|
145
146
|
payment_intent_id: paymentIntentId
|
|
146
147
|
});
|
|
@@ -174,12 +175,12 @@ function processPayment(order, paymentMethod, callbacks, options) {
|
|
|
174
175
|
handlePhonepePayment(order, callbacks);
|
|
175
176
|
}
|
|
176
177
|
async function fetchAvailableCoupons() {
|
|
177
|
-
const response = await
|
|
178
|
+
const response = await chunkXFOUNOKO_cjs.getCoupons();
|
|
178
179
|
return response.data;
|
|
179
180
|
}
|
|
180
181
|
async function fetchAppliedCoupon() {
|
|
181
182
|
try {
|
|
182
|
-
const response = await
|
|
183
|
+
const response = await chunkXFOUNOKO_cjs.getAppliedCoupon();
|
|
183
184
|
return response.data || null;
|
|
184
185
|
} catch {
|
|
185
186
|
return null;
|
|
@@ -187,7 +188,7 @@ async function fetchAppliedCoupon() {
|
|
|
187
188
|
}
|
|
188
189
|
async function applyCheckoutCoupon(code, callbacks) {
|
|
189
190
|
try {
|
|
190
|
-
const response = await
|
|
191
|
+
const response = await chunkXFOUNOKO_cjs.applyCoupon(code);
|
|
191
192
|
if (response.data?.coupon) {
|
|
192
193
|
await callbacks.onCartRefresh();
|
|
193
194
|
return response.data.coupon;
|
|
@@ -201,7 +202,7 @@ async function applyCheckoutCoupon(code, callbacks) {
|
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
async function removeCheckoutCoupon(couponCode, callbacks) {
|
|
204
|
-
await
|
|
205
|
+
await chunkXFOUNOKO_cjs.removeCoupon(couponCode);
|
|
205
206
|
await callbacks.onCartRefresh();
|
|
206
207
|
}
|
|
207
208
|
|
|
@@ -15,10 +15,30 @@ var addressFormInitialValues = {
|
|
|
15
15
|
city: "",
|
|
16
16
|
customer_email: ""
|
|
17
17
|
};
|
|
18
|
+
function sanitizePhoneNumber(input, countryCode) {
|
|
19
|
+
let cleaned = input.trim().replace(/\s+/g, "");
|
|
20
|
+
try {
|
|
21
|
+
const callingCode = getCountryCallingCode(countryCode);
|
|
22
|
+
const prefix = `+${callingCode}`;
|
|
23
|
+
if (cleaned.startsWith(prefix)) {
|
|
24
|
+
cleaned = cleaned.slice(prefix.length);
|
|
25
|
+
} else if (cleaned.startsWith(callingCode)) {
|
|
26
|
+
cleaned = cleaned.slice(callingCode.length);
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
if (cleaned.startsWith("+")) {
|
|
30
|
+
cleaned = cleaned.replace(/^\+\d{1,4}/, "");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
cleaned = cleaned.replace(/^0+/, "");
|
|
34
|
+
return cleaned;
|
|
35
|
+
}
|
|
18
36
|
function isValidPhoneNumber(input, countryCode) {
|
|
19
37
|
if (!input) return false;
|
|
20
38
|
const phone = parsePhoneNumberFromString(input, countryCode);
|
|
21
|
-
|
|
39
|
+
if (!phone?.isValid()) return false;
|
|
40
|
+
if (phone.country && phone.country !== countryCode) return false;
|
|
41
|
+
return true;
|
|
22
42
|
}
|
|
23
43
|
var addressValidationSchema = Yup.object({
|
|
24
44
|
customer_phone: Yup.string().required("Phone number required").test("is-valid", "Please enter a valid number", function(value) {
|
|
@@ -109,8 +129,13 @@ function buildSubmitPayload(values, country, states) {
|
|
|
109
129
|
customerCountryCode = values.customer_country_code;
|
|
110
130
|
}
|
|
111
131
|
}
|
|
132
|
+
const cleanPhone = sanitizePhoneNumber(
|
|
133
|
+
values.customer_phone,
|
|
134
|
+
values.customer_country_code
|
|
135
|
+
);
|
|
112
136
|
return {
|
|
113
137
|
...formValues,
|
|
138
|
+
customer_phone: cleanPhone,
|
|
114
139
|
country: country?.name || "india",
|
|
115
140
|
country_obj: country?.id || 105,
|
|
116
141
|
customer_country_code: customerCountryCode,
|
|
@@ -118,4 +143,4 @@ function buildSubmitPayload(values, country, states) {
|
|
|
118
143
|
};
|
|
119
144
|
}
|
|
120
145
|
|
|
121
|
-
export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, saveAddressFormToSession };
|
|
146
|
+
export { IP_API_CACHE_KEY, addressFormInitialValues, addressValidationSchema, buildAddressPayload, buildSubmitPayload, clearAddressFormSession, decodeAddress, encodeAddress, isValidPhoneNumber, loadAddressFormFromSession, parseEditAddress, sanitizePhoneNumber, saveAddressFormToSession };
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
|
|
4
4
|
|
|
5
|
-
// src/api/coupon.ts
|
|
6
|
-
async function getCoupons() {
|
|
7
|
-
return chunkECHV2JSY_cjs.http_service_default.get("/coupon/available/");
|
|
8
|
-
}
|
|
9
|
-
async function applyCoupon(couponCode) {
|
|
10
|
-
return chunkECHV2JSY_cjs.http_service_default.post("/coupon/use/", { coupon_code: couponCode });
|
|
11
|
-
}
|
|
12
|
-
async function getAppliedCoupon() {
|
|
13
|
-
return chunkECHV2JSY_cjs.http_service_default.get("/coupon/use/");
|
|
14
|
-
}
|
|
15
|
-
async function removeCoupon(couponCode) {
|
|
16
|
-
return chunkECHV2JSY_cjs.http_service_default.delete("/coupon/use/");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
// src/api/orders.ts
|
|
20
6
|
async function getOrders(url) {
|
|
21
7
|
const response = await chunkECHV2JSY_cjs.http_service_default.get(url);
|
|
@@ -122,10 +108,7 @@ async function verifyTabbyPayment(orderNumber) {
|
|
|
122
108
|
});
|
|
123
109
|
}
|
|
124
110
|
|
|
125
|
-
exports.applyCoupon = applyCoupon;
|
|
126
111
|
exports.checkPhonepePaymentStatus = checkPhonepePaymentStatus;
|
|
127
|
-
exports.getAppliedCoupon = getAppliedCoupon;
|
|
128
|
-
exports.getCoupons = getCoupons;
|
|
129
112
|
exports.getOrderDetails = getOrderDetails;
|
|
130
113
|
exports.getOrderDetailsByNumber = getOrderDetailsByNumber;
|
|
131
114
|
exports.getOrders = getOrders;
|
|
@@ -141,7 +124,6 @@ exports.publicPlaceOrder = publicPlaceOrder;
|
|
|
141
124
|
exports.razorpayOrderFail = razorpayOrderFail;
|
|
142
125
|
exports.razorpayOrderSuccess = razorpayOrderSuccess;
|
|
143
126
|
exports.razorpayPublicOrderSuccess = razorpayPublicOrderSuccess;
|
|
144
|
-
exports.removeCoupon = removeCoupon;
|
|
145
127
|
exports.stripeOrderFail = stripeOrderFail;
|
|
146
128
|
exports.stripeOrderSuccess = stripeOrderSuccess;
|
|
147
129
|
exports.stripePublicOrderSuccess = stripePublicOrderSuccess;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { updateAddress, addAddress, getCountries, getSubdivisions } from './chunk-ZGMLOLTC.js';
|
|
2
2
|
import { getCache, getAddressMeta } from './chunk-YUPBTD4M.js';
|
|
3
|
-
import { addressFormInitialValues, IP_API_CACHE_KEY, addressValidationSchema, buildSubmitPayload } from './chunk-
|
|
3
|
+
import { addressFormInitialValues, IP_API_CACHE_KEY, addressValidationSchema, buildSubmitPayload } from './chunk-ELP23UGF.js';
|
|
4
4
|
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
5
5
|
import { useFormik } from 'formik';
|
|
6
6
|
import { isSupportedCountry, getCountryCallingCode } from 'libphonenumber-js';
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkRDUT4W3B_cjs = require('./chunk-RDUT4W3B.cjs');
|
|
4
4
|
var chunk4CVKE6CC_cjs = require('./chunk-4CVKE6CC.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkTB72NPRM_cjs = require('./chunk-TB72NPRM.cjs');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var formik = require('formik');
|
|
8
8
|
var libphonenumberJs = require('libphonenumber-js');
|
|
9
9
|
|
|
10
10
|
var defaultInitialValues = {
|
|
11
|
-
...
|
|
11
|
+
...chunkTB72NPRM_cjs.addressFormInitialValues,
|
|
12
12
|
is_default: false,
|
|
13
13
|
country_obj: "IN"
|
|
14
14
|
};
|
|
@@ -17,7 +17,7 @@ function useAddressForm(options = {}) {
|
|
|
17
17
|
address,
|
|
18
18
|
onSuccess,
|
|
19
19
|
onError,
|
|
20
|
-
locationCacheKey =
|
|
20
|
+
locationCacheKey = chunkTB72NPRM_cjs.IP_API_CACHE_KEY,
|
|
21
21
|
defaultCountryId = 105
|
|
22
22
|
} = options;
|
|
23
23
|
const isEditing = !!address;
|
|
@@ -28,11 +28,11 @@ function useAddressForm(options = {}) {
|
|
|
28
28
|
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
29
29
|
const formik$1 = formik.useFormik({
|
|
30
30
|
initialValues: defaultInitialValues,
|
|
31
|
-
validationSchema:
|
|
31
|
+
validationSchema: chunkTB72NPRM_cjs.addressValidationSchema,
|
|
32
32
|
onSubmit: async (values) => {
|
|
33
33
|
try {
|
|
34
34
|
setIsSubmitting(true);
|
|
35
|
-
const payload =
|
|
35
|
+
const payload = chunkTB72NPRM_cjs.buildSubmitPayload(values, selectedCountry, states);
|
|
36
36
|
let response;
|
|
37
37
|
if (isEditing) {
|
|
38
38
|
response = await chunkRDUT4W3B_cjs.updateAddress({
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { http_service_default } from './chunk-3SYYP3XV.js';
|
|
2
2
|
|
|
3
|
-
// src/api/coupon.ts
|
|
4
|
-
async function getCoupons() {
|
|
5
|
-
return http_service_default.get("/coupon/available/");
|
|
6
|
-
}
|
|
7
|
-
async function applyCoupon(couponCode) {
|
|
8
|
-
return http_service_default.post("/coupon/use/", { coupon_code: couponCode });
|
|
9
|
-
}
|
|
10
|
-
async function getAppliedCoupon() {
|
|
11
|
-
return http_service_default.get("/coupon/use/");
|
|
12
|
-
}
|
|
13
|
-
async function removeCoupon(couponCode) {
|
|
14
|
-
return http_service_default.delete("/coupon/use/");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
3
|
// src/api/orders.ts
|
|
18
4
|
async function getOrders(url) {
|
|
19
5
|
const response = await http_service_default.get(url);
|
|
@@ -120,4 +106,4 @@ async function verifyTabbyPayment(orderNumber) {
|
|
|
120
106
|
});
|
|
121
107
|
}
|
|
122
108
|
|
|
123
|
-
export {
|
|
109
|
+
export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
|
|
@@ -37,10 +37,30 @@ var addressFormInitialValues = {
|
|
|
37
37
|
city: "",
|
|
38
38
|
customer_email: ""
|
|
39
39
|
};
|
|
40
|
+
function sanitizePhoneNumber(input, countryCode) {
|
|
41
|
+
let cleaned = input.trim().replace(/\s+/g, "");
|
|
42
|
+
try {
|
|
43
|
+
const callingCode = libphonenumberJs.getCountryCallingCode(countryCode);
|
|
44
|
+
const prefix = `+${callingCode}`;
|
|
45
|
+
if (cleaned.startsWith(prefix)) {
|
|
46
|
+
cleaned = cleaned.slice(prefix.length);
|
|
47
|
+
} else if (cleaned.startsWith(callingCode)) {
|
|
48
|
+
cleaned = cleaned.slice(callingCode.length);
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
if (cleaned.startsWith("+")) {
|
|
52
|
+
cleaned = cleaned.replace(/^\+\d{1,4}/, "");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
cleaned = cleaned.replace(/^0+/, "");
|
|
56
|
+
return cleaned;
|
|
57
|
+
}
|
|
40
58
|
function isValidPhoneNumber(input, countryCode) {
|
|
41
59
|
if (!input) return false;
|
|
42
60
|
const phone = libphonenumberJs.parsePhoneNumberFromString(input, countryCode);
|
|
43
|
-
|
|
61
|
+
if (!phone?.isValid()) return false;
|
|
62
|
+
if (phone.country && phone.country !== countryCode) return false;
|
|
63
|
+
return true;
|
|
44
64
|
}
|
|
45
65
|
var addressValidationSchema = Yup__namespace.object({
|
|
46
66
|
customer_phone: Yup__namespace.string().required("Phone number required").test("is-valid", "Please enter a valid number", function(value) {
|
|
@@ -131,8 +151,13 @@ function buildSubmitPayload(values, country, states) {
|
|
|
131
151
|
customerCountryCode = values.customer_country_code;
|
|
132
152
|
}
|
|
133
153
|
}
|
|
154
|
+
const cleanPhone = sanitizePhoneNumber(
|
|
155
|
+
values.customer_phone,
|
|
156
|
+
values.customer_country_code
|
|
157
|
+
);
|
|
134
158
|
return {
|
|
135
159
|
...formValues,
|
|
160
|
+
customer_phone: cleanPhone,
|
|
136
161
|
country: country?.name || "india",
|
|
137
162
|
country_obj: country?.id || 105,
|
|
138
163
|
customer_country_code: customerCountryCode,
|
|
@@ -151,4 +176,5 @@ exports.encodeAddress = encodeAddress;
|
|
|
151
176
|
exports.isValidPhoneNumber = isValidPhoneNumber;
|
|
152
177
|
exports.loadAddressFormFromSession = loadAddressFormFromSession;
|
|
153
178
|
exports.parseEditAddress = parseEditAddress;
|
|
179
|
+
exports.sanitizePhoneNumber = sanitizePhoneNumber;
|
|
154
180
|
exports.saveAddressFormToSession = saveAddressFormToSession;
|
|
@@ -11,7 +11,8 @@ async function getCart(url, addressId) {
|
|
|
11
11
|
total_quantity: 0,
|
|
12
12
|
products_quantity: {},
|
|
13
13
|
cart_count: 0,
|
|
14
|
-
missing_items:
|
|
14
|
+
missing_items: {},
|
|
15
|
+
missing_cart_items: {},
|
|
15
16
|
customization_inputs: [],
|
|
16
17
|
total_coupon_discount: 0,
|
|
17
18
|
variant_discounts: {},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkY2CPMT34_cjs = require('./chunk-Y2CPMT34.cjs');
|
|
4
4
|
var chunkSMHJRNCR_cjs = require('./chunk-SMHJRNCR.cjs');
|
|
5
|
+
var chunkHTFVROIV_cjs = require('./chunk-HTFVROIV.cjs');
|
|
5
6
|
var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
|
|
6
7
|
var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
|
|
7
8
|
var zustand = require('zustand');
|
|
@@ -22,7 +23,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
22
23
|
syncCart: async (addressId) => {
|
|
23
24
|
set({ status: "loading" /* LOADING */ });
|
|
24
25
|
try {
|
|
25
|
-
const response = await
|
|
26
|
+
const response = await chunkY2CPMT34_cjs.getCart("/customer/cart/", addressId);
|
|
26
27
|
if (response) {
|
|
27
28
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
28
29
|
}
|
|
@@ -33,7 +34,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
33
34
|
fetchCart: async (addressId) => {
|
|
34
35
|
set({ status: "loading" /* LOADING */ });
|
|
35
36
|
try {
|
|
36
|
-
const response = await
|
|
37
|
+
const response = await chunkY2CPMT34_cjs.getCart("/customer/cart/", addressId);
|
|
37
38
|
if (response) {
|
|
38
39
|
set({ cart: response, status: "idle" /* IDLE */ });
|
|
39
40
|
}
|
|
@@ -45,7 +46,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
45
46
|
set({ status: "loading" /* LOADING */ });
|
|
46
47
|
try {
|
|
47
48
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
48
|
-
await
|
|
49
|
+
await chunkY2CPMT34_cjs.addToCart(items, customizationInputs);
|
|
49
50
|
await useCartStore.getState().syncCart(addressId);
|
|
50
51
|
} else {
|
|
51
52
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -71,7 +72,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
71
72
|
set({ status: "loading" /* LOADING */ });
|
|
72
73
|
try {
|
|
73
74
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
74
|
-
await
|
|
75
|
+
await chunkY2CPMT34_cjs.removeFromCart(items);
|
|
75
76
|
await useCartStore.getState().syncCart(addressId);
|
|
76
77
|
} else {
|
|
77
78
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -99,7 +100,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
99
100
|
set({ status: "loading" /* LOADING */ });
|
|
100
101
|
try {
|
|
101
102
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
102
|
-
await
|
|
103
|
+
await chunkY2CPMT34_cjs.updateCart(items);
|
|
103
104
|
await useCartStore.getState().syncCart(addressId);
|
|
104
105
|
} else {
|
|
105
106
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -118,6 +119,16 @@ var useCartStore = zustand.create((set) => ({
|
|
|
118
119
|
} finally {
|
|
119
120
|
set({ status: "idle" /* IDLE */ });
|
|
120
121
|
}
|
|
122
|
+
},
|
|
123
|
+
updateCustomization: async (customizationInput) => {
|
|
124
|
+
set({ status: "loading" /* LOADING */ });
|
|
125
|
+
try {
|
|
126
|
+
await chunkHTFVROIV_cjs.updateOrderCustomization(customizationInput);
|
|
127
|
+
await useCartStore.getState().syncCart();
|
|
128
|
+
} catch {
|
|
129
|
+
} finally {
|
|
130
|
+
set({ status: "idle" /* IDLE */ });
|
|
131
|
+
}
|
|
121
132
|
}
|
|
122
133
|
}));
|
|
123
134
|
var getInitialState = () => ({
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
|
|
4
|
+
|
|
5
|
+
// src/api/coupon.ts
|
|
6
|
+
async function getCoupons() {
|
|
7
|
+
return chunkECHV2JSY_cjs.http_service_default.get("/coupon/available/");
|
|
8
|
+
}
|
|
9
|
+
async function applyCoupon(couponCode) {
|
|
10
|
+
return chunkECHV2JSY_cjs.http_service_default.post("/coupon/use/", { coupon_code: couponCode });
|
|
11
|
+
}
|
|
12
|
+
async function getAppliedCoupon() {
|
|
13
|
+
return chunkECHV2JSY_cjs.http_service_default.get("/coupon/use/");
|
|
14
|
+
}
|
|
15
|
+
async function removeCoupon(couponCode) {
|
|
16
|
+
return chunkECHV2JSY_cjs.http_service_default.delete("/coupon/use/");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.applyCoupon = applyCoupon;
|
|
20
|
+
exports.getAppliedCoupon = getAppliedCoupon;
|
|
21
|
+
exports.getCoupons = getCoupons;
|
|
22
|
+
exports.removeCoupon = removeCoupon;
|
|
@@ -13,7 +13,8 @@ async function getCart(url, addressId) {
|
|
|
13
13
|
total_quantity: 0,
|
|
14
14
|
products_quantity: {},
|
|
15
15
|
cart_count: 0,
|
|
16
|
-
missing_items:
|
|
16
|
+
missing_items: {},
|
|
17
|
+
missing_cart_items: {},
|
|
17
18
|
customization_inputs: [],
|
|
18
19
|
total_coupon_discount: 0,
|
|
19
20
|
variant_discounts: {},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-7M5CVYZJ.js';
|
|
2
2
|
import { pixelEvents } from './chunk-WFDKKOO7.js';
|
|
3
|
+
import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess } from './chunk-LW3V53WJ.js';
|
|
3
4
|
import { getCloudFront } from './chunk-JQMLHRWL.js';
|
|
4
5
|
import { AxiosError } from 'axios';
|
|
5
6
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkBBRB475I_cjs = require('../chunk-BBRB475I.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkJCOOINQF_cjs = require('../chunk-JCOOINQF.cjs');
|
|
5
5
|
require('../chunk-RDUT4W3B.cjs');
|
|
6
6
|
var chunk4CVKE6CC_cjs = require('../chunk-4CVKE6CC.cjs');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-TB72NPRM.cjs');
|
|
8
8
|
require('../chunk-ECHV2JSY.cjs');
|
|
9
9
|
require('../chunk-BBRXE57K.cjs');
|
|
10
10
|
require('../chunk-NE3ZHELZ.cjs');
|
|
@@ -343,7 +343,7 @@ var AddressForm = react.forwardRef(
|
|
|
343
343
|
handlePhoneChange,
|
|
344
344
|
isSubmitting,
|
|
345
345
|
isEditing
|
|
346
|
-
} =
|
|
346
|
+
} = chunkJCOOINQF_cjs.useAddressForm({
|
|
347
347
|
address,
|
|
348
348
|
onSuccess,
|
|
349
349
|
onError,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { U as UseAddressFormOptions, u as useAddressForm } from '../useAddressForm-DGbEn91-.cjs';
|
|
3
|
-
import { f as ProductDetail } from '../product-
|
|
3
|
+
import { f as ProductDetail } from '../product-DJMdi4D4.cjs';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { O as Order } from '../orders-
|
|
5
|
+
import { O as Order } from '../orders-CjNmCY5I.cjs';
|
|
6
6
|
import 'formik';
|
|
7
7
|
import '../address-DwBZHzbI.cjs';
|
|
8
8
|
import 'react-toastify';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { U as UseAddressFormOptions, u as useAddressForm } from '../useAddressForm-cO3Au33k.js';
|
|
3
|
-
import { f as ProductDetail } from '../product-
|
|
3
|
+
import { f as ProductDetail } from '../product-DJMdi4D4.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import { O as Order } from '../orders-
|
|
5
|
+
import { O as Order } from '../orders-L_8eIkUS.js';
|
|
6
6
|
import 'formik';
|
|
7
7
|
import '../address-DwBZHzbI.js';
|
|
8
8
|
import 'react-toastify';
|
package/dist/components/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { timeFromNow, isExpired } from '../chunk-HSF2D56O.js';
|
|
2
|
-
import { useAddressForm } from '../chunk-
|
|
2
|
+
import { useAddressForm } from '../chunk-ILVGYHNI.js';
|
|
3
3
|
import '../chunk-ZGMLOLTC.js';
|
|
4
4
|
import { shareLink, convertToCurrency } from '../chunk-YUPBTD4M.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-ELP23UGF.js';
|
|
6
6
|
import '../chunk-3SYYP3XV.js';
|
|
7
7
|
import '../chunk-WEMNXIRS.js';
|
|
8
8
|
import '../chunk-BQ256JKN.js';
|