@bowlos/reservations 0.7.0 → 0.12.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/README.md +74 -8
- 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 +252 -164
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +8 -3
- package/dist/components.d.ts +8 -3
- package/dist/components.js +242 -371
- 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 +20 -2
- 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,141 @@ 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
|
-
hold: "Book",
|
|
689
|
+
hold: "Book Now",
|
|
553
690
|
holding: "Booking\u2026",
|
|
554
691
|
continueToPayment: "Continue to payment",
|
|
555
692
|
preparing: "Preparing\u2026",
|
|
@@ -567,6 +704,23 @@ var DEFAULT_LABELS = {
|
|
|
567
704
|
notYou: "Not you?",
|
|
568
705
|
signInHint: "Sign in to book faster"
|
|
569
706
|
};
|
|
707
|
+
var COUNT_LABEL = {
|
|
708
|
+
per_unit_per_hour: "Lanes",
|
|
709
|
+
per_person_per_hour: "Bowlers",
|
|
710
|
+
per_game: "Games"
|
|
711
|
+
};
|
|
712
|
+
var ADDON_RATE_SUFFIX = {
|
|
713
|
+
per_person: " / person",
|
|
714
|
+
per_unit: " / unit",
|
|
715
|
+
flat: ""
|
|
716
|
+
};
|
|
717
|
+
function todayISO() {
|
|
718
|
+
const d = /* @__PURE__ */ new Date();
|
|
719
|
+
const y = d.getFullYear();
|
|
720
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
721
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
722
|
+
return `${y}-${m}-${day}`;
|
|
723
|
+
}
|
|
570
724
|
function BookingFlow({
|
|
571
725
|
centerId,
|
|
572
726
|
productId,
|
|
@@ -582,25 +736,46 @@ function BookingFlow({
|
|
|
582
736
|
labels,
|
|
583
737
|
className
|
|
584
738
|
}) {
|
|
585
|
-
const t = { ...
|
|
739
|
+
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
586
740
|
const account = useAccount();
|
|
587
741
|
const signedIn = account.status === "linked" && account.customer !== null;
|
|
588
742
|
const acctName = account.customer?.fullName ?? "";
|
|
589
743
|
const acctEmail = account.customer?.email ?? "";
|
|
590
744
|
const [dateISO, setDateISO] = react.useState(defaultDateISO);
|
|
745
|
+
react.useEffect(() => {
|
|
746
|
+
if (!defaultDateISO && dateISO === "") setDateISO(todayISO());
|
|
747
|
+
}, [defaultDateISO, dateISO]);
|
|
591
748
|
const [startMinuteOfDay, setStartMinuteOfDay] = react.useState(defaultStartMinuteOfDay);
|
|
592
749
|
const endMinuteOfDay = startMinuteOfDay + durationMinutes;
|
|
593
|
-
const [
|
|
594
|
-
const [fullName, setFullName] = react.useState("");
|
|
595
|
-
const [email, setEmail] = react.useState("");
|
|
750
|
+
const [count, setCount] = react.useState(1);
|
|
596
751
|
const [payMessage, setPayMessage] = react.useState(null);
|
|
752
|
+
const [addonQtys, setAddonQtys] = react.useState({});
|
|
753
|
+
const selectedAddons = react.useMemo(
|
|
754
|
+
() => Object.entries(addonQtys).filter(([, q]) => q > 0).map(([addonId, quantity]) => ({ addonId, quantity })),
|
|
755
|
+
[addonQtys]
|
|
756
|
+
);
|
|
757
|
+
const countArgs = pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count };
|
|
597
758
|
const availability = useAvailability(
|
|
598
759
|
{ productId, dateISO, startMinuteOfDay, endMinuteOfDay },
|
|
599
|
-
{ enabled: dateISO !== "" }
|
|
760
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
600
761
|
);
|
|
601
762
|
const preview = useBookingPreview(
|
|
602
|
-
{
|
|
603
|
-
|
|
763
|
+
{
|
|
764
|
+
centerId,
|
|
765
|
+
productId,
|
|
766
|
+
dateISO,
|
|
767
|
+
startMinuteOfDay,
|
|
768
|
+
endMinuteOfDay,
|
|
769
|
+
mode: pricingMode,
|
|
770
|
+
...countArgs,
|
|
771
|
+
addons: selectedAddons
|
|
772
|
+
},
|
|
773
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
774
|
+
);
|
|
775
|
+
const addons = useAddons({ productId }, { enabled: signedIn });
|
|
776
|
+
const startTimes = useStartTimes(
|
|
777
|
+
{ productId, dateISO, durationMinutes, mode: pricingMode },
|
|
778
|
+
{ enabled: dateISO !== "" && signedIn }
|
|
604
779
|
);
|
|
605
780
|
const flow = useBookingFlow();
|
|
606
781
|
const onConfirmedRef = react.useRef(onConfirmed);
|
|
@@ -610,6 +785,17 @@ function BookingFlow({
|
|
|
610
785
|
onConfirmedRef.current?.(flow.reservation);
|
|
611
786
|
}
|
|
612
787
|
}, [flow.status, flow.reservation]);
|
|
788
|
+
react.useEffect(() => {
|
|
789
|
+
if (typeof window !== "undefined" && (flow.status === "held" || flow.status === "preparingPayment" || flow.status === "awaitingPayment" || flow.status === "confirmed")) {
|
|
790
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
791
|
+
}
|
|
792
|
+
}, [flow.status]);
|
|
793
|
+
react.useEffect(() => {
|
|
794
|
+
const opts = startTimes.data;
|
|
795
|
+
if (opts && opts.length > 0 && !opts.includes(startMinuteOfDay)) {
|
|
796
|
+
setStartMinuteOfDay(opts[0]);
|
|
797
|
+
}
|
|
798
|
+
}, [startTimes.data, startMinuteOfDay]);
|
|
613
799
|
const prepareRef = react.useRef(flow.preparePayment);
|
|
614
800
|
prepareRef.current = flow.preparePayment;
|
|
615
801
|
react.useEffect(() => {
|
|
@@ -625,14 +811,17 @@ function BookingFlow({
|
|
|
625
811
|
startMinuteOfDay,
|
|
626
812
|
endMinuteOfDay,
|
|
627
813
|
mode: pricingMode,
|
|
628
|
-
units,
|
|
629
|
-
|
|
814
|
+
...pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count },
|
|
815
|
+
addons: selectedAddons,
|
|
816
|
+
// Always the signed-in customer — online booking requires login.
|
|
817
|
+
customer: { fullName: acctName, email: acctEmail, marketingOptIn: false }
|
|
630
818
|
}),
|
|
631
|
-
[centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode,
|
|
819
|
+
[centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, count, selectedAddons, acctName, acctEmail]
|
|
632
820
|
);
|
|
633
821
|
const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
|
|
634
822
|
const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
|
|
635
|
-
const
|
|
823
|
+
const addonList = addons.data ?? [];
|
|
824
|
+
const startOptions = startTimes.data ?? [];
|
|
636
825
|
const s = styles();
|
|
637
826
|
if (flow.status === "confirmed") {
|
|
638
827
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
@@ -679,6 +868,9 @@ function BookingFlow({
|
|
|
679
868
|
flow.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: flow.error.code })
|
|
680
869
|
] });
|
|
681
870
|
}
|
|
871
|
+
if (!signedIn) {
|
|
872
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, className });
|
|
873
|
+
}
|
|
682
874
|
const holding = flow.status === "holding";
|
|
683
875
|
const onSubmit = (e) => {
|
|
684
876
|
e.preventDefault();
|
|
@@ -692,57 +884,78 @@ function BookingFlow({
|
|
|
692
884
|
] }),
|
|
693
885
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
694
886
|
t.start,
|
|
695
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
696
|
-
"
|
|
887
|
+
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(
|
|
888
|
+
"select",
|
|
697
889
|
{
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
890
|
+
value: startMinuteOfDay,
|
|
891
|
+
onChange: (e) => setStartMinuteOfDay(Number(e.target.value)),
|
|
892
|
+
style: s.input,
|
|
893
|
+
children: startOptions.map((min) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: min, children: formatMinuteLabel(min) }, min))
|
|
702
894
|
}
|
|
703
895
|
)
|
|
704
896
|
] }),
|
|
705
897
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
|
|
706
|
-
|
|
898
|
+
COUNT_LABEL[pricingMode],
|
|
707
899
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
708
900
|
"input",
|
|
709
901
|
{
|
|
710
902
|
type: "number",
|
|
711
903
|
min: 1,
|
|
712
|
-
value:
|
|
713
|
-
onChange: (e) =>
|
|
904
|
+
value: count,
|
|
905
|
+
onChange: (e) => setCount(Math.max(1, Number(e.target.value) || 1)),
|
|
714
906
|
style: s.input
|
|
715
907
|
}
|
|
716
908
|
)
|
|
717
909
|
] }),
|
|
718
|
-
|
|
910
|
+
addonList.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.stack, children: [
|
|
911
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.sectionTitle, children: t.addonsHeading }),
|
|
912
|
+
addonList.map((addon) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.rowBetween, children: [
|
|
913
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.body, children: [
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: addon.name }),
|
|
915
|
+
" ",
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.muted, children: [
|
|
917
|
+
formatCents(addon.priceCents),
|
|
918
|
+
ADDON_RATE_SUFFIX[addon.rateMode]
|
|
919
|
+
] }),
|
|
920
|
+
addon.description ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.muted, children: [
|
|
921
|
+
" \xB7 ",
|
|
922
|
+
addon.description
|
|
923
|
+
] }) : null
|
|
924
|
+
] }),
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
926
|
+
"input",
|
|
927
|
+
{
|
|
928
|
+
type: "number",
|
|
929
|
+
min: 0,
|
|
930
|
+
value: addonQtys[addon.id] ?? 0,
|
|
931
|
+
onChange: (e) => setAddonQtys((prev) => ({
|
|
932
|
+
...prev,
|
|
933
|
+
[addon.id]: Math.max(0, Math.floor(Number(e.target.value) || 0))
|
|
934
|
+
})),
|
|
935
|
+
style: { ...s.input, width: "4.5rem" },
|
|
936
|
+
"aria-label": `${addon.name} quantity`
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
] }, addon.id))
|
|
940
|
+
] }) : null,
|
|
941
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.meta, children: [
|
|
719
942
|
t.bookingAs.replace("{name}", acctName),
|
|
720
943
|
accountHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
721
944
|
" \xB7 ",
|
|
722
945
|
/* @__PURE__ */ jsxRuntime.jsx("a", { href: accountHref, style: s.linkBtn, children: t.notYou })
|
|
723
946
|
] }) : 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
947
|
] }),
|
|
735
948
|
/* @__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)}` : ""
|
|
949
|
+
dateISO === "" || startOptions.length === 0 ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
|
|
950
|
+
startOptions.length > 0 && quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
|
|
738
951
|
] }),
|
|
739
952
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
740
953
|
"button",
|
|
741
954
|
{
|
|
742
955
|
type: "submit",
|
|
743
956
|
style: s.primaryBtn,
|
|
744
|
-
disabled: holding || dateISO === "" ||
|
|
745
|
-
children: holding ? t.holding :
|
|
957
|
+
disabled: holding || dateISO === "" || startOptions.length === 0,
|
|
958
|
+
children: holding ? t.holding : t.hold
|
|
746
959
|
}
|
|
747
960
|
),
|
|
748
961
|
flow.error && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.error, children: [
|
|
@@ -752,131 +965,6 @@ function BookingFlow({
|
|
|
752
965
|
] })
|
|
753
966
|
] });
|
|
754
967
|
}
|
|
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
968
|
var DEFAULT_LABELS3 = {
|
|
881
969
|
signIn: "Sign in",
|
|
882
970
|
signOut: "Sign out",
|