@bowlos/reservations 0.20.0 → 0.21.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/HEADLESS.md +203 -6
- package/README.md +7 -0
- package/dist/{catalog-eofYl46p.d.cts → catalog-BuafmB8y.d.cts} +67 -2
- package/dist/{catalog-BGPCoIOm.d.ts → catalog-bpCn9klL.d.ts} +67 -2
- package/dist/{chunk-3GAXATYP.js → chunk-FV6SROO2.js} +22 -4
- package/dist/chunk-FV6SROO2.js.map +1 -0
- package/dist/{chunk-32FTBLXQ.js → chunk-S5T4OCBY.js} +25 -3
- package/dist/chunk-S5T4OCBY.js.map +1 -0
- package/dist/components.cjs +11 -6
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +10 -4
- package/dist/components.d.ts +10 -4
- package/dist/components.js +11 -6
- package/dist/components.js.map +1 -1
- package/dist/{data-ymW_rWbz.d.cts → data-BKlgn8Ln.d.cts} +72 -1
- package/dist/{data-ymW_rWbz.d.ts → data-BKlgn8Ln.d.ts} +72 -1
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/payments.d.cts +1 -1
- package/dist/payments.d.ts +1 -1
- package/dist/{react-Bh0z-Lnb.d.ts → react-BI2RKM5p.d.ts} +1 -1
- package/dist/{react-DHvo_ZHf.d.cts → react-D2mBw_-l.d.cts} +1 -1
- package/dist/react.cjs +73 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +35 -5
- package/dist/react.d.ts +35 -5
- package/dist/react.js +37 -4
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/templates/center-site/package.json +1 -1
- package/dist/chunk-32FTBLXQ.js.map +0 -1
- package/dist/chunk-3GAXATYP.js.map +0 -1
package/HEADLESS.md
CHANGED
|
@@ -151,19 +151,26 @@ const chosen = (addons.data ?? [])
|
|
|
151
151
|
.map((a) => ({ ...a, quantity: qty[a.id] ?? 0 }))
|
|
152
152
|
.filter((a) => a.quantity > 0);
|
|
153
153
|
const addonsSubtotal = chosen.reduce((s, a) => s + a.priceCents * a.quantity, 0);
|
|
154
|
-
//
|
|
155
|
-
//
|
|
154
|
+
// TAX and the reservation FEE are both folded into the quote total — itemize
|
|
155
|
+
// each so neither vanishes, and subtract them from the base line below so they
|
|
156
|
+
// aren't double-counted. Tax lives in taxLinesPerPlan (NOT inside the base):
|
|
157
|
+
const plan = preview.data?.totalCentsPerPlan?.[0]; // headline plan
|
|
158
|
+
const taxLines = preview.data?.taxLinesPerPlan?.find((t) => t.pricePlanId === plan?.pricePlanId)?.taxLines ?? [];
|
|
159
|
+
const taxCents = taxLines.reduce((s, t) => s + t.taxCents, 0); // each line: { label, taxCents }
|
|
156
160
|
const fee = preview.data?.reservationFee; // { amountCents, label } | null
|
|
157
161
|
const feeCents = (fee?.amountCents as number) ?? 0;
|
|
158
|
-
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotal - feeCents : null; // base
|
|
162
|
+
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotal - taxCents - feeCents : null; // base only
|
|
159
163
|
// Summary rows: the reservation ({count} {label} · {date} · {start–end}) + each add-on
|
|
160
|
-
// ({name} × {qty}) +
|
|
161
|
-
//
|
|
164
|
+
// ({name} × {qty}) + one row per taxLine ({label} → {taxCents}) + a "{fee.label}" line
|
|
165
|
+
// (feeCents) when feeCents > 0 + Total = quoteCents. "Continue to payment" →
|
|
166
|
+
// flow.startHold(bookingArgs); "Edit order" → setReviewing(false).
|
|
162
167
|
```
|
|
163
168
|
|
|
164
169
|
The total shown **must** be the quote's `totalCents` — it already includes tax
|
|
165
170
|
**and** the reservation fee, so the review matches what the customer is charged.
|
|
166
|
-
Itemize `
|
|
171
|
+
Itemize **each `taxLinesPerPlan[plan].taxLines[]` row** and
|
|
172
|
+
`preview.data.reservationFee` as their own lines so neither the tax nor the fee
|
|
173
|
+
is hidden inside the reservation line (see the [Static purchase summary](#static-purchase-summary--tax--center-fee--setup-fee-every-category) field map).
|
|
167
174
|
|
|
168
175
|
### 8. Hold → pay → confirm, and pay-to-confirm
|
|
169
176
|
|
|
@@ -278,6 +285,140 @@ hold during the review step — hold on "Continue to payment" only (§7).
|
|
|
278
285
|
|
|
279
286
|
---
|
|
280
287
|
|
|
288
|
+
## Static purchase summary — tax · center fee · setup fee (every category)
|
|
289
|
+
|
|
290
|
+
Every BowlOS funnel ends in a **static, non-editable summary** the customer
|
|
291
|
+
reads before paying: itemized **tax**, the **center/booking fee**, and — for
|
|
292
|
+
memberships — the one-time **setup/joining fee**. This is the single most
|
|
293
|
+
common headless gap, so here is the exact field map. **Read it from the
|
|
294
|
+
server-computed preview; never compute tax, fee, or totals yourself** — the
|
|
295
|
+
preview is the same engine the PaymentIntent uses, so the summary and the charge
|
|
296
|
+
can never disagree.
|
|
297
|
+
|
|
298
|
+
| Category | Review hook (preview) | Base line(s) | Tax lines | Center / booking fee | Setup fee | Total(s) |
|
|
299
|
+
|---|---|---|---|---|---|---|
|
|
300
|
+
| **Bowling / other attractions** | `useBookingPreview` | reservation (count × rate, add-ons, less discount) | `taxLinesPerPlan[plan].taxLines[]` → `{ label, taxCents }` | `reservationFee` → `{ amountCents, label }` | — (n/a) | `totalCentsPerPlan[plan].totalCents` (already includes tax + fee) |
|
|
301
|
+
| **Events (ticket mode)** | `useEventTicketPreview` | `subtotalCents` ("Tickets") | `taxLines[]` → `{ label, taxCents }` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
302
|
+
| **Game passes** | `useGameCardPreview` | `subtotalCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
303
|
+
| **Packages** | `usePackagePreview` | `baseTotalCents` + `addons[]` (`{ name, quantity, lineCents }`) | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
304
|
+
| **Membership (one-time)** | `useMembershipPreview` | `duesCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | `setupFeeCents` | `grandTotalCents` |
|
|
305
|
+
| **Membership (recurring)** | `useMembershipSubscriptionPreview` | `duesCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | `setupFeeCents` (today only) | **Due today** `grandTotalCents` **and** **Auto-renews at** `recurringTotalCents` / `cadence` |
|
|
306
|
+
|
|
307
|
+
Rules that make the summary match the charge:
|
|
308
|
+
|
|
309
|
+
- **Static, not editable.** The summary re-states the customer's choices and the
|
|
310
|
+
server's numbers; the only actions are "Continue to payment" and "Edit order"
|
|
311
|
+
(which returns to the form). No price/qty inputs live on the summary.
|
|
312
|
+
- **Show every tax line.** Each `taxLine` is `{ label, taxCents, mode, … }`.
|
|
313
|
+
Render one row per line using `label` + `taxCents`. `mode: "included"` lines
|
|
314
|
+
are informational (tax is inside the price); `"none"`/exempt → there are no
|
|
315
|
+
lines, so render nothing. Never collapse tax into the base line — for bowling
|
|
316
|
+
in particular the tax is in `taxLinesPerPlan`, **not** inside the reservation
|
|
317
|
+
line (see §7).
|
|
318
|
+
- **Show the center fee when present.** Render `reservationFeeLabel` (the
|
|
319
|
+
operator's own wording, e.g. "Facility fee") + the amount **only when**
|
|
320
|
+
`reservationFeeCents > 0` (bowling: `reservationFee != null`). It is already
|
|
321
|
+
folded into the total — itemize it so it doesn't look like a hidden add-on.
|
|
322
|
+
- **Setup fee = per-purchase joining fee.** `setupFeeCents` is a **one-time**
|
|
323
|
+
charge applied on the **first payment of every membership purchase** whose
|
|
324
|
+
template has one configured — it is **not** waived for repeat buyers. Render
|
|
325
|
+
the "Joining fee" / "Setup fee" row **only when `setupFeeCents > 0`** (a
|
|
326
|
+
template with no setup fee returns `0`) and never fabricate it. On a recurring
|
|
327
|
+
membership it is part of **Due today** but is **excluded from**
|
|
328
|
+
`recurringTotalCents` (renewals charge dues + tax/fee only).
|
|
329
|
+
- **Trust the total.** `grandTotalCents` (or bowling's `totalCentsPerPlan[].totalCents`)
|
|
330
|
+
already = base + tax + center fee (+ setup fee for a first membership). Display
|
|
331
|
+
it verbatim; do not re-sum the rows yourself.
|
|
332
|
+
|
|
333
|
+
Each category's full funnel (config, auth gate, payment) is in its section below.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Event offers in the catalog
|
|
338
|
+
|
|
339
|
+
Use `useEventOffers({ centerId })` for public event lineup cards and event
|
|
340
|
+
landing-page links. `useEvents()` is the legacy pricing-event/date-preset list;
|
|
341
|
+
it does **not** carry the commerce controls (lineup toggle, landing-page slug,
|
|
342
|
+
purchase mode, included add-ons, tax/fee config).
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
const events = useEventOffers({ centerId });
|
|
346
|
+
// rows include:
|
|
347
|
+
// { id, slug, title, subtitle, description, date, startMinuteOfDay,
|
|
348
|
+
// endMinuteOfDay, purchaseMode, productId, pricePlanId, priceCents }
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Route catalog picks by `offer.slug` to your event landing page. On that page,
|
|
352
|
+
read the full offer with `useEventOffer({ slug })`.
|
|
353
|
+
|
|
354
|
+
For `purchaseMode: "reservation"`, start the normal booking flow with the
|
|
355
|
+
offer's `productId`, preselect `date`, `startMinuteOfDay`, and duration
|
|
356
|
+
(`endMinuteOfDay - startMinuteOfDay`) when present, and preselect
|
|
357
|
+
`includedAddons`. Pass `eventOfferSlug: offer.slug` into both
|
|
358
|
+
`useBookingPreview` and the booking hold/create call (`useBookingFlow.startHold`
|
|
359
|
+
or `createBooking`). The server uses that slug to bind the quote to the offer's
|
|
360
|
+
event price plan, tax override, and Center fee override/inheritance. Then
|
|
361
|
+
continue through the same [Review step](#7-review-step--an-order-summary-before-payment)
|
|
362
|
+
and `useBookingFlow` lifecycle above. That keeps event reservations on the same
|
|
363
|
+
pricing, hold, tax, fee, credit, and Stripe Connect path as regular bookings.
|
|
364
|
+
`useBookingPreview` returns `taxLinesPerPlan` alongside `totalCentsPerPlan`;
|
|
365
|
+
render the entry matching the selected/headline price plan so event tax appears
|
|
366
|
+
as its own Review row instead of being hidden inside the base reservation line.
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
const eventArgs = offer.purchaseMode === "reservation"
|
|
370
|
+
? { eventOfferSlug: offer.slug }
|
|
371
|
+
: {};
|
|
372
|
+
|
|
373
|
+
const preview = useBookingPreview(
|
|
374
|
+
{ centerId, productId: offer.productId!, dateISO, startMinuteOfDay, endMinuteOfDay, mode: pricingMode, ...countField(count), addons: selectedAddons, ...eventArgs },
|
|
375
|
+
{ enabled: offer.purchaseMode === "reservation" && signedIn },
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// Later, after your Review step:
|
|
379
|
+
flow.startHold({
|
|
380
|
+
centerId,
|
|
381
|
+
productId: offer.productId!,
|
|
382
|
+
dateISO,
|
|
383
|
+
startMinuteOfDay,
|
|
384
|
+
endMinuteOfDay,
|
|
385
|
+
mode: pricingMode,
|
|
386
|
+
...countField(count),
|
|
387
|
+
addons: selectedAddons,
|
|
388
|
+
customer,
|
|
389
|
+
...eventArgs,
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
For `purchaseMode: "ticket"`, route the customer to the hosted tenant ticket
|
|
394
|
+
checkout at `/tenant/<slug>/events/<eventSlug>/tickets`, or mirror that flow in
|
|
395
|
+
a first-party surface with `previewEventTicket(client, { eventOfferId, quantity })`
|
|
396
|
+
or `useEventTicketPreview` → Review → `createEventTicketOrder(client, { eventOfferId, quantity })`
|
|
397
|
+
or `useEventTicketPurchase().start({ eventOfferId, quantity })` (gateway action:
|
|
398
|
+
`createEventTicketPaymentIntent`). The preview returns the itemized base, tax
|
|
399
|
+
lines, Center event fee, and `grandTotalCents`; the PaymentIntent action uses
|
|
400
|
+
the same server-side snapshot and writes an `event_orders` row. Do not charge
|
|
401
|
+
tickets from `priceCents` alone.
|
|
402
|
+
|
|
403
|
+
Headless function twins (non-React): `listEventOffers(client, { centerId })`,
|
|
404
|
+
`getEventOffer(client, { slug })`.
|
|
405
|
+
|
|
406
|
+
After payment, re-query the signed-in account reads:
|
|
407
|
+
|
|
408
|
+
- `useMyEventOrders({ brandId })` / `getMyEventOrders(client, { brandId })`
|
|
409
|
+
lists the customer's event ticket purchases for account dashboards.
|
|
410
|
+
- `useMyEventOrder({ brandId, orderId })` / `getMyEventOrder(client, { brandId, orderId })`
|
|
411
|
+
returns the frozen receipt snapshot: ticket subtotal, tax lines, Center fee,
|
|
412
|
+
included add-ons, `grandTotalCents`, and refund fields (`refundedCents`,
|
|
413
|
+
`refundedAt`, `refundReason`) when staff have refunded the ticket order.
|
|
414
|
+
|
|
415
|
+
Paid ticket orders write `transaction_ledger.source === "event"` rows, so
|
|
416
|
+
finance/reporting surfaces can break event revenue out separately from
|
|
417
|
+
reservations and packages. Stripe card refunds for those PaymentIntents reverse
|
|
418
|
+
the same ledger row and preserve the `eventOrderId` back-reference.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
281
422
|
## Buying a game pass (memberships follow)
|
|
282
423
|
|
|
283
424
|
Game passes are a **direct purchase** — no inventory hold, no date/time. The buy
|
|
@@ -570,6 +711,61 @@ Headless function twins (non-React):
|
|
|
570
711
|
`createMembershipSubscriptionOrder(client, { templateId })`. (No status twin —
|
|
571
712
|
subscriptions materialize via webhook; read `getMyMemberships(client, { brandId })`.)
|
|
572
713
|
|
|
714
|
+
## The canonical catalog (visibility-aware) — `useCatalog`
|
|
715
|
+
|
|
716
|
+
`<BookingCatalog>` assembles the catalog from five per-category reads
|
|
717
|
+
(`useProducts` / `useEventOffers` / `usePackages` / `usePublicMemberships` /
|
|
718
|
+
`useGameCards`). Those reads do **not** apply the Center admin's per-surface
|
|
719
|
+
visibility settings — a category or offer the operator hid for a surface still
|
|
720
|
+
comes back.
|
|
721
|
+
|
|
722
|
+
For a visibility-aware catalog, use **`useCatalog`** (v0.21.0):
|
|
723
|
+
|
|
724
|
+
```tsx
|
|
725
|
+
import { useCatalog } from "@bowlos/reservations/react";
|
|
726
|
+
|
|
727
|
+
const { data, loading } = useCatalog({
|
|
728
|
+
brandId: "brand_…",
|
|
729
|
+
centerId: "center_…",
|
|
730
|
+
surface: "sdk_custom_site", // your surface — the backend applies its rules
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// data.sections: { key, label, items: CatalogItem[] }[] (six categories, in order)
|
|
734
|
+
// Render only sections with items (empty categories are hidden on customer surfaces).
|
|
735
|
+
data?.sections
|
|
736
|
+
.filter((s) => s.items.length > 0)
|
|
737
|
+
.map((section) => (
|
|
738
|
+
<section key={section.key}>
|
|
739
|
+
<h2>{section.label}</h2>
|
|
740
|
+
{section.items.map((item) => (
|
|
741
|
+
<button key={item.id} onClick={() => route(item)}>
|
|
742
|
+
{item.title} — {item.priceLabel ?? "See times & pricing"}
|
|
743
|
+
</button>
|
|
744
|
+
))}
|
|
745
|
+
</section>
|
|
746
|
+
));
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
Routing — switch on `item.action.type` and use the IDs in `action.payload`:
|
|
750
|
+
|
|
751
|
+
| `action.type` | payload | route to |
|
|
752
|
+
|---|---|---|
|
|
753
|
+
| `book_reservation` | `{ productId }` | your `<BookingFlow>` for that product |
|
|
754
|
+
| `view_event` | `{ slug, purchaseMode }` | the event landing/booking by `slug` (fetch detail with `getEventOffer({ slug })` for reservation-mode presets) |
|
|
755
|
+
| `buy_package` | `{ packageId }` | your headless package buy (see "Buying a package") |
|
|
756
|
+
| `buy_membership` | `{ templateId }` | your membership buy (see "Buying a … membership") |
|
|
757
|
+
| `buy_game_pass` | `{ templateId }` | your game-pass buy (see "Buying a game pass") |
|
|
758
|
+
|
|
759
|
+
`priceLabel` is an indicative **"from $X"** only (null for products → show
|
|
760
|
+
"See times & pricing"); the binding price comes from the per-category preview
|
|
761
|
+
after login. The framework-agnostic twin is `listCatalog(client, args)`.
|
|
762
|
+
|
|
763
|
+
`useCatalog` keeps the SDK custom site consistent with the white-label web and
|
|
764
|
+
mobile surfaces (all three consume the same backend read) and honors the admin
|
|
765
|
+
Public Catalog toggles. `<BookingCatalog>` itself still uses the per-category
|
|
766
|
+
hooks; migrating it to `useCatalog` (a breaking `onSelect` shape change) is a
|
|
767
|
+
future coordinated release.
|
|
768
|
+
|
|
573
769
|
## Adopting changes by version
|
|
574
770
|
|
|
575
771
|
What each SDK release changed in `<BookingFlow>` and the headless steps to match.
|
|
@@ -590,6 +786,7 @@ Headless sites do **not** get these from a version bump — apply them by hand.
|
|
|
590
786
|
| **0.18.0** | **Itemized package Review** — `usePackagePreview` (server-computed quote) | "Buying a package" §3. Insert a Review step between config and pay: `usePackagePreview({ packageId, centerId, quantity, optionalAddons })` returns the itemized breakdown (base, add-ons, tax lines, booking fee, `grandTotalCents`). Render it before `usePackagePurchase.start`. Same engine as the PaymentIntent, so it never diverges. (Auth required — applies tax exemptions.) |
|
|
591
787
|
| **0.19.0** | **Itemized game-pass Review** — `useGameCardPreview` (server-computed quote) | "Buying a game pass" §2. Insert a Review step before pay: `useGameCardPreview({ templateId })` returns the itemized breakdown (base, tax lines, booking fee, `grandTotalCents`). Render it before `useGameCardPurchase.start` — stop showing the bare `priceCents`, since the customer now pays base + tax + the selling Center's booking fee. Same engine as the PaymentIntent, so it never diverges. (Auth required — applies tax exemptions + resolves the home Center.) |
|
|
592
788
|
| **0.20.0** | **Membership buy hooks (one-time + recurring)** — `useMembershipPreview` / `useMembershipPurchase` and `useMembershipSubscriptionPreview` / `useMembershipSubscriptionCheckout` | "Buying a one-time membership" + "Buying a recurring membership" sections. One-time mirrors the game-pass buy (`useMembershipPreview` → `useMembershipPurchase`, poll `resultId` = membership). Recurring: `useMembershipSubscriptionPreview` shows **Due today** (`grandTotalCents`) *and* **Auto-renews at** (`recurringTotalCents` / `cadence`), then `useMembershipSubscriptionCheckout` confirms the first invoice — **no refToken poll; re-query `useMyMemberships` after payment** (the subscription materializes via webhook). Route the catalog's `membership` pick in-app, not to the portal. (Charges the operator's connected account.) |
|
|
789
|
+
| **0.21.0** | **Sellable event offers + ticket receipts** *and* **canonical visibility-aware catalog** — headless adds `useEventOffers` / `useEventOffer`, `useEventTicketPreview`, `createEventTicketOrder`, `useEventTicketPurchase`, signed-in event-order account reads, **and** `useCatalog` / `listCatalog` (one read, six categories, per-surface admin visibility applied); a consolidated [Static purchase summary](#static-purchase-summary--tax--center-fee--setup-fee-every-category) field map | "Event offers in the catalog" + "The canonical catalog" sections. Route `event` picks to an event landing page by `slug`. For reservation-mode events, preselect the event date/window/add-ons and pass `eventOfferSlug: offer.slug` into preview + hold/create so the server applies the event plan and tax/fee policy. For ticket-mode events, route to the hosted tenant ticket checkout or mirror `previewEventTicket` → Review → `createEventTicketOrder` / `useEventTicketPurchase`. After pay, re-query `useMyEventOrders` / `useMyEventOrder`. Prefer `useCatalog({ brandId, centerId, surface })` over the per-category hooks for the full, admin-controlled catalog (route each `CatalogItem` by `action.type`). `<BookingCatalog>` is unchanged. |
|
|
593
790
|
|
|
594
791
|
When you add the next release here, add its row **and** any new capability-map
|
|
595
792
|
section in the same PR.
|
package/README.md
CHANGED
|
@@ -215,6 +215,13 @@ import { BookingCatalog } from "@bowlos/reservations/components";
|
|
|
215
215
|
/>;
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
+
For a **visibility-aware** catalog (the Center admin's per-surface Public Catalog
|
|
219
|
+
toggles applied, consistent with the white-label web + mobile surfaces), build
|
|
220
|
+
your own listing from the **`useCatalog({ brandId, centerId, surface })`** hook
|
|
221
|
+
(framework-agnostic twin: `listCatalog`) instead of the per-category hooks. It
|
|
222
|
+
returns the six categories grouped; route each item by `action.type`. See
|
|
223
|
+
HEADLESS.md → "The canonical catalog".
|
|
224
|
+
|
|
218
225
|
The drop-in surfaces cover a center site end to end:
|
|
219
226
|
|
|
220
227
|
**`<BookingFlow>`** runs the whole funnel (availability + price → **review** → pay
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-
|
|
1
|
+
import { g as BowlosClient } from './data-BKlgn8Ln.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Typed account + flash reads for @bowlos/reservations.
|
|
@@ -19,6 +19,10 @@ type ReservationDetailArgs = {
|
|
|
19
19
|
brandId: string;
|
|
20
20
|
displayId: string;
|
|
21
21
|
};
|
|
22
|
+
type EventOrderDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
orderId: string;
|
|
25
|
+
};
|
|
22
26
|
type MembershipDetailArgs = {
|
|
23
27
|
brandId: string;
|
|
24
28
|
membershipId: string;
|
|
@@ -35,6 +39,8 @@ type FlashSalesArgs = {
|
|
|
35
39
|
};
|
|
36
40
|
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
37
41
|
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
+
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
38
44
|
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
39
45
|
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
40
46
|
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
@@ -60,6 +66,57 @@ type BrandCatalogArgs = {
|
|
|
60
66
|
brandId: string;
|
|
61
67
|
centerId?: string;
|
|
62
68
|
};
|
|
69
|
+
/** Which public surface is asking — the backend applies that surface's
|
|
70
|
+
* per-category + per-offer visibility before returning. */
|
|
71
|
+
type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
|
|
72
|
+
type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
|
|
73
|
+
type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
|
|
74
|
+
type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
|
|
75
|
+
/** A normalized, surface-agnostic catalog item. Route by `action.type`, using
|
|
76
|
+
* the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
|
|
77
|
+
* `templateId`). `priceLabel` is an indicative "from $X" only (null for
|
|
78
|
+
* products — show "See times & pricing"); the binding price comes from the
|
|
79
|
+
* per-category preview after login. */
|
|
80
|
+
interface CatalogItem {
|
|
81
|
+
id: string;
|
|
82
|
+
category: CatalogCategory;
|
|
83
|
+
sourceTable: CatalogSourceTable;
|
|
84
|
+
sourceId: string;
|
|
85
|
+
title: string;
|
|
86
|
+
subtitle?: string | null;
|
|
87
|
+
description?: string | null;
|
|
88
|
+
priceLabel?: string | null;
|
|
89
|
+
imageUrl?: string | null;
|
|
90
|
+
badgeLabel?: string | null;
|
|
91
|
+
action: {
|
|
92
|
+
type: CatalogActionType;
|
|
93
|
+
payload: Record<string, string>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
interface CatalogSection {
|
|
97
|
+
key: CatalogCategory;
|
|
98
|
+
label: string;
|
|
99
|
+
items: CatalogItem[];
|
|
100
|
+
}
|
|
101
|
+
interface CatalogResult {
|
|
102
|
+
sections: CatalogSection[];
|
|
103
|
+
}
|
|
104
|
+
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
105
|
+
* rules the backend applies. */
|
|
106
|
+
type CatalogArgs = {
|
|
107
|
+
brandId: string;
|
|
108
|
+
centerId: string;
|
|
109
|
+
surface: PublicSurface;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The canonical public catalog for a surface — every active, public,
|
|
113
|
+
* bookable/sellable item grouped into the six first-class categories, with the
|
|
114
|
+
* Center admin's per-surface category + offer visibility already applied.
|
|
115
|
+
* Anonymous. This is the recommended way to list "everything bookable here":
|
|
116
|
+
* one call, all categories, visibility-aware, consistent with the white-label
|
|
117
|
+
* web + mobile surfaces.
|
|
118
|
+
*/
|
|
119
|
+
declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
|
|
63
120
|
/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
|
|
64
121
|
type PackageDetailArgs = {
|
|
65
122
|
packageId: string;
|
|
@@ -75,6 +132,14 @@ type CenterHoursArgs = {
|
|
|
75
132
|
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
76
133
|
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
77
134
|
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
135
|
+
/** Sellable event offers at a Center. These are the public lineup + event
|
|
136
|
+
* landing-page records; use this instead of `listEvents` when routing a
|
|
137
|
+
* customer to an event purchase flow. */
|
|
138
|
+
declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
139
|
+
/** One sellable event offer by landing-page slug. */
|
|
140
|
+
declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
|
|
141
|
+
slug: string;
|
|
142
|
+
}): Promise<T>;
|
|
78
143
|
/** Purchasable packages at a Brand. */
|
|
79
144
|
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
80
145
|
/** Full detail for one package — components, optional add-ons, allowed start
|
|
@@ -90,4 +155,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
|
|
|
90
155
|
/** Purchasable game cards / passes at a Brand. */
|
|
91
156
|
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
92
157
|
|
|
93
|
-
export { type BrandCatalogArgs as B, type
|
|
158
|
+
export { getPackage as A, type BrandCatalogArgs as B, type CatalogActionType as C, listCatalog as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, listEventOffers as G, listEvents as H, listGameCards as I, listPackages as J, listProducts as K, listPublicMemberships as L, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CatalogArgs as b, type CatalogCategory as c, type CatalogItem as d, type CatalogResult as e, type CatalogSection as f, type CatalogSourceTable as g, type CenterHoursArgs as h, type CenterScoped as i, type FlashSaleArgs as j, type FlashSalesArgs as k, type PublicSurface as l, getCenterHours as m, getEventOffer as n, getFlashSale as o, getFlashSaleBookingOptions as p, getFlashSales as q, getMyCredits as r, getMyEventOrder as s, getMyEventOrders as t, getMyLoyalty as u, getMyMembershipDetail as v, getMyMemberships as w, getMyPasses as x, getMyReservationDetail as y, getMyReservations as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-
|
|
1
|
+
import { g as BowlosClient } from './data-BKlgn8Ln.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Typed account + flash reads for @bowlos/reservations.
|
|
@@ -19,6 +19,10 @@ type ReservationDetailArgs = {
|
|
|
19
19
|
brandId: string;
|
|
20
20
|
displayId: string;
|
|
21
21
|
};
|
|
22
|
+
type EventOrderDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
orderId: string;
|
|
25
|
+
};
|
|
22
26
|
type MembershipDetailArgs = {
|
|
23
27
|
brandId: string;
|
|
24
28
|
membershipId: string;
|
|
@@ -35,6 +39,8 @@ type FlashSalesArgs = {
|
|
|
35
39
|
};
|
|
36
40
|
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
37
41
|
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
+
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
38
44
|
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
39
45
|
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
40
46
|
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
@@ -60,6 +66,57 @@ type BrandCatalogArgs = {
|
|
|
60
66
|
brandId: string;
|
|
61
67
|
centerId?: string;
|
|
62
68
|
};
|
|
69
|
+
/** Which public surface is asking — the backend applies that surface's
|
|
70
|
+
* per-category + per-offer visibility before returning. */
|
|
71
|
+
type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
|
|
72
|
+
type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
|
|
73
|
+
type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
|
|
74
|
+
type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
|
|
75
|
+
/** A normalized, surface-agnostic catalog item. Route by `action.type`, using
|
|
76
|
+
* the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
|
|
77
|
+
* `templateId`). `priceLabel` is an indicative "from $X" only (null for
|
|
78
|
+
* products — show "See times & pricing"); the binding price comes from the
|
|
79
|
+
* per-category preview after login. */
|
|
80
|
+
interface CatalogItem {
|
|
81
|
+
id: string;
|
|
82
|
+
category: CatalogCategory;
|
|
83
|
+
sourceTable: CatalogSourceTable;
|
|
84
|
+
sourceId: string;
|
|
85
|
+
title: string;
|
|
86
|
+
subtitle?: string | null;
|
|
87
|
+
description?: string | null;
|
|
88
|
+
priceLabel?: string | null;
|
|
89
|
+
imageUrl?: string | null;
|
|
90
|
+
badgeLabel?: string | null;
|
|
91
|
+
action: {
|
|
92
|
+
type: CatalogActionType;
|
|
93
|
+
payload: Record<string, string>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
interface CatalogSection {
|
|
97
|
+
key: CatalogCategory;
|
|
98
|
+
label: string;
|
|
99
|
+
items: CatalogItem[];
|
|
100
|
+
}
|
|
101
|
+
interface CatalogResult {
|
|
102
|
+
sections: CatalogSection[];
|
|
103
|
+
}
|
|
104
|
+
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
105
|
+
* rules the backend applies. */
|
|
106
|
+
type CatalogArgs = {
|
|
107
|
+
brandId: string;
|
|
108
|
+
centerId: string;
|
|
109
|
+
surface: PublicSurface;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The canonical public catalog for a surface — every active, public,
|
|
113
|
+
* bookable/sellable item grouped into the six first-class categories, with the
|
|
114
|
+
* Center admin's per-surface category + offer visibility already applied.
|
|
115
|
+
* Anonymous. This is the recommended way to list "everything bookable here":
|
|
116
|
+
* one call, all categories, visibility-aware, consistent with the white-label
|
|
117
|
+
* web + mobile surfaces.
|
|
118
|
+
*/
|
|
119
|
+
declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
|
|
63
120
|
/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
|
|
64
121
|
type PackageDetailArgs = {
|
|
65
122
|
packageId: string;
|
|
@@ -75,6 +132,14 @@ type CenterHoursArgs = {
|
|
|
75
132
|
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
76
133
|
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
77
134
|
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
135
|
+
/** Sellable event offers at a Center. These are the public lineup + event
|
|
136
|
+
* landing-page records; use this instead of `listEvents` when routing a
|
|
137
|
+
* customer to an event purchase flow. */
|
|
138
|
+
declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
139
|
+
/** One sellable event offer by landing-page slug. */
|
|
140
|
+
declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
|
|
141
|
+
slug: string;
|
|
142
|
+
}): Promise<T>;
|
|
78
143
|
/** Purchasable packages at a Brand. */
|
|
79
144
|
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
80
145
|
/** Full detail for one package — components, optional add-ons, allowed start
|
|
@@ -90,4 +155,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
|
|
|
90
155
|
/** Purchasable game cards / passes at a Brand. */
|
|
91
156
|
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
92
157
|
|
|
93
|
-
export { type BrandCatalogArgs as B, type
|
|
158
|
+
export { getPackage as A, type BrandCatalogArgs as B, type CatalogActionType as C, listCatalog as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, listEventOffers as G, listEvents as H, listGameCards as I, listPackages as J, listProducts as K, listPublicMemberships as L, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CatalogArgs as b, type CatalogCategory as c, type CatalogItem as d, type CatalogResult as e, type CatalogSection as f, type CatalogSourceTable as g, type CenterHoursArgs as h, type CenterScoped as i, type FlashSaleArgs as j, type FlashSalesArgs as k, type PublicSurface as l, getCenterHours as m, getEventOffer as n, getFlashSale as o, getFlashSaleBookingOptions as p, getFlashSales as q, getMyCredits as r, getMyEventOrder as s, getMyEventOrders as t, getMyLoyalty as u, getMyMembershipDetail as v, getMyMemberships as w, getMyPasses as x, getMyReservationDetail as y, getMyReservations as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createBowlosClient, BowlosApiError, BOWLOS_ERROR_CODES, createBooking, createCheckoutPaymentIntent, getCheckoutStatus, abandonCheckout } from './chunk-
|
|
1
|
+
import { createBowlosClient, BowlosApiError, BOWLOS_ERROR_CODES, createBooking, createCheckoutPaymentIntent, getCheckoutStatus, abandonCheckout } from './chunk-S5T4OCBY.js';
|
|
2
2
|
import { createContext, useRef, useContext, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -122,6 +122,12 @@ function useMyReservations(args, options) {
|
|
|
122
122
|
function useMyReservationDetail(args, options) {
|
|
123
123
|
return useBowlosQuery("getMyReservationDetail", args, { ...options, auth: true });
|
|
124
124
|
}
|
|
125
|
+
function useMyEventOrders(args, options) {
|
|
126
|
+
return useBowlosQuery("listMyEventOrders", args, { ...options, auth: true });
|
|
127
|
+
}
|
|
128
|
+
function useMyEventOrder(args, options) {
|
|
129
|
+
return useBowlosQuery("getMyEventOrder", args, { ...options, auth: true });
|
|
130
|
+
}
|
|
125
131
|
function useMyMemberships(args, options) {
|
|
126
132
|
return useBowlosQuery("listMyMemberships", args, { ...options, auth: true });
|
|
127
133
|
}
|
|
@@ -146,12 +152,21 @@ function useFlashSales(args, options) {
|
|
|
146
152
|
function useFlashSaleBookingOptions(args, options) {
|
|
147
153
|
return useBowlosQuery("getFlashSaleBookingOptions", args, { ...options, auth: true });
|
|
148
154
|
}
|
|
155
|
+
function useCatalog(args, options) {
|
|
156
|
+
return useBowlosQuery("listPublicCatalog", args, options);
|
|
157
|
+
}
|
|
149
158
|
function useProducts(args, options) {
|
|
150
159
|
return useBowlosQuery("listPublicProducts", args, options);
|
|
151
160
|
}
|
|
152
161
|
function useEvents(args, options) {
|
|
153
162
|
return useBowlosQuery("listPublicEvents", args, options);
|
|
154
163
|
}
|
|
164
|
+
function useEventOffers(args, options) {
|
|
165
|
+
return useBowlosQuery("listPublicEventOffers", args, options);
|
|
166
|
+
}
|
|
167
|
+
function useEventOffer(args, options) {
|
|
168
|
+
return useBowlosQuery("getPublicEventOffer", args, options);
|
|
169
|
+
}
|
|
155
170
|
function usePackages(args, options) {
|
|
156
171
|
return useBowlosQuery("listPublicPackages", args, options);
|
|
157
172
|
}
|
|
@@ -173,6 +188,9 @@ function useGameCards(args, options) {
|
|
|
173
188
|
function useGameCardPreview(args, options) {
|
|
174
189
|
return useBowlosQuery("previewGameCardOrder", args, { ...options, auth: true });
|
|
175
190
|
}
|
|
191
|
+
function useEventTicketPreview(args, options) {
|
|
192
|
+
return useBowlosQuery("previewEventTicketOrder", args, { ...options, auth: true });
|
|
193
|
+
}
|
|
176
194
|
function useMembershipPreview(args, options) {
|
|
177
195
|
return useBowlosQuery("previewMembershipOrder", args, { ...options, auth: true });
|
|
178
196
|
}
|
|
@@ -347,6 +365,6 @@ function useBookingFlow() {
|
|
|
347
365
|
};
|
|
348
366
|
}
|
|
349
367
|
|
|
350
|
-
export { BowlosProvider, useAccount, useAddons, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useCenterHours, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCards, useMembershipPreview, useMembershipSubscriptionPreview, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackages, useProducts, usePublicMemberships, useStartTimes };
|
|
351
|
-
//# sourceMappingURL=chunk-
|
|
352
|
-
//# sourceMappingURL=chunk-
|
|
368
|
+
export { BowlosProvider, useAccount, useAddons, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventTicketPreview, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCards, useMembershipPreview, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackages, useProducts, usePublicMemberships, useStartTimes };
|
|
369
|
+
//# sourceMappingURL=chunk-FV6SROO2.js.map
|
|
370
|
+
//# sourceMappingURL=chunk-FV6SROO2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx","../src/hooks.tsx","../src/use-booking-flow.tsx"],"names":["useState","useRef","useCallback","useEffect"],"mappings":";;;;AAwBA,IAAM,aAAA,GAAgB,cAAmC,I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,MAER;AAAA,IACF;AACA,IAAA,SAAA,CAAU,WAAW,CAAA;AAAA,EACvB,CAAA,EAAG,CAAC,MAAA,EAAQ,WAAW,CAAC,CAAA;AAExB,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA,EAAiB,IAAA,GAAO,IAAA,CAAK,eAAA,GAAkB,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-FV6SROO2.js","sourcesContent":["/**\n * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\nconst AccountContext = createContext<UseAccountResult | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n const bowlosClient = ref.current as BowlosClient; // non-null after the guard above\n // Run the session machine ONCE here and share it via context, so every\n // useAccount() across the app sees the same session.\n const account = useAccountState(bowlosClient);\n return (\n <BowlosContext.Provider value={bowlosClient}>\n <AccountContext.Provider value={account}>{children}</AccountContext.Provider>\n </BowlosContext.Provider>\n );\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** The session state machine — runs ONCE inside `<BowlosProvider>` and is shared\n * via context. Probes once on mount; each action re-probes so `status`/`customer`\n * stay current. Consumers use `useAccount()`, never this directly. */\nfunction useAccountState(client: BowlosClient): UseAccountResult {\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return { status, customer, error, signIn, signUp, link, signOut, refresh };\n}\n\n/**\n * The customer session (state + actions), shared across the whole app. Every\n * call returns the SAME session — signing in or out anywhere updates the header,\n * the booking form, everywhere at once. Must be used within a `<BowlosProvider>`.\n */\nexport function useAccount(): UseAccountResult {\n const account = useContext(AccountContext);\n if (!account) {\n throw new Error(\"useAccount must be used within a <BowlosProvider>.\");\n }\n return account;\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport { useBowlosQuery, type UseQueryOptions, type UseQueryResult } from \"./react\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n PublicAddon,\n StartTimesArgs,\n PackagePreviewArgs,\n PackagePreviewResult,\n GameCardPreviewArgs,\n GameCardPreviewResult,\n EventTicketPreviewArgs,\n EventTicketPreviewResult,\n MembershipPreviewArgs,\n MembershipPreviewResult,\n MembershipSubscriptionPreviewResult,\n} from \"./data\";\nimport type {\n BrandScoped,\n EventOrderDetailArgs,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type {\n BrandCatalogArgs,\n CatalogArgs,\n CatalogResult,\n CenterScoped,\n PackageDetailArgs,\n CenterHoursArgs,\n} from \"./catalog\";\n\n/** Live free-unit availability for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n/** Bookable add-ons (shoe rental, upgrades…) for a product. */\nexport function useAddons(\n args: { productId: string },\n options?: UseQueryOptions,\n): UseQueryResult<PublicAddon[]> {\n return useBowlosQuery<PublicAddon[]>(\"listPublicAddons\", args, options);\n}\n\n/** Bookable start times (minute-of-day) for a product on a date. */\nexport function useStartTimes(\n args: StartTimesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<number[]> {\n return useBowlosQuery<number[]>(\"availableStartTimes\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The signed-in customer's event ticket orders. */\nexport function useMyEventOrders<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyEventOrders\", args, { ...options, auth: true });\n}\n\n/** One of the customer's event ticket orders. */\nexport function useMyEventOrder<T = unknown>(\n args: EventOrderDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyEventOrder\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function useFlashSales<T = unknown>(\n args: FlashSalesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicFlashSales\", args, options);\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n\n// ── public catalog (anonymous; power `<BookingCatalog>`) ──────────────────────\n\n/**\n * The canonical public catalog for a surface — every category grouped, with the\n * Center admin's per-surface visibility already applied. Prefer this over the\n * per-category hooks below when you want the full, visibility-aware catalog\n * (it stays consistent with the white-label web + mobile surfaces). Anonymous.\n */\nexport function useCatalog<T = CatalogResult>(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicCatalog\", args, options);\n}\n\n/** Bookable products at a Center (each carries `attractionTypeKey`). */\nexport function useProducts<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicProducts\", args, options);\n}\n\n/** Upcoming pricing events at a Center. */\nexport function useEvents<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEvents\", args, options);\n}\n\n/** Sellable event offers at a Center. Use these for the product lineup and\n * event landing pages; each row carries a slug and purchase mode. */\nexport function useEventOffers<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEventOffers\", args, options);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function useEventOffer<T = unknown>(\n args: { slug: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicEventOffer\", args, options);\n}\n\n/** Purchasable packages at a Brand. */\nexport function usePackages<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicPackages\", args, options);\n}\n\n/** Full detail for one package (components, add-ons, allowed start times, …) —\n * drives the headless package config UI before `usePackagePurchase`. */\nexport function usePackage<T = unknown>(\n args: PackageDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicPackage\", args, options);\n}\n\n/** A Center's open/close window for the given attraction types on a date — use\n * the package's component attraction-type keys to bound its bookable slots. */\nexport function useCenterHours<T = unknown>(\n args: CenterHoursArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getCenterOperatingHoursForTypes\", args, options);\n}\n\n/** Itemized quote for a package order — base, add-ons, tax lines, the selling\n * Center's booking fee, and the authoritative grand total. Drives the headless\n * **Review** step. Requires a signed-in customer (tax exemptions are applied),\n * and is computed by the same engine as the PaymentIntent, so it never diverges\n * from what the customer is charged. */\nexport function usePackagePreview<T = PackagePreviewResult>(\n args: PackagePreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewPackageOrder\", args, { ...options, auth: true });\n}\n\n/** Purchasable memberships at a Center. */\nexport function usePublicMemberships<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicMemberships\", args, options);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function useGameCards<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicGameCards\", args, options);\n}\n\n/** Itemized quote for a game-pass purchase — the base price, tax lines, the\n * selling Center's booking fee, and the authoritative grand total. Drives the\n * headless **Review** step. Requires a signed-in customer (tax exemptions are\n * applied + the home Center is resolved server-side), and is computed by the\n * same engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport function useGameCardPreview<T = GameCardPreviewResult>(\n args: GameCardPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewGameCardOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a ticket-mode event offer — base tickets, tax lines,\n * Center event fee, and authoritative grand total. Requires a signed-in\n * customer so tax exemptions match the eventual charge. */\nexport function useEventTicketPreview<T = EventTicketPreviewResult>(\n args: EventTicketPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewEventTicketOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a one-time membership purchase — dues, the one-time setup\n * fee, tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless **Review** step. Requires a signed-in customer (tax\n * exemptions are applied + the home Center is resolved server-side), and is\n * computed by the same engine as the PaymentIntent, so it never diverges from\n * what the customer is charged. */\nexport function useMembershipPreview<T = MembershipPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a RECURRING membership subscription — the one-time Review\n * fields (\"Due today\") PLUS `recurringTotalCents` + `cadence` (\"Auto-renews\n * at\"). Drives the recurring **Review** step. Requires a signed-in customer, and\n * is computed by the same engine as the subscription's first invoice, so it\n * never diverges from what the customer is charged. */\nexport function useMembershipSubscriptionPreview<T = MembershipSubscriptionPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipSubscriptionOrder\", args, {\n ...options,\n auth: true,\n });\n}\n","/**\n * useBookingFlow — the hold → pay → confirm state machine.\n *\n * Orchestrates the booking funnel and HANDS the Stripe (Connect) payment data\n * to the UI layer; it does NOT load Stripe.js. After `preparePayment()`, render\n * Stripe Elements from `paymentIntent` (initialize Stripe with\n * `connectedAccountId` + `clientSecret`), let the customer pay, then\n * `startPolling()` until the webhook materializes the booking\n * (`status: \"confirmed\"`).\n *\n * Flow:\n * startHold(args) → \"held\" (requiresPayment) | \"confirmed\" (credit covered)\n * preparePayment() → \"awaitingPayment\" (+ paymentIntent)\n * [consumer renders Stripe Elements + the customer pays]\n * startPolling() → \"confirmed\" | \"expired\" | \"failed\" | \"abandoned\"\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport {\n abandonCheckout as abandonCheckoutCall,\n createBooking as createBookingCall,\n createCheckoutPaymentIntent as createPaymentIntentCall,\n getCheckoutStatus as getCheckoutStatusCall,\n type BookingHold,\n type CheckoutStatusResult,\n type CreateBookingArgs,\n type PaymentIntentInfo,\n} from \"./data\";\n\nexport type BookingFlowStatus =\n | \"idle\"\n | \"holding\"\n | \"held\"\n | \"preparingPayment\"\n | \"awaitingPayment\"\n | \"confirmed\"\n | \"expired\"\n | \"failed\"\n | \"abandoned\"\n | \"error\";\n\nexport interface BookingReservationRef {\n reservationId: string | null;\n reservationDisplayId: string | null;\n}\n\nexport interface UseBookingFlowResult {\n status: BookingFlowStatus;\n hold: BookingHold | null;\n refToken: string | null;\n paymentIntent: PaymentIntentInfo | null;\n reservation: BookingReservationRef | null;\n requiresPayment: boolean | null;\n error: BowlosApiError | null;\n startHold: (args: CreateBookingArgs) => Promise<void>;\n preparePayment: () => Promise<PaymentIntentInfo | null>;\n pollStatus: () => Promise<CheckoutStatusResult | null>;\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n abandon: () => Promise<void>;\n reset: () => void;\n}\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function useBookingFlow(): UseBookingFlowResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<BookingFlowStatus>(\"idle\");\n const [hold, setHold] = useState<BookingHold | null>(null);\n const [refToken, setRefToken] = useState<string | null>(null);\n const [paymentIntent, setPaymentIntent] = useState<PaymentIntentInfo | null>(null);\n const [reservation, setReservation] = useState<BookingReservationRef | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n // Mirror of refToken for the polling interval (avoids a stale closure).\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n\n useEffect(() => stopPolling, [stopPolling]); // clear the interval on unmount\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setRefToken(null);\n setHold(null);\n setPaymentIntent(null);\n setReservation(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const applyStatus = useCallback(\n (s: CheckoutStatusResult) => {\n switch (s.status) {\n case \"paid_materialized\":\n setReservation({\n reservationId: s.reservationId,\n reservationDisplayId: s.reservationDisplayId,\n });\n setStatus(\"confirmed\");\n stopPolling();\n break;\n case \"expired\":\n setStatus(\"expired\");\n stopPolling();\n break;\n case \"abandoned\":\n setStatus(\"abandoned\");\n stopPolling();\n break;\n case \"payment_failed_retryable\":\n setStatus(\"failed\");\n stopPolling();\n break;\n case \"not_found\":\n setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, \"Checkout not found.\", 404));\n setStatus(\"error\");\n stopPolling();\n break;\n case \"pending_payment\":\n default:\n break; // keep waiting\n }\n },\n [stopPolling],\n );\n\n const startHold = useCallback(\n async (args: CreateBookingArgs) => {\n stopPolling();\n setError(null);\n setPaymentIntent(null);\n setReservation(null);\n setStatus(\"holding\");\n try {\n const h = await createBookingCall(client, args);\n setHold(h);\n const rt = typeof h.checkoutRefToken === \"string\" ? h.checkoutRefToken : null;\n refTokenRef.current = rt;\n setRefToken(rt);\n if (!h.requiresPayment) {\n setReservation({\n reservationId: h.reservationId ?? null,\n reservationDisplayId: h.reservationDisplayId ?? null,\n });\n setStatus(\"confirmed\");\n } else if (rt) {\n setStatus(\"held\");\n } else {\n setError(\n new BowlosApiError(\n \"UNSUPPORTED_BOOKING_PATH\",\n \"This booking requires payment but no checkout hold was returned.\",\n 0,\n ),\n );\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client, stopPolling],\n );\n\n const preparePayment = useCallback(async (): Promise<PaymentIntentInfo | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n setError(null);\n setStatus(\"preparingPayment\");\n try {\n const pi = await createPaymentIntentCall(client, rt);\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n return pi;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n return null;\n }\n }, [client]);\n\n const pollStatus = useCallback(async (): Promise<CheckoutStatusResult | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n try {\n const s = await getCheckoutStatusCall(client, rt);\n applyStatus(s);\n return s;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n return null;\n }\n }, [client, applyStatus]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n void pollStatus();\n pollRef.current = setInterval(() => {\n void pollStatus();\n }, intervalMs);\n },\n [pollStatus, stopPolling],\n );\n\n const abandon = useCallback(async () => {\n stopPolling();\n const rt = refTokenRef.current;\n if (rt) {\n try {\n await abandonCheckoutCall(client, rt);\n } catch {\n // best-effort: the hold also frees itself on its TTL\n }\n }\n setStatus(\"abandoned\");\n }, [client, stopPolling]);\n\n return {\n status,\n hold,\n refToken,\n paymentIntent,\n reservation,\n requiresPayment: hold ? hold.requiresPayment : null,\n error,\n startHold,\n preparePayment,\n pollStatus,\n startPolling,\n stopPolling,\n abandon,\n reset,\n };\n}\n"]}
|