@bowlos/reservations 0.7.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 +93 -12
- package/dist/{catalog-DBIisELC.d.ts → catalog-kd07kri0.d.ts} +1 -1
- package/dist/{catalog-DEwo88hz.d.cts → catalog-kdDjgvT1.d.cts} +1 -1
- package/dist/{chunk-YICHFUAY.js → chunk-2X7MFQWY.js} +9 -3
- package/dist/chunk-2X7MFQWY.js.map +1 -0
- package/dist/{chunk-JBBWGMRT.js → chunk-FPUWLOW3.js} +10 -4
- package/dist/chunk-FPUWLOW3.js.map +1 -0
- package/dist/chunk-Y3YSDO3H.js +221 -0
- package/dist/chunk-Y3YSDO3H.js.map +1 -0
- package/dist/components.cjs +332 -166
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +14 -3
- package/dist/components.d.ts +14 -3
- package/dist/components.js +322 -373
- package/dist/components.js.map +1 -1
- package/dist/{data-DrM0D6Pi.d.cts → data-lC-l-haz.d.cts} +33 -54
- package/dist/{data-DrM0D6Pi.d.ts → data-lC-l-haz.d.ts} +33 -54
- package/dist/errors-IIK7xibp.d.cts +54 -0
- package/dist/errors-IIK7xibp.d.ts +54 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -2
- package/dist/payments.cjs +245 -0
- package/dist/payments.cjs.map +1 -0
- package/dist/payments.d.cts +37 -0
- package/dist/payments.d.ts +37 -0
- package/dist/payments.js +83 -0
- package/dist/payments.js.map +1 -0
- package/dist/{react-7ruEsubp.d.cts → react-B3dlcklN.d.ts} +2 -1
- package/dist/{react-Cb_NZCXa.d.ts → react-aZplAyHS.d.cts} +2 -1
- package/dist/react.cjs +8 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +12 -5
- package/dist/react.d.ts +12 -5
- package/dist/react.js +2 -2
- package/package.json +22 -3
- package/templates/center-site/README.md +8 -7
- package/templates/center-site/app/book/page.tsx +10 -3
- package/templates/center-site/package.json +1 -1
- package/dist/chunk-JBBWGMRT.js.map +0 -1
- package/dist/chunk-YICHFUAY.js.map +0 -1
- package/templates/center-site/app/book/checkout-form.tsx +0 -85
package/dist/components.cjs
CHANGED
|
@@ -143,6 +143,12 @@ function useAvailability(args, options) {
|
|
|
143
143
|
function useBookingPreview(args, options) {
|
|
144
144
|
return useBowlosQuery("bookingPreview", args, options);
|
|
145
145
|
}
|
|
146
|
+
function useAddons(args, options) {
|
|
147
|
+
return useBowlosQuery("listPublicAddons", args, options);
|
|
148
|
+
}
|
|
149
|
+
function useStartTimes(args, options) {
|
|
150
|
+
return useBowlosQuery("availableStartTimes", args, options);
|
|
151
|
+
}
|
|
146
152
|
function useMyReservations(args, options) {
|
|
147
153
|
return useBowlosQuery("listMyReservations", args, { ...options, auth: true });
|
|
148
154
|
}
|
|
@@ -514,9 +520,12 @@ function minutesToTime(min) {
|
|
|
514
520
|
const m = (min % 60).toString().padStart(2, "0");
|
|
515
521
|
return `${h}:${m}`;
|
|
516
522
|
}
|
|
517
|
-
function
|
|
518
|
-
const
|
|
519
|
-
|
|
523
|
+
function formatMinuteLabel(min) {
|
|
524
|
+
const h24 = Math.floor(min / 60) % 24;
|
|
525
|
+
const m = min % 60;
|
|
526
|
+
const period = h24 < 12 ? "AM" : "PM";
|
|
527
|
+
const h12 = h24 % 12 === 0 ? 12 : h24 % 12;
|
|
528
|
+
return `${h12}:${m.toString().padStart(2, "0")} ${period}`;
|
|
520
529
|
}
|
|
521
530
|
function useCountdown(targetMs) {
|
|
522
531
|
const [now, setNow] = react.useState(null);
|
|
@@ -543,13 +552,147 @@ function humanizeRemaining(ms) {
|
|
|
543
552
|
return `${s}s`;
|
|
544
553
|
}
|
|
545
554
|
var DEFAULT_LABELS = {
|
|
555
|
+
signInHeading: "Sign in",
|
|
556
|
+
signUpHeading: "Create your account",
|
|
557
|
+
linkHeading: "Finish your profile",
|
|
558
|
+
loading: "Loading\u2026",
|
|
559
|
+
email: "Email",
|
|
560
|
+
password: "Password",
|
|
561
|
+
name: "Name",
|
|
562
|
+
signIn: "Sign in",
|
|
563
|
+
signingIn: "Signing in\u2026",
|
|
564
|
+
createAccount: "Create account",
|
|
565
|
+
haveAccount: "Already have an account? Sign in",
|
|
566
|
+
needAccount: "New here? Create an account",
|
|
567
|
+
finishProfile: "Save profile",
|
|
568
|
+
saving: "Saving\u2026",
|
|
569
|
+
signOut: "Sign out"
|
|
570
|
+
};
|
|
571
|
+
function AuthForm({
|
|
572
|
+
account,
|
|
573
|
+
labels,
|
|
574
|
+
className
|
|
575
|
+
}) {
|
|
576
|
+
const t = { ...DEFAULT_LABELS, ...labels };
|
|
577
|
+
const [mode, setMode] = react.useState("signIn");
|
|
578
|
+
const [email, setEmail] = react.useState("");
|
|
579
|
+
const [password, setPassword] = react.useState("");
|
|
580
|
+
const [fullName, setFullName] = react.useState("");
|
|
581
|
+
const [busy, setBusy] = react.useState(false);
|
|
582
|
+
const s = styles();
|
|
583
|
+
async function guard(action) {
|
|
584
|
+
setBusy(true);
|
|
585
|
+
try {
|
|
586
|
+
await action();
|
|
587
|
+
} catch {
|
|
588
|
+
} finally {
|
|
589
|
+
setBusy(false);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const onAuth = (e) => {
|
|
593
|
+
e.preventDefault();
|
|
594
|
+
void guard(
|
|
595
|
+
() => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
|
|
596
|
+
);
|
|
597
|
+
};
|
|
598
|
+
const onLink = (e) => {
|
|
599
|
+
e.preventDefault();
|
|
600
|
+
void guard(() => account.link({ fullName, email, marketingOptIn: false }));
|
|
601
|
+
};
|
|
602
|
+
if (account.status === "loading") {
|
|
603
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading }) });
|
|
604
|
+
}
|
|
605
|
+
if (account.status === "authed_no_customer") {
|
|
606
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.linkHeading }),
|
|
608
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
609
|
+
t.name,
|
|
610
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
|
|
611
|
+
] }),
|
|
612
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
613
|
+
t.email,
|
|
614
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
615
|
+
"input",
|
|
616
|
+
{
|
|
617
|
+
type: "email",
|
|
618
|
+
value: email,
|
|
619
|
+
onChange: (e) => setEmail(e.target.value),
|
|
620
|
+
style: s.input,
|
|
621
|
+
required: true
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
] }),
|
|
625
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
|
|
626
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
|
|
627
|
+
account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
|
|
628
|
+
] });
|
|
629
|
+
}
|
|
630
|
+
if (account.status === "linked") return null;
|
|
631
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
|
|
633
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
634
|
+
t.email,
|
|
635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
636
|
+
"input",
|
|
637
|
+
{
|
|
638
|
+
type: "email",
|
|
639
|
+
value: email,
|
|
640
|
+
onChange: (e) => setEmail(e.target.value),
|
|
641
|
+
style: s.input,
|
|
642
|
+
required: true
|
|
643
|
+
}
|
|
644
|
+
)
|
|
645
|
+
] }),
|
|
646
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
647
|
+
t.password,
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
+
"input",
|
|
650
|
+
{
|
|
651
|
+
type: "password",
|
|
652
|
+
value: password,
|
|
653
|
+
onChange: (e) => setPassword(e.target.value),
|
|
654
|
+
style: s.input,
|
|
655
|
+
required: true
|
|
656
|
+
}
|
|
657
|
+
)
|
|
658
|
+
] }),
|
|
659
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
|
|
660
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
661
|
+
"button",
|
|
662
|
+
{
|
|
663
|
+
type: "button",
|
|
664
|
+
style: s.linkBtn,
|
|
665
|
+
onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
|
|
666
|
+
children: mode === "signIn" ? t.needAccount : t.haveAccount
|
|
667
|
+
}
|
|
668
|
+
),
|
|
669
|
+
account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
|
|
670
|
+
] });
|
|
671
|
+
}
|
|
672
|
+
function AuthGate({ children, labels, className }) {
|
|
673
|
+
const account = useAccount();
|
|
674
|
+
if (account.status === "linked" && account.customer) {
|
|
675
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.({ customer: account.customer, account }) });
|
|
676
|
+
}
|
|
677
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, labels, className });
|
|
678
|
+
}
|
|
679
|
+
var DEFAULT_LABELS2 = {
|
|
546
680
|
heading: "Book",
|
|
547
681
|
date: "Date",
|
|
548
682
|
start: "Start time",
|
|
683
|
+
loadingTimes: "Finding times\u2026",
|
|
684
|
+
noTimes: "No times available for this date.",
|
|
549
685
|
quantity: "Quantity",
|
|
686
|
+
addonsHeading: "Add-ons",
|
|
550
687
|
name: "Name",
|
|
551
688
|
email: "Email",
|
|
552
|
-
|
|
689
|
+
reviewOrder: "Review order",
|
|
690
|
+
reviewHeading: "Review your order",
|
|
691
|
+
reservationLineLabel: "{count} {unit} \xB7 {date} \xB7 {time}",
|
|
692
|
+
reservationFeeLabel: "Reservation fee",
|
|
693
|
+
orderTotal: "Total",
|
|
694
|
+
editOrder: "Edit order",
|
|
695
|
+
hold: "Book Now",
|
|
553
696
|
holding: "Booking\u2026",
|
|
554
697
|
continueToPayment: "Continue to payment",
|
|
555
698
|
preparing: "Preparing\u2026",
|
|
@@ -567,6 +710,32 @@ var DEFAULT_LABELS = {
|
|
|
567
710
|
notYou: "Not you?",
|
|
568
711
|
signInHint: "Sign in to book faster"
|
|
569
712
|
};
|
|
713
|
+
var COUNT_LABEL = {
|
|
714
|
+
per_unit_per_hour: "Lanes",
|
|
715
|
+
per_person_per_hour: "Bowlers",
|
|
716
|
+
per_game: "Games"
|
|
717
|
+
};
|
|
718
|
+
var ADDON_RATE_SUFFIX = {
|
|
719
|
+
per_person: " / person",
|
|
720
|
+
per_unit: " / unit",
|
|
721
|
+
flat: ""
|
|
722
|
+
};
|
|
723
|
+
function todayISO() {
|
|
724
|
+
const d = /* @__PURE__ */ new Date();
|
|
725
|
+
const y = d.getFullYear();
|
|
726
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
727
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
728
|
+
return `${y}-${m}-${day}`;
|
|
729
|
+
}
|
|
730
|
+
function formatDateLabel(dateISO) {
|
|
731
|
+
const [y, m, d] = dateISO.split("-").map(Number);
|
|
732
|
+
if (!y || !m || !d) return dateISO;
|
|
733
|
+
return new Date(y, m - 1, d).toLocaleDateString(void 0, {
|
|
734
|
+
weekday: "short",
|
|
735
|
+
month: "short",
|
|
736
|
+
day: "numeric"
|
|
737
|
+
});
|
|
738
|
+
}
|
|
570
739
|
function BookingFlow({
|
|
571
740
|
centerId,
|
|
572
741
|
productId,
|
|
@@ -582,25 +751,47 @@ function BookingFlow({
|
|
|
582
751
|
labels,
|
|
583
752
|
className
|
|
584
753
|
}) {
|
|
585
|
-
const t = { ...
|
|
754
|
+
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
586
755
|
const account = useAccount();
|
|
587
756
|
const signedIn = account.status === "linked" && account.customer !== null;
|
|
588
757
|
const acctName = account.customer?.fullName ?? "";
|
|
589
758
|
const acctEmail = account.customer?.email ?? "";
|
|
590
759
|
const [dateISO, setDateISO] = react.useState(defaultDateISO);
|
|
760
|
+
react.useEffect(() => {
|
|
761
|
+
if (!defaultDateISO && dateISO === "") setDateISO(todayISO());
|
|
762
|
+
}, [defaultDateISO, dateISO]);
|
|
591
763
|
const [startMinuteOfDay, setStartMinuteOfDay] = react.useState(defaultStartMinuteOfDay);
|
|
592
764
|
const endMinuteOfDay = startMinuteOfDay + durationMinutes;
|
|
593
|
-
const [
|
|
594
|
-
const [fullName, setFullName] = react.useState("");
|
|
595
|
-
const [email, setEmail] = react.useState("");
|
|
765
|
+
const [count, setCount] = react.useState(1);
|
|
596
766
|
const [payMessage, setPayMessage] = react.useState(null);
|
|
767
|
+
const [reviewing, setReviewing] = react.useState(false);
|
|
768
|
+
const [addonQtys, setAddonQtys] = react.useState({});
|
|
769
|
+
const selectedAddons = react.useMemo(
|
|
770
|
+
() => Object.entries(addonQtys).filter(([, q]) => q > 0).map(([addonId, quantity]) => ({ addonId, quantity })),
|
|
771
|
+
[addonQtys]
|
|
772
|
+
);
|
|
773
|
+
const countArgs = pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count };
|
|
597
774
|
const availability = useAvailability(
|
|
598
775
|
{ productId, dateISO, startMinuteOfDay, endMinuteOfDay },
|
|
599
|
-
{ enabled: dateISO !== "" }
|
|
776
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
600
777
|
);
|
|
601
778
|
const preview = useBookingPreview(
|
|
602
|
-
{
|
|
603
|
-
|
|
779
|
+
{
|
|
780
|
+
centerId,
|
|
781
|
+
productId,
|
|
782
|
+
dateISO,
|
|
783
|
+
startMinuteOfDay,
|
|
784
|
+
endMinuteOfDay,
|
|
785
|
+
mode: pricingMode,
|
|
786
|
+
...countArgs,
|
|
787
|
+
addons: selectedAddons
|
|
788
|
+
},
|
|
789
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
790
|
+
);
|
|
791
|
+
const addons = useAddons({ productId }, { enabled: signedIn });
|
|
792
|
+
const startTimes = useStartTimes(
|
|
793
|
+
{ productId, dateISO, durationMinutes, mode: pricingMode },
|
|
794
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
604
795
|
);
|
|
605
796
|
const flow = useBookingFlow();
|
|
606
797
|
const onConfirmedRef = react.useRef(onConfirmed);
|
|
@@ -610,6 +801,17 @@ function BookingFlow({
|
|
|
610
801
|
onConfirmedRef.current?.(flow.reservation);
|
|
611
802
|
}
|
|
612
803
|
}, [flow.status, flow.reservation]);
|
|
804
|
+
react.useEffect(() => {
|
|
805
|
+
if (typeof window !== "undefined" && (flow.status === "held" || flow.status === "preparingPayment" || flow.status === "awaitingPayment" || flow.status === "confirmed")) {
|
|
806
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
807
|
+
}
|
|
808
|
+
}, [flow.status]);
|
|
809
|
+
react.useEffect(() => {
|
|
810
|
+
const opts = startTimes.data;
|
|
811
|
+
if (opts && opts.length > 0 && !opts.includes(startMinuteOfDay)) {
|
|
812
|
+
setStartMinuteOfDay(opts[0]);
|
|
813
|
+
}
|
|
814
|
+
}, [startTimes.data, startMinuteOfDay]);
|
|
613
815
|
const prepareRef = react.useRef(flow.preparePayment);
|
|
614
816
|
prepareRef.current = flow.preparePayment;
|
|
615
817
|
react.useEffect(() => {
|
|
@@ -625,14 +827,17 @@ function BookingFlow({
|
|
|
625
827
|
startMinuteOfDay,
|
|
626
828
|
endMinuteOfDay,
|
|
627
829
|
mode: pricingMode,
|
|
628
|
-
units,
|
|
629
|
-
|
|
830
|
+
...pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count },
|
|
831
|
+
addons: selectedAddons,
|
|
832
|
+
// Always the signed-in customer — online booking requires login.
|
|
833
|
+
customer: { fullName: acctName, email: acctEmail, marketingOptIn: false }
|
|
630
834
|
}),
|
|
631
|
-
[centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode,
|
|
835
|
+
[centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, count, selectedAddons, acctName, acctEmail]
|
|
632
836
|
);
|
|
633
837
|
const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
|
|
634
838
|
const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
|
|
635
|
-
const
|
|
839
|
+
const addonList = addons.data ?? [];
|
|
840
|
+
const startOptions = startTimes.data ?? [];
|
|
636
841
|
const s = styles();
|
|
637
842
|
if (flow.status === "confirmed") {
|
|
638
843
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
@@ -642,7 +847,18 @@ function BookingFlow({
|
|
|
642
847
|
": ",
|
|
643
848
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: flow.reservation?.reservationDisplayId ?? "\u2014" })
|
|
644
849
|
] }),
|
|
645
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
850
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
851
|
+
"button",
|
|
852
|
+
{
|
|
853
|
+
type: "button",
|
|
854
|
+
style: s.primaryBtn,
|
|
855
|
+
onClick: () => {
|
|
856
|
+
setReviewing(false);
|
|
857
|
+
flow.reset();
|
|
858
|
+
},
|
|
859
|
+
children: t.bookAnother
|
|
860
|
+
}
|
|
861
|
+
)
|
|
646
862
|
] });
|
|
647
863
|
}
|
|
648
864
|
if (flow.status === "awaitingPayment" && flow.paymentIntent) {
|
|
@@ -679,10 +895,64 @@ function BookingFlow({
|
|
|
679
895
|
flow.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: flow.error.code })
|
|
680
896
|
] });
|
|
681
897
|
}
|
|
898
|
+
if (!signedIn) {
|
|
899
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, className });
|
|
900
|
+
}
|
|
682
901
|
const holding = flow.status === "holding";
|
|
902
|
+
if (reviewing) {
|
|
903
|
+
const chosenAddons = addonList.map((a) => ({ ...a, quantity: addonQtys[a.id] ?? 0 })).filter((a) => a.quantity > 0);
|
|
904
|
+
const addonsSubtotalCents = chosenAddons.reduce(
|
|
905
|
+
(sum, a) => sum + a.priceCents * a.quantity,
|
|
906
|
+
0
|
|
907
|
+
);
|
|
908
|
+
const fee = preview.data?.reservationFee;
|
|
909
|
+
const feeCents = typeof fee?.amountCents === "number" ? fee.amountCents : 0;
|
|
910
|
+
const feeLabel = typeof fee?.label === "string" && fee.label ? fee.label : t.reservationFeeLabel;
|
|
911
|
+
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotalCents - feeCents : null;
|
|
912
|
+
const reservationLine = t.reservationLineLabel.replace("{count}", String(count)).replace("{unit}", COUNT_LABEL[pricingMode]).replace("{date}", formatDateLabel(dateISO)).replace("{time}", `${formatMinuteLabel(startMinuteOfDay)}\u2013${formatMinuteLabel(endMinuteOfDay)}`);
|
|
913
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.reviewHeading }),
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.body, children: reservationLine }),
|
|
917
|
+
reservationCents != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.body, children: formatCents(reservationCents) }) : null
|
|
918
|
+
] }),
|
|
919
|
+
chosenAddons.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
920
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.muted, children: [
|
|
921
|
+
a.name,
|
|
922
|
+
" \xD7 ",
|
|
923
|
+
a.quantity
|
|
924
|
+
] }),
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.muted, children: formatCents(a.priceCents * a.quantity) })
|
|
926
|
+
] }, a.id)),
|
|
927
|
+
feeCents > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
928
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.muted, children: feeLabel }),
|
|
929
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.muted, children: formatCents(feeCents) })
|
|
930
|
+
] }) : null,
|
|
931
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
932
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: t.orderTotal }),
|
|
933
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: quoteCents != null ? formatCents(quoteCents) : "\u2014" })
|
|
934
|
+
] }),
|
|
935
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
936
|
+
"button",
|
|
937
|
+
{
|
|
938
|
+
type: "button",
|
|
939
|
+
style: s.primaryBtn,
|
|
940
|
+
disabled: holding || quoteCents == null,
|
|
941
|
+
onClick: () => void flow.startHold(bookingArgs),
|
|
942
|
+
children: holding ? t.securing : t.continueToPayment
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.linkBtn, disabled: holding, onClick: () => setReviewing(false), children: t.editOrder }),
|
|
946
|
+
flow.error && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.error, children: [
|
|
947
|
+
flow.error.code,
|
|
948
|
+
" \u2014 ",
|
|
949
|
+
flow.error.message
|
|
950
|
+
] })
|
|
951
|
+
] });
|
|
952
|
+
}
|
|
683
953
|
const onSubmit = (e) => {
|
|
684
954
|
e.preventDefault();
|
|
685
|
-
|
|
955
|
+
setReviewing(true);
|
|
686
956
|
};
|
|
687
957
|
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit, children: [
|
|
688
958
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.heading }),
|
|
@@ -692,57 +962,78 @@ function BookingFlow({
|
|
|
692
962
|
] }),
|
|
693
963
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
694
964
|
t.start,
|
|
695
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
696
|
-
"
|
|
965
|
+
startTimes.loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.meta, children: t.loadingTimes }) : startOptions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.meta, children: t.noTimes }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
966
|
+
"select",
|
|
697
967
|
{
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
968
|
+
value: startMinuteOfDay,
|
|
969
|
+
onChange: (e) => setStartMinuteOfDay(Number(e.target.value)),
|
|
970
|
+
style: s.input,
|
|
971
|
+
children: startOptions.map((min) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: min, children: formatMinuteLabel(min) }, min))
|
|
702
972
|
}
|
|
703
973
|
)
|
|
704
974
|
] }),
|
|
705
975
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
706
|
-
|
|
976
|
+
COUNT_LABEL[pricingMode],
|
|
707
977
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
708
978
|
"input",
|
|
709
979
|
{
|
|
710
980
|
type: "number",
|
|
711
981
|
min: 1,
|
|
712
|
-
value:
|
|
713
|
-
onChange: (e) =>
|
|
982
|
+
value: count,
|
|
983
|
+
onChange: (e) => setCount(Math.max(1, Number(e.target.value) || 1)),
|
|
714
984
|
style: s.input
|
|
715
985
|
}
|
|
716
986
|
)
|
|
717
987
|
] }),
|
|
718
|
-
|
|
988
|
+
addonList.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.stack, children: [
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.sectionTitle, children: t.addonsHeading }),
|
|
990
|
+
addonList.map((addon) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
991
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.body, children: [
|
|
992
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: addon.name }),
|
|
993
|
+
" ",
|
|
994
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.muted, children: [
|
|
995
|
+
formatCents(addon.priceCents),
|
|
996
|
+
ADDON_RATE_SUFFIX[addon.rateMode]
|
|
997
|
+
] }),
|
|
998
|
+
addon.description ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.muted, children: [
|
|
999
|
+
" \xB7 ",
|
|
1000
|
+
addon.description
|
|
1001
|
+
] }) : null
|
|
1002
|
+
] }),
|
|
1003
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1004
|
+
"input",
|
|
1005
|
+
{
|
|
1006
|
+
type: "number",
|
|
1007
|
+
min: 0,
|
|
1008
|
+
value: addonQtys[addon.id] ?? 0,
|
|
1009
|
+
onChange: (e) => setAddonQtys((prev) => ({
|
|
1010
|
+
...prev,
|
|
1011
|
+
[addon.id]: Math.max(0, Math.floor(Number(e.target.value) || 0))
|
|
1012
|
+
})),
|
|
1013
|
+
style: { ...s.input, width: "4.5rem" },
|
|
1014
|
+
"aria-label": `${addon.name} quantity`
|
|
1015
|
+
}
|
|
1016
|
+
)
|
|
1017
|
+
] }, addon.id))
|
|
1018
|
+
] }) : null,
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.meta, children: [
|
|
719
1020
|
t.bookingAs.replace("{name}", acctName),
|
|
720
1021
|
accountHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
721
1022
|
" \xB7 ",
|
|
722
1023
|
/* @__PURE__ */ jsxRuntime.jsx("a", { href: accountHref, style: s.linkBtn, children: t.notYou })
|
|
723
1024
|
] }) : null
|
|
724
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
725
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
726
|
-
t.name,
|
|
727
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
|
|
728
|
-
] }),
|
|
729
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
730
|
-
t.email,
|
|
731
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), style: s.input, required: true })
|
|
732
|
-
] }),
|
|
733
|
-
accountHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { href: accountHref, style: s.linkBtn, children: t.signInHint }) : null
|
|
734
1025
|
] }),
|
|
735
1026
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.meta, "aria-live": "polite", children: [
|
|
736
|
-
dateISO === "" ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
|
|
737
|
-
quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
|
|
1027
|
+
dateISO === "" || startOptions.length === 0 ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
|
|
1028
|
+
startOptions.length > 0 && quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
|
|
738
1029
|
] }),
|
|
739
1030
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
740
1031
|
"button",
|
|
741
1032
|
{
|
|
742
1033
|
type: "submit",
|
|
743
1034
|
style: s.primaryBtn,
|
|
744
|
-
disabled:
|
|
745
|
-
children:
|
|
1035
|
+
disabled: dateISO === "" || startOptions.length === 0 || quoteCents === null,
|
|
1036
|
+
children: t.reviewOrder
|
|
746
1037
|
}
|
|
747
1038
|
),
|
|
748
1039
|
flow.error && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.error, children: [
|
|
@@ -752,131 +1043,6 @@ function BookingFlow({
|
|
|
752
1043
|
] })
|
|
753
1044
|
] });
|
|
754
1045
|
}
|
|
755
|
-
var DEFAULT_LABELS2 = {
|
|
756
|
-
signInHeading: "Sign in",
|
|
757
|
-
signUpHeading: "Create your account",
|
|
758
|
-
linkHeading: "Finish your profile",
|
|
759
|
-
loading: "Loading\u2026",
|
|
760
|
-
email: "Email",
|
|
761
|
-
password: "Password",
|
|
762
|
-
name: "Name",
|
|
763
|
-
signIn: "Sign in",
|
|
764
|
-
signingIn: "Signing in\u2026",
|
|
765
|
-
createAccount: "Create account",
|
|
766
|
-
haveAccount: "Already have an account? Sign in",
|
|
767
|
-
needAccount: "New here? Create an account",
|
|
768
|
-
finishProfile: "Save profile",
|
|
769
|
-
saving: "Saving\u2026",
|
|
770
|
-
signOut: "Sign out"
|
|
771
|
-
};
|
|
772
|
-
function AuthForm({
|
|
773
|
-
account,
|
|
774
|
-
labels,
|
|
775
|
-
className
|
|
776
|
-
}) {
|
|
777
|
-
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
778
|
-
const [mode, setMode] = react.useState("signIn");
|
|
779
|
-
const [email, setEmail] = react.useState("");
|
|
780
|
-
const [password, setPassword] = react.useState("");
|
|
781
|
-
const [fullName, setFullName] = react.useState("");
|
|
782
|
-
const [busy, setBusy] = react.useState(false);
|
|
783
|
-
const s = styles();
|
|
784
|
-
async function guard(action) {
|
|
785
|
-
setBusy(true);
|
|
786
|
-
try {
|
|
787
|
-
await action();
|
|
788
|
-
} catch {
|
|
789
|
-
} finally {
|
|
790
|
-
setBusy(false);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
const onAuth = (e) => {
|
|
794
|
-
e.preventDefault();
|
|
795
|
-
void guard(
|
|
796
|
-
() => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
|
|
797
|
-
);
|
|
798
|
-
};
|
|
799
|
-
const onLink = (e) => {
|
|
800
|
-
e.preventDefault();
|
|
801
|
-
void guard(() => account.link({ fullName, email, marketingOptIn: false }));
|
|
802
|
-
};
|
|
803
|
-
if (account.status === "loading") {
|
|
804
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading }) });
|
|
805
|
-
}
|
|
806
|
-
if (account.status === "authed_no_customer") {
|
|
807
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
|
|
808
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.linkHeading }),
|
|
809
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
810
|
-
t.name,
|
|
811
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
|
|
812
|
-
] }),
|
|
813
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
814
|
-
t.email,
|
|
815
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
816
|
-
"input",
|
|
817
|
-
{
|
|
818
|
-
type: "email",
|
|
819
|
-
value: email,
|
|
820
|
-
onChange: (e) => setEmail(e.target.value),
|
|
821
|
-
style: s.input,
|
|
822
|
-
required: true
|
|
823
|
-
}
|
|
824
|
-
)
|
|
825
|
-
] }),
|
|
826
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
|
|
827
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
|
|
828
|
-
account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
|
|
829
|
-
] });
|
|
830
|
-
}
|
|
831
|
-
if (account.status === "linked") return null;
|
|
832
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
|
|
833
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
|
|
834
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
835
|
-
t.email,
|
|
836
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
837
|
-
"input",
|
|
838
|
-
{
|
|
839
|
-
type: "email",
|
|
840
|
-
value: email,
|
|
841
|
-
onChange: (e) => setEmail(e.target.value),
|
|
842
|
-
style: s.input,
|
|
843
|
-
required: true
|
|
844
|
-
}
|
|
845
|
-
)
|
|
846
|
-
] }),
|
|
847
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
848
|
-
t.password,
|
|
849
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
850
|
-
"input",
|
|
851
|
-
{
|
|
852
|
-
type: "password",
|
|
853
|
-
value: password,
|
|
854
|
-
onChange: (e) => setPassword(e.target.value),
|
|
855
|
-
style: s.input,
|
|
856
|
-
required: true
|
|
857
|
-
}
|
|
858
|
-
)
|
|
859
|
-
] }),
|
|
860
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
|
|
861
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
862
|
-
"button",
|
|
863
|
-
{
|
|
864
|
-
type: "button",
|
|
865
|
-
style: s.linkBtn,
|
|
866
|
-
onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
|
|
867
|
-
children: mode === "signIn" ? t.needAccount : t.haveAccount
|
|
868
|
-
}
|
|
869
|
-
),
|
|
870
|
-
account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
|
|
871
|
-
] });
|
|
872
|
-
}
|
|
873
|
-
function AuthGate({ children, labels, className }) {
|
|
874
|
-
const account = useAccount();
|
|
875
|
-
if (account.status === "linked" && account.customer) {
|
|
876
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.({ customer: account.customer, account }) });
|
|
877
|
-
}
|
|
878
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, labels, className });
|
|
879
|
-
}
|
|
880
1046
|
var DEFAULT_LABELS3 = {
|
|
881
1047
|
signIn: "Sign in",
|
|
882
1048
|
signOut: "Sign out",
|