@bowlos/reservations 0.6.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.
Files changed (50) hide show
  1. package/README.md +96 -9
  2. package/dist/catalog-kd07kri0.d.ts +74 -0
  3. package/dist/catalog-kdDjgvT1.d.cts +74 -0
  4. package/dist/{chunk-YICHFUAY.js → chunk-2X7MFQWY.js} +9 -3
  5. package/dist/chunk-2X7MFQWY.js.map +1 -0
  6. package/dist/{chunk-H42X4FRR.js → chunk-FPUWLOW3.js} +25 -4
  7. package/dist/chunk-FPUWLOW3.js.map +1 -0
  8. package/dist/chunk-Y3YSDO3H.js +221 -0
  9. package/dist/chunk-Y3YSDO3H.js.map +1 -0
  10. package/dist/components.cjs +366 -164
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +79 -4
  13. package/dist/components.d.ts +79 -4
  14. package/dist/components.js +340 -371
  15. package/dist/components.js.map +1 -1
  16. package/dist/{data-DrM0D6Pi.d.cts → data-lC-l-haz.d.cts} +33 -54
  17. package/dist/{data-DrM0D6Pi.d.ts → data-lC-l-haz.d.ts} +33 -54
  18. package/dist/errors-IIK7xibp.d.cts +54 -0
  19. package/dist/errors-IIK7xibp.d.ts +54 -0
  20. package/dist/index.cjs +34 -0
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +4 -3
  23. package/dist/index.d.ts +4 -3
  24. package/dist/index.js +23 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/payments.cjs +245 -0
  27. package/dist/payments.cjs.map +1 -0
  28. package/dist/payments.d.cts +37 -0
  29. package/dist/payments.d.ts +37 -0
  30. package/dist/payments.js +83 -0
  31. package/dist/payments.js.map +1 -0
  32. package/dist/{react-7ruEsubp.d.cts → react-B3dlcklN.d.ts} +2 -1
  33. package/dist/{react-Cb_NZCXa.d.ts → react-aZplAyHS.d.cts} +2 -1
  34. package/dist/react.cjs +28 -0
  35. package/dist/react.cjs.map +1 -1
  36. package/dist/react.d.cts +22 -5
  37. package/dist/react.d.ts +22 -5
  38. package/dist/react.js +2 -2
  39. package/package.json +20 -2
  40. package/templates/center-site/README.md +8 -7
  41. package/templates/center-site/app/book/page.tsx +33 -25
  42. package/templates/center-site/app/buy/page.tsx +36 -0
  43. package/templates/center-site/app/catalog/page.tsx +35 -0
  44. package/templates/center-site/app/site-header.tsx +1 -1
  45. package/templates/center-site/package.json +1 -1
  46. package/dist/account-BRapzoNI.d.cts +0 -46
  47. package/dist/account-VO6BzPNK.d.ts +0 -46
  48. package/dist/chunk-H42X4FRR.js.map +0 -1
  49. package/dist/chunk-YICHFUAY.js.map +0 -1
  50. package/templates/center-site/app/book/checkout-form.tsx +0 -85
@@ -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
  }
