@bowlos/reservations 0.35.0 → 0.41.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 (79) hide show
  1. package/AGENTS.md +300 -0
  2. package/HEADLESS.md +716 -11
  3. package/README.md +363 -2
  4. package/dist/{data-qw8P3JW3.d.cts → account-DEX2Lr78.d.cts} +218 -3
  5. package/dist/{data-qw8P3JW3.d.ts → account-DEX2Lr78.d.ts} +218 -3
  6. package/dist/booking-change-4DGu-B08.d.ts +1282 -0
  7. package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
  8. package/dist/{chunk-UN5E6UEZ.js → chunk-44WKP6MW.js} +38 -7
  9. package/dist/chunk-44WKP6MW.js.map +1 -0
  10. package/dist/{chunk-MMSVM3QS.js → chunk-BWJHRJN6.js} +75 -187
  11. package/dist/chunk-BWJHRJN6.js.map +1 -0
  12. package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
  13. package/dist/chunk-FMFHNBDH.js.map +1 -0
  14. package/dist/chunk-I37IJNYU.js +139 -0
  15. package/dist/chunk-I37IJNYU.js.map +1 -0
  16. package/dist/chunk-VJIS56OO.js +717 -0
  17. package/dist/chunk-VJIS56OO.js.map +1 -0
  18. package/dist/{chunk-SMPDCDMB.js → chunk-YAXBZJMI.js} +3 -3
  19. package/dist/chunk-YAXBZJMI.js.map +1 -0
  20. package/dist/cli.cjs +34 -6
  21. package/dist/cli.cjs.map +1 -1
  22. package/dist/components.cjs +1596 -4
  23. package/dist/components.cjs.map +1 -1
  24. package/dist/components.d.cts +208 -7
  25. package/dist/components.d.ts +208 -7
  26. package/dist/components.js +1046 -8
  27. package/dist/components.js.map +1 -1
  28. package/dist/index.cjs +299 -6
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +56 -5
  31. package/dist/index.d.ts +56 -5
  32. package/dist/index.js +77 -5
  33. package/dist/index.js.map +1 -1
  34. package/dist/payments.cjs +203 -0
  35. package/dist/payments.cjs.map +1 -1
  36. package/dist/payments.d.cts +16 -2
  37. package/dist/payments.d.ts +16 -2
  38. package/dist/payments.js +78 -2
  39. package/dist/payments.js.map +1 -1
  40. package/dist/{react-C2V1kXnO.d.ts → react-CrRciA7I.d.ts} +2 -2
  41. package/dist/{react-DtncBQ3b.d.cts → react-QJrsaOnN.d.cts} +2 -2
  42. package/dist/react.cjs +801 -30
  43. package/dist/react.cjs.map +1 -1
  44. package/dist/react.d.cts +150 -7
  45. package/dist/react.d.ts +150 -7
  46. package/dist/react.js +72 -4
  47. package/dist/react.js.map +1 -1
  48. package/package.json +10 -3
  49. package/templates/center-site/README.md +5 -0
  50. package/templates/center-site/app/account/game-cards/page.tsx +17 -0
  51. package/templates/center-site/app/account/layout.tsx +16 -0
  52. package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
  53. package/templates/center-site/app/account/memberships/page.tsx +33 -0
  54. package/templates/center-site/app/account/orders/page.tsx +17 -0
  55. package/templates/center-site/app/account/page.tsx +14 -0
  56. package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
  57. package/templates/center-site/app/account/privacy/page.tsx +17 -0
  58. package/templates/center-site/app/account/profile/page.tsx +45 -0
  59. package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
  60. package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
  61. package/templates/center-site/app/account/reservations/page.tsx +35 -0
  62. package/templates/center-site/app/account/security/page.tsx +17 -0
  63. package/templates/center-site/app/book/page.tsx +11 -23
  64. package/templates/center-site/app/catalog/page.tsx +21 -12
  65. package/templates/center-site/app/events/[slug]/page.tsx +130 -0
  66. package/templates/center-site/app/events/page.tsx +57 -0
  67. package/templates/center-site/app/pay/[token]/page.tsx +53 -0
  68. package/templates/center-site/app/site-header.tsx +1 -0
  69. package/templates/center-site/lib/reservation.ts +14 -0
  70. package/templates/center-site/package.json +1 -1
  71. package/templates/center-site/tsconfig.json +7 -9
  72. package/dist/account-BJ5UjC0r.d.ts +0 -165
  73. package/dist/account-QoFg8-i1.d.cts +0 -165
  74. package/dist/catalog-CGitz1PG.d.ts +0 -221
  75. package/dist/catalog-p9cwB6Qv.d.cts +0 -221
  76. package/dist/chunk-MMSVM3QS.js.map +0 -1
  77. package/dist/chunk-SMPDCDMB.js.map +0 -1
  78. package/dist/chunk-UN5E6UEZ.js.map +0 -1
  79. package/dist/chunk-Y3YSDO3H.js.map +0 -1
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@bowlos/reservations",
3
- "version": "0.35.0",
3
+ "version": "0.41.0",
4
4
  "description": "BowlOS Reservations SDK — headless client + React hooks for the Module 14 public API gateway. White-label booking, account, and flash-sale reads for third-party-hosted center sites.",
