@instockng/storefront-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +394 -0
  2. package/dist/components/CartItem.d.ts +15 -0
  3. package/dist/components/CartItem.d.ts.map +1 -0
  4. package/dist/components/Checkout.d.ts +39 -0
  5. package/dist/components/Checkout.d.ts.map +1 -0
  6. package/dist/components/DiscountCodeInput.d.ts +20 -0
  7. package/dist/components/DiscountCodeInput.d.ts.map +1 -0
  8. package/dist/components/OrderConfirmation.d.ts +30 -0
  9. package/dist/components/OrderConfirmation.d.ts.map +1 -0
  10. package/dist/components/ProductCard.d.ts +42 -0
  11. package/dist/components/ProductCard.d.ts.map +1 -0
  12. package/dist/components/ProductGrid.d.ts +33 -0
  13. package/dist/components/ProductGrid.d.ts.map +1 -0
  14. package/dist/components/ShoppingCart.d.ts +28 -0
  15. package/dist/components/ShoppingCart.d.ts.map +1 -0
  16. package/dist/components/ui/badge.d.ts +10 -0
  17. package/dist/components/ui/badge.d.ts.map +1 -0
  18. package/dist/components/ui/button.d.ts +12 -0
  19. package/dist/components/ui/button.d.ts.map +1 -0
  20. package/dist/components/ui/card.d.ts +9 -0
  21. package/dist/components/ui/card.d.ts.map +1 -0
  22. package/dist/components/ui/form-input.d.ts +20 -0
  23. package/dist/components/ui/form-input.d.ts.map +1 -0
  24. package/dist/components/ui/form-select.d.ts +18 -0
  25. package/dist/components/ui/form-select.d.ts.map +1 -0
  26. package/dist/components/ui/modal.d.ts +31 -0
  27. package/dist/components/ui/modal.d.ts.map +1 -0
  28. package/dist/contexts/CartContext.d.ts +60 -0
  29. package/dist/contexts/CartContext.d.ts.map +1 -0
  30. package/dist/hooks/usePaystackPayment.d.ts +46 -0
  31. package/dist/hooks/usePaystackPayment.d.ts.map +1 -0
  32. package/dist/index.d.ts +34 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.mjs +99 -0
  35. package/dist/index10.mjs +644 -0
  36. package/dist/index100.mjs +7 -0
  37. package/dist/index101.mjs +35 -0
  38. package/dist/index102.mjs +33 -0
  39. package/dist/index103.mjs +30 -0
  40. package/dist/index104.mjs +63 -0
  41. package/dist/index105.mjs +5 -0
  42. package/dist/index106.mjs +4 -0
  43. package/dist/index107.mjs +4 -0
  44. package/dist/index108.mjs +19 -0
  45. package/dist/index109.mjs +15 -0
  46. package/dist/index11.mjs +62 -0
  47. package/dist/index110.mjs +8 -0
  48. package/dist/index111.mjs +32 -0
  49. package/dist/index12.mjs +64 -0
  50. package/dist/index13.mjs +26 -0
  51. package/dist/index14.mjs +117 -0
  52. package/dist/index15.mjs +44 -0
  53. package/dist/index16.mjs +44 -0
  54. package/dist/index17.mjs +44 -0
  55. package/dist/index18.mjs +43 -0
  56. package/dist/index19.mjs +11 -0
  57. package/dist/index2.mjs +24 -0
  58. package/dist/index20.mjs +29 -0
  59. package/dist/index21.mjs +34 -0
  60. package/dist/index22.mjs +22 -0
  61. package/dist/index23.mjs +90 -0
  62. package/dist/index24.mjs +22 -0
  63. package/dist/index25.mjs +13 -0
  64. package/dist/index26.mjs +99 -0
  65. package/dist/index27.mjs +20 -0
  66. package/dist/index28.mjs +67 -0
  67. package/dist/index29.mjs +98 -0
  68. package/dist/index3.mjs +121 -0
  69. package/dist/index30.mjs +21 -0
  70. package/dist/index31.mjs +21 -0
  71. package/dist/index32.mjs +13 -0
  72. package/dist/index33.mjs +6 -0
  73. package/dist/index34.mjs +1435 -0
  74. package/dist/index35.mjs +4 -0
  75. package/dist/index36.mjs +59 -0
  76. package/dist/index37.mjs +53 -0
  77. package/dist/index38.mjs +35 -0
  78. package/dist/index39.mjs +17 -0
  79. package/dist/index4.mjs +201 -0
  80. package/dist/index40.mjs +2265 -0
  81. package/dist/index41.mjs +25 -0
  82. package/dist/index42.mjs +38 -0
  83. package/dist/index43.mjs +46 -0
  84. package/dist/index44.mjs +101 -0
  85. package/dist/index45.mjs +114 -0
  86. package/dist/index46.mjs +78 -0
  87. package/dist/index47.mjs +89 -0
  88. package/dist/index48.mjs +106 -0
  89. package/dist/index49.mjs +87 -0
  90. package/dist/index5.mjs +112 -0
  91. package/dist/index50.mjs +76 -0
  92. package/dist/index51.mjs +20 -0
  93. package/dist/index52.mjs +19 -0
  94. package/dist/index53.mjs +64 -0
  95. package/dist/index54.mjs +131 -0
  96. package/dist/index55.mjs +135 -0
  97. package/dist/index56.mjs +77 -0
  98. package/dist/index57.mjs +17 -0
  99. package/dist/index58.mjs +65 -0
  100. package/dist/index59.mjs +6 -0
  101. package/dist/index6.mjs +82 -0
  102. package/dist/index60.mjs +4 -0
  103. package/dist/index61.mjs +7 -0
  104. package/dist/index62.mjs +36 -0
  105. package/dist/index63.mjs +45 -0
  106. package/dist/index64.mjs +237 -0
  107. package/dist/index65.mjs +8 -0
  108. package/dist/index66.mjs +136 -0
  109. package/dist/index67.mjs +70 -0
  110. package/dist/index68.mjs +89 -0
  111. package/dist/index69.mjs +31 -0
  112. package/dist/index7.mjs +100 -0
  113. package/dist/index70.mjs +11 -0
  114. package/dist/index71.mjs +77 -0
  115. package/dist/index72.mjs +6 -0
  116. package/dist/index73.mjs +4 -0
  117. package/dist/index74.mjs +85 -0
  118. package/dist/index75.mjs +56 -0
  119. package/dist/index76.mjs +8 -0
  120. package/dist/index77.mjs +7 -0
  121. package/dist/index78.mjs +181 -0
  122. package/dist/index79.mjs +55 -0
  123. package/dist/index8.mjs +165 -0
  124. package/dist/index80.mjs +71 -0
  125. package/dist/index81.mjs +23 -0
  126. package/dist/index82.mjs +58 -0
  127. package/dist/index83.mjs +31 -0
  128. package/dist/index84.mjs +9 -0
  129. package/dist/index85.mjs +54 -0
  130. package/dist/index86.mjs +8 -0
  131. package/dist/index87.mjs +14 -0
  132. package/dist/index88.mjs +9 -0
  133. package/dist/index89.mjs +30 -0
  134. package/dist/index9.mjs +100 -0
  135. package/dist/index90.mjs +4 -0
  136. package/dist/index91.mjs +72 -0
  137. package/dist/index92.mjs +169 -0
  138. package/dist/index93.mjs +15 -0
  139. package/dist/index94.mjs +9 -0
  140. package/dist/index95.mjs +33 -0
  141. package/dist/index96.mjs +13 -0
  142. package/dist/index97.mjs +6 -0
  143. package/dist/index98.mjs +6 -0
  144. package/dist/index99.mjs +14 -0
  145. package/dist/lib/utils.d.ts +7 -0
  146. package/dist/lib/utils.d.ts.map +1 -0
  147. package/dist/mockServiceWorker.js +349 -0
  148. package/dist/providers/StorefrontProvider.d.ts +47 -0
  149. package/dist/providers/StorefrontProvider.d.ts.map +1 -0
  150. package/dist/test-utils/MockCartProvider.d.ts +21 -0
  151. package/dist/test-utils/MockCartProvider.d.ts.map +1 -0
  152. package/package.json +77 -0