@@ -164,6 +170,21 @@ function useFlashSale(args, options) {
164
170
  function useFlashSales(args, options) {
165
171
  return useBowlosQuery("listPublicFlashSales", args, options);
166
172
  }
173
+ function useProducts(args, options) {
174
+ return useBowlosQuery("listPublicProducts", args, options);
175
+ }
176
+ function useEvents(args, options) {
177
+ return useBowlosQuery("listPublicEvents", args, options);
178
+ }
179
+ function usePackages(args, options) {
180
+ return useBowlosQuery("listPublicPackages", args, options);
181
+ }
182
+ function usePublicMemberships(args, options) {
183
+ return useBowlosQuery("listPublicMemberships", args, options);
184
+ }
185
+ function useGameCards(args, options) {
186
+ return useBowlosQuery("listPublicGameCards", args, options);
187
+ }
167
188
 
168
189
  // src/data.ts
169
190
  function availableUnitCount(availability) {
@@ -499,9 +520,12 @@ function minutesToTime(min) {
499
520
  const m = (min % 60).toString().padStart(2, "0");
500
521
  return `${h}:${m}`;
501
522
  }
502
- function timeToMinutes(t) {
503
- const [h, m] = t.split(":").map(Number);
504
- return (h ?? 0) * 60 + (m ?? 0);
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}`;
505
529
  }
506
530
  function useCountdown(targetMs) {
507
531
  const [now, setNow] = react.useState(null);
@@ -528,13 +552,141 @@ function humanizeRemaining(ms) {
528
552
  return `${s}s`;
529
553
  }
530
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 = {
531
680
  heading: "Book",
532
681
  date: "Date",
533
682
  start: "Start time",
683
+ loadingTimes: "Finding times\u2026",
684
+ noTimes: "No times available for this date.",
534
685
  quantity: "Quantity",
686
+ addonsHeading: "Add-ons",
535
687
  name: "Name",
536
688
  email: "Email",
537
- hold: "Book",
689
+ hold: "Book Now",
538
690
  holding: "Booking\u2026",
539
691
  continueToPayment: "Continue to payment",
540
692
  preparing: "Preparing\u2026",
@@ -552,6 +704,23 @@ var DEFAULT_LABELS = {
552
704
  notYou: "Not you?",
553
705
  signInHint: "Sign in to book faster"
554
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
+ }
555
724
  function BookingFlow({
556
725
  centerId,
557
726
  productId,
@@ -567,25 +736,46 @@ function BookingFlow({
567
736
  labels,
568
737
  className
569
738
  }) {
570
- const t = { ...DEFAULT_LABELS, ...labels };
739
+ const t = { ...DEFAULT_LABELS2, ...labels };
571
740
  const account = useAccount();
572
741
  const signedIn = account.status === "linked" && account.customer !== null;
573
742
  const acctName = account.customer?.fullName ?? "";
574
743
  const acctEmail = account.customer?.email ?? "";
575
744
  const [dateISO, setDateISO] = react.useState(defaultDateISO);
745
+ react.useEffect(() => {
746
+ if (!defaultDateISO && dateISO === "") setDateISO(todayISO());
747
+ }, [defaultDateISO, dateISO]);
576
748
  const [startMinuteOfDay, setStartMinuteOfDay] = react.useState(defaultStartMinuteOfDay);
577
749
  const endMinuteOfDay = startMinuteOfDay + durationMinutes;
578
- const [units, setUnits] = react.useState(1);
579
- const [fullName, setFullName] = react.useState("");
580
- const [email, setEmail] = react.useState("");
750
+ const [count, setCount] = react.useState(1);
581
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 };
582
758
  const availability = useAvailability(
583
759
  { productId, dateISO, startMinuteOfDay, endMinuteOfDay },
584
- { enabled: dateISO !== "" }
760
+ { enabled: dateISO !== "" && signedIn }
585
761
  );
586
762
  const preview = useBookingPreview(
587
- { centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, mode: pricingMode, units },
588
- { enabled: dateISO !== "" }
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 }
589
779
  );
590
780
  const flow = useBookingFlow();
591
781
  const onConfirmedRef = react.useRef(onConfirmed);
@@ -595,6 +785,17 @@ function BookingFlow({
595
785
  onConfirmedRef.current?.(flow.reservation);
596
786
  }
597
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]);
598
799
  const prepareRef = react.useRef(flow.preparePayment);
599
800
  prepareRef.current = flow.preparePayment;
600
801
  react.useEffect(() => {
@@ -610,14 +811,17 @@ function BookingFlow({
610
811
  startMinuteOfDay,
611
812
  endMinuteOfDay,
612
813
  mode: pricingMode,
613
- units,
614
- customer: signedIn ? { fullName: acctName, email: acctEmail, marketingOptIn: false } : { fullName, email, marketingOptIn: false }
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 }
615
818
  }),
616
- [centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, units, signedIn, acctName, acctEmail, fullName, email]
819
+ [centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, count, selectedAddons, acctName, acctEmail]
617
820
  );
618
821
  const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
619
822
  const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
620
- const unitNoun = units === 1 ? unitLabel.singular : unitLabel.plural;
823
+ const addonList = addons.data ?? [];
824
+ const startOptions = startTimes.data ?? [];
621
825
  const s = styles();
622
826
  if (flow.status === "confirmed") {
623
827
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
@@ -664,6 +868,9 @@ function BookingFlow({
664
868
  flow.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: flow.error.code })
665
869
  ] });
666
870
  }
871
+ if (!signedIn) {
872
+ return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, className });
873
+ }
667
874
  const holding = flow.status === "holding";
668
875
  const onSubmit = (e) => {
669
876
  e.preventDefault();
@@ -677,57 +884,78 @@ function BookingFlow({
677
884
  ] }),
678
885
  /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
679
886
  t.start,
680
- /* @__PURE__ */ jsxRuntime.jsx(
681
- "input",
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",
682
889
  {
683
- type: "time",
684
- value: minutesToTime(startMinuteOfDay),
685
- onChange: (e) => setStartMinuteOfDay(timeToMinutes(e.target.value)),
686
- style: s.input
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))
687
894
  }
688
895
  )
689
896
  ] }),
690
897
  /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
691
- t.quantity,
898
+ COUNT_LABEL[pricingMode],
692
899
  /* @__PURE__ */ jsxRuntime.jsx(
693
900
  "input",
694
901
  {
695
902
  type: "number",
696
903
  min: 1,
697
- value: units,
698
- onChange: (e) => setUnits(Math.max(1, Number(e.target.value) || 1)),
904
+ value: count,
905
+ onChange: (e) => setCount(Math.max(1, Number(e.target.value) || 1)),
699
906
  style: s.input
700
907
  }
701
908
  )
702
909
  ] }),
703
- signedIn ? /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.meta, children: [
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: [
704
942
  t.bookingAs.replace("{name}", acctName),
705
943
  accountHref ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
706
944
  " \xB7 ",
707
945
  /* @__PURE__ */ jsxRuntime.jsx("a", { href: accountHref, style: s.linkBtn, children: t.notYou })
708
946
  ] }) : null
709
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
710
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
711
- t.name,
712
- /* @__PURE__ */ jsxRuntime.jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
713
- ] }),
714
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
715
- t.email,
716
- /* @__PURE__ */ jsxRuntime.jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), style: s.input, required: true })
717
- ] }),
718
- accountHref ? /* @__PURE__ */ jsxRuntime.jsx("a", { href: accountHref, style: s.linkBtn, children: t.signInHint }) : null
719
947
  ] }),
720
948
  /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.meta, "aria-live": "polite", children: [
721
- dateISO === "" ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
722
- 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)}` : ""
723
951
  ] }),
