@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
@@ -1,226 +1,146 @@
1
- import { useAccount, useAvailability, useBookingPreview, useBookingFlow, useMyReservations, useMyMemberships, useMyLoyalty, useMyCredits, useMyPasses, useFlashSale, useFlashSales } from './chunk-H42X4FRR.js';
2
- import { availableUnitCount } from './chunk-YICHFUAY.js';
1
+ import { useAccount, useAvailability, useBookingPreview, useAddons, useStartTimes, useBookingFlow, useMyReservations, useMyMemberships, useMyLoyalty, useMyCredits, useMyPasses, useFlashSale, useFlashSales, useProducts, useEvents, usePackages, usePublicMemberships, useGameCards } from './chunk-FPUWLOW3.js';
2
+ import { availableUnitCount } from './chunk-2X7MFQWY.js';
3
+ import { styles, formatCents, formatMinuteLabel, token, minutesToTime, useCountdown, formatCentsRange } from './chunk-Y3YSDO3H.js';
4
+ export { BOWLOS_DEFAULT_THEME, BowlosTheme, formatCents, formatCentsRange } from './chunk-Y3YSDO3H.js';
5
+ import { useState, useEffect, useMemo, useRef } from 'react';
3
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { useState, useRef, useEffect, useMemo } from 'react';
5
7
 