5
5
  "license": "MIT",
6
6
  "author": "BowlOS",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/wormwood806108/bowlos.git",
10
+ "directory": "packages/reservations"
11
+ },
7
12
  "keywords": [
8
13
  "bowlos",
9
14
  "bowling",
@@ -19,7 +24,8 @@
19
24
  "files": [
20
25
  "dist",
21
26
  "templates",
22
- "HEADLESS.md"
27
+ "HEADLESS.md",
28
+ "AGENTS.md"
23
29
  ],
24
30
  "main": "./dist/index.cjs",
25
31
  "module": "./dist/index.js",
@@ -75,7 +81,8 @@
75
81
  "lint": "echo \"reservations lint deferred until ESLint workspace plumbing lands\"",
76
82
  "typecheck": "tsc --noEmit",
77
83
  "test": "echo \"reservations tests run via the root vitest config (packages/**/*.test.{ts,tsx})\"",
78
- "prepublishOnly": "npm run build"
84
+ "prepublishOnly": "npm run build",
85
+ "release:gate": "node scripts/release-gate.mjs"
79
86
  },
80
87
  "peerDependencies": {
81
88
  "react": ">=18.0.0",
@@ -84,3 +84,8 @@ key and a connected Stripe test account:
84
84
  site would discover them via `listPublicCenters` / `listPublicProducts` (also on the gateway).
85
85
  - Versions mirror the BowlOS web app (Next 16.2.4, React 19.2, `@stripe/*` 9.4 / 6.3). Bump as you
86
86
  like — `@bowlos/reservations` only requires React as a peer.
87
+
88
+ Events: `app/events/page.tsx` follows all Brand cursor pages (including empty
89
+ filtered pages), or reads the configured Center. Links use `/events/<slug>`.
90
+ Implement the event detail destination with `useEventOffer` and your ticket or
91
+ reservation funnel before launching; this template does not yet include that page.
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { AuthGate, AccountDashboard } from "@bowlos/reservations/components";
3
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
4
+
5
+ export default function Page() {
6
+ return (
7
+ <main>
8
+ <AuthGate>
9
+ {() => (
10
+ <>
11
+ <AccountDashboard brandId={BRAND_ID} sections={["gameCards"]} />
12
+ </>
13
+ )}
14
+ </AuthGate>
15
+ </main>
16
+ );
17
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ export default function AccountLayout({ children }: { children: ReactNode }) {
3
+ return (
4
+ <>
5
+ <nav aria-label="Account">
6
+ <a href="/account">Overview</a> · <a href="/account/profile">Profile</a> ·{" "}
7
+ <a href="/account/payment-methods">Payment methods</a> ·{" "}
8
+ <a href="/account/security">Security</a> · <a href="/account/memberships">Memberships</a> ·{" "}
9
+ <a href="/account/reservations">Reservations</a> ·{" "}
10
+ <a href="/account/game-cards">Game cards</a> · <a href="/account/orders">Orders</a> ·{" "}
11
+ <a href="/account/privacy">Privacy</a> · <a href="/events">Events</a>
12
+ </nav>
13
+ {children}
14
+ </>
15
+ );
16
+ }
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useParams } from "next/navigation";
3
+ import { AuthGate, MembershipDetail } from "@bowlos/reservations/components";
4
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
5
+ export default function Page() {
6
+ const { id } = useParams<{ id: string }>();
7
+ return (
8
+ <main>
9
+ <AuthGate>
10
+ {() => (
11
+ <>
12
+ <MembershipDetail
13
+ brandId={BRAND_ID}
14
+ centerId={CENTER_ID}
15
+ membershipId={id}
16
+ returnUrl={typeof window === "undefined" ? "" : window.location.href}
17
+ />
18
+ </>
19
+ )}
20
+ </AuthGate>
21
+ </main>
22
+ );
23
+ }
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { AuthGate } from "@bowlos/reservations/components";
3
+ import { useMyMemberships } from "@bowlos/reservations/react";
4
+ import { BRAND_ID } from "@/lib/bowlos";
5
+ export default function Page() {
6
+ return (
7
+ <AuthGate>
8
+ {() => (
9
+ <>
10
+ <Memberships />
11
+ </>
12
+ )}
13
+ </AuthGate>
14
+ );
15
+ }
16
+ function Memberships() {
17
+ const q = useMyMemberships<Array<{ id: string; templateName: string }>>({ brandId: BRAND_ID });
18
+ return (
19
+ <main>
20
+ <h1>Memberships</h1>
21
+ {q.loading && <p role="status">Loading…</p>}
22
+ {q.error && <p role="alert">{q.error.message}</p>}
23
+ {q.data?.length === 0 && <p>No memberships.</p>}
24
+ <ul>
25
+ {q.data?.map((m) => (
26
+ <li key={m.id}>
27
+ <a href={`/account/memberships/${encodeURIComponent(m.id)}`}>{m.templateName}</a>
28
+ </li>
29
+ ))}
30
+ </ul>
31
+ </main>
32
+ );
33
+ }
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { AuthGate, AccountDashboard } from "@bowlos/reservations/components";
3
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
4
+
5
+ export default function Page() {
6
+ return (
7
+ <main>
8
+ <AuthGate>
9
+ {() => (
10
+ <>
11
+ <AccountDashboard brandId={BRAND_ID} sections={["eventOrders", "packageOrders"]} />
12
+ </>
13
+ )}
14
+ </AuthGate>
15
+ </main>
16
+ );
17
+ }
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useState } from "react";
2
3
  import { AccountDashboard } from "@bowlos/reservations/components";