724
952
  /* @__PURE__ */ jsxRuntime.jsx(
725
953
  "button",
726
954
  {
727
955
  type: "submit",
728
956
  style: s.primaryBtn,
729
- disabled: holding || dateISO === "" || !signedIn && (!fullName || !email),
730
- children: holding ? t.holding : `${t.hold} ${unitNoun}`
957
+ disabled: holding || dateISO === "" || startOptions.length === 0,
958
+ children: holding ? t.holding : t.hold
731
959
  }
732
960
  ),
733
961
  flow.error && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: s.error, children: [
@@ -737,131 +965,6 @@ function BookingFlow({
737
965
  ] })
738
966
  ] });
739
967
  }
740
- var DEFAULT_LABELS2 = {
741
- signInHeading: "Sign in",
742
- signUpHeading: "Create your account",
743
- linkHeading: "Finish your profile",
744
- loading: "Loading\u2026",
745
- email: "Email",
746
- password: "Password",
747
- name: "Name",
748
- signIn: "Sign in",
749
- signingIn: "Signing in\u2026",
750
- createAccount: "Create account",
751
- haveAccount: "Already have an account? Sign in",
752
- needAccount: "New here? Create an account",
753
- finishProfile: "Save profile",
754
- saving: "Saving\u2026",
755
- signOut: "Sign out"
756
- };
757
- function AuthForm({
758
- account,
759
- labels,
760
- className
761
- }) {
762
- const t = { ...DEFAULT_LABELS2, ...labels };
763
- const [mode, setMode] = react.useState("signIn");
764
- const [email, setEmail] = react.useState("");
765
- const [password, setPassword] = react.useState("");
766
- const [fullName, setFullName] = react.useState("");
767
- const [busy, setBusy] = react.useState(false);
768
- const s = styles();
769
- async function guard(action) {
770
- setBusy(true);
771
- try {
772
- await action();
773
- } catch {
774
- } finally {
775
- setBusy(false);
776
- }
777
- }
778
- const onAuth = (e) => {
779
- e.preventDefault();
780
- void guard(
781
- () => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
782
- );
783
- };
784
- const onLink = (e) => {
785
- e.preventDefault();
786
- void guard(() => account.link({ fullName, email, marketingOptIn: false }));
787
- };
788
- if (account.status === "loading") {
789
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading }) });
790
- }
791
- if (account.status === "authed_no_customer") {
792
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
793
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.linkHeading }),
794
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
795
- t.name,
796
- /* @__PURE__ */ jsxRuntime.jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
797
- ] }),
798
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
799
- t.email,
800
- /* @__PURE__ */ jsxRuntime.jsx(
801
- "input",
802
- {
803
- type: "email",
804
- value: email,
805
- onChange: (e) => setEmail(e.target.value),
806
- style: s.input,
807
- required: true
808
- }
809
- )
810
- ] }),
811
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
812
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
813
- account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
814
- ] });
815
- }
816
- if (account.status === "linked") return null;
817
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
818
- /* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
819
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
820
- t.email,
821
- /* @__PURE__ */ jsxRuntime.jsx(
822
- "input",
823
- {
824
- type: "email",
825
- value: email,
826
- onChange: (e) => setEmail(e.target.value),
827
- style: s.input,
828
- required: true
829
- }
830
- )
831
- ] }),
832
- /* @__PURE__ */ jsxRuntime.jsxs("label", { style: s.label, children: [
833
- t.password,
834
- /* @__PURE__ */ jsxRuntime.jsx(
835
- "input",
836
- {
837
- type: "password",
838
- value: password,
839
- onChange: (e) => setPassword(e.target.value),
840
- style: s.input,
841
- required: true
842
- }
843
- )
844
- ] }),
845
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
846
- /* @__PURE__ */ jsxRuntime.jsx(
847
- "button",
848
- {
849
- type: "button",
850
- style: s.linkBtn,
851
- onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
852
- children: mode === "signIn" ? t.needAccount : t.haveAccount
853
- }
854
- ),
855
- account.error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.error, children: account.error.code })
856
- ] });
857
- }
858
- function AuthGate({ children, labels, className }) {
859
- const account = useAccount();
860
- if (account.status === "linked" && account.customer) {
861
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children?.({ customer: account.customer, account }) });
862
- }
863
- return /* @__PURE__ */ jsxRuntime.jsx(AuthForm, { account, labels, className });
864
- }
865
968
  var DEFAULT_LABELS3 = {
866
969
  signIn: "Sign in",
867
970
  signOut: "Sign out",
@@ -1188,12 +1291,111 @@ function When({ ms }) {
1188
1291
  }, [ms]);