6
- var VAR = {
7
- colorPrimary: "--bowlos-color-primary",
8
- colorPrimaryContrast: "--bowlos-color-primary-contrast",
9
- colorText: "--bowlos-color-text",
10
- colorMuted: "--bowlos-color-muted",
11
- colorBg: "--bowlos-color-bg",
12
- colorSurface: "--bowlos-color-surface",
13
- colorBorder: "--bowlos-color-border",
14
- colorError: "--bowlos-color-error",
15
- colorSuccess: "--bowlos-color-success",
16
- radius: "--bowlos-radius",
17
- fontFamily: "--bowlos-font"
18
- };
19
- var BOWLOS_DEFAULT_THEME = {
20
- colorPrimary: "#1f2937",
21
- colorPrimaryContrast: "#ffffff",
22
- colorText: "#111827",
23
- colorMuted: "#6b7280",
24
- colorBg: "#ffffff",
25
- colorSurface: "#f9fafb",
26
- colorBorder: "#e5e7eb",
27
- colorError: "#dc2626",
28
- colorSuccess: "#16a34a",
29
- radius: "10px",
30
- fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"
8
+ var DEFAULT_LABELS = {
9
+ signInHeading: "Sign in",
10
+ signUpHeading: "Create your account",
11
+ linkHeading: "Finish your profile",
12
+ loading: "Loading\u2026",
13
+ email: "Email",
14
+ password: "Password",
15
+ name: "Name",
16
+ signIn: "Sign in",
17
+ signingIn: "Signing in\u2026",
18
+ createAccount: "Create account",
19
+ haveAccount: "Already have an account? Sign in",
20
+ needAccount: "New here? Create an account",
21
+ finishProfile: "Save profile",
22
+ saving: "Saving\u2026",
23
+ signOut: "Sign out"
31
24
  };
32
- function themeToVars(theme) {
33
- const out = {};
34
- for (const key of Object.keys(VAR)) {
35
- const value = theme[key];
36
- if (value) out[VAR[key]] = value;
37
- }
38
- return out;
39
- }
40
- function BowlosTheme({
41
- theme = {},
42
- className,
43
- style,
44
- children
25
+ function AuthForm({
26
+ account,
27
+ labels,
28
+ className
45
29
  }) {
46
- return /* @__PURE__ */ jsx("div", { className, style: { ...themeToVars(theme), ...style }, children });
47
- }
48
- function token(key) {
49
- return `var(${VAR[key]}, ${BOWLOS_DEFAULT_THEME[key]})`;
50
- }
51
- function styles() {
52
- return {
53
- // containers
54
- card: {
55
- fontFamily: token("fontFamily"),
56
- color: token("colorText"),
57
- background: token("colorBg"),
58
- border: `1px solid ${token("colorBorder")}`,
59
- borderRadius: token("radius"),
60
- padding: "1.25rem",
61
- display: "flex",
62
- flexDirection: "column",
63
- gap: "0.75rem",
64
- maxWidth: 380
65
- },
66
- panel: {
67
- fontFamily: token("fontFamily"),
68
- color: token("colorText"),
69
- background: token("colorBg"),
70
- border: `1px solid ${token("colorBorder")}`,
71
- borderRadius: token("radius"),
72
- padding: "1rem 1.25rem",
73
- display: "flex",
74
- flexDirection: "column",
75
- gap: "0.625rem"
76
- },
77
- // text
78
- heading: { margin: "0 0 0.25rem", fontSize: "1.25rem" },
79
- sectionTitle: {
80
- margin: "0 0 0.5rem",
81
- fontSize: "0.8rem",
82
- fontWeight: 700,
83
- letterSpacing: "0.04em",
84
- textTransform: "uppercase",
85
- color: token("colorMuted")
86
- },
87
- body: { margin: 0, color: token("colorText") },
88
- meta: { margin: 0, fontSize: "0.9rem", color: token("colorMuted"), minHeight: "1.2em" },
89
- muted: { margin: 0, fontSize: "0.9rem", color: token("colorMuted") },
90
- error: { margin: 0, color: token("colorError"), fontSize: "0.9rem" },
91
- // form
92
- label: {
93
- display: "flex",
94
- flexDirection: "column",
95
- gap: "0.25rem",
96
- fontSize: "0.85rem",
97
- color: token("colorMuted")
98
- },
99
- input: {
100
- padding: "0.5rem 0.625rem",
101
- fontSize: "1rem",
102
- color: token("colorText"),
103
- background: token("colorSurface"),
104
- border: `1px solid ${token("colorBorder")}`,
105
- borderRadius: token("radius")
106
- },
107
- // layout
108
- row: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" },
109
- rowBetween: { display: "flex", gap: "0.5rem", justifyContent: "space-between", alignItems: "center" },
110
- stack: { display: "flex", flexDirection: "column", gap: "0.75rem" },
111
- // buttons
112
- primaryBtn: {
113
- padding: "0.625rem 1rem",
114
- fontSize: "1rem",
115
- fontWeight: 600,
116
- color: token("colorPrimaryContrast"),
117
- background: token("colorPrimary"),
118
- border: "none",
119
- borderRadius: token("radius"),
120
- cursor: "pointer"
121
- },
122
- ghostBtn: {
123
- padding: "0.625rem 1rem",
124
- fontSize: "1rem",
125
- color: token("colorText"),
126
- background: "transparent",
127
- border: `1px solid ${token("colorBorder")}`,
128
- borderRadius: token("radius"),
129
- cursor: "pointer"
130
- },
131
- linkBtn: {
132
- padding: 0,
133
- fontSize: "0.9rem",
134
- color: token("colorPrimary"),
135
- background: "transparent",
136
- border: "none",
137
- cursor: "pointer",
138
- textDecoration: "underline"
139
- },
140
- // list rows (reservations, memberships, ledger, passes, flash items)
141
- listItem: {
142
- display: "flex",
143
- justifyContent: "space-between",
144
- alignItems: "baseline",
145
- gap: "0.75rem",
146
- padding: "0.625rem 0",
147
- borderTop: `1px solid ${token("colorBorder")}`
148
- },
149
- listTitle: { margin: 0, fontSize: "1rem", fontWeight: 600 },
150
- listMeta: { margin: 0, fontSize: "0.85rem", color: token("colorMuted") },
151
- // badges + prices
152
- badge: {
153
- display: "inline-block",
154
- padding: "0.125rem 0.5rem",
155
- fontSize: "0.75rem",
156
- fontWeight: 600,
157
- color: token("colorMuted"),
158
- background: token("colorSurface"),
159
- border: `1px solid ${token("colorBorder")}`,
160
- borderRadius: "999px",
161
- whiteSpace: "nowrap"
162
- },
163
- priceSale: { fontSize: "1.05rem", fontWeight: 700, color: token("colorText") },
164
- priceStrike: { fontSize: "0.9rem", color: token("colorMuted"), textDecoration: "line-through" },
165
- // flash hero
166
- banner: {
167
- width: "100%",
168
- height: 140,
169
- objectFit: "cover",
170
- borderTopLeftRadius: token("radius"),
171
- borderTopRightRadius: token("radius"),
172
- display: "block"
173
- },
174
- countdown: { margin: 0, fontSize: "0.95rem", fontWeight: 600, color: token("colorPrimary") }
30
+ const t = { ...DEFAULT_LABELS, ...labels };
31
+ const [mode, setMode] = useState("signIn");
32
+ const [email, setEmail] = useState("");
33
+ const [password, setPassword] = useState("");
34
+ const [fullName, setFullName] = useState("");
35
+ const [busy, setBusy] = useState(false);
36
+ const s = styles();
37
+ async function guard(action) {
38
+ setBusy(true);
39
+ try {
40
+ await action();
41
+ } catch {
42
+ } finally {
43
+ setBusy(false);
44
+ }
45
+ }
46
+ const onAuth = (e) => {
47
+ e.preventDefault();
48
+ void guard(
49
+ () => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
50
+ );
175
51
  };
52
+ const onLink = (e) => {
53
+ e.preventDefault();
54
+ void guard(() => account.link({ fullName, email, marketingOptIn: false }));
55
+ };
56
+ if (account.status === "loading") {
57
+ return /* @__PURE__ */ jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) });
58
+ }
59
+ if (account.status === "authed_no_customer") {
60
+ return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
61
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.linkHeading }),
62
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
63
+ t.name,
64
+ /* @__PURE__ */ jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
65
+ ] }),
66
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
67
+ t.email,
68
+ /* @__PURE__ */ jsx(
69
+ "input",
70
+ {
71
+ type: "email",
72
+ value: email,
73
+ onChange: (e) => setEmail(e.target.value),
74
+ style: s.input,
75
+ required: true
76
+ }
77
+ )
78
+ ] }),
79
+ /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
80
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
81
+ account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
82
+ ] });
83
+ }
84
+ if (account.status === "linked") return null;
85
+ return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
86
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
87
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
88
+ t.email,
89
+ /* @__PURE__ */ jsx(
90
+ "input",
91
+ {
92
+ type: "email",
93
+ value: email,
94
+ onChange: (e) => setEmail(e.target.value),
95
+ style: s.input,
96
+ required: true
97
+ }
98
+ )
99
+ ] }),
100
+ /* @__PURE__ */ jsxs("label", { style: s.label, children: [
101
+ t.password,
102
+ /* @__PURE__ */ jsx(
103
+ "input",
104
+ {
105
+ type: "password",
106
+ value: password,
107
+ onChange: (e) => setPassword(e.target.value),
108
+ style: s.input,
109
+ required: true
110
+ }
111
+ )
112
+ ] }),
113
+ /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
114
+ /* @__PURE__ */ jsx(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ style: s.linkBtn,
119
+ onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
120
+ children: mode === "signIn" ? t.needAccount : t.haveAccount
121
+ }
122
+ ),
123
+ account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
124
+ ] });
176
125
  }