3
4
  import { BRAND_ID } from "../../lib/bowlos";
4
5
 
@@ -10,9 +11,22 @@ import { BRAND_ID } from "../../lib/bowlos";
10
11
  * `app/book/page.tsx`, which drives the lower-level hooks by hand.
11
12
  */
12
13
  export default function AccountPage() {
14
+ const [token, setToken] = useState("");
13
15
  return (
14
16
  <main>
15
17
  <h1>My account</h1>
18
+ <form action={token ? `/pay/${encodeURIComponent(token)}` : undefined}>
19
+ <label>
20
+ Pay link token
21
+ <input
22
+ required
23
+ value={token}
24
+ onChange={(e) => setToken(e.target.value.trim())}
25
+ autoComplete="off"
26
+ />
27
+ </label>
28
+ <button disabled={!token}>Open pay link</button>
29
+ </form>
16
30
  <AccountDashboard brandId={BRAND_ID} />
17
31
  </main>
18
32
  );
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { AuthGate, SavedCards } from "@bowlos/reservations/components";
3
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
4
+ import { AddCardForm } from "@bowlos/reservations/payments";
5
+ export default function Page() {
6
+ return (
7
+ <main>
8
+ <AuthGate>
9
+ {() => (
10
+ <>
11
+ <SavedCards
12
+ brandId={BRAND_ID}
13
+ centerId={CENTER_ID}
14
+ renderAddCard={(onAdded) => (
15
+ <AddCardForm brandId={BRAND_ID} centerId={CENTER_ID} onAdded={onAdded} />
16
+ )}
17
+ />
18
+ </>
19
+ )}
20
+ </AuthGate>
21
+ </main>
22
+ );
23
+ }
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { AuthGate, PrivacyCenter } from "@bowlos/reservations/components";
3
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
4
+
5
+ export default function Page() {
6
+ return (
7
+ <main>
8
+ <AuthGate>
9
+ {() => (
10
+ <>
11
+ <PrivacyCenter brandId={BRAND_ID} supportHref="/account/profile#support" />
12
+ </>
13
+ )}
14
+ </AuthGate>
15
+ </main>
16
+ );
17
+ }
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { AuthGate, ProfileForm, CommunicationPrefs } from "@bowlos/reservations/components";
3
+ import { useState } from "react";
4
+ import { useSubmitSupportRequest } from "@bowlos/reservations/react";
5
+ import { BRAND_ID } from "@/lib/bowlos";
6
+
7
+ export default function Page() {
8
+ return (
9
+ <main>
10
+ <AuthGate>
11
+ {() => (
12
+ <>
13
+ <ProfileForm brandId={BRAND_ID} />
14
+ <CommunicationPrefs brandId={BRAND_ID} />
15
+ <Support />
16
+ </>
17
+ )}
18
+ </AuthGate>
19
+ </main>
20
+ );
21
+ }
22
+
23
+ function Support() {
24
+ const [message, setMessage] = useState("");
25
+ const request = useSubmitSupportRequest();
26
+ return (
27
+ <section id="support" aria-label="Support">
28
+ <h2>Contact support</h2>
29
+ <form
30
+ onSubmit={(e) => {
31
+ e.preventDefault();
32
+ void request.run({ brandId: BRAND_ID, message }).catch(() => {});
33
+ }}
34
+ >
35
+ <label>
36
+ How can we help?
37
+ <textarea required value={message} onChange={(e) => setMessage(e.target.value)} />
38
+ </label>
39
+ <button disabled={request.loading}>Send request</button>
40
+ </form>
41
+ {request.error && <p role="alert">{request.error.message}</p>}
42
+ {request.data && <p role="status">Request sent. The center will contact you.</p>}
43
+ </section>
44
+ );
45
+ }
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { useParams } from "next/navigation";
3
+ import { AuthGate, BookingChange } from "@bowlos/reservations/components";
4
+ import { BowlosPaymentForm } from "@bowlos/reservations/payments";
5
+ import { useMyReservationDetail } from "@bowlos/reservations/react";
6
+ import { BRAND_ID } from "@/lib/bowlos";
7
+ import type { ReservationDetail } from "@/lib/reservation";
8
+ export default function Page() {
9
+ return (
10
+ <AuthGate>
11
+ {() => (
12
+ <>
13
+ <Change />
14
+ </>
15
+ )}
16
+ </AuthGate>
17
+ );
18
+ }
19
+ function Change() {
20
+ const { displayId } = useParams<{ displayId: string }>();
21
+ const q = useMyReservationDetail<ReservationDetail>({ brandId: BRAND_ID, displayId });
22
+ return (
23
+ <main>
24
+ <button onClick={() => void q.refetch()}>Reload reservation</button>
25
+ {q.loading && <p role="status">Loading…</p>}
26
+ {q.error && <p role="alert">{q.error.message}</p>}
27
+ {q.data && (
28
+ <BookingChange
29
+ brandId={BRAND_ID}
30
+ centerId={q.data.center.id}
31
+ reservationId={q.data.id}
32
+ expectedVersion={q.data.version}
33
+ initial={{ ...q.data, units: q.data.units ?? 1, persons: q.data.persons ?? 1 }}
34
+ renderPayment={(p, onPaid) => (
35
+ <BowlosPaymentForm
36
+ paymentIntent={{ ...p, connectedAccountId: p.stripeAccount }}
37
+ publishableKey={p.publishableKey}
38
+ amountCents={p.amountCents}
39
+ onPaid={onPaid}
40
+ />
41
+ )}
42
+ />
43
+ )}
44
+ </main>
45
+ );
46
+ }
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useParams } from "next/navigation";
3
+ import { AuthGate, AddToWalletButtons } from "@bowlos/reservations/components";
4
+ import { useMyReservationDetail } from "@bowlos/reservations/react";
5
+ import { BRAND_ID, formatCents } from "@/lib/bowlos";
6
+ import type { ReservationDetail } from "@/lib/reservation";
7
+ export default function Page() {
8
+ return (
9
+ <AuthGate>
10
+ {() => (
11
+ <>
12
+ <Detail />
13
+ </>
14
+ )}
15
+ </AuthGate>
16
+ );
17
+ }
18
+ function Detail() {
19
+ const { displayId } = useParams<{ displayId: string }>();
20
+ const q = useMyReservationDetail<ReservationDetail>({ brandId: BRAND_ID, displayId });
21
+ return (
22
+ <main>
23
+ <h1>Reservation</h1>
24
+ {q.loading && <p role="status">Loading…</p>}
25
+ {q.error && <p role="alert">{q.error.message}</p>}
26
+ {q.data && (
27
+ <>
28
+ <h2>{q.data.product.name}</h2>
29
+ <p>
30
+ {q.data.displayId} — {q.data.dateISO} — {q.data.status}
31
+ </p>
32
+ <p>{formatCents(q.data.snapshot.finalCents)}</p>
33
+ <a href={`/account/reservations/${encodeURIComponent(displayId)}/change`}>
34
+ Change reservation
35
+ </a>
36
+ <AddToWalletButtons brandId={BRAND_ID} kind="reservation" id={q.data.id} />
37
+ </>
38
+ )}
39
+ </main>
40
+ );
41
+ }
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { AuthGate } from "@bowlos/reservations/components";
3
+ import { useMyReservations } from "@bowlos/reservations/react";
4
+ import { BRAND_ID } from "@/lib/bowlos";
5
+ export default function Page() {
6
+ return (
7
+ <AuthGate>
8
+ {() => (
9
+ <>
10
+ <Reservations />
11
+ </>
12
+ )}
13
+ </AuthGate>
14
+ );
15
+ }
16
+ function Reservations() {
17
+ const q = useMyReservations<Array<{ displayId: string; dateISO: string }>>({ brandId: BRAND_ID });
18
+ return (
19
+ <main>
20
+ <h1>Reservations</h1>
21
+ {q.loading && <p role="status">Loading…</p>}
22
+ {q.error && <p role="alert">{q.error.message}</p>}
23
+ {q.data?.length === 0 && <p>No reservations.</p>}
24
+ <ul>
25
+ {q.data?.map((r) => (
26
+ <li key={r.displayId}>
27
+ <a href={`/account/reservations/${encodeURIComponent(r.displayId)}`}>
28
+ {r.displayId} — {r.dateISO}
29
+ </a>
30
+ </li>
31
+ ))}
32
+ </ul>
33
+ </main>
34
+ );
35
+ }
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { AuthGate, ChangePasswordForm } from "@bowlos/reservations/components";
3
+ import { BRAND_ID, CENTER_ID } from "@/lib/bowlos";
4
+
5
+ export default function Page() {
6
+ return (
7
+ <main>
8
+ <AuthGate>
9
+ {() => (
10
+ <>
11
+ <ChangePasswordForm />
12
+ </>
13
+ )}
14
+ </AuthGate>
15
+ </main>
16
+ );
17
+ }
@@ -36,8 +36,6 @@ function BookInner() {
36
36
  const [startMinuteOfDay, setStartMinuteOfDay] = useState(18 * 60); // 6:00 PM
37
37
  const endMinuteOfDay = startMinuteOfDay + 60;
38
38
  const [units, setUnits] = useState(1);
39
- const [fullName, setFullName] = useState("");
40
- const [email, setEmail] = useState("");
41
39
 
42
40
  const availability = useAvailability({ productId, dateISO, startMinuteOfDay, endMinuteOfDay });
43
41
  const preview = useBookingPreview({
@@ -70,19 +68,18 @@ function BookInner() {
70
68
  endMinuteOfDay,
71
69
  mode: "per_unit_per_hour",
72
70
  units,
73
- customer: signedIn
74
- ? {
75
- fullName: account.customer?.fullName ?? "",
76
- email: account.customer?.email ?? "",
77
- marketingOptIn: false,
78
- }
79
- : { fullName, email, marketingOptIn: false },
71
+ customer: {
72
+ fullName: account.customer?.fullName ?? "",
73
+ email: account.customer?.email ?? "",
74
+ marketingOptIn: false,
75
+ },
80
76
  }),
81
- [productId, dateISO, startMinuteOfDay, endMinuteOfDay, units, signedIn, account.customer, fullName, email],
77
+ [productId, dateISO, startMinuteOfDay, endMinuteOfDay, units, account.customer],
82
78
  );
83
79
 
84
80
  async function onBook(e: FormEvent) {
85
81
  e.preventDefault();
82
+ if (!signedIn) return;
86
83
  await flow.startHold(bookingArgs);
87
84
  }
88
85
 
@@ -156,18 +153,9 @@ function BookInner() {
156
153
  Booking as <strong>{account.customer?.fullName}</strong>.
157
154
  </p>
158
155
  ) : (
159
- <>
160
- <label>
161
- Name <input value={fullName} onChange={(e) => setFullName(e.target.value)} required />
162
- </label>
163
- <label>
164
- Email{" "}
165
- <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
166
- </label>
167
- <p style={{ fontSize: "0.85rem" }}>
168
- <a href="/account">Sign in to book faster</a>
169
- </p>
170
- </>
156
+ <p style={{ fontSize: "0.85rem" }}>
157
+ <a href="/account">Sign in or create an account</a> to book.
158
+ </p>
171
159
  )}