1189
1292
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text ?? "" });
1190
1293
  }
1294
+ var DEFAULT_LABELS7 = {
1295
+ heading: "What would you like to book?",
1296
+ loading: "Loading\u2026",
1297
+ empty: "Nothing is available to book online right now.",
1298
+ bowling: "Bowling",
1299
+ otherAttractions: "Other attractions",
1300
+ events: "Events",
1301
+ packages: "Packages",
1302
+ memberships: "Memberships",
1303
+ gamePasses: "Game passes",
1304
+ select: "Select",
1305
+ minutesAbbrev: "min",
1306
+ perMonth: "/mo"
1307
+ };
1308
+ function BookingCatalog({ brandId, centerId, onSelect, labels, className }) {
1309
+ const t = { ...DEFAULT_LABELS7, ...labels };
1310
+ const s = styles();
1311
+ const products = useProducts({ centerId });
1312
+ const events = useEvents({ centerId });
1313
+ const packages = usePackages({ brandId, centerId });
1314
+ const memberships = usePublicMemberships({ centerId });
1315
+ const gameCards = useGameCards({ brandId, centerId });
1316
+ const reads = [products, events, packages, memberships, gameCards];
1317
+ const anyLoading = reads.some((r) => r.loading && !r.data);
1318
+ const productRows = products.data ?? [];
1319
+ const bowling = productRows.filter((p) => p.attractionTypeKey === "bowling").map((p) => ({ kind: "product", ...p }));
1320
+ const other = productRows.filter((p) => p.attractionTypeKey !== "bowling").map((p) => ({ kind: "product", ...p }));
1321
+ const eventOffers = (events.data ?? []).map((e) => ({
1322
+ kind: "event",
1323
+ id: e.id,
1324
+ name: e.name,
1325
+ date: e.date,
1326
+ description: e.description
1327
+ }));
1328
+ const packageOffers = (packages.data ?? []).map((p) => ({
1329
+ kind: "package",
1330
+ id: p.id,
1331
+ name: p.name,
1332
+ priceCents: p.basePriceCents,
1333
+ description: p.description
1334
+ }));
1335
+ const membershipOffers = (memberships.data ?? []).map((m) => ({
1336
+ kind: "membership",
1337
+ id: m.id,
1338
+ name: m.name,
1339
+ priceCents: m.recurringPriceCents,
1340
+ description: m.description
1341
+ }));
1342
+ const gameCardOffers = (gameCards.data ?? []).map((g) => ({
1343
+ kind: "gamecard",
1344
+ id: g.id,
1345
+ name: g.name,
1346
+ priceCents: g.priceCents,
1347
+ description: g.description
1348
+ }));
1349
+ const sections = [
1350
+ { title: t.bowling, offers: bowling },
1351
+ { title: t.otherAttractions, offers: other },
1352
+ { title: t.events, offers: eventOffers },
1353
+ { title: t.packages, offers: packageOffers },
1354
+ { title: t.memberships, offers: membershipOffers },
1355
+ { title: t.gamePasses, offers: gameCardOffers }
1356
+ ].filter((sec) => sec.offers.length > 0);
1357
+ let body;
1358
+ if (anyLoading) {
1359
+ body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading });
1360
+ } else if (sections.length === 0) {
1361
+ body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.empty });
1362
+ } else {
1363
+ body = sections.map((sec) => /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
1364
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: sec.title }),
1365
+ sec.offers.map((offer) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.listItem, children: [
1366
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1367
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: offer.name }),
1368
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: subtitle(offer, t) })
1369
+ ] }),
1370
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(offer), children: t.select })
1371
+ ] }, `${offer.kind}:${offer.id}`))
1372
+ ] }, sec.title));
1373
+ }
1374
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
1375
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.heading }),
1376
+ body
1377
+ ] });
1378
+ }
1379
+ function subtitle(offer, t) {
1380
+ switch (offer.kind) {
1381
+ case "product":
1382
+ return `${offer.attractionName} \xB7 ${offer.durationMinutes} ${t.minutesAbbrev}`;
1383
+ case "event":
1384
+ return offer.date;
1385
+ case "membership":
1386
+ return `${formatCents(offer.priceCents)}${t.perMonth}`;
1387
+ case "package":
1388
+ case "gamecard":
1389
+ return formatCents(offer.priceCents);
1390
+ }
1391
+ }
1191
1392
 
1192
1393
  exports.AccountDashboard = AccountDashboard;
1193
1394
  exports.AccountMenu = AccountMenu;
1194
1395
  exports.AuthForm = AuthForm;
1195
1396
  exports.AuthGate = AuthGate;
1196
1397
  exports.BOWLOS_DEFAULT_THEME = BOWLOS_DEFAULT_THEME;
1398
+ exports.BookingCatalog = BookingCatalog;
1197
1399
  exports.BookingFlow = BookingFlow;
1198
1400
  exports.BowlosTheme = BowlosTheme;
1199
1401
  exports.FlashSale = FlashSale;