177
- function formatCents(cents) {
178
- return (cents / 100).toLocaleString(void 0, { style: "currency", currency: "USD" });
179
- }
180
- function formatCentsRange(minCents, maxCents) {
181
- return maxCents > minCents ? `${formatCents(minCents)} \u2013 ${formatCents(maxCents)}` : formatCents(minCents);
182
- }
183
- function minutesToTime(min) {
184
- const h = Math.floor(min / 60).toString().padStart(2, "0");
185
- const m = (min % 60).toString().padStart(2, "0");
186
- return `${h}:${m}`;
187
- }
188
- function timeToMinutes(t) {
189
- const [h, m] = t.split(":").map(Number);
190
- return (h ?? 0) * 60 + (m ?? 0);
191
- }
192
- function useCountdown(targetMs) {
193
- const [now, setNow] = useState(null);
194
- useEffect(() => {
195
- if (targetMs === null) return;
196
- setNow(Date.now());
197
- const id = setInterval(() => setNow(Date.now()), 1e3);
198
- return () => clearInterval(id);
199
- }, [targetMs]);
200
- if (now === null || targetMs === null) return null;
201
- const remaining = targetMs - now;
202
- if (remaining <= 0) return { ended: true, label: "" };
203
- return { ended: false, label: humanizeRemaining(remaining) };
204
- }
205
- function humanizeRemaining(ms) {
206
- const totalSec = Math.floor(ms / 1e3);
207
- const d = Math.floor(totalSec / 86400);
208
- const h = Math.floor(totalSec % 86400 / 3600);
209
- const m = Math.floor(totalSec % 3600 / 60);
210
- const s = totalSec % 60;
211
- if (d > 0) return `${d}d ${h}h ${m}m`;
212
- if (h > 0) return `${h}h ${m}m ${s}s`;
213
- if (m > 0) return `${m}m ${s}s`;
214
- return `${s}s`;
126
+ function AuthGate({ children, labels, className }) {
127
+ const account = useAccount();
128
+ if (account.status === "linked" && account.customer) {
129
+ return /* @__PURE__ */ jsx(Fragment, { children: children?.({ customer: account.customer, account }) });
130
+ }
131
+ return /* @__PURE__ */ jsx(AuthForm, { account, labels, className });
215
132
  }
216
- var DEFAULT_LABELS = {
133
+ var DEFAULT_LABELS2 = {
217
134
  heading: "Book",
218
135
  date: "Date",
219
136
  start: "Start time",
137
+ loadingTimes: "Finding times\u2026",
138
+ noTimes: "No times available for this date.",
220
139
  quantity: "Quantity",
140
+ addonsHeading: "Add-ons",
221
141
  name: "Name",
222
142
  email: "Email",
223
- hold: "Book",
143
+ hold: "Book Now",
224
144
  holding: "Booking\u2026",
225
145
  continueToPayment: "Continue to payment",
226
146
  preparing: "Preparing\u2026",
@@ -238,6 +158,23 @@ var DEFAULT_LABELS = {
238
158
  notYou: "Not you?",
239
159
  signInHint: "Sign in to book faster"
240
160
  };
161
+ var COUNT_LABEL = {
162
+ per_unit_per_hour: "Lanes",
163
+ per_person_per_hour: "Bowlers",
164
+ per_game: "Games"
165
+ };
166
+ var ADDON_RATE_SUFFIX = {
167
+ per_person: " / person",
168
+ per_unit: " / unit",
169
+ flat: ""
170
+ };
171
+ function todayISO() {
172
+ const d = /* @__PURE__ */ new Date();
173
+ const y = d.getFullYear();
174
+ const m = String(d.getMonth() + 1).padStart(2, "0");
175
+ const day = String(d.getDate()).padStart(2, "0");
176
+ return `${y}-${m}-${day}`;
177
+ }
241
178
  function BookingFlow({
242
179
  centerId,
243
180
  productId,
@@ -253,25 +190,46 @@ function BookingFlow({
253
190
  labels,
254
191
  className
255
192
  }) {
256
- const t = { ...DEFAULT_LABELS, ...labels };
193
+ const t = { ...DEFAULT_LABELS2, ...labels };
257
194
  const account = useAccount();
258
195
  const signedIn = account.status === "linked" && account.customer !== null;
259
196
  const acctName = account.customer?.fullName ?? "";
260
197
  const acctEmail = account.customer?.email ?? "";
261
198
  const [dateISO, setDateISO] = useState(defaultDateISO);
199
+ useEffect(() => {
200
+ if (!defaultDateISO && dateISO === "") setDateISO(todayISO());
201
+ }, [defaultDateISO, dateISO]);
262
202
  const [startMinuteOfDay, setStartMinuteOfDay] = useState(defaultStartMinuteOfDay);
263
203
  const endMinuteOfDay = startMinuteOfDay + durationMinutes;
264
- const [units, setUnits] = useState(1);
265
- const [fullName, setFullName] = useState("");
266
- const [email, setEmail] = useState("");
204
+ const [count, setCount] = useState(1);
267
205
  const [payMessage, setPayMessage] = useState(null);
206
+ const [addonQtys, setAddonQtys] = useState({});
207
+ const selectedAddons = useMemo(
208
+ () => Object.entries(addonQtys).filter(([, q]) => q > 0).map(([addonId, quantity]) => ({ addonId, quantity })),
209
+ [addonQtys]
210
+ );
211
+ const countArgs = pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count };
268
212
  const availability = useAvailability(
269
213
  { productId, dateISO, startMinuteOfDay, endMinuteOfDay },
270
- { enabled: dateISO !== "" }
214
+ { enabled: dateISO !== "" && signedIn }
271
215
  );
272
216
  const preview = useBookingPreview(
273
- { centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, mode: pricingMode, units },
274
- { enabled: dateISO !== "" }
217
+ {
218
+ centerId,
219
+ productId,
220
+ dateISO,
221
+ startMinuteOfDay,
222
+ endMinuteOfDay,
223
+ mode: pricingMode,
224
+ ...countArgs,
225
+ addons: selectedAddons
226
+ },
227
+ { enabled: dateISO !== "" && signedIn }
228
+ );
229
+ const addons = useAddons({ productId }, { enabled: signedIn });
230
+ const startTimes = useStartTimes(
231
+ { productId, dateISO, durationMinutes, mode: pricingMode },
232
+ { enabled: dateISO !== "" && signedIn }
275
233
  );
276
234
  const flow = useBookingFlow();
277
235
  const onConfirmedRef = useRef(onConfirmed);
@@ -281,6 +239,17 @@ function BookingFlow({
281
239
  onConfirmedRef.current?.(flow.reservation);
282
240
  }
283
241
  }, [flow.status, flow.reservation]);
242
+ useEffect(() => {
243
+ if (typeof window !== "undefined" && (flow.status === "held" || flow.status === "preparingPayment" || flow.status === "awaitingPayment" || flow.status === "confirmed")) {
244
+ window.scrollTo({ top: 0, behavior: "smooth" });
245
+ }
246
+ }, [flow.status]);
247
+ useEffect(() => {
248
+ const opts = startTimes.data;
249
+ if (opts && opts.length > 0 && !opts.includes(startMinuteOfDay)) {
250
+ setStartMinuteOfDay(opts[0]);
251
+ }
252
+ }, [startTimes.data, startMinuteOfDay]);
284
253
  const prepareRef = useRef(flow.preparePayment);
285
254
  prepareRef.current = flow.preparePayment;
286
255
  useEffect(() => {
@@ -296,14 +265,17 @@ function BookingFlow({
296
265
  startMinuteOfDay,
297
266
  endMinuteOfDay,
298
267
  mode: pricingMode,
299
- units,
300
- customer: signedIn ? { fullName: acctName, email: acctEmail, marketingOptIn: false } : { fullName, email, marketingOptIn: false }
268
+ ...pricingMode === "per_person_per_hour" ? { persons: count } : pricingMode === "per_game" ? { games: count } : { units: count },
269
+ addons: selectedAddons,
270
+ // Always the signed-in customer — online booking requires login.
271
+ customer: { fullName: acctName, email: acctEmail, marketingOptIn: false }
301
272
  }),
302
- [centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, units, signedIn, acctName, acctEmail, fullName, email]
273
+ [centerId, productId, dateISO, startMinuteOfDay, endMinuteOfDay, pricingMode, count, selectedAddons, acctName, acctEmail]
303
274
  );
304
275
  const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
305
276
  const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
306
- const unitNoun = units === 1 ? unitLabel.singular : unitLabel.plural;
277
+ const addonList = addons.data ?? [];
278
+ const startOptions = startTimes.data ?? [];
307
279
  const s = styles();
308
280
  if (flow.status === "confirmed") {
309
281
  return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
@@ -350,6 +322,9 @@ function BookingFlow({
350
322
  flow.error && /* @__PURE__ */ jsx("p", { style: s.error, children: flow.error.code })
351
323
  ] });
352
324
  }
325
+ if (!signedIn) {
326
+ return /* @__PURE__ */ jsx(AuthForm, { account, className });
327
+ }
353
328
  const holding = flow.status === "holding";
354
329
  const onSubmit = (e) => {
355
330
  e.preventDefault();
@@ -363,57 +338,78 @@ function BookingFlow({
363
338
  ] }),
364
339
  /* @__PURE__ */ jsxs("label", { style: s.label, children: [
365
340
  t.start,
366
- /* @__PURE__ */ jsx(
367
- "input",
341
+ startTimes.loading ? /* @__PURE__ */ jsx("span", { style: s.meta, children: t.loadingTimes }) : startOptions.length === 0 ? /* @__PURE__ */ jsx("span", { style: s.meta, children: t.noTimes }) : /* @__PURE__ */ jsx(
342
+ "select",
368
343
  {
369
- type: "time",
370
- value: minutesToTime(startMinuteOfDay),
371
- onChange: (e) => setStartMinuteOfDay(timeToMinutes(e.target.value)),
372
- style: s.input
344
+ value: startMinuteOfDay,
345
+ onChange: (e) => setStartMinuteOfDay(Number(e.target.value)),
346
+ style: s.input,
347
+ children: startOptions.map((min) => /* @__PURE__ */ jsx("option", { value: min, children: formatMinuteLabel(min) }, min))
373
348
  }
374
349
  )
375
350
  ] }),
376
351
  /* @__PURE__ */ jsxs("label", { style: s.label, children: [
377
- t.quantity,
352
+ COUNT_LABEL[pricingMode],
378
353
  /* @__PURE__ */ jsx(
379
354
  "input",
380
355
  {
381
356
  type: "number",
382
357
  min: 1,
383
- value: units,
384
- onChange: (e) => setUnits(Math.max(1, Number(e.target.value) || 1)),
358
+ value: count,
359
+ onChange: (e) => setCount(Math.max(1, Number(e.target.value) || 1)),
385
360
  style: s.input
386
361
  }
387
362
  )
388
363
  ] }),
389
- signedIn ? /* @__PURE__ */ jsxs("p", { style: s.meta, children: [
364
+ addonList.length > 0 ? /* @__PURE__ */ jsxs("div", { style: s.stack, children: [
365
+ /* @__PURE__ */ jsx("p", { style: s.sectionTitle, children: t.addonsHeading }),
366
+ addonList.map((addon) => /* @__PURE__ */ jsxs("div", { style: s.rowBetween, children: [
367
+ /* @__PURE__ */ jsxs("span", { style: s.body, children: [
368
+ /* @__PURE__ */ jsx("strong", { children: addon.name }),
369
+ " ",
370
+ /* @__PURE__ */ jsxs("span", { style: s.muted, children: [
371
+ formatCents(addon.priceCents),
372
+ ADDON_RATE_SUFFIX[addon.rateMode]
373
+ ] }),
374
+ addon.description ? /* @__PURE__ */ jsxs("span", { style: s.muted, children: [
375
+ " \xB7 ",
376
+ addon.description
377
+ ] }) : null
378
+ ] }),
379
+ /* @__PURE__ */ jsx(
380
+ "input",
381
+ {
382
+ type: "number",
383
+ min: 0,
384
+ value: addonQtys[addon.id] ?? 0,
385
+ onChange: (e) => setAddonQtys((prev) => ({
386
+ ...prev,
387
+ [addon.id]: Math.max(0, Math.floor(Number(e.target.value) || 0))
388
+ })),
389
+ style: { ...s.input, width: "4.5rem" },
390
+ "aria-label": `${addon.name} quantity`
391
+ }
392
+ )
393
+ ] }, addon.id))
394
+ ] }) : null,
395
+ /* @__PURE__ */ jsxs("p", { style: s.meta, children: [
390
396
  t.bookingAs.replace("{name}", acctName),
391
397
  accountHref ? /* @__PURE__ */ jsxs(Fragment, { children: [
392
398
  " \xB7 ",
393
399
  /* @__PURE__ */ jsx("a", { href: accountHref, style: s.linkBtn, children: t.notYou })
394
400
  ] }) : null
395
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
396
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
397
- t.name,
398
- /* @__PURE__ */ jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
399
- ] }),
400
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
401
- t.email,
402
- /* @__PURE__ */ jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), style: s.input, required: true })
403
- ] }),
404
- accountHref ? /* @__PURE__ */ jsx("a", { href: accountHref, style: s.linkBtn, children: t.signInHint }) : null
405
401
  ] }),
