@loczer/storefront-sdk 0.241.0 → 0.243.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.
- package/dist/chunks/pkg/booking-engine/dist/models/{Product.shared-VisFafx-.js → Product.shared-JIXwUVrg.js} +1 -1
- package/dist/chunks/pkg/booking-engine/dist/schemas/{base-asset-BuqI-BM_.js → base-asset-DtBfhenO.js} +1 -1
- package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-gCY-ZP5p.js → base-booking-D9S-zS-D.js} +2 -2
- package/dist/chunks/pkg/booking-engine/dist/schemas/{base-product-r04ZJglB.js → base-product-Dj-bv0QD.js} +1 -1
- package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-ps94yuAR.js → cart-inputs-CIeuiTzp.js} +1 -1
- package/dist/chunks/pkg/booking-engine/dist/schemas/{insurance-XwIj1m3Z.js → insurance-v2GZHSVq.js} +1 -1
- package/dist/chunks/pkg/booking-engine/dist/{schemas-7yx45S2o.js → schemas-B82mPOxs.js} +6 -6
- package/dist/components/Footer/businessHoursStatus.js +1 -1
- package/dist/i18n/en.d.ts +1 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +2 -1
- package/dist/i18n/fr.d.ts +1 -0
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/lib/booking-period.js +1 -1
- package/dist/lib/booking.js +2 -2
- package/dist/lib/checkoutSubmit.d.ts +4 -0
- package/dist/lib/checkoutSubmit.d.ts.map +1 -1
- package/dist/lib/checkoutSubmit.js +19 -11
- package/dist/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPage.js +199 -199
- package/dist/pages/CheckoutPaymentPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPaymentPage.js +168 -167
- package/dist/pages/CheckoutSuccessPage.d.ts.map +1 -1
- package/dist/pages/CheckoutSuccessPage.js +37 -25
- package/dist/storefront.css +1 -1
- package/dist/storefrontSchemas.js +1 -1
- package/dist/ui/drawer.d.ts +12 -13
- package/dist/ui/drawer.d.ts.map +1 -1
- package/dist/ui/drawer.js +119 -143
- package/package.json +1 -1
|
@@ -2,31 +2,31 @@ import { applyBookingParamsToSearch as e, getBookingParamsFromSearch as t, pickB
|
|
|
2
2
|
import { useStorefrontCart as ee } from "../lib/cart.js";
|
|
3
3
|
import { calculateBookingRentalUnitSummary as te, getPricingUnitLabel as ne } from "../lib/pricing.js";
|
|
4
4
|
import { buildStorefrontCartSummary as re } from "../lib/cartSummary.js";
|
|
5
|
-
import { ROUTE as ie,
|
|
6
|
-
import { ROUTE as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { useStorefront as
|
|
5
|
+
import { ROUTE as ie, addCheckoutBookingNumberToPath as ae, responseSchema as oe } from "../lib/checkoutSubmit.js";
|
|
6
|
+
import { ROUTE as se, buildStorefrontAvailabilityKey as ce, getStorefrontAvailabilityIssue as le, getValidStorefrontAvailabilitySchedule as ue, responseSchema as de } from "../lib/storefrontAvailability.js";
|
|
7
|
+
import { Button as fe } from "../ui/button.js";
|
|
8
|
+
import { useStorefront as pe, useStorefrontProducts as me } from "../StorefrontContext.js";
|
|
9
9
|
import { toast as a } from "../lib/toast.js";
|
|
10
10
|
import { apiPost as o } from "../lib/apiCall.js";
|
|
11
|
-
import { FulfillmentSection as
|
|
12
|
-
import { BookingFlowPageLayout as
|
|
13
|
-
import { Spinner as
|
|
14
|
-
import { ROUTE as
|
|
15
|
-
import { ROUTE as
|
|
16
|
-
import { CheckoutDetailsCard as
|
|
17
|
-
import { CheckoutInsuranceCard as
|
|
18
|
-
import { CheckoutLoadingSkeleton as
|
|
19
|
-
import { CheckoutMobileSummaryDrawer as
|
|
20
|
-
import { CheckoutSummaryColumn as
|
|
21
|
-
import { checkoutFormSchema as
|
|
22
|
-
import { useEffect as s, useMemo as c, useRef as
|
|
11
|
+
import { FulfillmentSection as he } from "../components/FulfillmentSection/index.js";
|
|
12
|
+
import { BookingFlowPageLayout as ge } from "../components/BookingFlowPageLayout/index.js";
|
|
13
|
+
import { Spinner as _e } from "../chunks/pkg/ui/dist/Spinner/index-Cgi70z_E.js";
|
|
14
|
+
import { ROUTE as ve, responseSchema as ye } from "../lib/checkoutPaymentDecision.js";
|
|
15
|
+
import { ROUTE as be, responseSchema as xe } from "../lib/checkoutVerifyCoupon.js";
|
|
16
|
+
import { CheckoutDetailsCard as Se } from "./checkout/components/CheckoutDetailsCard.js";
|
|
17
|
+
import { CheckoutInsuranceCard as Ce } from "./checkout/components/CheckoutInsuranceCard.js";
|
|
18
|
+
import { CheckoutLoadingSkeleton as we } from "./checkout/components/CheckoutLoadingSkeleton.js";
|
|
19
|
+
import { CheckoutMobileSummaryDrawer as Te } from "./checkout/components/CheckoutMobileSummaryDrawer.js";
|
|
20
|
+
import { CheckoutSummaryColumn as Ee } from "./checkout/components/CheckoutSummaryColumn.js";
|
|
21
|
+
import { checkoutFormSchema as De } from "./checkout/types.js";
|
|
22
|
+
import { useEffect as s, useMemo as c, useRef as Oe, useState as l } from "react";
|
|
23
23
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
24
|
-
import { Link as
|
|
25
|
-
import { useTranslation as
|
|
26
|
-
import { AlertTriangle as
|
|
27
|
-
import { useForm as
|
|
24
|
+
import { Link as ke, useNavigate as Ae, useParams as je, useSearchParams as Me } from "@rpcbase/router";
|
|
25
|
+
import { useTranslation as Ne } from "react-i18next";
|
|
26
|
+
import { AlertTriangle as Pe, ArrowLeft as Fe } from "lucide-react";
|
|
27
|
+
import { useForm as Ie, zodResolver as Le } from "@rpcbase/form";
|
|
28
28
|
//#region src/pages/CheckoutPage.tsx
|
|
29
|
-
var
|
|
29
|
+
var Re = .2, f = (e, t, n) => {
|
|
30
30
|
try {
|
|
31
31
|
return new Intl.NumberFormat(n, {
|
|
32
32
|
style: "currency",
|
|
@@ -35,7 +35,7 @@ var Le = .2, f = (e, t, n) => {
|
|
|
35
35
|
} catch {
|
|
36
36
|
return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
|
|
37
37
|
}
|
|
38
|
-
},
|
|
38
|
+
}, ze = (e, t) => {
|
|
39
39
|
try {
|
|
40
40
|
return new Intl.NumberFormat(t, {
|
|
41
41
|
style: "percent",
|
|
@@ -47,103 +47,103 @@ var Le = .2, f = (e, t, n) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
function p() {
|
|
50
|
-
let { t: p, i18n: m } =
|
|
50
|
+
let { t: p, i18n: m } = Ne(), { storefrontConfiguration: h } = pe(), Be = h.workspace?.workspaceLanguage, { bikes: g, accessories: Ve } = me(), { storeSlug: _ } = je(), [v, He] = Me(), Ue = Ae(), { items: We, itemCount: Ge, isReady: Ke, setQuantity: qe, removeItem: Je, beginCheckoutSubmission: Ye, confirmCheckoutPaymentSession: Xe, clearCheckoutSession: Ze, clear: Qe } = ee(), [y, $e] = l(!1), b = Oe(!1), [x, S] = l(null), [et, C] = l(!1), [w, T] = l(null), tt = v.get("coupon") ?? v.get("code") ?? "", [nt, E] = l(tt), [rt, it] = l(tt.trim()), [D, O] = l(null), [at, k] = l(null), [A, j] = l(!1), [ot, M] = l(null), [st, N] = l(null), [P, ct] = l(!1), [F, lt] = l(!1), ut = n(v).toString(), dt = c(() => r(new URLSearchParams(ut), _), [ut, _]), I = h.settings.fulfillmentModes.includes("delivery"), ft = h.settings.deliveryDisabledReason.trim(), pt = I || ft.length > 0, mt = h.shop.address?.trim() ?? "", L = c(() => {
|
|
51
51
|
let e = t(dt, {
|
|
52
52
|
startTime: "",
|
|
53
53
|
endTime: ""
|
|
54
54
|
});
|
|
55
|
-
return e.fulfillment === "delivery" && !
|
|
55
|
+
return e.fulfillment === "delivery" && !I ? {
|
|
56
56
|
...e,
|
|
57
57
|
fulfillment: "pickup"
|
|
58
58
|
} : e;
|
|
59
|
-
}, [dt,
|
|
60
|
-
items:
|
|
59
|
+
}, [dt, I]), R = c(() => ue(L), [L]), z = h.bookingEngine.pricing, ht = te(L, z, h.bookingEngine.shop.timeZone), gt = ne(z.baseUnit, p), _t = ht?.billableUnitCount, B = c(() => re({
|
|
60
|
+
items: We,
|
|
61
61
|
language: m.language,
|
|
62
|
-
fallbackLanguage:
|
|
62
|
+
fallbackLanguage: Be,
|
|
63
63
|
products: {
|
|
64
64
|
bikes: g,
|
|
65
|
-
accessories:
|
|
65
|
+
accessories: Ve
|
|
66
66
|
},
|
|
67
|
-
priceUnit:
|
|
67
|
+
priceUnit: z.baseUnit,
|
|
68
68
|
billableUnitCount: _t
|
|
69
69
|
}), [
|
|
70
|
-
|
|
70
|
+
Ve,
|
|
71
71
|
g,
|
|
72
72
|
_t,
|
|
73
73
|
m.language,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
]),
|
|
74
|
+
We,
|
|
75
|
+
z.baseUnit,
|
|
76
|
+
Be
|
|
77
|
+
]), V = c(() => B.lines.map((e) => ({
|
|
78
78
|
productId: e.checkoutProductId,
|
|
79
79
|
productVariantId: e.productVariantId,
|
|
80
80
|
quantity: e.quantity
|
|
81
|
-
})), [
|
|
81
|
+
})), [B.lines]), [vt, H] = l([]), [U, W] = l(!1);
|
|
82
82
|
s(() => {
|
|
83
|
-
if (!_ ||
|
|
84
|
-
|
|
83
|
+
if (!_ || V.length === 0) {
|
|
84
|
+
H([]), W(!1);
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
if (!
|
|
88
|
-
|
|
87
|
+
if (!R) {
|
|
88
|
+
H([]), W(!1);
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
let e = !1;
|
|
92
|
-
return
|
|
92
|
+
return W(!0), H([]), (async () => {
|
|
93
93
|
try {
|
|
94
|
-
let t = await o(
|
|
94
|
+
let t = await o(se, {
|
|
95
95
|
storeSlug: _,
|
|
96
|
-
schedule:
|
|
97
|
-
products:
|
|
98
|
-
}), n =
|
|
96
|
+
schedule: R,
|
|
97
|
+
products: V
|
|
98
|
+
}), n = de.parse(t);
|
|
99
99
|
if (e) return;
|
|
100
|
-
|
|
100
|
+
H(n.success ? n.availability ?? [] : []);
|
|
101
101
|
} catch (t) {
|
|
102
102
|
if (e) return;
|
|
103
|
-
console.error("Failed to load checkout cart availability", t),
|
|
103
|
+
console.error("Failed to load checkout cart availability", t), H([]);
|
|
104
104
|
} finally {
|
|
105
|
-
e ||
|
|
105
|
+
e || W(!1);
|
|
106
106
|
}
|
|
107
107
|
})(), () => {
|
|
108
108
|
e = !0;
|
|
109
109
|
};
|
|
110
110
|
}, [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
L.endDate,
|
|
112
|
+
L.endTime,
|
|
113
|
+
L.startDate,
|
|
114
|
+
L.startTime,
|
|
115
|
+
R,
|
|
116
|
+
V,
|
|
117
117
|
_
|
|
118
118
|
]);
|
|
119
|
-
let yt = c(() => new Map(vt.map((e) => [
|
|
120
|
-
...
|
|
121
|
-
lines:
|
|
122
|
-
let t = yt.get(
|
|
119
|
+
let yt = c(() => new Map(vt.map((e) => [ce(e.productId, e.productVariantId), e])), [vt]), bt = c(() => ({
|
|
120
|
+
...B,
|
|
121
|
+
lines: B.lines.map((e) => {
|
|
122
|
+
let t = yt.get(ce(e.checkoutProductId, e.productVariantId)), n = t ? le(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
|
|
123
123
|
return {
|
|
124
124
|
...e,
|
|
125
|
-
insufficientCapacity: !
|
|
126
|
-
availabilityIssue:
|
|
125
|
+
insufficientCapacity: !U && n !== void 0,
|
|
126
|
+
availabilityIssue: U ? void 0 : n
|
|
127
127
|
};
|
|
128
128
|
})
|
|
129
129
|
}), [
|
|
130
130
|
yt,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
]),
|
|
131
|
+
U,
|
|
132
|
+
B
|
|
133
|
+
]), G = c(() => B.lines.map((e) => ({
|
|
134
134
|
kind: e.kind,
|
|
135
135
|
productId: e.checkoutProductId,
|
|
136
136
|
productVariantId: e.productVariantId,
|
|
137
137
|
quantity: e.quantity
|
|
138
|
-
})), [
|
|
138
|
+
})), [B.lines]), xt = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), K = B.lines.flatMap((e) => {
|
|
139
139
|
let t = xt.get(e.checkoutProductId);
|
|
140
140
|
return t?.insurance?.enabled ? [{
|
|
141
141
|
quantity: e.quantity,
|
|
142
142
|
pricePerDayMinor: t.insurance.pricePerDayMinor,
|
|
143
143
|
deductibleAmountMinor: t.insurance.deductibleAmountMinor
|
|
144
144
|
}] : [];
|
|
145
|
-
}),
|
|
146
|
-
resolver:
|
|
145
|
+
}), q = h.modules?.insurance?.enabled === !0 && K.length > 0, J = q && F, St = K.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), Ct = K.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), wt = B.totalMinor ?? 0, Y = at?.totalMinor ?? wt, X = at?.insuranceSubtotalMinor ?? 0, Tt = D?.discountAmountMinor ?? 0, Z = e(new URLSearchParams(), L).toString(), Q = `/${_ ?? ""}/booking${Z ? `?${Z}` : ""}`, Et = `/${_ ?? ""}/checkout${Z ? `?${Z}` : ""}`, Dt = Ie({
|
|
146
|
+
resolver: Le(De),
|
|
147
147
|
defaultValues: {
|
|
148
148
|
fullName: "",
|
|
149
149
|
email: "",
|
|
@@ -152,183 +152,183 @@ function p() {
|
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
154
|
s(() => {
|
|
155
|
-
i(_,
|
|
156
|
-
}, [
|
|
157
|
-
!
|
|
158
|
-
}, [
|
|
159
|
-
let
|
|
155
|
+
i(_, L);
|
|
156
|
+
}, [L, _]), s(() => {
|
|
157
|
+
!q && F && lt(!1);
|
|
158
|
+
}, [F, q]);
|
|
159
|
+
let Ot = (t) => {
|
|
160
160
|
let n = {
|
|
161
|
-
...
|
|
161
|
+
...L,
|
|
162
162
|
...t
|
|
163
163
|
}, r = e(v, n);
|
|
164
|
-
r.toString() !== v.toString() && (
|
|
164
|
+
r.toString() !== v.toString() && (He(r, { replace: !0 }), i(_, r));
|
|
165
165
|
};
|
|
166
166
|
s(() => {
|
|
167
|
-
if (!_ ||
|
|
168
|
-
|
|
167
|
+
if (!_ || G.length === 0 || !R) {
|
|
168
|
+
O(null), k(null), j(!1), M(null), N(null);
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
let e =
|
|
172
|
-
return
|
|
171
|
+
let e = rt.trim(), t = e.length === 0 && !P, n = !1;
|
|
172
|
+
return j(!0), N(null), M(null), (async () => {
|
|
173
173
|
try {
|
|
174
|
-
let r = await o(
|
|
174
|
+
let r = await o(be, {
|
|
175
175
|
storeSlug: _,
|
|
176
|
-
schedule:
|
|
177
|
-
items:
|
|
176
|
+
schedule: R,
|
|
177
|
+
items: G,
|
|
178
178
|
couponCode: e || void 0,
|
|
179
179
|
includeAutoApply: t,
|
|
180
|
-
insuranceAccepted:
|
|
181
|
-
}), i =
|
|
180
|
+
insuranceAccepted: J
|
|
181
|
+
}), i = xe.parse(r);
|
|
182
182
|
if (n) return;
|
|
183
|
-
if (
|
|
183
|
+
if (k(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
|
|
184
184
|
subtotalMinor: i.subtotalMinor,
|
|
185
185
|
totalMinor: i.totalMinor,
|
|
186
186
|
lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
|
|
187
187
|
insuranceSubtotalMinor: i.insuranceSubtotalMinor,
|
|
188
188
|
insuranceBillableDays: i.insuranceBillableDays
|
|
189
189
|
} : null), !i.success) {
|
|
190
|
-
|
|
190
|
+
O(null), N(i.message || p("checkout_coupon_invalid"));
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
O(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (E(i.coupon.code), M(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : M(p("checkout_coupon_manual_applied")));
|
|
194
194
|
} catch (e) {
|
|
195
195
|
if (n) return;
|
|
196
|
-
console.error("Failed to verify checkout coupon", e),
|
|
196
|
+
console.error("Failed to verify checkout coupon", e), O(null), k(null), N(p("checkout_coupon_error"));
|
|
197
197
|
} finally {
|
|
198
|
-
n ||
|
|
198
|
+
n || j(!1);
|
|
199
199
|
}
|
|
200
200
|
})(), () => {
|
|
201
201
|
n = !0;
|
|
202
202
|
};
|
|
203
203
|
}, [
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
P,
|
|
205
|
+
L.endDate,
|
|
206
|
+
L.endTime,
|
|
207
|
+
L.startDate,
|
|
208
|
+
L.startTime,
|
|
209
|
+
R,
|
|
210
|
+
G,
|
|
211
|
+
J,
|
|
212
212
|
_,
|
|
213
|
-
|
|
213
|
+
rt,
|
|
214
214
|
p
|
|
215
215
|
]), s(() => {
|
|
216
|
-
if (!_ ||
|
|
217
|
-
|
|
216
|
+
if (!_ || B.lines.length === 0 || !R) {
|
|
217
|
+
S(null), T(null), C(!1);
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
220
|
let e = !1;
|
|
221
|
-
return
|
|
221
|
+
return C(!0), T(null), (async () => {
|
|
222
222
|
try {
|
|
223
|
-
let t = await o(
|
|
223
|
+
let t = await o(ve, {
|
|
224
224
|
storeSlug: _,
|
|
225
|
-
schedule:
|
|
226
|
-
estimatedTotalMinor:
|
|
227
|
-
insuranceAmountMinor:
|
|
228
|
-
}), n =
|
|
225
|
+
schedule: R,
|
|
226
|
+
estimatedTotalMinor: Y,
|
|
227
|
+
insuranceAmountMinor: X
|
|
228
|
+
}), n = ye.parse(t);
|
|
229
229
|
if (e) return;
|
|
230
230
|
if (!n.success || !n.decision) {
|
|
231
|
-
|
|
231
|
+
S(null), T(n.message || p("checkout_payment_error"));
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
-
|
|
234
|
+
S(n.decision);
|
|
235
235
|
} catch (t) {
|
|
236
236
|
if (e) return;
|
|
237
|
-
console.error("Failed to load checkout payment decision", t),
|
|
237
|
+
console.error("Failed to load checkout payment decision", t), S(null), T(p("checkout_payment_error"));
|
|
238
238
|
} finally {
|
|
239
|
-
e ||
|
|
239
|
+
e || C(!1);
|
|
240
240
|
}
|
|
241
241
|
})(), () => {
|
|
242
242
|
e = !0;
|
|
243
243
|
};
|
|
244
244
|
}, [
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
J,
|
|
251
|
-
z.lines.length,
|
|
245
|
+
L.endDate,
|
|
246
|
+
L.endTime,
|
|
247
|
+
L.startDate,
|
|
248
|
+
L.startTime,
|
|
249
|
+
R,
|
|
252
250
|
Y,
|
|
251
|
+
B.lines.length,
|
|
252
|
+
X,
|
|
253
253
|
_,
|
|
254
254
|
p
|
|
255
255
|
]);
|
|
256
|
-
let $ =
|
|
257
|
-
if (!_ ||
|
|
258
|
-
$e(!0),
|
|
259
|
-
let t =
|
|
256
|
+
let $ = x?.currency ?? "EUR", kt = f(Y, $, m.language), At = Math.max(0, Y - X), jt = Math.round(At / 1.2), Mt = jt + X, Nt = Math.max(0, At - jt), Pt = f(Mt, $, m.language), Ft = f(Nt, $, m.language), It = ze(Re, m.language), Lt = X > 0 ? f(X, $, m.language) : void 0, Rt = x?.amountToCollectMinor ?? 0, zt = x?.shouldCollectOnlinePayment === !0 && Rt > 0, Bt = Dt.handleSubmit(async (e) => {
|
|
257
|
+
if (!_ || G.length === 0 || !R || b.current) return;
|
|
258
|
+
$e(!0), b.current = !0;
|
|
259
|
+
let t = Ye();
|
|
260
260
|
try {
|
|
261
261
|
let n = await o(ie, {
|
|
262
262
|
storeSlug: _,
|
|
263
263
|
checkoutSessionId: t.checkoutSessionId,
|
|
264
264
|
replacesCheckoutSessionId: t.replacesCheckoutSessionId,
|
|
265
|
-
schedule:
|
|
266
|
-
fulfillment:
|
|
267
|
-
startAddress:
|
|
268
|
-
endAddress:
|
|
269
|
-
couponCode:
|
|
270
|
-
couponAutoApplied: !
|
|
271
|
-
insuranceAccepted:
|
|
265
|
+
schedule: R,
|
|
266
|
+
fulfillment: L.fulfillment,
|
|
267
|
+
startAddress: L.fulfillment === "delivery" ? L.startAddress : void 0,
|
|
268
|
+
endAddress: L.fulfillment === "delivery" ? L.endAddress : void 0,
|
|
269
|
+
couponCode: D?.code,
|
|
270
|
+
couponAutoApplied: !P && D?.autoApplied,
|
|
271
|
+
insuranceAccepted: J,
|
|
272
272
|
customer: {
|
|
273
273
|
name: e.fullName,
|
|
274
274
|
email: e.email,
|
|
275
275
|
phone: e.phone,
|
|
276
276
|
notes: e.notes
|
|
277
277
|
},
|
|
278
|
-
items:
|
|
279
|
-
}), r =
|
|
278
|
+
items: G
|
|
279
|
+
}), r = oe.parse(n);
|
|
280
280
|
if (!r.success || !r.checkout) {
|
|
281
|
-
|
|
281
|
+
Ze(), a.error(r.message || p("checkout_payment_error"));
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
r.checkout.requiresPayment ?
|
|
284
|
+
r.checkout.requiresPayment ? Xe(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : a.success(p("checkout_success_toast")), await Ue(ae(r.checkout.nextPath, r.checkout.bookingExternalId)), r.checkout.requiresPayment || Qe();
|
|
285
285
|
} catch (e) {
|
|
286
286
|
console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
|
|
287
287
|
} finally {
|
|
288
|
-
|
|
288
|
+
b.current = !1, $e(!1);
|
|
289
289
|
}
|
|
290
|
-
}),
|
|
291
|
-
|
|
292
|
-
},
|
|
290
|
+
}), Vt = p(zt ? "checkout_continue_to_payment" : "checkout_submit"), Ht = p(zt ? "checkout_mobile_continue_to_payment" : "checkout_mobile_submit"), Ut = L.fulfillment === "delivery" && L.startAddress.trim().length === 0, Wt = !y && !et && !w && !U && !A && !st && !!x && !!R && !Ut && G.length > 0, Gt = () => {
|
|
291
|
+
Wt && Bt();
|
|
292
|
+
}, Kt = ({ className: e, presentation: t, stickyTopClassName: n } = {}) => /* @__PURE__ */ u(Ee, {
|
|
293
293
|
className: e,
|
|
294
294
|
lines: bt.lines,
|
|
295
|
-
itemCount:
|
|
295
|
+
itemCount: Ge,
|
|
296
296
|
baseUnitLabel: gt,
|
|
297
|
-
bookingSubtotalLabel:
|
|
298
|
-
vatAmountLabel:
|
|
299
|
-
vatRateLabel:
|
|
300
|
-
bookingTotalLabel:
|
|
301
|
-
bookingPeriod:
|
|
302
|
-
bookingPath:
|
|
303
|
-
startDate:
|
|
304
|
-
startTime:
|
|
305
|
-
endDate:
|
|
306
|
-
endTime:
|
|
297
|
+
bookingSubtotalLabel: Pt,
|
|
298
|
+
vatAmountLabel: Ft,
|
|
299
|
+
vatRateLabel: It,
|
|
300
|
+
bookingTotalLabel: kt,
|
|
301
|
+
bookingPeriod: R ? {
|
|
302
|
+
bookingPath: Q,
|
|
303
|
+
startDate: R.startDate,
|
|
304
|
+
startTime: R.startTime,
|
|
305
|
+
endDate: R.endDate,
|
|
306
|
+
endTime: R.endTime
|
|
307
307
|
} : void 0,
|
|
308
308
|
presentation: t,
|
|
309
309
|
stickyTopClassName: n,
|
|
310
|
-
onQuantityChange:
|
|
311
|
-
onRemove:
|
|
310
|
+
onQuantityChange: qe,
|
|
311
|
+
onRemove: Je,
|
|
312
312
|
coupon: {
|
|
313
|
-
code:
|
|
314
|
-
appliedCode:
|
|
315
|
-
discountLabel:
|
|
313
|
+
code: nt,
|
|
314
|
+
appliedCode: D?.code,
|
|
315
|
+
discountLabel: D && Tt > 0 ? f(Tt, $, m.language) : null,
|
|
316
316
|
message: ot,
|
|
317
317
|
error: st,
|
|
318
|
-
loading:
|
|
319
|
-
disabled:
|
|
318
|
+
loading: A,
|
|
319
|
+
disabled: y,
|
|
320
320
|
onCodeChange: (e) => {
|
|
321
|
-
|
|
321
|
+
E(e), N(null), M(null);
|
|
322
322
|
},
|
|
323
323
|
onApply: () => {
|
|
324
|
-
ct(!1),
|
|
324
|
+
ct(!1), it(nt.trim());
|
|
325
325
|
},
|
|
326
326
|
onRemove: () => {
|
|
327
|
-
|
|
327
|
+
E(""), it(""), O(null), k(null), N(null), M(null), ct(!0);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
});
|
|
331
|
-
return
|
|
331
|
+
return Ke ? B.lines.length === 0 ? /* @__PURE__ */ u("div", {
|
|
332
332
|
className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
|
|
333
333
|
children: /* @__PURE__ */ d("div", {
|
|
334
334
|
className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
|
|
@@ -343,11 +343,11 @@ function p() {
|
|
|
343
343
|
}),
|
|
344
344
|
/* @__PURE__ */ u("div", {
|
|
345
345
|
className: "mt-6",
|
|
346
|
-
children: /* @__PURE__ */ u(
|
|
347
|
-
to:
|
|
348
|
-
children: /* @__PURE__ */ d(
|
|
346
|
+
children: /* @__PURE__ */ u(ke, {
|
|
347
|
+
to: Q,
|
|
348
|
+
children: /* @__PURE__ */ d(fe, {
|
|
349
349
|
className: "gap-2",
|
|
350
|
-
children: [/* @__PURE__ */ u(
|
|
350
|
+
children: [/* @__PURE__ */ u(Fe, {
|
|
351
351
|
className: "h-4 w-4",
|
|
352
352
|
"aria-hidden": "true"
|
|
353
353
|
}), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
|
|
@@ -356,11 +356,11 @@ function p() {
|
|
|
356
356
|
})
|
|
357
357
|
]
|
|
358
358
|
})
|
|
359
|
-
}) : /* @__PURE__ */ d(
|
|
359
|
+
}) : /* @__PURE__ */ d(ge, {
|
|
360
360
|
currentStep: "checkout",
|
|
361
|
-
bookingPath:
|
|
361
|
+
bookingPath: Q,
|
|
362
362
|
checkoutPath: Et,
|
|
363
|
-
backPath:
|
|
363
|
+
backPath: Q,
|
|
364
364
|
backLabel: p("back_to_booking"),
|
|
365
365
|
children: [/* @__PURE__ */ d("div", {
|
|
366
366
|
className: "grid gap-6 pb-24 lg:grid-cols-12 lg:pb-0",
|
|
@@ -371,7 +371,7 @@ function p() {
|
|
|
371
371
|
className: "text-xl font-semibold tracking-tight text-slate-950",
|
|
372
372
|
children: /* @__PURE__ */ u("span", { children: p("checkout_title") })
|
|
373
373
|
}),
|
|
374
|
-
|
|
374
|
+
R ? null : /* @__PURE__ */ u("p", {
|
|
375
375
|
role: "alert",
|
|
376
376
|
className: "mt-3 text-sm text-destructive",
|
|
377
377
|
children: /* @__PURE__ */ u("span", { children: p("booking_time_slots_required") })
|
|
@@ -381,76 +381,76 @@ function p() {
|
|
|
381
381
|
children: [
|
|
382
382
|
pt ? /* @__PURE__ */ u("div", {
|
|
383
383
|
className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
|
|
384
|
-
children: /* @__PURE__ */ u(
|
|
385
|
-
value:
|
|
386
|
-
onValueChange: (e) =>
|
|
384
|
+
children: /* @__PURE__ */ u(he, {
|
|
385
|
+
value: L.fulfillment,
|
|
386
|
+
onValueChange: (e) => Ot({ fulfillment: e }),
|
|
387
387
|
pickupAddress: mt,
|
|
388
|
-
deliveryEnabled:
|
|
388
|
+
deliveryEnabled: I,
|
|
389
389
|
deliveryDisabledReason: ft,
|
|
390
|
-
startAddress:
|
|
391
|
-
onStartAddressChange: (e) =>
|
|
392
|
-
endAddress:
|
|
393
|
-
onEndAddressChange: (e) =>
|
|
390
|
+
startAddress: L.startAddress,
|
|
391
|
+
onStartAddressChange: (e) => Ot({ startAddress: e }),
|
|
392
|
+
endAddress: L.endAddress,
|
|
393
|
+
onEndAddressChange: (e) => Ot({ endAddress: e }),
|
|
394
394
|
showPickupAddressWhenPickupOnly: !1,
|
|
395
395
|
testIdPrefix: "storefront-checkout-fulfillment"
|
|
396
396
|
})
|
|
397
397
|
}) : null,
|
|
398
|
-
/* @__PURE__ */ u(
|
|
398
|
+
/* @__PURE__ */ u(Se, {
|
|
399
399
|
form: Dt,
|
|
400
|
-
onSubmit:
|
|
400
|
+
onSubmit: Gt
|
|
401
401
|
}),
|
|
402
|
-
|
|
403
|
-
accepted:
|
|
404
|
-
disabled:
|
|
402
|
+
q ? /* @__PURE__ */ u(Ce, {
|
|
403
|
+
accepted: J,
|
|
404
|
+
disabled: y || A,
|
|
405
405
|
dailyAmountLabel: f(St, $, m.language),
|
|
406
|
-
totalAmountLabel:
|
|
407
|
-
billableDays:
|
|
406
|
+
totalAmountLabel: Lt,
|
|
407
|
+
billableDays: at?.insuranceBillableDays,
|
|
408
408
|
deductibleLabel: Ct > 0 ? f(Ct, $, m.language) : void 0,
|
|
409
409
|
onAcceptedChange: lt
|
|
410
410
|
}) : null,
|
|
411
|
-
|
|
411
|
+
et ? /* @__PURE__ */ d("div", {
|
|
412
412
|
className: "flex items-center gap-2 text-sm text-slate-600",
|
|
413
413
|
role: "status",
|
|
414
|
-
children: [/* @__PURE__ */ u(
|
|
414
|
+
children: [/* @__PURE__ */ u(_e, {
|
|
415
415
|
className: "size-4",
|
|
416
416
|
"aria-hidden": "true"
|
|
417
417
|
}), /* @__PURE__ */ u("span", { children: p("checkout_payment_loading") })]
|
|
418
418
|
}) : null,
|
|
419
|
-
|
|
419
|
+
w ? /* @__PURE__ */ d("div", {
|
|
420
420
|
className: "flex items-start gap-2 rounded-md bg-destructive p-3 text-sm text-destructive-foreground shadow-sm",
|
|
421
421
|
role: "alert",
|
|
422
|
-
children: [/* @__PURE__ */ u(
|
|
422
|
+
children: [/* @__PURE__ */ u(Pe, {
|
|
423
423
|
className: "mt-0.5 h-4 w-4",
|
|
424
424
|
"aria-hidden": "true"
|
|
425
|
-
}), /* @__PURE__ */ u("span", { children:
|
|
425
|
+
}), /* @__PURE__ */ u("span", { children: w })]
|
|
426
426
|
}) : null,
|
|
427
|
-
/* @__PURE__ */ u(
|
|
427
|
+
/* @__PURE__ */ u(fe, {
|
|
428
428
|
type: "button",
|
|
429
429
|
size: "lg",
|
|
430
|
-
onClick:
|
|
431
|
-
disabled: !
|
|
430
|
+
onClick: Gt,
|
|
431
|
+
disabled: !Wt,
|
|
432
432
|
className: "mt-4 hidden w-fit lg:inline-flex",
|
|
433
|
-
children: /* @__PURE__ */ u("span", { children:
|
|
433
|
+
children: /* @__PURE__ */ u("span", { children: Vt })
|
|
434
434
|
}),
|
|
435
|
-
|
|
435
|
+
Ut ? /* @__PURE__ */ u("p", {
|
|
436
436
|
className: "text-sm text-slate-600",
|
|
437
437
|
children: /* @__PURE__ */ u("span", { children: p("checkout_delivery_address_required") })
|
|
438
438
|
}) : null
|
|
439
439
|
]
|
|
440
440
|
})
|
|
441
441
|
]
|
|
442
|
-
}),
|
|
443
|
-
}), /* @__PURE__ */ u(
|
|
444
|
-
canSubmit:
|
|
445
|
-
compactSubmitLabel:
|
|
446
|
-
itemCount:
|
|
447
|
-
submitLabel:
|
|
448
|
-
totalLabel:
|
|
449
|
-
onSubmit:
|
|
450
|
-
children:
|
|
442
|
+
}), Kt({ className: "hidden lg:block" })]
|
|
443
|
+
}), /* @__PURE__ */ u(Te, {
|
|
444
|
+
canSubmit: Wt,
|
|
445
|
+
compactSubmitLabel: Ht,
|
|
446
|
+
itemCount: Ge,
|
|
447
|
+
submitLabel: Vt,
|
|
448
|
+
totalLabel: kt,
|
|
449
|
+
onSubmit: Gt,
|
|
450
|
+
children: Kt({ presentation: "flat" })
|
|
451
451
|
})]
|
|
452
|
-
}) : /* @__PURE__ */ u(
|
|
453
|
-
bookingPath:
|
|
452
|
+
}) : /* @__PURE__ */ u(we, {
|
|
453
|
+
bookingPath: Q,
|
|
454
454
|
checkoutPath: Et
|
|
455
455
|
});
|
|
456
456
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"AAwGA,MAAM,CAAC,OAAO,UAAU,mBAAmB,4CA2Z1C"}
|