@bowlos/reservations 0.41.0 → 1.0.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 +20 -5
- package/CHANGELOG.md +22 -0
- package/HEADLESS.md +187 -41
- package/README.md +77 -0
- package/dist/{account-DEX2Lr78.d.cts → account-b8chVpED.d.cts} +892 -14
- package/dist/{account-DEX2Lr78.d.ts → account-b8chVpED.d.ts} +892 -14
- package/dist/booking-change-B-ADuVEz.d.cts +562 -0
- package/dist/booking-change-BrJ-XESC.d.ts +562 -0
- package/dist/chunk-43WZ6TLQ.js +12 -0
- package/dist/chunk-43WZ6TLQ.js.map +1 -0
- package/dist/{chunk-VJIS56OO.js → chunk-CTJODEHR.js} +119 -7
- package/dist/chunk-CTJODEHR.js.map +1 -0
- package/dist/{chunk-YAXBZJMI.js → chunk-EPYGIJRJ.js} +20 -3
- package/dist/chunk-EPYGIJRJ.js.map +1 -0
- package/dist/{chunk-BWJHRJN6.js → chunk-EXEKCMQ2.js} +57 -22
- package/dist/chunk-EXEKCMQ2.js.map +1 -0
- package/dist/{chunk-44WKP6MW.js → chunk-IDRTMFJJ.js} +36 -3
- package/dist/chunk-IDRTMFJJ.js.map +1 -0
- package/dist/{chunk-FMFHNBDH.js → chunk-LFFANITL.js} +98 -12
- package/dist/chunk-LFFANITL.js.map +1 -0
- package/dist/cli.cjs +5 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +670 -131
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +19 -7
- package/dist/components.d.ts +19 -7
- package/dist/components.js +304 -66
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +34 -12
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +10 -2
- package/dist/payments.d.ts +10 -2
- package/dist/payments.js +6 -78
- package/dist/payments.js.map +1 -1
- package/dist/{react-CrRciA7I.d.ts → react-cqGEohr0.d.cts} +4 -2
- package/dist/{react-QJrsaOnN.d.cts → react-s4J-e10i.d.ts} +4 -2
- package/dist/react.cjs +202 -19
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +28 -6
- package/dist/react.d.ts +28 -6
- package/dist/react.js +5 -5
- package/package.json +2 -1
- package/templates/center-site/README.md +1 -0
- package/templates/center-site/app/book/event-reservation-form.tsx +276 -0
- package/templates/center-site/app/book/page.tsx +107 -49
- package/templates/center-site/app/catalog/page.tsx +3 -1
- package/templates/center-site/app/events/[slug]/page.tsx +7 -10
- package/templates/center-site/package.json +1 -1
- package/dist/booking-change-4DGu-B08.d.ts +0 -1282
- package/dist/booking-change-aK6P37FZ.d.cts +0 -1282
- package/dist/chunk-44WKP6MW.js.map +0 -1
- package/dist/chunk-BWJHRJN6.js.map +0 -1
- package/dist/chunk-FMFHNBDH.js.map +0 -1
- package/dist/chunk-VJIS56OO.js.map +0 -1
- package/dist/chunk-YAXBZJMI.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Suspense, useEffect, useMemo, useRef, useState, type FormEvent } from "react";
|
|
2
|
+
import { Suspense, useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from "react";
|
|
3
3
|
import { useSearchParams } from "next/navigation";
|
|
4
4
|
import {
|
|
5
5
|
useAccount,
|
|
6
6
|
useAvailability,
|
|
7
7
|
useBookingPreview,
|
|
8
8
|
useBookingFlow,
|
|
9
|
+
useEventOffer,
|
|
9
10
|
} from "@bowlos/reservations/react";
|
|
10
|
-
import { availableUnitCount, type CreateBookingArgs } from "@bowlos/reservations";
|
|
11
|
+
import { availableUnitCount, type CreateBookingArgs, type EventOfferDetail } from "@bowlos/reservations";
|
|
12
|
+
import { EventReservationForm } from "./event-reservation-form";
|
|
11
13
|
import { BowlosPaymentForm } from "@bowlos/reservations/payments";
|
|
12
14
|
import { CENTER_ID, DEMO_PRODUCT_ID, STRIPE_PUBLISHABLE_KEY, formatCents } from "../../lib/bowlos";
|
|
13
15
|
|
|
@@ -27,26 +29,47 @@ export default function BookPage() {
|
|
|
27
29
|
|
|
28
30
|
function BookInner() {
|
|
29
31
|
const params = useSearchParams();
|
|
30
|
-
const
|
|
32
|
+
const slug = params.get("eventOfferSlug");
|
|
33
|
+
if (slug !== null) return <EventBooking key={slug} slug={slug.trim()} />;
|
|
34
|
+
return (
|
|
35
|
+
<Checkout>
|
|
36
|
+
{(book, holding) => (
|
|
37
|
+
<RegularBookingForm
|
|
38
|
+
productId={params.get("productId") ?? DEMO_PRODUCT_ID}
|
|
39
|
+
defaultDate={params.get("date") ?? "2026-07-04"}
|
|
40
|
+
book={book}
|
|
41
|
+
holding={holding}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
</Checkout>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
const
|
|
48
|
+
function EventBooking({ slug }: { slug: string }) {
|
|
49
|
+
const offer = useEventOffer<EventOfferDetail>({ slug }, { enabled: slug !== "" });
|
|
50
|
+
if (offer.loading) return <main><p role="status">Loading event…</p></main>;
|
|
51
|
+
if (offer.error && offer.error.code !== "NOT_FOUND") {
|
|
52
|
+
return (
|
|
53
|
+
<main>
|
|
54
|
+
<p role="alert">{offer.error.message}</p>
|
|
55
|
+
<button onClick={() => void offer.refetch()}>Retry</button>
|
|
56
|
+
</main>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const event = offer.data;
|
|
60
|
+
if (!slug || event?.purchaseMode !== "reservation" || !event.session || !event.productId) {
|
|
61
|
+
return <main><p role="status">This event session is unavailable.</p></main>;
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<Checkout>
|
|
65
|
+
{(book, holding) => <EventReservationForm event={event} book={book} holding={holding} />}
|
|
66
|
+
</Checkout>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
34
69
|
|
|
35
|
-
|
|
36
|
-
const [startMinuteOfDay, setStartMinuteOfDay] = useState(18 * 60); // 6:00 PM
|
|
37
|
-
const endMinuteOfDay = startMinuteOfDay + 60;
|
|
38
|
-
const [units, setUnits] = useState(1);
|
|
70
|
+
type Book = (args: CreateBookingArgs) => Promise<void>;
|
|
39
71
|
|
|
40
|
-
|
|
41
|
-
const preview = useBookingPreview({
|
|
42
|
-
centerId: CENTER_ID,
|
|
43
|
-
productId,
|
|
44
|
-
dateISO,
|
|
45
|
-
startMinuteOfDay,
|
|
46
|
-
endMinuteOfDay,
|
|
47
|
-
mode: "per_unit_per_hour",
|
|
48
|
-
units,
|
|
49
|
-
});
|
|
72
|
+
function Checkout({ children }: { children: (book: Book, holding: boolean) => ReactNode }) {
|
|
50
73
|
const flow = useBookingFlow();
|
|
51
74
|
|
|
52
75
|
// Complete-sale-only: as soon as the hold lands, go straight to payment.
|
|
@@ -56,33 +79,19 @@ function BookInner() {
|
|
|
56
79
|
if (flow.status === "held") void prepareRef.current();
|
|
57
80
|
}, [flow.status]);
|
|
58
81
|
|
|
59
|
-
const
|
|
60
|
-
|
|
82
|
+
const showForm = flow.status !== "confirmed" &&
|
|
83
|
+
!(flow.status === "awaitingPayment" && flow.paymentIntent) &&
|
|
84
|
+
flow.status !== "held" && flow.status !== "preparingPayment";
|
|
61
85
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
startMinuteOfDay,
|
|
68
|
-
endMinuteOfDay,
|
|
69
|
-
mode: "per_unit_per_hour",
|
|
70
|
-
units,
|
|
71
|
-
customer: {
|
|
72
|
-
fullName: account.customer?.fullName ?? "",
|
|
73
|
-
email: account.customer?.email ?? "",
|
|
74
|
-
marketingOptIn: false,
|
|
75
|
-
},
|
|
76
|
-
}),
|
|
77
|
-
[productId, dateISO, startMinuteOfDay, endMinuteOfDay, units, account.customer],
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<div hidden={!showForm}>{children(flow.startHold, flow.status === "holding")}</div>
|
|
89
|
+
<CheckoutStatus flow={flow} />
|
|
90
|
+
</>
|
|
78
91
|
);
|
|
92
|
+
}
|
|
79
93
|
|
|
80
|
-
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
if (!signedIn) return;
|
|
83
|
-
await flow.startHold(bookingArgs);
|
|
84
|
-
}
|
|
85
|
-
|
|
94
|
+
function CheckoutStatus({ flow }: { flow: ReturnType<typeof useBookingFlow> }) {
|
|
86
95
|
if (flow.status === "confirmed") {
|
|
87
96
|
return (
|
|
88
97
|
<main>
|
|
@@ -122,7 +131,61 @@ function BookInner() {
|
|
|
122
131
|
);
|
|
123
132
|
}
|
|
124
133
|
|
|
125
|
-
|
|
134
|
+
return flow.error && (
|
|
135
|
+
<p role="alert">Booking error: {flow.error.code} — {flow.error.message}</p>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function RegularBookingForm({ productId, defaultDate, book, holding }: {
|
|
140
|
+
productId: string;
|
|
141
|
+
defaultDate: string;
|
|
142
|
+
book: Book;
|
|
143
|
+
holding: boolean;
|
|
144
|
+
}) {
|
|
145
|
+
const account = useAccount();
|
|
146
|
+
const signedIn = account.status === "linked" && account.customer !== null;
|
|
147
|
+
const [dateISO, setDateISO] = useState(defaultDate);
|
|
148
|
+
const [startMinuteOfDay, setStartMinuteOfDay] = useState(18 * 60);
|
|
149
|
+
const endMinuteOfDay = startMinuteOfDay + 60;
|
|
150
|
+
const [units, setUnits] = useState(1);
|
|
151
|
+
const availability = useAvailability({ productId, dateISO, startMinuteOfDay, endMinuteOfDay });
|
|
152
|
+
const preview = useBookingPreview({
|
|
153
|
+
centerId: CENTER_ID,
|
|
154
|
+
productId,
|
|
155
|
+
dateISO,
|
|
156
|
+
startMinuteOfDay,
|
|
157
|
+
endMinuteOfDay,
|
|
158
|
+
mode: "per_unit_per_hour",
|
|
159
|
+
units,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const freeUnits = availability.data ? availableUnitCount(availability.data) : null;
|
|
163
|
+
const quoteCents = preview.data?.totalCentsPerPlan?.[0]?.totalCents ?? null;
|
|
164
|
+
|
|
165
|
+
const bookingArgs: CreateBookingArgs = useMemo(
|
|
166
|
+
() => ({
|
|
167
|
+
centerId: CENTER_ID,
|
|
168
|
+
productId,
|
|
169
|
+
dateISO,
|
|
170
|
+
startMinuteOfDay,
|
|
171
|
+
endMinuteOfDay,
|
|
172
|
+
mode: "per_unit_per_hour",
|
|
173
|
+
units,
|
|
174
|
+
customer: {
|
|
175
|
+
fullName: account.customer?.fullName ?? "",
|
|
176
|
+
email: account.customer?.email ?? "",
|
|
177
|
+
marketingOptIn: false,
|
|
178
|
+
},
|
|
179
|
+
}),
|
|
180
|
+
[productId, dateISO, startMinuteOfDay, endMinuteOfDay, units, account.customer],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
async function onBook(e: FormEvent) {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
if (!signedIn) return;
|
|
186
|
+
await book(bookingArgs);
|
|
187
|
+
}
|
|
188
|
+
|
|
126
189
|
return (
|
|
127
190
|
<main>
|
|
128
191
|
<h1>Book a lane</h1>
|
|
@@ -181,11 +244,6 @@ function BookInner() {
|
|
|
181
244
|
{holding ? "Booking…" : "Book my lane"}
|
|
182
245
|
</button>
|
|
183
246
|
</form>
|
|
184
|
-
{flow.error && (
|
|
185
|
-
<p role="alert">
|
|
186
|
-
Booking error: {flow.error.code} — {flow.error.message}
|
|
187
|
-
</p>
|
|
188
|
-
)}
|
|
189
247
|
</main>
|
|
190
248
|
);
|
|
191
249
|
}
|
|
@@ -23,7 +23,9 @@ export default function CatalogPage() {
|
|
|
23
23
|
break;
|
|
24
24
|
case "view_event":
|
|
25
25
|
case "buy_ticket":
|
|
26
|
-
router.push(
|
|
26
|
+
router.push(payload.purchaseMode === "reservation"
|
|
27
|
+
? `/events/${encodeURIComponent(payload.slug)}`
|
|
28
|
+
: `/buy?kind=event&id=${encodeURIComponent(payload.slug)}`);
|
|
27
29
|
break;
|
|
28
30
|
case "buy_package":
|
|
29
31
|
router.push(`/buy?kind=package&id=${encodeURIComponent(payload.packageId)}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useParams } from "next/navigation";
|
|
4
|
-
import type {
|
|
4
|
+
import type { EventOfferDetail } from "@bowlos/reservations";
|
|
5
5
|
import {
|
|
6
6
|
useEventOffer,
|
|
7
7
|
useEventTicketPreview,
|
|
@@ -11,14 +11,9 @@ import { AuthGate } from "@bowlos/reservations/components";
|
|
|
11
11
|
import { BowlosPaymentForm } from "@bowlos/reservations/payments";
|
|
12
12
|
import { formatCents, STRIPE_PUBLISHABLE_KEY } from "@/lib/bowlos";
|
|
13
13
|
|
|
14
|
-
type Detail = EventOffer & {
|
|
15
|
-
minQuantity: number | null;
|
|
16
|
-
maxQuantity: number | null;
|
|
17
|
-
center: { name: string; timezone: string };
|
|
18
|
-
};
|
|
19
14
|
export default function EventPage() {
|
|
20
15
|
const { slug } = useParams<{ slug: string }>();
|
|
21
|
-
const event = useEventOffer<
|
|
16
|
+
const event = useEventOffer<EventOfferDetail | null>({ slug });
|
|
22
17
|
return (
|
|
23
18
|
<main>
|
|
24
19
|
{event.loading ? (
|
|
@@ -48,12 +43,14 @@ export default function EventPage() {
|
|
|
48
43
|
</>
|
|
49
44
|
)}
|
|
50
45
|
</AuthGate>
|
|
51
|
-
) : (
|
|
46
|
+
) : event.data.session && event.data.productId ? (
|
|
52
47
|
<a
|
|
53
|
-
href={`/book?
|
|
48
|
+
href={`/book?eventOfferSlug=${encodeURIComponent(event.data.slug)}`}
|
|
54
49
|
>
|
|
55
50
|
Book this event
|
|
56
51
|
</a>
|
|
52
|
+
) : (
|
|
53
|
+
<p>This event session is unavailable.</p>
|
|
57
54
|
)}
|
|
58
55
|
</>
|
|
59
56
|
)}
|
|
@@ -63,7 +60,7 @@ export default function EventPage() {
|
|
|
63
60
|
</main>
|
|
64
61
|
);
|
|
65
62
|
}
|
|
66
|
-
function Tickets({ event }: { event:
|
|
63
|
+
function Tickets({ event }: { event: EventOfferDetail }) {
|
|
67
64
|
const [quantity, setQuantity] = useState(event.minQuantity ?? 1);
|
|
68
65
|
const args = { eventOfferId: event.id, quantity };
|
|
69
66
|
const preview = useEventTicketPreview(args);
|