406
402
  /* @__PURE__ */ jsxs("p", { style: s.meta, "aria-live": "polite", children: [
407
- dateISO === "" ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
408
- quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
403
+ dateISO === "" || startOptions.length === 0 ? "" : availability.loading ? t.checkingAvailability : freeUnits !== null ? `${freeUnits} ${freeUnits === 1 ? unitLabel.singular : unitLabel.plural} available` : availability.error ? availability.error.code : "",
404
+ startOptions.length > 0 && quoteCents !== null ? ` \xB7 ${formatCents(quoteCents)}` : ""
409
405
  ] }),
410
406
  /* @__PURE__ */ jsx(
411
407
  "button",
412
408
  {
413
409
  type: "submit",
414
410
  style: s.primaryBtn,
415
- disabled: holding || dateISO === "" || !signedIn && (!fullName || !email),
416
- children: holding ? t.holding : `${t.hold} ${unitNoun}`
411
+ disabled: holding || dateISO === "" || startOptions.length === 0,
412
+ children: holding ? t.holding : t.hold
417
413
  }
418
414
  ),
419
415
  flow.error && /* @__PURE__ */ jsxs("p", { style: s.error, children: [
@@ -423,131 +419,6 @@ function BookingFlow({
423
419
  ] })
424
420
  ] });
