@bowlos/reservations 0.12.0 → 0.14.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/HEADLESS.md +294 -0
- package/README.md +22 -7
- package/dist/components.cjs +82 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +6 -0
- package/dist/components.d.ts +6 -0
- package/dist/components.js +82 -4
- package/dist/components.js.map +1 -1
- package/package.json +3 -2
- package/templates/center-site/package.json +1 -1
package/dist/components.d.cts
CHANGED
|
@@ -57,6 +57,12 @@ interface BookingFlowLabels {
|
|
|
57
57
|
addonsHeading: string;
|
|
58
58
|
name: string;
|
|
59
59
|
email: string;
|
|
60
|
+
reviewOrder: string;
|
|
61
|
+
reviewHeading: string;
|
|
62
|
+
reservationLineLabel: string;
|
|
63
|
+
reservationFeeLabel: string;
|
|
64
|
+
orderTotal: string;
|
|
65
|
+
editOrder: string;
|
|
60
66
|
hold: string;
|
|
61
67
|
holding: string;
|
|
62
68
|
continueToPayment: string;
|
package/dist/components.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ interface BookingFlowLabels {
|
|
|
57
57
|
addonsHeading: string;
|
|
58
58
|
name: string;
|
|
59
59
|
email: string;
|
|
60
|
+
reviewOrder: string;
|
|
61
|
+
reviewHeading: string;
|
|
62
|
+
reservationLineLabel: string;
|
|
63
|
+
reservationFeeLabel: string;
|
|
64
|
+
orderTotal: string;
|
|
65
|
+
editOrder: string;
|
|
60
66
|
hold: string;
|
|
61
67
|
holding: string;
|
|
62
68
|
continueToPayment: string;
|
package/dist/components.js
CHANGED
|
@@ -140,6 +140,12 @@ var DEFAULT_LABELS2 = {
|
|
|
140
140
|
addonsHeading: "Add-ons",
|
|
141
141
|
name: "Name",
|
|
142
142
|
email: "Email",
|
|
143
|
+
reviewOrder: "Review order",
|
|
144
|
+
reviewHeading: "Review your order",
|
|
145
|
+
reservationLineLabel: "{count} {unit} \xB7 {date} \xB7 {time}",
|
|
146
|
+
reservationFeeLabel: "Reservation fee",
|
|
147
|
+
orderTotal: "Total",
|
|
148
|
+
editOrder: "Edit order",
|
|
143
149
|
hold: "Book Now",
|
|
144
150
|
holding: "Booking\u2026",
|
|
145
151
|
continueToPayment: "Continue to payment",
|
|
@@ -175,6 +181,15 @@ function todayISO() {
|
|
|
175
181
|
const day = String(d.getDate()).padStart(2, "0");
|
|
176
182
|
return `${y}-${m}-${day}`;
|
|
177
183
|
}
|
|
184
|
+
function formatDateLabel(dateISO) {
|
|
185
|
+
const [y, m, d] = dateISO.split("-").map(Number);
|
|
186
|
+
if (!y || !m || !d) return dateISO;
|
|
187
|
+
return new Date(y, m - 1, d).toLocaleDateString(void 0, {
|
|
188
|
+
weekday: "short",
|
|
189
|
+
month: "short",
|
|
190
|
+
day: "numeric"
|
|
191
|
+
});
|
|
192
|
+
}
|
|
178
193
|
function BookingFlow({
|
|
179
194
|
centerId,
|
|
180
195
|
productId,
|
|
@@ -203,6 +218,7 @@ function BookingFlow({
|
|
|
203
218
|
const endMinuteOfDay = startMinuteOfDay + durationMinutes;
|
|
204
219
|
const [count, setCount] = useState(1);
|
|
205
220
|
const [payMessage, setPayMessage] = useState(null);
|
|
221
|
+
const [reviewing, setReviewing] = useState(false);
|
|
206
222
|
const [addonQtys, setAddonQtys] = useState({});
|
|
207
223
|
const selectedAddons = useMemo(
|
|
208
224
|
() => Object.entries(addonQtys).filter(([, q]) => q > 0).map(([addonId, quantity]) => ({ addonId, quantity })),
|
|
@@ -285,7 +301,18 @@ function BookingFlow({
|
|
|
285
301
|
": ",
|
|
286
302
|
/* @__PURE__ */ jsx("strong", { children: flow.reservation?.reservationDisplayId ?? "\u2014" })
|
|
287
303
|
] }),
|
|
288
|
-
/* @__PURE__ */ jsx(
|
|
304
|
+
/* @__PURE__ */ jsx(
|
|
305
|
+
"button",
|
|
306
|
+
{
|
|
307
|
+
type: "button",
|
|
308
|
+
style: s.primaryBtn,
|
|
309
|
+
onClick: () => {
|
|
310
|
+
setReviewing(false);
|
|
311
|
+
flow.reset();
|
|
312
|
+
},
|
|
313
|
+
children: t.bookAnother
|
|
314
|
+
}
|
|
315
|
+
)
|
|
289
316
|
] });
|
|
290
317
|
}
|
|
291
318
|
if (flow.status === "awaitingPayment" && flow.paymentIntent) {
|
|
@@ -326,9 +353,60 @@ function BookingFlow({
|
|
|
326
353
|
return /* @__PURE__ */ jsx(AuthForm, { account, className });
|
|
327
354
|
}
|
|
328
355
|
const holding = flow.status === "holding";
|
|
356
|
+
if (reviewing) {
|
|
357
|
+
const chosenAddons = addonList.map((a) => ({ ...a, quantity: addonQtys[a.id] ?? 0 })).filter((a) => a.quantity > 0);
|
|
358
|
+
const addonsSubtotalCents = chosenAddons.reduce(
|
|
359
|
+
(sum, a) => sum + a.priceCents * a.quantity,
|
|
360
|
+
0
|
|
361
|
+
);
|
|
362
|
+
const fee = preview.data?.reservationFee;
|
|
363
|
+
const feeCents = typeof fee?.amountCents === "number" ? fee.amountCents : 0;
|
|
364
|
+
const feeLabel = typeof fee?.label === "string" && fee.label ? fee.label : t.reservationFeeLabel;
|
|
365
|
+
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotalCents - feeCents : null;
|
|
366
|
+
const reservationLine = t.reservationLineLabel.replace("{count}", String(count)).replace("{unit}", COUNT_LABEL[pricingMode]).replace("{date}", formatDateLabel(dateISO)).replace("{time}", `${formatMinuteLabel(startMinuteOfDay)}\u2013${formatMinuteLabel(endMinuteOfDay)}`);
|
|
367
|
+
return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
|
|
368
|
+
/* @__PURE__ */ jsx("h3", { style: s.heading, children: t.reviewHeading }),
|
|
369
|
+
/* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
|
|
370
|
+
/* @__PURE__ */ jsx("span", { style: s.body, children: reservationLine }),
|
|
371
|
+
reservationCents != null ? /* @__PURE__ */ jsx("span", { style: s.body, children: formatCents(reservationCents) }) : null
|
|
372
|
+
] }),
|
|
373
|
+
chosenAddons.map((a) => /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
|
|
374
|
+
/* @__PURE__ */ jsxs("span", { style: s.muted, children: [
|
|
375
|
+
a.name,
|
|
376
|
+
" \xD7 ",
|
|
377
|
+
a.quantity
|
|
378
|
+
] }),
|
|
379
|
+
/* @__PURE__ */ jsx("span", { style: s.muted, children: formatCents(a.priceCents * a.quantity) })
|
|
380
|
+
] }, a.id)),
|
|
381
|
+
feeCents > 0 ? /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
|
|
382
|
+
/* @__PURE__ */ jsx("span", { style: s.muted, children: feeLabel }),
|
|
383
|
+
/* @__PURE__ */ jsx("span", { style: s.muted, children: formatCents(feeCents) })
|
|
384
|
+
] }) : null,
|
|
385
|
+
/* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
|
|
386
|
+
/* @__PURE__ */ jsx("strong", { children: t.orderTotal }),
|
|
387
|
+
/* @__PURE__ */ jsx("strong", { children: quoteCents != null ? formatCents(quoteCents) : "\u2014" })
|
|
388
|
+
] }),
|
|
389
|
+
/* @__PURE__ */ jsx(
|
|
390
|
+
"button",
|
|
391
|
+
{
|
|
392
|
+
type: "button",
|
|
393
|
+
style: s.primaryBtn,
|
|
394
|
+
disabled: holding || quoteCents == null,
|
|
395
|
+
onClick: () => void flow.startHold(bookingArgs),
|
|
396
|
+
children: holding ? t.securing : t.continueToPayment
|
|
397
|
+
}
|
|
398
|
+
),
|
|
399
|
+
/* @__PURE__ */ jsx("button", { type: "button", style: s.linkBtn, disabled: holding, onClick: () => setReviewing(false), children: t.editOrder }),
|
|
400
|
+
flow.error && /* @__PURE__ */ jsxs("p", { style: s.error, children: [
|
|
401
|
+
flow.error.code,
|
|
402
|
+
" \u2014 ",
|
|
403
|
+
flow.error.message
|
|
404
|
+
] })
|
|
405
|
+
] });
|
|
406
|
+
}
|
|
329
407
|
const onSubmit = (e) => {
|
|
330
408
|
e.preventDefault();
|
|
331
|
-
|
|
409
|
+
setReviewing(true);
|
|
332
410
|
};
|
|
333
411
|
return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit, children: [
|
|
334
412
|
/* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heading }),
|
|
@@ -408,8 +486,8 @@ function BookingFlow({
|
|
|
408
486
|
{
|
|
409
487
|
type: "submit",
|
|
410
488
|
style: s.primaryBtn,
|
|
411
|
-
disabled:
|
|
412
|
-
children:
|
|
489
|
+
disabled: dateISO === "" || startOptions.length === 0 || quoteCents === null,
|
|
490
|
+
children: t.reviewOrder
|
|
413
491
|
}
|
|
414
492
|
),
|
|
415
493
|
flow.error && /* @__PURE__ */ jsxs("p", { style: s.error, children: [
|