@instockng/storefront-ui 1.0.29 → 1.0.31
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/components/Checkout.d.ts.map +1 -1
- package/dist/index12.mjs +136 -132
- package/dist/index134.mjs +1 -1
- package/dist/index135.mjs +1 -1
- package/dist/index136.mjs +5 -5
- package/dist/index138.mjs +2 -2
- package/dist/index140.mjs +2 -2
- package/dist/index142.mjs +1 -1
- package/dist/index144.mjs +4 -4
- package/dist/index145.mjs +3 -3
- package/dist/index150.mjs +1 -1
- package/dist/index151.mjs +1 -1
- package/dist/index153.mjs +1 -1
- package/dist/index154.mjs +1 -1
- package/dist/index156.mjs +1 -1
- package/dist/index157.mjs +1 -1
- package/dist/index159.mjs +2 -2
- package/dist/index160.mjs +1 -1
- package/dist/index165.mjs +2 -2
- package/dist/index167.mjs +1 -1
- package/dist/index169.mjs +2 -2
- package/dist/index170.mjs +5 -5
- package/dist/index173.mjs +1 -1
- package/dist/index176.mjs +1 -1
- package/dist/index179.mjs +1 -1
- package/dist/index180.mjs +1 -1
- package/dist/index184.mjs +1 -1
- package/dist/index186.mjs +1 -1
- package/dist/index201.mjs +2 -2
- package/dist/index203.mjs +1 -1
- package/dist/index204.mjs +1 -1
- package/dist/index205.mjs +1 -1
- package/dist/index206.mjs +3 -3
- package/dist/index209.mjs +3 -3
- package/dist/index211.mjs +1 -1
- package/dist/index213.mjs +3 -3
- package/dist/index214.mjs +5 -5
- package/dist/index215.mjs +3 -3
- package/dist/index217.mjs +2 -2
- package/dist/index218.mjs +2 -2
- package/dist/index220.mjs +2 -2
- package/dist/index221.mjs +2 -2
- package/dist/index222.mjs +2 -2
- package/dist/index223.mjs +2 -2
- package/dist/index224.mjs +244 -2
- package/dist/index225.mjs +2 -37
- package/dist/index226.mjs +33 -2
- package/dist/index227.mjs +56 -99
- package/dist/index228.mjs +25 -2
- package/dist/index229.mjs +2 -2
- package/dist/index230.mjs +37 -2
- package/dist/index231.mjs +2 -2
- package/dist/index232.mjs +2 -244
- package/dist/index233.mjs +2 -2
- package/dist/index234.mjs +2 -33
- package/dist/index235.mjs +2 -65
- package/dist/index236.mjs +2 -25
- package/dist/index237.mjs +2 -2
- package/dist/index238.mjs +108 -2
- package/dist/index244.mjs +2 -2
- package/dist/index245.mjs +4 -2
- package/dist/index246.mjs +2 -2
- package/dist/index247.mjs +2 -4
- package/dist/index248.mjs +2 -3
- package/dist/index249.mjs +18 -2
- package/dist/index250.mjs +47 -2
- package/dist/index251.mjs +2 -17
- package/dist/index252.mjs +2 -13
- package/dist/index253.mjs +2 -6
- package/dist/index254.mjs +2 -30
- package/dist/index255.mjs +91 -2
- package/dist/index256.mjs +2 -18
- package/dist/index257.mjs +2 -47
- package/dist/index258.mjs +3 -2
- package/dist/index259.mjs +2 -2
- package/dist/index260.mjs +2 -2
- package/dist/index261.mjs +17 -2
- package/dist/index262.mjs +13 -2
- package/dist/index263.mjs +6 -91
- package/dist/index264.mjs +30 -2
- package/dist/index265.mjs +2 -2
- package/dist/index267.mjs +2 -2
- package/dist/index29.mjs +1 -1
- package/dist/index32.mjs +1 -1
- package/dist/index33.mjs +1 -1
- package/dist/index34.mjs +1 -1
- package/dist/index35.mjs +1 -1
- package/dist/index36.mjs +1 -1
- package/dist/index37.mjs +2 -2
- package/dist/index38.mjs +1 -1
- package/dist/index39.mjs +3 -3
- package/dist/index42.mjs +1 -1
- package/dist/index47.mjs +17 -17
- package/dist/index48.mjs +2 -2
- package/dist/index49.mjs +45 -45
- package/dist/index50.mjs +1 -1
- package/dist/index51.mjs +1 -1
- package/dist/index52.mjs +1 -1
- package/dist/index53.mjs +1 -1
- package/dist/index54.mjs +1 -1
- package/dist/index55.mjs +1 -1
- package/dist/index56.mjs +1 -1
- package/dist/index57.mjs +1 -1
- package/dist/index58.mjs +1 -1
- package/dist/index59.mjs +1 -1
- package/dist/index60.mjs +21 -20
- package/dist/index61.mjs +2 -24
- package/dist/index62.mjs +23 -2
- package/dist/index64.mjs +74 -4
- package/dist/index65.mjs +14 -74
- package/dist/index66.mjs +62 -14
- package/dist/index67.mjs +4 -62
- package/dist/index75.mjs +2 -235
- package/dist/index76.mjs +233 -4
- package/dist/index77.mjs +5 -133
- package/dist/index78.mjs +129 -63
- package/dist/index79.mjs +67 -86
- package/dist/index80.mjs +85 -27
- package/dist/index81.mjs +28 -8
- package/dist/index82.mjs +8 -74
- package/dist/index83.mjs +74 -3
- package/dist/index84.mjs +4 -2
- package/dist/index85.mjs +2 -83
- package/dist/index86.mjs +81 -52
- package/dist/index87.mjs +53 -5
- package/dist/index88.mjs +5 -4
- package/dist/index89.mjs +4 -178
- package/dist/index90.mjs +174 -48
- package/dist/index91.mjs +51 -67
- package/dist/index92.mjs +69 -34
- package/dist/index93.mjs +31 -40
- package/dist/index94.mjs +43 -2
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/components/Checkout.tsx +7 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../src/components/Checkout.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../src/components/Checkout.tsx"],"names":[],"mappings":"AA6FA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACxC,sCAAsC;IACtC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,4BAA4B;IAC5B,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAID,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,OAAO,EACP,WAAW,EACX,SAAS,EACT,OAAO,EACP,gBAAgC,EAChC,YAAY,GACb,EAAE,aAAa,2CAw2Bf"}
|
package/dist/index12.mjs
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs as a, jsx as e, Fragment as
|
|
3
|
-
import { useState as x, useEffect as I, useMemo as
|
|
4
|
-
import { object as G, string as v, ValidationError as
|
|
2
|
+
import { jsxs as a, jsx as e, Fragment as Ce } from "react/jsx-runtime";
|
|
3
|
+
import { useState as x, useEffect as I, useMemo as O, useCallback as Pe } from "react";
|
|
4
|
+
import { object as G, string as v, ValidationError as ke } from "./index39.mjs";
|
|
5
5
|
import "./index20.mjs";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
|
-
import { useGetDeliveryZones as
|
|
8
|
-
import { useCart as
|
|
9
|
-
import { Modal as
|
|
7
|
+
import { useGetDeliveryZones as Me } from "./index35.mjs";
|
|
8
|
+
import { useCart as qe } from "./index3.mjs";
|
|
9
|
+
import { Modal as ie } from "./index16.mjs";
|
|
10
10
|
import { FormInput as k } from "./index17.mjs";
|
|
11
|
-
import { FormSelect as
|
|
12
|
-
import { Button as
|
|
13
|
-
import { Loader2 as
|
|
14
|
-
import { formatCurrency as M, cn as C, getFbCookies as
|
|
15
|
-
import
|
|
11
|
+
import { FormSelect as ce } from "./index18.mjs";
|
|
12
|
+
import { Button as T } from "./index13.mjs";
|
|
13
|
+
import { Loader2 as K, ChevronLeft as Ie, ChevronRight as je, CheckCircle as Ze, Package as oe, Banknote as me, Mail as Se, Phone as ze, ChevronDown as Fe, Zap as Le } from "lucide-react";
|
|
14
|
+
import { formatCurrency as M, cn as C, getFbCookies as ue } from "./index19.mjs";
|
|
15
|
+
import Te from "./index40.mjs";
|
|
16
16
|
import { usePaystackPayment as Be } from "./index41.mjs";
|
|
17
|
-
const
|
|
17
|
+
const Ae = (i) => i.replace(/\D/g, ""), _e = G({
|
|
18
18
|
firstName: v().required("First name is required").min(2, "First name must be at least 2 characters").max(50, "First name must be less than 50 characters"),
|
|
19
19
|
lastName: v().required("Last name is required").min(2, "Last name must be at least 2 characters").max(50, "Last name must be less than 50 characters"),
|
|
20
20
|
email: v().required("Email is required").email("Please enter a valid email address"),
|
|
21
21
|
phone: v().required("Phone number is required").test("nigerian-phone", "Please enter a valid Nigerian phone number (e.g. 0812 564 8668)", (i) => {
|
|
22
22
|
if (!i) return !1;
|
|
23
|
-
const q =
|
|
23
|
+
const q = Ae(i);
|
|
24
24
|
return [
|
|
25
25
|
/^0[789]\d{9}$/
|
|
26
26
|
// 0xxxxxxxxx (11 digits total)
|
|
27
27
|
].some((N) => N.test(q));
|
|
28
28
|
})
|
|
29
|
-
}),
|
|
29
|
+
}), Re = G({
|
|
30
30
|
address: v().required("Street address is required").min(10, "Please provide a complete address"),
|
|
31
31
|
city: v().required("City is required").min(3, "City name must be at least 3 characters"),
|
|
32
32
|
state: v().required("State is required").test("not-empty", "State is required", (i) => !!i && i.trim() !== ""),
|
|
33
33
|
deliveryZoneId: v().required("Delivery zone is required").test("not-empty", "Delivery zone is required", (i) => !!i && i.trim() !== "")
|
|
34
|
-
}),
|
|
34
|
+
}), $e = G({
|
|
35
35
|
paymentMethod: v().oneOf(["cod", "online"], "Please select a payment method").required("Payment method is required")
|
|
36
36
|
});
|
|
37
|
-
function
|
|
37
|
+
function rt({
|
|
38
38
|
isOpen: i,
|
|
39
39
|
onClose: q,
|
|
40
40
|
initialData: n,
|
|
41
41
|
onSuccess: N,
|
|
42
|
-
onError:
|
|
43
|
-
submitButtonText:
|
|
42
|
+
onError: c,
|
|
43
|
+
submitButtonText: he = "Place Order",
|
|
44
44
|
refundPolicy: j
|
|
45
45
|
}) {
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
publicKey:
|
|
46
|
+
var D, ee, te, ae, re, se, le, ne, de;
|
|
47
|
+
const [o, b] = x("customer"), [Z, ye] = x(void 0), [f, W] = x(void 0), [p, B] = x(null), { refetch: V, isLoading: Y, cart: s, updateCartMutation: A, checkoutMutation: fe, clearAndCreateNewCart: H } = qe(), U = (D = s == null ? void 0 : s.brand) == null ? void 0 : D.paystackPublicKey, J = Be({
|
|
48
|
+
publicKey: U || "",
|
|
49
49
|
onSuccess: async (t) => {
|
|
50
50
|
try {
|
|
51
|
-
const { fbc: l, fbp: d } =
|
|
51
|
+
const { fbc: l, fbp: d } = ue(), m = await P.mutateAsync({
|
|
52
52
|
firstName: r.firstName,
|
|
53
53
|
lastName: r.lastName,
|
|
54
54
|
email: r.email,
|
|
55
55
|
phone: r.phone,
|
|
56
56
|
address: r.address,
|
|
57
57
|
city: r.city,
|
|
58
|
-
deliveryZoneId:
|
|
58
|
+
deliveryZoneId: f || r.deliveryZoneId,
|
|
59
59
|
paymentMethod: r.paymentMethod,
|
|
60
60
|
paystackReference: t.reference,
|
|
61
61
|
fbc: l,
|
|
62
62
|
fbp: d
|
|
63
63
|
});
|
|
64
|
-
if ("error" in
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
if ("error" in m) {
|
|
65
|
+
const $ = m.error;
|
|
66
|
+
c == null || c(new Error(($ == null ? void 0 : $.message) || "Checkout failed"));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
B(m), H(), N == null || N(m.id);
|
|
70
70
|
} catch (l) {
|
|
71
|
-
|
|
71
|
+
c == null || c(l);
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
onClose: () => {
|
|
@@ -76,15 +76,15 @@ function at({
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
I(() => {
|
|
79
|
-
i &&
|
|
80
|
-
}, [i,
|
|
81
|
-
const { data: w } =
|
|
82
|
-
enabled: !!((
|
|
83
|
-
}), u =
|
|
79
|
+
i && V();
|
|
80
|
+
}, [i, V]);
|
|
81
|
+
const { data: w } = Me(((ee = s == null ? void 0 : s.brand) == null ? void 0 : ee.id) || "", {
|
|
82
|
+
enabled: !!((te = s == null ? void 0 : s.brand) != null && te.id)
|
|
83
|
+
}), u = O(() => w == null ? void 0 : w.find((t) => t.id === Z), [w, Z]), y = O(() => u == null ? void 0 : u.zones.find((t) => t.id === f), [u, f]), P = fe;
|
|
84
84
|
I(() => {
|
|
85
|
-
i || (
|
|
85
|
+
i || (B(null), b("customer"), P.reset());
|
|
86
86
|
}, [i]);
|
|
87
|
-
const [r,
|
|
87
|
+
const [r, _] = x({
|
|
88
88
|
firstName: (n == null ? void 0 : n.firstName) || "",
|
|
89
89
|
lastName: (n == null ? void 0 : n.lastName) || "",
|
|
90
90
|
email: (n == null ? void 0 : n.email) || "",
|
|
@@ -98,9 +98,9 @@ function at({
|
|
|
98
98
|
I(() => {
|
|
99
99
|
i && b("customer");
|
|
100
100
|
}, [i]);
|
|
101
|
-
const [
|
|
101
|
+
const [Q, X] = x(!1);
|
|
102
102
|
I(() => {
|
|
103
|
-
i && s && !n && !
|
|
103
|
+
i && s && !n && !Q && (_((t) => {
|
|
104
104
|
var l;
|
|
105
105
|
return {
|
|
106
106
|
...t,
|
|
@@ -110,27 +110,27 @@ function at({
|
|
|
110
110
|
phone: s.customerPhone || t.phone,
|
|
111
111
|
deliveryZoneId: ((l = s.deliveryZone) == null ? void 0 : l.id) || t.deliveryZoneId
|
|
112
112
|
};
|
|
113
|
-
}),
|
|
114
|
-
}, [i, s, n,
|
|
115
|
-
if (
|
|
116
|
-
const t = u == null ? void 0 : u.zones.find((l) => l.id ===
|
|
117
|
-
t &&
|
|
113
|
+
}), X(!0)), i || X(!1);
|
|
114
|
+
}, [i, s, n, Q]), I(() => {
|
|
115
|
+
if (f) {
|
|
116
|
+
const t = u == null ? void 0 : u.zones.find((l) => l.id === f);
|
|
117
|
+
t && _((l) => ({
|
|
118
118
|
...l,
|
|
119
119
|
paymentMethod: t.allowOnline ? "online" : "cod"
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
|
-
}, [
|
|
123
|
-
const [h, S] = x({}), [
|
|
122
|
+
}, [f, u]);
|
|
123
|
+
const [h, S] = x({}), [R, pe] = x(!1), g = (t) => {
|
|
124
124
|
const { name: l, value: d } = t.target;
|
|
125
|
-
|
|
126
|
-
}, z =
|
|
125
|
+
_((m) => ({ ...m, [l]: d })), h[l] && S((m) => ({ ...m, [l]: void 0 }));
|
|
126
|
+
}, z = Pe(
|
|
127
127
|
(t) => {
|
|
128
128
|
const l = r[t];
|
|
129
129
|
if (!l) return;
|
|
130
130
|
const d = {};
|
|
131
|
-
t === "firstName" ? d.customerFirstName = l : t === "lastName" ? d.customerLastName = l : t === "email" ? d.customerEmail = l : t === "phone" && (d.customerPhone = l),
|
|
131
|
+
t === "firstName" ? d.customerFirstName = l : t === "lastName" ? d.customerLastName = l : t === "email" ? d.customerEmail = l : t === "phone" && (d.customerPhone = l), A.mutate(d);
|
|
132
132
|
},
|
|
133
|
-
[r,
|
|
133
|
+
[r, A]
|
|
134
134
|
), F = (t) => {
|
|
135
135
|
const l = {};
|
|
136
136
|
try {
|
|
@@ -141,21 +141,21 @@ function at({
|
|
|
141
141
|
address: r.address,
|
|
142
142
|
city: r.city,
|
|
143
143
|
state: Z || r.state || "",
|
|
144
|
-
deliveryZoneId:
|
|
144
|
+
deliveryZoneId: f || r.deliveryZoneId || ""
|
|
145
145
|
};
|
|
146
|
-
|
|
147
|
-
} else t === "payment" &&
|
|
146
|
+
Re.validateSync(d, { abortEarly: !1 });
|
|
147
|
+
} else t === "payment" && $e.validateSync(r, { abortEarly: !1 });
|
|
148
148
|
} catch (d) {
|
|
149
|
-
d instanceof
|
|
150
|
-
|
|
149
|
+
d instanceof ke && d.inner.forEach((m) => {
|
|
150
|
+
m.path && (l[m.path] = m.message);
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
return S(l), Object.keys(l).length === 0;
|
|
154
|
-
}, pe = () => {
|
|
155
|
-
F(c) && (c === "customer" ? b("delivery") : c === "delivery" && b("payment"));
|
|
156
154
|
}, ve = () => {
|
|
157
|
-
|
|
158
|
-
}, Ne =
|
|
155
|
+
F(o) && (o === "customer" ? b("delivery") : o === "delivery" && b("payment"));
|
|
156
|
+
}, Ne = () => {
|
|
157
|
+
o === "payment" ? b("delivery") : o === "delivery" && b("customer");
|
|
158
|
+
}, be = async () => {
|
|
159
159
|
if (!F("customer")) {
|
|
160
160
|
b("customer");
|
|
161
161
|
return;
|
|
@@ -166,12 +166,16 @@ function at({
|
|
|
166
166
|
}
|
|
167
167
|
if (F("payment")) {
|
|
168
168
|
if (r.paymentMethod === "online") {
|
|
169
|
-
if (!U
|
|
170
|
-
|
|
169
|
+
if (!U) {
|
|
170
|
+
c == null || c(new Error("Paystack is not configured. Please contact support."));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!J.isLoaded) {
|
|
174
|
+
c == null || c(new Error("Payment system is loading. Please try again."));
|
|
171
175
|
return;
|
|
172
176
|
}
|
|
173
177
|
const t = Math.round(s.pricing.total * 100);
|
|
174
|
-
|
|
178
|
+
J.initializePayment({
|
|
175
179
|
email: r.email || (s == null ? void 0 : s.customerEmail) || "customer@example.com",
|
|
176
180
|
amount: t,
|
|
177
181
|
currency: "NGN",
|
|
@@ -194,109 +198,109 @@ function at({
|
|
|
194
198
|
return;
|
|
195
199
|
}
|
|
196
200
|
try {
|
|
197
|
-
const { fbc: t, fbp: l } =
|
|
201
|
+
const { fbc: t, fbp: l } = ue(), d = await P.mutateAsync({
|
|
198
202
|
firstName: r.firstName,
|
|
199
203
|
lastName: r.lastName,
|
|
200
204
|
email: r.email,
|
|
201
205
|
phone: r.phone,
|
|
202
206
|
address: r.address,
|
|
203
207
|
city: r.city,
|
|
204
|
-
deliveryZoneId:
|
|
208
|
+
deliveryZoneId: f || r.deliveryZoneId,
|
|
205
209
|
paymentMethod: r.paymentMethod,
|
|
206
210
|
fbc: t,
|
|
207
211
|
fbp: l
|
|
208
212
|
});
|
|
209
213
|
if ("error" in d) {
|
|
210
|
-
const
|
|
211
|
-
|
|
214
|
+
const m = d.error;
|
|
215
|
+
c == null || c(new Error((m == null ? void 0 : m.message) || "Checkout failed"));
|
|
212
216
|
return;
|
|
213
217
|
}
|
|
214
|
-
|
|
218
|
+
B(d), H(), N == null || N(d.id);
|
|
215
219
|
} catch (t) {
|
|
216
|
-
|
|
220
|
+
c == null || c(t);
|
|
217
221
|
}
|
|
218
222
|
}
|
|
219
|
-
},
|
|
223
|
+
}, ge = {
|
|
220
224
|
customer: "Customer Information",
|
|
221
225
|
delivery: "Delivery Address",
|
|
222
226
|
payment: "Payment Method"
|
|
223
|
-
},
|
|
224
|
-
(
|
|
225
|
-
|
|
227
|
+
}, xe = O(() => ge[o], [o]), we = /* @__PURE__ */ a("div", { className: "space-y-3", children: [
|
|
228
|
+
(o === "payment" || o === "delivery") && ((ae = s == null ? void 0 : s.pricing) == null ? void 0 : ae.total) && /* @__PURE__ */ a("div", { className: "text-sm text-black relative", children: [
|
|
229
|
+
Y && /* @__PURE__ */ e("div", { className: "absolute flex items-center justify-center inset-0 bg-white opacity-50", children: /* @__PURE__ */ e(K, { className: "animate-spin text-accent-500" }) }),
|
|
226
230
|
/* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
|
|
227
231
|
/* @__PURE__ */ e("span", { children: "Subtotal" }),
|
|
228
|
-
/* @__PURE__ */ e("span", { children: M(((
|
|
232
|
+
/* @__PURE__ */ e("span", { children: M(((re = s == null ? void 0 : s.pricing) == null ? void 0 : re.subtotal) ?? 0) })
|
|
229
233
|
] }),
|
|
230
234
|
s.pricing.discount && /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
|
|
231
235
|
/* @__PURE__ */ e("span", { children: "Discount" }),
|
|
232
236
|
/* @__PURE__ */ a("span", { className: "text-green-600", children: [
|
|
233
237
|
"-",
|
|
234
|
-
M(((
|
|
238
|
+
M(((le = (se = s == null ? void 0 : s.pricing) == null ? void 0 : se.discount) == null ? void 0 : le.amount) ?? 0)
|
|
235
239
|
] })
|
|
236
240
|
] }),
|
|
237
241
|
/* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
|
|
238
242
|
/* @__PURE__ */ e("span", { children: "Delivery Fee" }),
|
|
239
|
-
/* @__PURE__ */ e("span", { children: M(((
|
|
243
|
+
/* @__PURE__ */ e("span", { children: M(((ne = s == null ? void 0 : s.pricing) == null ? void 0 : ne.deliveryCharge) ?? 0) })
|
|
240
244
|
] }),
|
|
241
245
|
/* @__PURE__ */ e("hr", { className: "border-gray-200 my-2" }),
|
|
242
246
|
/* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
|
|
243
247
|
/* @__PURE__ */ e("span", { children: "Total" }),
|
|
244
|
-
/* @__PURE__ */ e("span", { children: M(((
|
|
248
|
+
/* @__PURE__ */ e("span", { children: M(((de = s == null ? void 0 : s.pricing) == null ? void 0 : de.total) ?? 0) })
|
|
245
249
|
] })
|
|
246
250
|
] }),
|
|
247
251
|
/* @__PURE__ */ a("div", { className: "flex gap-3", children: [
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
o !== "customer" && /* @__PURE__ */ a(
|
|
253
|
+
T,
|
|
250
254
|
{
|
|
251
255
|
type: "button",
|
|
252
256
|
variant: "outline",
|
|
253
|
-
onClick:
|
|
257
|
+
onClick: Ne,
|
|
254
258
|
className: "flex-1 border-gray-400",
|
|
255
259
|
size: "lg",
|
|
256
260
|
children: [
|
|
257
|
-
/* @__PURE__ */ e(
|
|
261
|
+
/* @__PURE__ */ e(Ie, { className: "mr-2 h-4 w-4" }),
|
|
258
262
|
"Back"
|
|
259
263
|
]
|
|
260
264
|
}
|
|
261
265
|
),
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
o !== "payment" ? /* @__PURE__ */ a(
|
|
267
|
+
T,
|
|
264
268
|
{
|
|
265
269
|
type: "button",
|
|
266
|
-
onClick:
|
|
270
|
+
onClick: ve,
|
|
267
271
|
className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
|
|
268
272
|
size: "lg",
|
|
269
273
|
children: [
|
|
270
274
|
"Next",
|
|
271
|
-
/* @__PURE__ */ e(
|
|
275
|
+
/* @__PURE__ */ e(je, { className: "ml-2 h-4 w-4" })
|
|
272
276
|
]
|
|
273
277
|
}
|
|
274
278
|
) : /* @__PURE__ */ e(
|
|
275
|
-
|
|
279
|
+
T,
|
|
276
280
|
{
|
|
277
281
|
type: "button",
|
|
278
|
-
onClick:
|
|
282
|
+
onClick: be,
|
|
279
283
|
disabled: P.isPending,
|
|
280
284
|
className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
|
|
281
285
|
size: "lg",
|
|
282
|
-
children: P.isPending ? /* @__PURE__ */ a(
|
|
283
|
-
/* @__PURE__ */ e(
|
|
286
|
+
children: P.isPending ? /* @__PURE__ */ a(Ce, { children: [
|
|
287
|
+
/* @__PURE__ */ e(K, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
284
288
|
"Processing..."
|
|
285
|
-
] }) :
|
|
289
|
+
] }) : he
|
|
286
290
|
}
|
|
287
291
|
)
|
|
288
292
|
] }),
|
|
289
293
|
P.isError && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 p-3 text-sm text-red-600", children: "Failed to place order. Please check your information and try again." })
|
|
290
294
|
] }), L = (t) => !(s != null && s.availablePaymentMethods.includes(t));
|
|
291
|
-
if (
|
|
295
|
+
if (p)
|
|
292
296
|
return /* @__PURE__ */ e(
|
|
293
|
-
|
|
297
|
+
ie,
|
|
294
298
|
{
|
|
295
299
|
isOpen: i,
|
|
296
300
|
onClose: q,
|
|
297
301
|
title: "Order Placed Successfully!",
|
|
298
302
|
footer: /* @__PURE__ */ e(
|
|
299
|
-
|
|
303
|
+
T,
|
|
300
304
|
{
|
|
301
305
|
onClick: q,
|
|
302
306
|
className: "w-full bg-accent-500 text-white hover:bg-accent-600",
|
|
@@ -307,43 +311,43 @@ function at({
|
|
|
307
311
|
size: "lg",
|
|
308
312
|
contentClassName: "p-6",
|
|
309
313
|
children: /* @__PURE__ */ a("div", { className: "text-center space-y-6", children: [
|
|
310
|
-
/* @__PURE__ */ e("div", { className: "flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-20 h-20 bg-green-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
314
|
+
/* @__PURE__ */ e("div", { className: "flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-20 h-20 bg-green-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e(Ze, { className: "h-12 w-12 text-green-600" }) }) }),
|
|
311
315
|
/* @__PURE__ */ a("div", { className: "space-y-2", children: [
|
|
312
316
|
/* @__PURE__ */ e("h3", { className: "text-2xl font-bold text-gray-900", children: "Thank You!" }),
|
|
313
317
|
/* @__PURE__ */ e("p", { className: "text-gray-600", children: "Your order has been placed successfully." })
|
|
314
318
|
] }),
|
|
315
319
|
/* @__PURE__ */ a("div", { className: "bg-gray-50 rounded-lg p-6 space-y-4", children: [
|
|
316
320
|
/* @__PURE__ */ a("div", { className: "flex items-center justify-center space-x-2 text-gray-700", children: [
|
|
317
|
-
/* @__PURE__ */ e(
|
|
321
|
+
/* @__PURE__ */ e(oe, { className: "h-5 w-5" }),
|
|
318
322
|
/* @__PURE__ */ a("span", { className: "font-medium", children: [
|
|
319
323
|
"Order #",
|
|
320
|
-
|
|
324
|
+
p.orderNumber
|
|
321
325
|
] })
|
|
322
326
|
] }),
|
|
323
327
|
/* @__PURE__ */ a("div", { className: "border-t border-gray-200 pt-4 space-y-3", children: [
|
|
324
328
|
/* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
|
|
325
329
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Customer" }),
|
|
326
330
|
/* @__PURE__ */ a("span", { className: "font-medium text-gray-900", children: [
|
|
327
|
-
|
|
331
|
+
p.firstName,
|
|
328
332
|
" ",
|
|
329
|
-
|
|
333
|
+
p.lastName
|
|
330
334
|
] })
|
|
331
335
|
] }),
|
|
332
336
|
/* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
|
|
333
337
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Phone" }),
|
|
334
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children:
|
|
338
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: p.phone })
|
|
335
339
|
] }),
|
|
336
|
-
|
|
340
|
+
p.email && /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
|
|
337
341
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Email" }),
|
|
338
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children:
|
|
342
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: p.email })
|
|
339
343
|
] }),
|
|
340
344
|
/* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
|
|
341
345
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Payment Method" }),
|
|
342
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children:
|
|
346
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: p.paymentMethod === "cod" ? "Cash on Delivery" : "Online Payment" })
|
|
343
347
|
] }),
|
|
344
348
|
/* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
|
|
345
349
|
/* @__PURE__ */ e("span", { className: "text-gray-600", children: "Total" }),
|
|
346
|
-
/* @__PURE__ */ e("span", { className: "font-bold text-gray-900", children: M(
|
|
350
|
+
/* @__PURE__ */ e("span", { className: "font-bold text-gray-900", children: M(p.totalPrice) })
|
|
347
351
|
] })
|
|
348
352
|
] })
|
|
349
353
|
] }),
|
|
@@ -355,27 +359,27 @@ function at({
|
|
|
355
359
|
] })
|
|
356
360
|
}
|
|
357
361
|
);
|
|
358
|
-
const
|
|
362
|
+
const E = y && (o === "delivery" || o === "payment") && (y.waybillOnly || !(y != null && y.allowCOD));
|
|
359
363
|
return /* @__PURE__ */ e(
|
|
360
|
-
|
|
364
|
+
ie,
|
|
361
365
|
{
|
|
362
366
|
isOpen: i,
|
|
363
367
|
onClose: q,
|
|
364
|
-
title:
|
|
365
|
-
footer:
|
|
368
|
+
title: xe,
|
|
369
|
+
footer: we,
|
|
366
370
|
size: "lg",
|
|
367
371
|
contentClassName: "p-0",
|
|
368
|
-
children:
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
/* @__PURE__ */ e(
|
|
372
|
+
children: Y ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-[300px]", children: /* @__PURE__ */ e(K, { className: "h-8 w-8 animate-spin text-gray-600" }) }) : /* @__PURE__ */ e("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
|
|
373
|
+
E && /* @__PURE__ */ a("div", { className: "space-y-3 p-4 pb-0", children: [
|
|
374
|
+
y.noteTitle && y.noteContent && /* @__PURE__ */ e("div", { className: "bg-amber-50 border border-amber-200 rounded-lg p-4", children: /* @__PURE__ */ a("div", { className: "flex items-start gap-3", children: [
|
|
375
|
+
/* @__PURE__ */ e(oe, { className: "h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5" }),
|
|
372
376
|
/* @__PURE__ */ a("div", { className: "space-y-1", children: [
|
|
373
|
-
/* @__PURE__ */ e("p", { className: "text-sm font-semibold text-amber-900", children:
|
|
374
|
-
/* @__PURE__ */ e("p", { className: "text-sm text-amber-800", children:
|
|
377
|
+
/* @__PURE__ */ e("p", { className: "text-sm font-semibold text-amber-900 whitespace-pre-wrap", children: y.noteTitle }),
|
|
378
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-amber-800 whitespace-pre-wrap", children: y.noteContent })
|
|
375
379
|
] })
|
|
376
380
|
] }) }),
|
|
377
|
-
!(
|
|
378
|
-
/* @__PURE__ */ e(
|
|
381
|
+
!(y != null && y.allowCOD) && /* @__PURE__ */ e("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: /* @__PURE__ */ a("div", { className: "flex items-start gap-3", children: [
|
|
382
|
+
/* @__PURE__ */ e(me, { className: "h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5" }),
|
|
379
383
|
/* @__PURE__ */ a("div", { className: "space-y-1", children: [
|
|
380
384
|
/* @__PURE__ */ e("p", { className: "text-sm font-semibold text-blue-900", children: "Cash on Delivery Unavailable" }),
|
|
381
385
|
/* @__PURE__ */ e("p", { className: "text-sm text-blue-800", children: "We're unable to offer cash on delivery to this location. Please use online payment to complete your order." })
|
|
@@ -387,9 +391,9 @@ function at({
|
|
|
387
391
|
{
|
|
388
392
|
className: C(
|
|
389
393
|
"flex transition-transform duration-300 ease-in-out w-full",
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
394
|
+
o === "customer" && "translate-x-0",
|
|
395
|
+
o === "delivery" && "-translate-x-full",
|
|
396
|
+
o === "payment" && "-translate-x-[200%]"
|
|
393
397
|
),
|
|
394
398
|
children: [
|
|
395
399
|
/* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: /* @__PURE__ */ a("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
|
|
@@ -431,7 +435,7 @@ function at({
|
|
|
431
435
|
onChange: g,
|
|
432
436
|
onBlur: () => z("email"),
|
|
433
437
|
error: h.email,
|
|
434
|
-
icon: /* @__PURE__ */ e(
|
|
438
|
+
icon: /* @__PURE__ */ e(Se, { size: 16 }),
|
|
435
439
|
autoCorrect: "off",
|
|
436
440
|
required: !0
|
|
437
441
|
}
|
|
@@ -448,7 +452,7 @@ function at({
|
|
|
448
452
|
placeholder: "e.g. 08012345678",
|
|
449
453
|
maxLength: 18,
|
|
450
454
|
error: h.phone,
|
|
451
|
-
icon: /* @__PURE__ */ e(
|
|
455
|
+
icon: /* @__PURE__ */ e(ze, { size: 16 }),
|
|
452
456
|
autoCorrect: "off",
|
|
453
457
|
required: !0,
|
|
454
458
|
className: "font-semibold"
|
|
@@ -484,15 +488,15 @@ function at({
|
|
|
484
488
|
}
|
|
485
489
|
),
|
|
486
490
|
/* @__PURE__ */ a(
|
|
487
|
-
|
|
491
|
+
ce,
|
|
488
492
|
{
|
|
489
493
|
label: "State",
|
|
490
494
|
name: "state",
|
|
491
495
|
value: Z || "",
|
|
492
496
|
onChange: (t) => {
|
|
493
|
-
|
|
497
|
+
W("");
|
|
494
498
|
const l = t.target.value;
|
|
495
|
-
|
|
499
|
+
ye(l || void 0), h.state && S((d) => ({ ...d, state: void 0 }));
|
|
496
500
|
},
|
|
497
501
|
error: h.state,
|
|
498
502
|
required: !0,
|
|
@@ -503,13 +507,13 @@ function at({
|
|
|
503
507
|
}
|
|
504
508
|
),
|
|
505
509
|
/* @__PURE__ */ a(
|
|
506
|
-
|
|
510
|
+
ce,
|
|
507
511
|
{
|
|
508
512
|
label: "Delivery Zone",
|
|
509
|
-
value:
|
|
513
|
+
value: f || "",
|
|
510
514
|
onChange: (t) => {
|
|
511
515
|
const l = t.target.value;
|
|
512
|
-
|
|
516
|
+
W(l || void 0), h.deliveryZoneId && S((d) => ({ ...d, deliveryZoneId: void 0 })), l && A.mutate({ deliveryZoneId: l });
|
|
513
517
|
},
|
|
514
518
|
disabled: !u,
|
|
515
519
|
error: h.deliveryZoneId,
|
|
@@ -528,22 +532,22 @@ function at({
|
|
|
528
532
|
] })
|
|
529
533
|
] }) }),
|
|
530
534
|
/* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-6", children: [
|
|
531
|
-
j && /* @__PURE__ */ a("div", { className: `border border-gray-200 rounded-lg ${
|
|
535
|
+
j && /* @__PURE__ */ a("div", { className: `border border-gray-200 rounded-lg ${E ? "mt-4" : ""}`, children: [
|
|
532
536
|
/* @__PURE__ */ a(
|
|
533
537
|
"button",
|
|
534
538
|
{
|
|
535
539
|
type: "button",
|
|
536
|
-
onClick: () =>
|
|
540
|
+
onClick: () => pe(!R),
|
|
537
541
|
className: "overflow-hidden w-full flex items-center overflow-hidden rounded-lg rounded-b-none justify-between p-4 text-left hover:bg-gray-50 transition-colors",
|
|
538
542
|
children: [
|
|
539
543
|
/* @__PURE__ */ e("span", { className: "text-sm font-bold text-accent-700", children: j.title || "🤔 Curious about Refunds?" }),
|
|
540
544
|
/* @__PURE__ */ e(
|
|
541
|
-
|
|
545
|
+
Fe,
|
|
542
546
|
{
|
|
543
547
|
size: 16,
|
|
544
548
|
className: C(
|
|
545
549
|
"transform transition-transform duration-200 text-gray-500",
|
|
546
|
-
|
|
550
|
+
R && "rotate-180"
|
|
547
551
|
)
|
|
548
552
|
}
|
|
549
553
|
)
|
|
@@ -555,7 +559,7 @@ function at({
|
|
|
555
559
|
{
|
|
556
560
|
className: C(
|
|
557
561
|
"overflow-hidden transition-all duration-300 ease-in-out",
|
|
558
|
-
|
|
562
|
+
R ? "max-h-96 opacity-100" : "max-h-0 opacity-0"
|
|
559
563
|
),
|
|
560
564
|
children: /* @__PURE__ */ e("div", { className: "px-4 pb-4 border-t border-gray-100", children: /* @__PURE__ */ e("div", { className: "text-sm text-gray-600 space-y-3 pt-4", children: j.policies && /* @__PURE__ */ a("div", { children: [
|
|
561
565
|
/* @__PURE__ */ e("h4", { className: "font-bold text-gray-800 mb-2", children: "Our Refund Policy" }),
|
|
@@ -597,7 +601,7 @@ function at({
|
|
|
597
601
|
"p-3 rounded-full",
|
|
598
602
|
r.paymentMethod === "online" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
|
|
599
603
|
),
|
|
600
|
-
children: /* @__PURE__ */ e(
|
|
604
|
+
children: /* @__PURE__ */ e(Le, { size: 24 })
|
|
601
605
|
}
|
|
602
606
|
),
|
|
603
607
|
/* @__PURE__ */ a("div", { children: [
|
|
@@ -606,7 +610,7 @@ function at({
|
|
|
606
610
|
/* @__PURE__ */ e(
|
|
607
611
|
"img",
|
|
608
612
|
{
|
|
609
|
-
src:
|
|
613
|
+
src: Te,
|
|
610
614
|
alt: "Paystack",
|
|
611
615
|
className: "h-4 w-auto mt-2 mx-auto"
|
|
612
616
|
}
|
|
@@ -646,7 +650,7 @@ function at({
|
|
|
646
650
|
"p-3 rounded-full",
|
|
647
651
|
r.paymentMethod === "cod" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
|
|
648
652
|
),
|
|
649
|
-
children: /* @__PURE__ */ e(
|
|
653
|
+
children: /* @__PURE__ */ e(me, { size: 24 })
|
|
650
654
|
}
|
|
651
655
|
),
|
|
652
656
|
/* @__PURE__ */ a("div", { children: [
|
|
@@ -669,5 +673,5 @@ function at({
|
|
|
669
673
|
);
|
|
670
674
|
}
|
|
671
675
|
export {
|
|
672
|
-
|
|
676
|
+
rt as Checkout
|
|
673
677
|
};
|
package/dist/index134.mjs
CHANGED
package/dist/index135.mjs
CHANGED