425
421
  }
426
- var DEFAULT_LABELS2 = {
427
- signInHeading: "Sign in",
428
- signUpHeading: "Create your account",
429
- linkHeading: "Finish your profile",
430
- loading: "Loading\u2026",
431
- email: "Email",
432
- password: "Password",
433
- name: "Name",
434
- signIn: "Sign in",
435
- signingIn: "Signing in\u2026",
436
- createAccount: "Create account",
437
- haveAccount: "Already have an account? Sign in",
438
- needAccount: "New here? Create an account",
439
- finishProfile: "Save profile",
440
- saving: "Saving\u2026",
441
- signOut: "Sign out"
442
- };
443
- function AuthForm({
444
- account,
445
- labels,
446
- className
447
- }) {
448
- const t = { ...DEFAULT_LABELS2, ...labels };
449
- const [mode, setMode] = useState("signIn");
450
- const [email, setEmail] = useState("");
451
- const [password, setPassword] = useState("");
452
- const [fullName, setFullName] = useState("");
453
- const [busy, setBusy] = useState(false);
454
- const s = styles();
455
- async function guard(action) {
456
- setBusy(true);
457
- try {
458
- await action();
459
- } catch {
460
- } finally {
461
- setBusy(false);
462
- }
463
- }
464
- const onAuth = (e) => {
465
- e.preventDefault();
466
- void guard(
467
- () => mode === "signIn" ? account.signIn(email, password) : account.signUp(email, password)
468
- );
469
- };
470
- const onLink = (e) => {
471
- e.preventDefault();
472
- void guard(() => account.link({ fullName, email, marketingOptIn: false }));
473
- };
474
- if (account.status === "loading") {
475
- return /* @__PURE__ */ jsx("div", { className, style: s.card, children: /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading }) });
476
- }
477
- if (account.status === "authed_no_customer") {
478
- return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onLink, children: [
479
- /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.linkHeading }),
480
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
481
- t.name,
482
- /* @__PURE__ */ jsx("input", { value: fullName, onChange: (e) => setFullName(e.target.value), style: s.input, required: true })
483
- ] }),
484
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
485
- t.email,
486
- /* @__PURE__ */ jsx(
487
- "input",
488
- {
489
- type: "email",
490
- value: email,
491
- onChange: (e) => setEmail(e.target.value),
492
- style: s.input,
493
- required: true
494
- }
495
- )
496
- ] }),
497
- /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.saving : t.finishProfile }),
498
- /* @__PURE__ */ jsx("button", { type: "button", style: s.linkBtn, onClick: () => void account.signOut(), children: t.signOut }),
499
- account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
500
- ] });
501
- }
502
- if (account.status === "linked") return null;
503
- return /* @__PURE__ */ jsxs("form", { className, style: s.card, onSubmit: onAuth, children: [
504
- /* @__PURE__ */ jsx("h3", { style: s.heading, children: mode === "signIn" ? t.signInHeading : t.signUpHeading }),
505
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
506
- t.email,
507
- /* @__PURE__ */ jsx(
508
- "input",
509
- {
510
- type: "email",
511
- value: email,
512
- onChange: (e) => setEmail(e.target.value),
513
- style: s.input,
514
- required: true
515
- }
516
- )
517
- ] }),
518
- /* @__PURE__ */ jsxs("label", { style: s.label, children: [
519
- t.password,
520
- /* @__PURE__ */ jsx(
521
- "input",
522
- {
523
- type: "password",
524
- value: password,
525
- onChange: (e) => setPassword(e.target.value),
526
- style: s.input,
527
- required: true
528
- }
529
- )
530
- ] }),
531
- /* @__PURE__ */ jsx("button", { type: "submit", style: s.primaryBtn, disabled: busy, children: busy ? t.signingIn : mode === "signIn" ? t.signIn : t.createAccount }),
532
- /* @__PURE__ */ jsx(
533
- "button",
534
- {
535
- type: "button",
536
- style: s.linkBtn,
537
- onClick: () => setMode(mode === "signIn" ? "signUp" : "signIn"),
538
- children: mode === "signIn" ? t.needAccount : t.haveAccount
539
- }
540
- ),
541
- account.error && /* @__PURE__ */ jsx("p", { style: s.error, children: account.error.code })
542
- ] });
543
- }
544
- function AuthGate({ children, labels, className }) {
545
- const account = useAccount();
546
- if (account.status === "linked" && account.customer) {
547
- return /* @__PURE__ */ jsx(Fragment, { children: children?.({ customer: account.customer, account }) });
548
- }
549
- return /* @__PURE__ */ jsx(AuthForm, { account, labels, className });
550
- }
551
422
  var DEFAULT_LABELS3 = {
552
423
  signIn: "Sign in",
553
424
  signOut: "Sign out",
@@ -874,7 +745,105 @@ function When({ ms }) {
874
745
  }, [ms]);