172
160
 
173
161
  <p aria-live="polite">
@@ -189,7 +177,7 @@ function BookInner() {
189
177
  : ""}
190
178
  </p>
191
179
 
192
- <button type="submit" disabled={holding || (!signedIn && (!fullName || !email))}>
180
+ <button type="submit" disabled={holding || !signedIn}>
193
181
  {holding ? "Booking…" : "Book my lane"}
194
182
  </button>
195
183
  </form>
@@ -1,29 +1,38 @@
1
1
  "use client";
2
2
  import { useRouter } from "next/navigation";
3
- import { BookingCatalog, type CatalogOffer } from "@bowlos/reservations/components";
4
- import { BRAND_ID, CENTER_ID, DEMO_PRODUCT_ID } from "../../lib/bowlos";
3
+ import { BookingCatalog, type CatalogItem } from "@bowlos/reservations/components";
4
+ import { BRAND_ID, CENTER_ID } from "../../lib/bowlos";
5
5
 
6
6
  /**
7
7
  * The catalog landing — "what would you like to book?" Lists everything the
8
8
  * center sells online, grouped by category, and routes each pick:
9
- * • product / event → the booking flow (Phase 1: this demo books the one
10
- * wired product; an event preselects its date)
9
+ * • product → the booking flow
10
+ * • event → the buy stub by event slug (an /events/[slug] page lands with
11
+ * the events index, PLAN §3b / PR-8)
11
12
  * • package / membership / game pass → a buy page (Phase 2 in the SDK; here a
12
13
  * stub that's where your checkout — or the white-label portal — would go)
13
14
  */
