@bowlos/reservations 0.36.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.
- package/AGENTS.md +300 -0
- package/HEADLESS.md +534 -10
- package/README.md +242 -2
- package/dist/{data-BJkB-tvM.d.cts → account-DEX2Lr78.d.cts} +208 -1
- package/dist/{data-BJkB-tvM.d.ts → account-DEX2Lr78.d.ts} +208 -1
- package/dist/booking-change-4DGu-B08.d.ts +1282 -0
- package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
- package/dist/{chunk-3JSVEOKG.js → chunk-44WKP6MW.js} +32 -5
- package/dist/chunk-44WKP6MW.js.map +1 -0
- package/dist/{chunk-TEHRROVY.js → chunk-BWJHRJN6.js} +47 -192
- package/dist/chunk-BWJHRJN6.js.map +1 -0
- package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
- package/dist/chunk-FMFHNBDH.js.map +1 -0
- package/dist/chunk-I37IJNYU.js +139 -0
- package/dist/chunk-I37IJNYU.js.map +1 -0
- package/dist/chunk-VJIS56OO.js +717 -0
- package/dist/chunk-VJIS56OO.js.map +1 -0
- package/dist/cli.cjs +29 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +1595 -2
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +208 -7
- package/dist/components.d.ts +208 -7
- package/dist/components.js +1045 -7
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +270 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -5
- package/dist/index.d.ts +56 -5
- package/dist/index.js +58 -3
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +203 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +16 -2
- package/dist/payments.d.ts +16 -2
- package/dist/payments.js +78 -2
- package/dist/payments.js.map +1 -1
- package/dist/{react-0MyyTtE4.d.ts → react-CrRciA7I.d.ts} +2 -2
- package/dist/{react-CWAG4cW0.d.cts → react-QJrsaOnN.d.cts} +2 -2
- package/dist/react.cjs +758 -27
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +139 -12
- package/dist/react.d.ts +139 -12
- package/dist/react.js +72 -4
- package/dist/react.js.map +1 -1
- package/package.json +8 -2
- package/templates/center-site/README.md +5 -0
- package/templates/center-site/app/account/game-cards/page.tsx +17 -0
- package/templates/center-site/app/account/layout.tsx +16 -0
- package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
- package/templates/center-site/app/account/memberships/page.tsx +33 -0
- package/templates/center-site/app/account/orders/page.tsx +17 -0
- package/templates/center-site/app/account/page.tsx +14 -0
- package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
- package/templates/center-site/app/account/privacy/page.tsx +17 -0
- package/templates/center-site/app/account/profile/page.tsx +45 -0
- package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
- package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
- package/templates/center-site/app/account/reservations/page.tsx +35 -0
- package/templates/center-site/app/account/security/page.tsx +17 -0
- package/templates/center-site/app/events/[slug]/page.tsx +130 -0
- package/templates/center-site/app/events/page.tsx +57 -0
- package/templates/center-site/app/pay/[token]/page.tsx +53 -0
- package/templates/center-site/app/site-header.tsx +1 -0
- package/templates/center-site/lib/reservation.ts +14 -0
- package/templates/center-site/package.json +1 -1
- package/templates/center-site/tsconfig.json +7 -9
- package/dist/account-DfM2COaz.d.ts +0 -210
- package/dist/account-oCvYWmO9.d.cts +0 -210
- package/dist/catalog-DbhdwmnX.d.cts +0 -224
- package/dist/catalog-XkjgPI5C.d.ts +0 -224
- package/dist/chunk-3JSVEOKG.js.map +0 -1
- package/dist/chunk-TEHRROVY.js.map +0 -1
- package/dist/chunk-Y3YSDO3H.js.map +0 -1
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { listBrandEventOffers, listEventOffers, type EventOffer } from "@bowlos/reservations";
|
|
4
|
+
import { useBowlosClient } from "@bowlos/reservations/react";
|
|
5
|
+
import { EventList } from "@bowlos/reservations/components";
|
|
6
|
+
import { BRAND_ID, CENTER_ID } from "../../lib/bowlos";
|
|
7
|
+
|
|
8
|
+
/** Every sellable occurrence with a landing page; one row per scheduled event. */
|
|
9
|
+
export default function EventsPage() {
|
|
10
|
+
const client = useBowlosClient();
|
|
11
|
+
const [items, setItems] = useState<EventOffer[]>([]);
|
|
12
|
+
const [loading, setLoading] = useState(true);
|
|
13
|
+
const [error, setError] = useState<Error | null>(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let active = true;
|
|
16
|
+
async function load() {
|
|
17
|
+
try {
|
|
18
|
+
const all: EventOffer[] = [];
|
|
19
|
+
if (CENTER_ID) {
|
|
20
|
+
all.push(
|
|
21
|
+
...(await listEventOffers(client, {
|
|
22
|
+
centerId: CENTER_ID,
|
|
23
|
+
includeWithoutLandingPage: false,
|
|
24
|
+
})),
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
let cursor: string | undefined;
|
|
28
|
+
for (;;) {
|
|
29
|
+
const page = await listBrandEventOffers(client, {
|
|
30
|
+
brandId: BRAND_ID,
|
|
31
|
+
includeWithoutLandingPage: false,
|
|
32
|
+
cursor,
|
|
33
|
+
});
|
|
34
|
+
if (!active) return;
|
|
35
|
+
all.push(...page.items);
|
|
36
|
+
if (page.isDone) break;
|
|
37
|
+
cursor = page.continueCursor; // Follow even when a filtered page is empty.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (active) setItems(all);
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
if (active) setError(cause instanceof Error ? cause : new Error("Unable to load events."));
|
|
43
|
+
} finally {
|
|
44
|
+
if (active) setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
void load();
|
|
48
|
+
return () => {
|
|
49
|
+
active = false;
|
|
50
|
+
};
|
|
51
|
+
}, [client]);
|
|
52
|
+
return (
|
|
53
|
+
<main>
|
|
54
|
+
<EventList items={items} loading={loading} error={error} />
|
|
55
|
+
</main>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useParams } from "next/navigation";
|
|
4
|
+
import { usePayLink, useCreatePayLinkPayment } from "@bowlos/reservations/react";
|
|
5
|
+
import { BowlosPaymentForm } from "@bowlos/reservations/payments";
|
|
6
|
+
import { BRAND_ID, CENTER_ID, formatCents } from "@/lib/bowlos";
|
|
7
|
+
export default function Page() {
|
|
8
|
+
const { token } = useParams<{ token: string }>();
|
|
9
|
+
const args = { token, brandId: BRAND_ID, centerId: CENTER_ID || undefined };
|
|
10
|
+
const q = usePayLink(args);
|
|
11
|
+
const payment = useCreatePayLinkPayment();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const timer = setInterval(() => void q.refetch(), 2000);
|
|
14
|
+
return () => clearInterval(timer);
|
|
15
|
+
}, [q.refetch]);
|
|
16
|
+
return (
|
|
17
|
+
<main>
|
|
18
|
+
<h1>Pay balance</h1>
|
|
19
|
+
{q.loading && <p role="status">Loading…</p>}
|
|
20
|
+
{q.error && <p role="alert">{q.error.message}</p>}
|
|
21
|
+
{payment.error && <p role="alert">{payment.error.message}</p>}
|
|
22
|
+
{q.data && (
|
|
23
|
+
<>
|
|
24
|
+
<p>
|
|
25
|
+
{q.data.reservation.displayId} — {q.data.reservation.dateISO}
|
|
26
|
+
</p>
|
|
27
|
+
<p role="status">{q.data.status}</p>
|
|
28
|
+
<p>{formatCents(q.data.remainingDueCents)}</p>
|
|
29
|
+
{q.data.status === "pending_payment" && q.data.expiresAt > Date.now() && (
|
|
30
|
+
<>
|
|
31
|
+
{!payment.data ? (
|
|
32
|
+
<button
|
|
33
|
+
disabled={payment.loading}
|
|
34
|
+
onClick={() => void payment.run(args).catch(() => {})}
|
|
35
|
+
>
|
|
36
|
+
Pay balance
|
|
37
|
+
</button>
|
|
38
|
+
) : (
|
|
39
|
+
<BowlosPaymentForm
|
|
40
|
+
paymentIntent={payment.data}
|
|
41
|
+
publishableKey={payment.data.publishableKey}
|
|
42
|
+
amountCents={payment.data.amountCents}
|
|
43
|
+
onPaid={() => void q.refetch()}
|
|
44
|
+
/>
|
|
45
|
+
)}
|
|
46
|
+
</>
|
|
47
|
+
)}
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
<a href="/account">My account</a>
|
|
51
|
+
</main>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -22,6 +22,7 @@ export function SiteHeader() {
|
|
|
22
22
|
<nav style={{ display: "flex", gap: "1rem", fontSize: "0.9rem" }}>
|
|
23
23
|
<Link href="/">Home</Link>
|
|
24
24
|
<Link href="/catalog">Book</Link>
|
|
25
|
+
<Link href="/events">Events</Link>
|
|
25
26
|
<Link href="/flash">Flash sales</Link>
|
|
26
27
|
<Link href="/account">My account</Link>
|
|
27
28
|
</nav>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ReservationDetail {
|
|
2
|
+
id: string;
|
|
3
|
+
displayId: string;
|
|
4
|
+
version: number;
|
|
5
|
+
status: string;
|
|
6
|
+
dateISO: string;
|
|
7
|
+
startMinuteOfDay: number;
|
|
8
|
+
endMinuteOfDay: number;
|
|
9
|
+
units?: number;
|
|
10
|
+
persons?: number;
|
|
11
|
+
center: { id: string; name: string };
|
|
12
|
+
product: { name: string };
|
|
13
|
+
snapshot: { finalCents: number };
|
|
14
|
+
}
|