875
746
  return /* @__PURE__ */ jsx(Fragment, { children: text ?? "" });
876
747
  }
748
+ var DEFAULT_LABELS7 = {
749
+ heading: "What would you like to book?",
750
+ loading: "Loading\u2026",
751
+ empty: "Nothing is available to book online right now.",
752
+ bowling: "Bowling",
753
+ otherAttractions: "Other attractions",
754
+ events: "Events",
755
+ packages: "Packages",
756
+ memberships: "Memberships",
757
+ gamePasses: "Game passes",
758
+ select: "Select",
759
+ minutesAbbrev: "min",
760
+ perMonth: "/mo"
761
+ };
762
+ function BookingCatalog({ brandId, centerId, onSelect, labels, className }) {
763
+ const t = { ...DEFAULT_LABELS7, ...labels };
764
+ const s = styles();
765
+ const products = useProducts({ centerId });
766
+ const events = useEvents({ centerId });
767
+ const packages = usePackages({ brandId, centerId });
768
+ const memberships = usePublicMemberships({ centerId });
769
+ const gameCards = useGameCards({ brandId, centerId });
770
+ const reads = [products, events, packages, memberships, gameCards];
771
+ const anyLoading = reads.some((r) => r.loading && !r.data);
772
+ const productRows = products.data ?? [];
773
+ const bowling = productRows.filter((p) => p.attractionTypeKey === "bowling").map((p) => ({ kind: "product", ...p }));
774
+ const other = productRows.filter((p) => p.attractionTypeKey !== "bowling").map((p) => ({ kind: "product", ...p }));
775
+ const eventOffers = (events.data ?? []).map((e) => ({
776
+ kind: "event",
777
+ id: e.id,
778
+ name: e.name,
779
+ date: e.date,
780
+ description: e.description
781
+ }));
782
+ const packageOffers = (packages.data ?? []).map((p) => ({
783
+ kind: "package",
784
+ id: p.id,
785
+ name: p.name,
786
+ priceCents: p.basePriceCents,
787
+ description: p.description
788
+ }));
789
+ const membershipOffers = (memberships.data ?? []).map((m) => ({
790
+ kind: "membership",
791
+ id: m.id,
792
+ name: m.name,
793
+ priceCents: m.recurringPriceCents,
794
+ description: m.description
795
+ }));
796
+ const gameCardOffers = (gameCards.data ?? []).map((g) => ({
797
+ kind: "gamecard",
798
+ id: g.id,
799
+ name: g.name,
800
+ priceCents: g.priceCents,
801
+ description: g.description
802
+ }));
803
+ const sections = [
804
+ { title: t.bowling, offers: bowling },
805
+ { title: t.otherAttractions, offers: other },
806
+ { title: t.events, offers: eventOffers },
807
+ { title: t.packages, offers: packageOffers },
808
+ { title: t.memberships, offers: membershipOffers },
809
+ { title: t.gamePasses, offers: gameCardOffers }
810
+ ].filter((sec) => sec.offers.length > 0);
811
+ let body;
812
+ if (anyLoading) {
813
+ body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.loading });
814
+ } else if (sections.length === 0) {
815
+ body = /* @__PURE__ */ jsx("p", { style: s.muted, children: t.empty });
816
+ } else {
817
+ body = sections.map((sec) => /* @__PURE__ */ jsxs("section", { style: { marginTop: "0.5rem" }, children: [
818
+ /* @__PURE__ */ jsx("h4", { style: s.sectionTitle, children: sec.title }),
819
+ sec.offers.map((offer) => /* @__PURE__ */ jsxs("div", { style: s.listItem, children: [
820
+ /* @__PURE__ */ jsxs("div", { children: [
821
+ /* @__PURE__ */ jsx("p", { style: s.listTitle, children: offer.name }),
822
+ /* @__PURE__ */ jsx("p", { style: s.listMeta, children: subtitle(offer, t) })
823
+ ] }),
824
+ /* @__PURE__ */ jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(offer), children: t.select })
825
+ ] }, `${offer.kind}:${offer.id}`))
826
+ ] }, sec.title));
827
+ }
828
+ return /* @__PURE__ */ jsxs("div", { className, style: s.card, children: [
829
+ /* @__PURE__ */ jsx("h3", { style: s.heading, children: t.heading }),
830
+ body
831
+ ] });
832
+ }
833
+ function subtitle(offer, t) {
834
+ switch (offer.kind) {
835
+ case "product":
836
+ return `${offer.attractionName} \xB7 ${offer.durationMinutes} ${t.minutesAbbrev}`;
837
+ case "event":
838
+ return offer.date;
839
+ case "membership":
840
+ return `${formatCents(offer.priceCents)}${t.perMonth}`;
841
+ case "package":
842
+ case "gamecard":
843
+ return formatCents(offer.priceCents);
844
+ }
845
+ }
877
846
 
878
- export { AccountDashboard, AccountMenu, AuthForm, AuthGate, BOWLOS_DEFAULT_THEME, BookingFlow, BowlosTheme, FlashSale, FlashSaleIndex, formatCents, formatCentsRange };
847
+ export { AccountDashboard, AccountMenu, AuthForm, AuthGate, BookingCatalog, BookingFlow, FlashSale, FlashSaleIndex };
879
848
  //# sourceMappingURL=components.js.map
880
849
  //# sourceMappingURL=components.js.map