@@ -0,0 +1,644 @@
1
+ import { jsxs as a, jsx as e, Fragment as he } from "react/jsx-runtime";
2
+ import { useState as w, useEffect as q, useMemo as X, useCallback as ye } from "react";
3
+ import { object as R, string as y, ValidationError as fe } from "./index34.mjs";
4
+ import "./index18.mjs";
5
+ import "@tanstack/react-query";
6
+ import { useGetDeliveryZones as pe } from "./index32.mjs";
7
+ import { useCart as ve } from "./index3.mjs";
8
+ import { Modal as E } from "./index14.mjs";
9
+ import { FormInput as P } from "./index15.mjs";
10
+ import { FormSelect as D } from "./index16.mjs";
11
+ import { Button as L } from "./index11.mjs";
12
+ import { ChevronLeft as Ne, ChevronRight as ge, Loader2 as ee, CheckCircle as be, Package as xe, Mail as we, Phone as Ce, Zap as Pe, Banknote as ke, ChevronDown as Me } from "lucide-react";
13
+ import { formatCurrency as k, cn as C } from "./index17.mjs";
14
+ import qe from "./index35.mjs";
15
+ import { usePaystackPayment as Ie } from "./index36.mjs";
16
+ const Ze = (i) => i.replace(/\D/g, ""), je = R({
17
+ firstName: y().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"),
18
+ lastName: y().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"),
19
+ email: y().required("Email is required").email("Please enter a valid email address"),
20
+ phone: y().required("Phone number is required").test("nigerian-phone", "Please enter a valid Nigerian phone number (e.g. 0812 564 8668)", (i) => {
21
+ if (!i) return !1;
22
+ const M = Ze(i);
23
+ return [
24
+ /^0[789]\d{9}$/
25
+ // 0xxxxxxxxx (11 digits total)
26
+ ].some((f) => f.test(M));
27
+ })
28
+ }), Se = R({
29
+ address: y().required("Street address is required").min(10, "Please provide a complete address"),
30
+ city: y().required("City is required").min(3, "City name must be at least 3 characters"),
31
+ state: y().required("State is required").test("not-empty", "State is required", (i) => !!i && i.trim() !== ""),
32
+ deliveryZoneId: y().required("Delivery zone is required").test("not-empty", "Delivery zone is required", (i) => !!i && i.trim() !== "")
33
+ }), ze = R({
34
+ paymentMethod: y().oneOf(["cod", "online"], "Please select a payment method").required("Payment method is required")
35
+ });
36
+ function Qe({
37
+ isOpen: i,
38
+ onClose: M,
39
+ initialData: l,
40
+ onSuccess: f,
41
+ onError: c,
42
+ submitButtonText: te = "Place Order",
43
+ refundPolicy: I
44
+ }) {
45
+ var K, V, Y, W, H, J, Q, U;
46
+ const re = "pk_live_dfb74efb5f74d2acbc253d5ca396ab9015ef0fa7", [o, p] = w("customer"), [Z, ae] = w(void 0), [N, O] = w(void 0), [u, B] = w(null), { refetch: $, isLoading: se, cart: n, updateCartMutation: T, checkoutMutation: ne } = ve(), G = Ie({
47
+ publicKey: re,
48
+ onSuccess: async (t) => {
49
+ try {
50
+ const s = await b.mutateAsync({
51
+ firstName: r.firstName,
52
+ lastName: r.lastName,
53
+ email: r.email,
54
+ phone: r.phone,
55
+ address: r.address,
56
+ city: r.city,
57
+ deliveryZoneId: N || r.deliveryZoneId,
58
+ paymentMethod: r.paymentMethod,
59
+ paystackReference: t.reference
60
+ });
61
+ if ("error" in s) {
62
+ const d = s.error;
63
+ c == null || c(new Error((d == null ? void 0 : d.message) || "Checkout failed"));
64
+ return;
65
+ }
66
+ B(s), f == null || f(s.id);
67
+ } catch (s) {
68
+ c == null || c(s);
69
+ }
70
+ },
71
+ onClose: () => {
72
+ console.log("Payment popup closed by user");
73
+ }
74
+ });
75
+ q(() => {
76
+ i && $();
77
+ }, [i, $]);
78
+ const { data: g } = pe(((K = n == null ? void 0 : n.brand) == null ? void 0 : K.id) || "", {
79
+ enabled: !!((V = n == null ? void 0 : n.brand) != null && V.id)
80
+ }), h = X(() => g == null ? void 0 : g.find((t) => t.id === Z), [g, Z]), b = ne;
81
+ q(() => {
82
+ i || (B(null), p("customer"), b.reset());
83
+ }, [i, b]);
84
+ const [r, _] = w({
85
+ firstName: (l == null ? void 0 : l.firstName) || "",
86
+ lastName: (l == null ? void 0 : l.lastName) || "",
87
+ email: (l == null ? void 0 : l.email) || "",
88
+ phone: (l == null ? void 0 : l.phone) || "",
89
+ address: (l == null ? void 0 : l.address) || "",
90
+ city: (l == null ? void 0 : l.city) || "",
91
+ deliveryZoneId: (l == null ? void 0 : l.deliveryZoneId) || "",
92
+ paymentMethod: (l == null ? void 0 : l.paymentMethod) || "online",
93
+ notes: (l == null ? void 0 : l.notes) || ""
94
+ });
95
+ q(() => {
96
+ i && p("customer");
97
+ }, [i]), q(() => {
98
+ n && !l && _((t) => {
99
+ var s;
100
+ return {
101
+ ...t,
102
+ firstName: n.customerFirstName || "",
103
+ lastName: n.customerLastName || "",
104
+ email: n.customerEmail || "",
105
+ phone: n.customerPhone || "",
106
+ deliveryZoneId: ((s = n.deliveryZone) == null ? void 0 : s.id) || ""
107
+ };
108
+ });
109
+ }, [n, l]), q(() => {
110
+ if (N) {
111
+ const t = h == null ? void 0 : h.zones.find((s) => s.id === N);
112
+ t && _((s) => ({
113
+ ...s,
114
+ paymentMethod: t.allowOnline ? "online" : "cod"
115
+ }));
116
+ }
117
+ }, [N, h]);
118
+ const [m, j] = w({}), [A, le] = w(!1), v = (t) => {
119
+ const { name: s, value: d } = t.target;
120
+ _((x) => ({ ...x, [s]: d })), m[s] && j((x) => ({ ...x, [s]: void 0 }));
121
+ }, S = ye(
122
+ (t) => {
123
+ const s = r[t];
124
+ if (!s) return;
125
+ const d = {};
126
+ t === "firstName" ? d.customerFirstName = s : t === "lastName" ? d.customerLastName = s : t === "email" ? d.customerEmail = s : t === "phone" && (d.customerPhone = s), T.mutate(d);
127
+ },
128
+ [r, T]
129
+ ), z = (t) => {
130
+ const s = {};
131
+ try {
132
+ if (t === "customer")
133
+ je.validateSync(r, { abortEarly: !1 });
134
+ else if (t === "delivery") {
135
+ const d = {
136
+ address: r.address,
137
+ city: r.city,
138
+ state: Z || r.state || "",
139
+ deliveryZoneId: N || r.deliveryZoneId || ""
140
+ };
141
+ Se.validateSync(d, { abortEarly: !1 });
142
+ } else t === "payment" && ze.validateSync(r, { abortEarly: !1 });
143
+ } catch (d) {
144
+ d instanceof fe && d.inner.forEach((x) => {
145
+ x.path && (s[x.path] = x.message);
146
+ });
147
+ }
148
+ return j(s), Object.keys(s).length === 0;
149
+ }, de = () => {
150
+ z(o) && (o === "customer" ? p("delivery") : o === "delivery" && p("payment"));
151
+ }, ie = () => {
152
+ o === "payment" ? p("delivery") : o === "delivery" && p("customer");
153
+ }, ce = async () => {
154
+ if (!z("customer")) {
155
+ p("customer");
156
+ return;
157
+ }
158
+ if (!z("delivery")) {
159
+ p("delivery");
160
+ return;
161
+ }
162
+ if (z("payment")) {
163
+ if (r.paymentMethod === "online") {
164
+ if (!G.isLoaded) {
165
+ c == null || c(new Error("Payment system is loading. Please try again."));
166
+ return;
167
+ }
168
+ const t = Math.round(n.pricing.total * 100);
169
+ G.initializePayment({
170
+ email: r.email || (n == null ? void 0 : n.customerEmail) || "customer@example.com",
171
+ amount: t,
172
+ currency: "NGN",
173
+ metadata: {
174
+ cartId: n == null ? void 0 : n.id,
175
+ custom_fields: [
176
+ {
177
+ display_name: "Customer Name",
178
+ variable_name: "customer_name",
179
+ value: `${r.firstName} ${r.lastName}`
180
+ },
181
+ {
182
+ display_name: "Phone Number",
183
+ variable_name: "phone_number",
184
+ value: r.phone
185
+ }
186
+ ]
187
+ }
188
+ });
189
+ return;
190
+ }
191
+ try {
192
+ const t = await b.mutateAsync({
193
+ firstName: r.firstName,
194
+ lastName: r.lastName,
195
+ email: r.email,
196
+ phone: r.phone,
197
+ address: r.address,
198
+ city: r.city,
199
+ deliveryZoneId: N || r.deliveryZoneId,
200
+ paymentMethod: r.paymentMethod
201
+ });
202
+ if ("error" in t) {
203
+ const s = t.error;
204
+ c == null || c(new Error((s == null ? void 0 : s.message) || "Checkout failed"));
205
+ return;
206
+ }
207
+ B(t), f == null || f(t.id);
208
+ } catch (t) {
209
+ c == null || c(t);
210
+ }
211
+ }
212
+ }, oe = {
213
+ customer: "Customer Information",
214
+ delivery: "Delivery Address",
215
+ payment: "Payment Method"
216
+ }, me = X(() => oe[o], [o]), ue = /* @__PURE__ */ a("div", { className: "space-y-3", children: [
217
+ (o === "payment" || o === "delivery") && ((Y = n == null ? void 0 : n.pricing) == null ? void 0 : Y.total) && /* @__PURE__ */ a("div", { className: "text-sm text-black", children: [
218
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
219
+ /* @__PURE__ */ e("span", { children: "Subtotal" }),
220
+ /* @__PURE__ */ e("span", { children: k(((W = n == null ? void 0 : n.pricing) == null ? void 0 : W.subtotal) ?? 0) })
221
+ ] }),
222
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
223
+ /* @__PURE__ */ e("span", { children: "Discount" }),
224
+ /* @__PURE__ */ a("span", { className: "text-green-600", children: [
225
+ "-",
226
+ k(((J = (H = n == null ? void 0 : n.pricing) == null ? void 0 : H.discount) == null ? void 0 : J.amount) ?? 0)
227
+ ] })
228
+ ] }),
229
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
230
+ /* @__PURE__ */ e("span", { children: "Delivery Fee" }),
231
+ /* @__PURE__ */ e("span", { children: k(((Q = n == null ? void 0 : n.pricing) == null ? void 0 : Q.deliveryCharge) ?? 0) })
232
+ ] }),
233
+ /* @__PURE__ */ e("hr", { className: "border-gray-200 my-2" }),
234
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
235
+ /* @__PURE__ */ e("span", { children: "Total" }),
236
+ /* @__PURE__ */ e("span", { children: k(((U = n == null ? void 0 : n.pricing) == null ? void 0 : U.total) ?? 0) })
237
+ ] })
238
+ ] }),
239
+ /* @__PURE__ */ a("div", { className: "flex gap-3", children: [
240
+ o !== "customer" && /* @__PURE__ */ a(
241
+ L,
242
+ {
243
+ type: "button",
244
+ variant: "outline",
245
+ onClick: ie,
246
+ className: "flex-1 border-gray-400",
247
+ size: "lg",
248
+ children: [
249
+ /* @__PURE__ */ e(Ne, { className: "mr-2 h-4 w-4" }),
250
+ "Back"
251
+ ]
252
+ }
253
+ ),
254
+ o !== "payment" ? /* @__PURE__ */ a(
255
+ L,
256
+ {
257
+ type: "button",
258
+ onClick: de,
259
+ className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
260
+ size: "lg",
261
+ children: [
262
+ "Next",
263
+ /* @__PURE__ */ e(ge, { className: "ml-2 h-4 w-4" })
264
+ ]
265
+ }
266
+ ) : /* @__PURE__ */ e(
267
+ L,
268
+ {
269
+ type: "button",
270
+ onClick: ce,
271
+ disabled: b.isPending,
272
+ className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
273
+ size: "lg",
274
+ children: b.isPending ? /* @__PURE__ */ a(he, { children: [
275
+ /* @__PURE__ */ e(ee, { className: "mr-2 h-4 w-4 animate-spin" }),
276
+ "Processing..."
277
+ ] }) : te
278
+ }
279
+ )
280
+ ] }),
281
+ b.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." })
282
+ ] }), F = (t) => !(n != null && n.availablePaymentMethods.includes(t));
283
+ return u ? /* @__PURE__ */ e(
284
+ E,
285
+ {
286
+ isOpen: i,
287
+ onClose: M,
288
+ title: "Order Placed Successfully!",
289
+ footer: /* @__PURE__ */ e(
290
+ L,
291
+ {
292
+ onClick: M,
293
+ className: "w-full bg-accent-500 text-white hover:bg-accent-600",
294
+ size: "lg",
295
+ children: "Close"
296
+ }
297
+ ),
298
+ size: "lg",
299
+ contentClassName: "p-6",
300
+ children: /* @__PURE__ */ a("div", { className: "text-center space-y-6", children: [
301
+ /* @__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(be, { className: "h-12 w-12 text-green-600" }) }) }),
302
+ /* @__PURE__ */ a("div", { className: "space-y-2", children: [
303
+ /* @__PURE__ */ e("h3", { className: "text-2xl font-bold text-gray-900", children: "Thank You!" }),
304
+ /* @__PURE__ */ e("p", { className: "text-gray-600", children: "Your order has been placed successfully." })
305
+ ] }),
306
+ /* @__PURE__ */ a("div", { className: "bg-gray-50 rounded-lg p-6 space-y-4", children: [
307
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-center space-x-2 text-gray-700", children: [
308
+ /* @__PURE__ */ e(xe, { className: "h-5 w-5" }),
309
+ /* @__PURE__ */ a("span", { className: "font-medium", children: [
310
+ "Order #",
311
+ u.orderNumber
312
+ ] })
313
+ ] }),
314
+ /* @__PURE__ */ a("div", { className: "border-t border-gray-200 pt-4 space-y-3", children: [
315
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
316
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Customer" }),
317
+ /* @__PURE__ */ a("span", { className: "font-medium text-gray-900", children: [
318
+ u.firstName,
319
+ " ",
320
+ u.lastName
321
+ ] })
322
+ ] }),
323
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
324
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Phone" }),
325
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: u.phone })
326
+ ] }),
327
+ u.email && /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
328
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Email" }),
329
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: u.email })
330
+ ] }),
331
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
332
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Payment Method" }),
333
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: u.paymentMethod === "cod" ? "Cash on Delivery" : "Online Payment" })
334
+ ] }),
335
+ /* @__PURE__ */ a("div", { className: "flex justify-between text-sm", children: [
336
+ /* @__PURE__ */ e("span", { className: "text-gray-600", children: "Total" }),
337
+ /* @__PURE__ */ e("span", { className: "font-bold text-gray-900", children: k(u.totalPrice) })
338
+ ] })
339
+ ] })
340
+ ] }),
341
+ /* @__PURE__ */ e("div", { className: "bg-blue-50 rounded-lg p-4", children: /* @__PURE__ */ a("p", { className: "text-sm text-blue-900", children: [
342
+ /* @__PURE__ */ e("span", { className: "font-semibold", children: "We'll be in touch shortly!" }),
343
+ /* @__PURE__ */ e("br", {}),
344
+ "Our team will contact you soon to arrange delivery and confirm your order details."
345
+ ] }) })
346
+ ] })
347
+ }
348
+ ) : /* @__PURE__ */ e(
349
+ E,
350
+ {
351
+ isOpen: i,
352
+ onClose: M,
353
+ title: me,
354
+ footer: ue,
355
+ size: "lg",
356
+ contentClassName: "p-0",
357
+ children: se ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-[300px]", children: /* @__PURE__ */ e(ee, { className: "h-8 w-8 animate-spin text-gray-600" }) }) : /* @__PURE__ */ e("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ e("div", { className: "relative w-full", children: /* @__PURE__ */ a(
358
+ "div",
359
+ {
360
+ className: C(
361
+ "flex transition-transform duration-300 ease-in-out w-full",
362
+ o === "customer" && "translate-x-0",
363
+ o === "delivery" && "-translate-x-full",
364
+ o === "payment" && "-translate-x-[200%]"
365
+ ),
366
+ children: [
367
+ /* @__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: [
368
+ /* @__PURE__ */ e(
369
+ P,
370
+ {
371
+ label: "First Name",
372
+ type: "text",
373
+ name: "firstName",
374
+ value: r.firstName,
375
+ onChange: v,
376
+ onBlur: () => S("firstName"),
377
+ error: m.firstName,
378
+ autoCorrect: "off",
379
+ required: !0
380
+ }
381
+ ),
382
+ /* @__PURE__ */ e(
383
+ P,
384
+ {
385
+ label: "Last Name",
386
+ type: "text",
387
+ name: "lastName",
388
+ value: r.lastName,
389
+ onChange: v,
390
+ onBlur: () => S("lastName"),
391
+ error: m.lastName,
392
+ autoCorrect: "off",
393
+ required: !0
394
+ }
395
+ ),
396
+ /* @__PURE__ */ e(
397
+ P,
398
+ {
399
+ label: "Email",
400
+ type: "email",
401
+ name: "email",
402
+ value: r.email,
403
+ onChange: v,
404
+ onBlur: () => S("email"),
405
+ error: m.email,
406
+ icon: /* @__PURE__ */ e(we, { size: 16 }),
407
+ autoCorrect: "off",
408
+ required: !0
409
+ }
410
+ ),
411
+ /* @__PURE__ */ e(
412
+ P,
413
+ {
414
+ label: "Phone Number",
415
+ type: "tel",
416
+ name: "phone",
417
+ value: r.phone,
418
+ onChange: v,
419
+ onBlur: () => S("phone"),
420
+ placeholder: "e.g. 08012345678",
421
+ maxLength: 18,
422
+ error: m.phone,
423
+ icon: /* @__PURE__ */ e(Ce, { size: 16 }),
424
+ autoCorrect: "off",
425
+ required: !0,
426
+ className: "font-semibold"
427
+ }
428
+ )
429
+ ] }) }) }),
430
+ /* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-4", children: [
431
+ /* @__PURE__ */ e(
432
+ P,
433
+ {
434
+ label: "Street Address",
435
+ type: "text",
436
+ name: "address",
437
+ value: r.address,
438
+ onChange: v,
439
+ error: m.address,
440
+ autoCorrect: "off",
441
+ required: !0
442
+ }
443
+ ),
444
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
445
+ /* @__PURE__ */ e(
446
+ P,
447
+ {
448
+ label: "Area",
449
+ type: "text",
450
+ name: "city",
451
+ value: r.city,
452
+ onChange: v,
453
+ error: m.city,
454
+ autoCorrect: "off",
455
+ required: !0
456
+ }
457
+ ),
458
+ /* @__PURE__ */ a(
459
+ D,
460
+ {
461
+ label: "State",
462
+ name: "state",
463
+ value: Z || "",
464
+ onChange: (t) => {
465
+ O("");
466
+ const s = t.target.value;
467
+ ae(s || void 0), m.state && j((d) => ({ ...d, state: void 0 }));
468
+ },
469
+ error: m.state,
470
+ required: !0,
471
+ children: [
472
+ /* @__PURE__ */ e("option", { disabled: !0, value: "", children: "Select State" }),
473
+ g == null ? void 0 : g.map((t) => /* @__PURE__ */ e("option", { value: t.id, children: t.name }, t.id))
474
+ ]
475
+ }
476
+ ),
477
+ /* @__PURE__ */ a(
478
+ D,
479
+ {
480
+ label: "Delivery Zone",
481
+ value: N || "",
482
+ onChange: (t) => {
483
+ const s = t.target.value;
484
+ O(s || void 0), m.deliveryZoneId && j((d) => ({ ...d, deliveryZoneId: void 0 })), s && T.mutate({ deliveryZoneId: s });
485
+ },
486
+ disabled: !h,
487
+ error: m.deliveryZoneId,
488
+ required: !0,
489
+ children: [
490
+ /* @__PURE__ */ e("option", { disabled: !0, value: "", children: h ? "Select Delivery Zone" : "Select State First" }),
491
+ h == null ? void 0 : h.zones.map((t) => /* @__PURE__ */ a("option", { value: t.id, children: [
492
+ t.name,
493
+ " (",
494
+ k(t.deliveryCost),
495
+ ")"
496
+ ] }, t.id))
497
+ ]
498
+ }
499
+ )
500
+ ] })
501
+ ] }) }),
502
+ /* @__PURE__ */ e("div", { className: "w-full min-w-full flex-shrink-0 p-4", children: /* @__PURE__ */ a("div", { className: "space-y-6", children: [
503
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
504
+ /* @__PURE__ */ e("div", { className: "relative", children: /* @__PURE__ */ a(
505
+ "label",
506
+ {
507
+ className: C(
508
+ "flex items-center justify-center relative p-4 border-2 rounded-xl cursor-pointer transition-all duration-200",
509
+ r.paymentMethod === "online" ? "border-accent-500 bg-accent-50" : "border-gray-200 hover:border-gray-300",
510
+ F("online") && "opacity-50 cursor-not-allowed"
511
+ ),
512
+ children: [
513
+ /* @__PURE__ */ e(
514
+ "input",
515
+ {
516
+ type: "radio",
517
+ name: "paymentMethod",
518
+ value: "online",
519
+ disabled: F("online"),
520
+ checked: r.paymentMethod === "online",
521
+ onChange: v,
522
+ className: "sr-only"
523
+ }
524
+ ),
525
+ /* @__PURE__ */ a("div", { className: "flex flex-col items-center text-center space-y-3", children: [
526
+ /* @__PURE__ */ e(
527
+ "div",
528
+ {
529
+ className: C(
530
+ "p-3 rounded-full",
531
+ r.paymentMethod === "online" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
532
+ ),
533
+ children: /* @__PURE__ */ e(Pe, { size: 24 })
534
+ }
535
+ ),
536
+ /* @__PURE__ */ a("div", { children: [
537
+ /* @__PURE__ */ e("div", { className: "font-semibold text-gray-900", children: "Pay Online" }),
538
+ /* @__PURE__ */ e("div", { className: "text-sm text-gray-500 mt-1", children: "Bank transfer" }),
539
+ /* @__PURE__ */ e(
540
+ "img",
541
+ {
542
+ src: qe,
543
+ alt: "Paystack",
544
+ className: "h-4 w-auto mt-2 mx-auto"
545
+ }
546
+ )
547
+ ] })
548
+ ] }),
549
+ r.paymentMethod === "online" && /* @__PURE__ */ e("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ e("div", { className: "w-5 h-5 bg-accent-600 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-2 h-2 bg-white rounded-full" }) }) })
550
+ ]
551
+ }
552
+ ) }),
553
+ /* @__PURE__ */ a(
554
+ "label",
555
+ {
556
+ className: C(
557
+ "flex items-center justify-center relative p-4 border-2 rounded-xl cursor-pointer transition-all duration-200",
558
+ r.paymentMethod === "cod" ? "border-accent-500 bg-accent-50" : "border-gray-200 hover:border-gray-300",
559
+ F("cod") && "opacity-50 cursor-not-allowed"
560
+ ),
561
+ children: [
562
+ /* @__PURE__ */ e(
563
+ "input",
564
+ {
565
+ type: "radio",
566
+ name: "paymentMethod",
567
+ value: "cod",
568
+ disabled: F("cod"),
569
+ checked: r.paymentMethod === "cod",
570
+ onChange: v,
571
+ className: "sr-only"
572
+ }
573
+ ),
574
+ /* @__PURE__ */ a("div", { className: "flex flex-col items-center text-center space-y-3", children: [
575
+ /* @__PURE__ */ e(
576
+ "div",
577
+ {
578
+ className: C(
579
+ "p-3 rounded-full",
580
+ r.paymentMethod === "cod" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
581
+ ),
582
+ children: /* @__PURE__ */ e(ke, { size: 24 })
583
+ }
584
+ ),
585
+ /* @__PURE__ */ a("div", { children: [
586
+ /* @__PURE__ */ e("div", { className: "font-semibold text-gray-900", children: "Pay on Delivery" }),
587
+ /* @__PURE__ */ e("div", { className: "text-sm text-gray-500 mt-1", children: "Cash when item arrives" })
588
+ ] })
589
+ ] }),
590
+ r.paymentMethod === "cod" && /* @__PURE__ */ e("div", { className: "absolute top-2 right-2", children: /* @__PURE__ */ e("div", { className: "w-5 h-5 bg-accent-600 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-2 h-2 bg-white rounded-full" }) }) })
591
+ ]
592
+ }
593
+ )
594
+ ] }),
595
+ m.paymentMethod && /* @__PURE__ */ e("p", { className: "text-red-600 text-sm", children: m.paymentMethod }),
596
+ I && /* @__PURE__ */ a("div", { className: "border border-gray-200 rounded-lg", children: [
597
+ /* @__PURE__ */ a(
598
+ "button",
599
+ {
600
+ type: "button",
601
+ onClick: () => le(!A),
602
+ 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",
603
+ children: [
604
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-gray-700", children: I.title || "🤔 Curious about Refunds?" }),
605
+ /* @__PURE__ */ e(
606
+ Me,
607
+ {
608
+ size: 16,
609
+ className: C(
610
+ "transform transition-transform duration-200 text-gray-500",
611
+ A && "rotate-180"
612
+ )
613
+ }
614
+ )
615
+ ]
616
+ }
617
+ ),
618
+ /* @__PURE__ */ e(
619
+ "div",
620
+ {
621
+ className: C(
622
+ "overflow-hidden transition-all duration-300 ease-in-out",
623
+ A ? "max-h-96 opacity-100" : "max-h-0 opacity-0"
624
+ ),
625
+ 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: I.policies && /* @__PURE__ */ a("div", { children: [
626
+ /* @__PURE__ */ e("h4", { className: "font-bold text-gray-800 mb-2", children: "Our Refund Policy" }),
627
+ /* @__PURE__ */ e("ul", { className: "space-y-1 ml-4", children: I.policies.map((t, s) => /* @__PURE__ */ a("li", { className: "flex items-start", children: [
628
+ /* @__PURE__ */ e("span", { className: "text-green-600 mr-2", children: "✓" }),
629
+ /* @__PURE__ */ e("span", { children: t })
630
+ ] }, s)) })
631
+ ] }) }) })
632
+ }
633
+ )
634
+ ] })
635
+ ] }) })
636
+ ]
637
+ }
638
+ ) }) })
639
+ }
640
+ );
641
+ }
642
+ export {
643
+ Qe as Checkout
644
+ };
@@ -0,0 +1,7 @@
1
+ function o(e) {
2
+ const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
3
+ return t && t[1] || "";
4
+ }
5
+ export {
6
+ o as default
7
+ };