14
15
  export default function CatalogPage() {
15
16
  const router = useRouter();
16
17
 
17
- function onSelect(offer: CatalogOffer) {
18
- switch (offer.kind) {
19
- case "product":
20
- router.push(`/book?productId=${offer.id}`);
18
+ function onSelect(item: CatalogItem) {
19
+ const { type, payload } = item.action;
20
+ switch (type) {
21
+ case "book_reservation":
22
+ router.push(`/book?productId=${encodeURIComponent(payload.productId)}`);
21
23
  break;
22
- case "event":
23
- router.push(`/book?productId=${DEMO_PRODUCT_ID}&date=${offer.date}`);
24
+ case "view_event":
25
+ case "buy_ticket":
26
+ router.push(`/buy?kind=event&id=${encodeURIComponent(payload.slug)}`);
24
27
  break;
25
- default:
26
- router.push(`/buy?kind=${offer.kind}&id=${offer.id}`);
28
+ case "buy_package":
29
+ router.push(`/buy?kind=package&id=${encodeURIComponent(payload.packageId)}`);
30
+ break;
31
+ case "buy_membership":
32
+ router.push(`/buy?kind=membership&id=${encodeURIComponent(payload.templateId)}`);
33
+ break;
34
+ case "buy_game_pass":
35
+ router.push(`/buy?kind=game_pass&id=${encodeURIComponent(payload.templateId)}`);
27
36
  }
28
37
  }
29
38
 
@@ -0,0 +1,130 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+ import { useParams } from "next/navigation";
4
+ import type { EventOffer } from "@bowlos/reservations";
5
+ import {
6
+ useEventOffer,
7
+ useEventTicketPreview,
8
+ useEventTicketPurchase,
9
+ } from "@bowlos/reservations/react";
10
+ import { AuthGate } from "@bowlos/reservations/components";
11
+ import { BowlosPaymentForm } from "@bowlos/reservations/payments";
12
+ import { formatCents, STRIPE_PUBLISHABLE_KEY } from "@/lib/bowlos";
13
+
14
+ type Detail = EventOffer & {
15
+ minQuantity: number | null;
16
+ maxQuantity: number | null;
17
+ center: { name: string; timezone: string };
18
+ };
19
+ export default function EventPage() {
20
+ const { slug } = useParams<{ slug: string }>();
21
+ const event = useEventOffer<Detail | null>({ slug });
22
+ return (
23
+ <main>
24
+ {event.loading ? (
25
+ <p role="status">Loading event…</p>
26
+ ) : event.error ? (
27
+ <>
28
+ <p role="alert">
29
+ {event.error.code === "NOT_FOUND" ? "Event not found." : event.error.message}
30
+ </p>
31
+ <button onClick={() => void event.refetch()}>Retry</button>
32
+ </>
33
+ ) : !event.data ? (
34
+ <p>No event available.</p>
35
+ ) : (
36
+ <>
37
+ <h1>{event.data.title}</h1>
38
+ {event.data.subtitle && <p>{event.data.subtitle}</p>}
39
+ <p>{event.data.description}</p>
40
+ <p>
41
+ {event.data.center.name} — <time dateTime={event.data.date}>{event.data.date}</time>
42
+ </p>
43
+ {event.data.purchaseMode === "ticket" ? (
44
+ <AuthGate>
45
+ {() => (
46
+ <>
47
+ <Tickets key={event.data!.id} event={event.data!} />
48
+ </>
49
+ )}
50
+ </AuthGate>
51
+ ) : (
52
+ <a
53
+ href={`/book?productId=${encodeURIComponent(event.data.productId ?? "")}&date=${encodeURIComponent(event.data.date)}`}
54
+ >
55
+ Book this event
56
+ </a>
57
+ )}
58
+ </>
59
+ )}
60
+ <p>
61
+ <a href="/events">All events</a> · <a href="/account">My account</a>
62
+ </p>
63
+ </main>
64
+ );
65
+ }
66
+ function Tickets({ event }: { event: Detail }) {
67
+ const [quantity, setQuantity] = useState(event.minQuantity ?? 1);
68
+ const args = { eventOfferId: event.id, quantity };
69
+ const preview = useEventTicketPreview(args);
70
+ const purchase = useEventTicketPurchase();
71
+ const editing = purchase.status === "idle" || purchase.status === "error";
72
+ return (
73
+ <section aria-label="Tickets">
74
+ {editing && (
75
+ <>
76
+ <label>
77
+ Tickets
78
+ <input
79
+ type="number"
80
+ required
81
+ min={event.minQuantity ?? 1}
82
+ max={event.maxQuantity ?? undefined}
83
+ value={quantity}
84
+ onChange={(e) => setQuantity(Number(e.target.value))}
85
+ />
86
+ </label>
87
+ {preview.loading && <p role="status">Loading price…</p>}
88
+ {preview.error && <p role="alert">{preview.error.message}</p>}
89
+ {preview.data && !preview.loading && !preview.error && (
90
+ <>
91
+ <p>
92
+ {formatCents(preview.data.subtotalCents)} +{" "}
93
+ {formatCents(preview.data.taxTotalCents)} tax +{" "}
94
+ {formatCents(preview.data.reservationFeeCents ?? 0)} fee
95
+ </p>
96
+ <p>Total: {formatCents(preview.data.grandTotalCents)}</p>
97
+ <button
98
+ disabled={
99
+ !Number.isInteger(quantity) ||
100
+ quantity < (event.minQuantity ?? 1) ||
101
+ quantity > (event.maxQuantity ?? Infinity)
102
+ }
103
+ onClick={() => void purchase.start(args).catch(() => {})}
104
+ >
105
+ Buy tickets
106
+ </button>
107
+ </>
108
+ )}
109
+ </>
110
+ )}
111
+ {purchase.status === "awaitingPayment" && purchase.paymentIntent && (
112
+ <BowlosPaymentForm
113
+ paymentIntent={purchase.paymentIntent}
114
+ publishableKey={STRIPE_PUBLISHABLE_KEY}
115
+ amountCents={purchase.paymentIntent.amountCents}
116
+ onPaid={purchase.startPolling}
117
+ />
118
+ )}
119
+ {purchase.error && <p role="alert">{purchase.error.message}</p>}
120
+ <p role="status">
121
+ {purchase.status === "confirmed"
122
+ ? "Tickets confirmed. View your orders in your account."
123
+ : purchase.status}
124
+ </p>
125
+ {["failed", "expired", "error"].includes(purchase.status) && (
126
+ <button onClick={purchase.reset}>Try again</button>
127
+ )}
128
+ </section>
129
+ );
130
+ }