@bowlos/reservations 0.6.0 → 0.7.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/README.md +22 -1
- package/dist/catalog-DBIisELC.d.ts +74 -0
- package/dist/catalog-DEwo88hz.d.cts +74 -0
- package/dist/{chunk-H42X4FRR.js → chunk-JBBWGMRT.js} +18 -3
- package/dist/chunk-JBBWGMRT.js.map +1 -0
- package/dist/components.cjs +114 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +71 -1
- package/dist/components.d.ts +71 -1
- package/dist/components.js +100 -2
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +20 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +12 -2
- package/dist/react.d.ts +12 -2
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/templates/center-site/app/book/page.tsx +23 -22
- package/templates/center-site/app/buy/page.tsx +36 -0
- package/templates/center-site/app/catalog/page.tsx +35 -0
- package/templates/center-site/app/site-header.tsx +1 -1
- package/templates/center-site/package.json +1 -1
- package/dist/account-BRapzoNI.d.cts +0 -46
- package/dist/account-VO6BzPNK.d.ts +0 -46
- package/dist/chunk-H42X4FRR.js.map +0 -1
package/README.md
CHANGED
|
@@ -152,7 +152,28 @@ import { BookingFlow, BowlosTheme } from "@bowlos/reservations/components";
|
|
|
152
152
|
</BowlosProvider>;
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
**`<BookingCatalog brandId centerId onSelect>`** is the catalog landing — "what
|
|
156
|
+
would you like to book?" It lists everything the center sells online under
|
|
157
|
+
category headings (**Bowling**, **Other attractions**, **Events**, **Packages**,
|
|
158
|
+
**Memberships**, **Game passes**) and hands off each pick via `onSelect`: a
|
|
159
|
+
`product` or `event` → your `<BookingFlow>` (preset the event's date); a
|
|
160
|
+
`package` / `membership` / `gamecard` → its buy page.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { BookingCatalog } from "@bowlos/reservations/components";
|
|
164
|
+
|
|
165
|
+
<BookingCatalog
|
|
166
|
+
brandId="brand_…"
|
|
167
|
+
centerId="center_…"
|
|
168
|
+
onSelect={(o) =>
|
|
169
|
+
o.kind === "product" || o.kind === "event"
|
|
170
|
+
? router.push(`/book?productId=${o.id}`)
|
|
171
|
+
: router.push(`/buy?kind=${o.kind}&id=${o.id}`)
|
|
172
|
+
}
|
|
173
|
+
/>;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The drop-in surfaces cover a center site end to end:
|
|
156
177
|
|
|
157
178
|
**`<BookingFlow>`** runs the whole funnel (availability + price → book → pay →
|
|
158
179
|
confirm). It's **account-aware** — when a customer is signed in it hides the
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { j as BowlosClient } from './data-DrM0D6Pi.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
+
*
|
|
6
|
+
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
+
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
+
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
+
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
+
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
+
* function here and a React hook in `hooks.tsx`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
+
type BrandScoped = {
|
|
16
|
+
brandId: string;
|
|
17
|
+
};
|
|
18
|
+
type ReservationDetailArgs = {
|
|
19
|
+
brandId: string;
|
|
20
|
+
displayId: string;
|
|
21
|
+
};
|
|
22
|
+
type MembershipDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
membershipId: string;
|
|
25
|
+
};
|
|
26
|
+
type FlashSaleArgs = {
|
|
27
|
+
slug: string;
|
|
28
|
+
};
|
|
29
|
+
type FlashBookingOptionsArgs = {
|
|
30
|
+
slug: string;
|
|
31
|
+
itemId: string;
|
|
32
|
+
};
|
|
33
|
+
type FlashSalesArgs = {
|
|
34
|
+
brandId: string;
|
|
35
|
+
};
|
|
36
|
+
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
37
|
+
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
38
|
+
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
39
|
+
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
40
|
+
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
+
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
42
|
+
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
44
|
+
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
45
|
+
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
46
|
+
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
50
|
+
* surface that powers `<BookingCatalog>`. All anonymous (no customer login).
|
|
51
|
+
* Products + events + memberships are Center-scoped; packages + game cards are
|
|
52
|
+
* Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
|
|
53
|
+
* the component types the display fields it needs.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
type CenterScoped = {
|
|
57
|
+
centerId: string;
|
|
58
|
+
};
|
|
59
|
+
type BrandCatalogArgs = {
|
|
60
|
+
brandId: string;
|
|
61
|
+
centerId?: string;
|
|
62
|
+
};
|
|
63
|
+
/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
|
|
64
|
+
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
65
|
+
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
66
|
+
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
67
|
+
/** Purchasable packages at a Brand. */
|
|
68
|
+
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
69
|
+
/** Purchasable memberships at a Center. */
|
|
70
|
+
declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
71
|
+
/** Purchasable game cards / passes at a Brand. */
|
|
72
|
+
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
73
|
+
|
|
74
|
+
export { type BrandCatalogArgs as B, type CenterScoped as C, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type BrandScoped as a, type FlashSaleArgs as b, type FlashSalesArgs as c, getFlashSaleBookingOptions as d, getFlashSales as e, getMyCredits as f, getFlashSale as g, getMyLoyalty as h, getMyMembershipDetail as i, getMyMemberships as j, getMyPasses as k, getMyReservationDetail as l, getMyReservations as m, listEvents as n, listGameCards as o, listPackages as p, listProducts as q, listPublicMemberships as r };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { j as BowlosClient } from './data-DrM0D6Pi.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
+
*
|
|
6
|
+
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
+
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
+
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
+
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
+
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
+
* function here and a React hook in `hooks.tsx`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
+
type BrandScoped = {
|
|
16
|
+
brandId: string;
|
|
17
|
+
};
|
|
18
|
+
type ReservationDetailArgs = {
|
|
19
|
+
brandId: string;
|
|
20
|
+
displayId: string;
|
|
21
|
+
};
|
|
22
|
+
type MembershipDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
membershipId: string;
|
|
25
|
+
};
|
|
26
|
+
type FlashSaleArgs = {
|
|
27
|
+
slug: string;
|
|
28
|
+
};
|
|
29
|
+
type FlashBookingOptionsArgs = {
|
|
30
|
+
slug: string;
|
|
31
|
+
itemId: string;
|
|
32
|
+
};
|
|
33
|
+
type FlashSalesArgs = {
|
|
34
|
+
brandId: string;
|
|
35
|
+
};
|
|
36
|
+
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
37
|
+
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
38
|
+
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
39
|
+
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
40
|
+
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
+
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
42
|
+
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
44
|
+
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
45
|
+
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
46
|
+
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
50
|
+
* surface that powers `<BookingCatalog>`. All anonymous (no customer login).
|
|
51
|
+
* Products + events + memberships are Center-scoped; packages + game cards are
|
|
52
|
+
* Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
|
|
53
|
+
* the component types the display fields it needs.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
type CenterScoped = {
|
|
57
|
+
centerId: string;
|
|
58
|
+
};
|
|
59
|
+
type BrandCatalogArgs = {
|
|
60
|
+
brandId: string;
|
|
61
|
+
centerId?: string;
|
|
62
|
+
};
|
|
63
|
+
/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
|
|
64
|
+
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
65
|
+
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
66
|
+
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
67
|
+
/** Purchasable packages at a Brand. */
|
|
68
|
+
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
69
|
+
/** Purchasable memberships at a Center. */
|
|
70
|
+
declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
71
|
+
/** Purchasable game cards / passes at a Brand. */
|
|
72
|
+
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
73
|
+
|
|
74
|
+
export { type BrandCatalogArgs as B, type CenterScoped as C, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type BrandScoped as a, type FlashSaleArgs as b, type FlashSalesArgs as c, getFlashSaleBookingOptions as d, getFlashSales as e, getMyCredits as f, getFlashSale as g, getMyLoyalty as h, getMyMembershipDetail as i, getMyMemberships as j, getMyPasses as k, getMyReservationDetail as l, getMyReservations as m, listEvents as n, listGameCards as o, listPackages as p, listProducts as q, listPublicMemberships as r };
|
|
@@ -140,6 +140,21 @@ function useFlashSales(args, options) {
|
|
|
140
140
|
function useFlashSaleBookingOptions(args, options) {
|
|
141
141
|
return useBowlosQuery("getFlashSaleBookingOptions", args, { ...options, auth: true });
|
|
142
142
|
}
|
|
143
|
+
function useProducts(args, options) {
|
|
144
|
+
return useBowlosQuery("listPublicProducts", args, options);
|
|
145
|
+
}
|
|
146
|
+
function useEvents(args, options) {
|
|
147
|
+
return useBowlosQuery("listPublicEvents", args, options);
|
|
148
|
+
}
|
|
149
|
+
function usePackages(args, options) {
|
|
150
|
+
return useBowlosQuery("listPublicPackages", args, options);
|
|
151
|
+
}
|
|
152
|
+
function usePublicMemberships(args, options) {
|
|
153
|
+
return useBowlosQuery("listPublicMemberships", args, options);
|
|
154
|
+
}
|
|
155
|
+
function useGameCards(args, options) {
|
|
156
|
+
return useBowlosQuery("listPublicGameCards", args, options);
|
|
157
|
+
}
|
|
143
158
|
var DEFAULT_POLL_MS = 2500;
|
|
144
159
|
function useBookingFlow() {
|
|
145
160
|
const client = useBowlosClient();
|
|
@@ -305,6 +320,6 @@ function useBookingFlow() {
|
|
|
305
320
|
};
|
|
306
321
|
}
|
|
307
322
|
|
|
308
|
-
export { BowlosProvider, useAccount, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations };
|
|
309
|
-
//# sourceMappingURL=chunk-
|
|
310
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
export { BowlosProvider, useAccount, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCards, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackages, useProducts, usePublicMemberships };
|
|
324
|
+
//# sourceMappingURL=chunk-JBBWGMRT.js.map
|
|
325
|
+
//# sourceMappingURL=chunk-JBBWGMRT.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,IAAI,CAAA;AAC7D,IAAM,cAAA,GAAiB,cAAuC,IAAI,CAAA;AAS3D,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,MAAA,EAAQ,UAAS,EAAwB;AAChF,EAAA,MAAM,GAAA,GAAM,MAAA,CAA4B,MAAA,IAAU,IAAI,CAAA;AACtD,EAAA,IAAI,CAAC,IAAI,OAAA,EAAS;AAChB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,IAC5E;AACA,IAAA,GAAA,CAAI,OAAA,GAAU,mBAAmB,MAAM,CAAA;AAAA,EACzC;AACA,EAAA,MAAM,eAAe,GAAA,CAAI,OAAA;AAGzB,EAAA,MAAM,OAAA,GAAU,gBAAgB,YAAY,CAAA;AAC5C,EAAA,uBACE,GAAA,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,KAAA,EAAO,YAAA,EAC7B,QAAA,kBAAA,GAAA,CAAC,cAAA,CAAe,QAAA,EAAf,EAAwB,KAAA,EAAO,OAAA,EAAU,UAAS,CAAA,EACrD,CAAA;AAEJ;AAEO,SAAS,eAAA,GAAgC;AAC9C,EAAA,MAAM,MA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A,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-JBBWGMRT.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} from \"./data\";\nimport type {\n BrandScoped,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type { BrandCatalogArgs, CenterScoped } 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// ── 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 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/** 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/** 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/** 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 * 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"]}
|
package/dist/components.cjs
CHANGED
|
@@ -164,6 +164,21 @@ function useFlashSale(args, options) {
|
|
|
164
164
|
function useFlashSales(args, options) {
|
|
165
165
|
return useBowlosQuery("listPublicFlashSales", args, options);
|
|
166
166
|
}
|
|
167
|
+
function useProducts(args, options) {
|
|
168
|
+
return useBowlosQuery("listPublicProducts", args, options);
|
|
169
|
+
}
|
|
170
|
+
function useEvents(args, options) {
|
|
171
|
+
return useBowlosQuery("listPublicEvents", args, options);
|
|
172
|
+
}
|
|
173
|
+
function usePackages(args, options) {
|
|
174
|
+
return useBowlosQuery("listPublicPackages", args, options);
|
|
175
|
+
}
|
|
176
|
+
function usePublicMemberships(args, options) {
|
|
177
|
+
return useBowlosQuery("listPublicMemberships", args, options);
|
|
178
|
+
}
|
|
179
|
+
function useGameCards(args, options) {
|
|
180
|
+
return useBowlosQuery("listPublicGameCards", args, options);
|
|
181
|
+
}
|
|
167
182
|
|
|
168
183
|
// src/data.ts
|
|
169
184
|
function availableUnitCount(availability) {
|
|
@@ -1188,12 +1203,111 @@ function When({ ms }) {
|
|
|
1188
1203
|
}, [ms]);
|
|
1189
1204
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text ?? "" });
|
|
1190
1205
|
}
|
|
1206
|
+
var DEFAULT_LABELS7 = {
|
|
1207
|
+
heading: "What would you like to book?",
|
|
1208
|
+
loading: "Loading\u2026",
|
|
1209
|
+
empty: "Nothing is available to book online right now.",
|
|
1210
|
+
bowling: "Bowling",
|
|
1211
|
+
otherAttractions: "Other attractions",
|
|
1212
|
+
events: "Events",
|
|
1213
|
+
packages: "Packages",
|
|
1214
|
+
memberships: "Memberships",
|
|
1215
|
+
gamePasses: "Game passes",
|
|
1216
|
+
select: "Select",
|
|
1217
|
+
minutesAbbrev: "min",
|
|
1218
|
+
perMonth: "/mo"
|
|
1219
|
+
};
|
|
1220
|
+
function BookingCatalog({ brandId, centerId, onSelect, labels, className }) {
|
|
1221
|
+
const t = { ...DEFAULT_LABELS7, ...labels };
|
|
1222
|
+
const s = styles();
|
|
1223
|
+
const products = useProducts({ centerId });
|
|
1224
|
+
const events = useEvents({ centerId });
|
|
1225
|
+
const packages = usePackages({ brandId, centerId });
|
|
1226
|
+
const memberships = usePublicMemberships({ centerId });
|
|
1227
|
+
const gameCards = useGameCards({ brandId, centerId });
|
|
1228
|
+
const reads = [products, events, packages, memberships, gameCards];
|
|
1229
|
+
const anyLoading = reads.some((r) => r.loading && !r.data);
|
|
1230
|
+
const productRows = products.data ?? [];
|
|
1231
|
+
const bowling = productRows.filter((p) => p.attractionTypeKey === "bowling").map((p) => ({ kind: "product", ...p }));
|
|
1232
|
+
const other = productRows.filter((p) => p.attractionTypeKey !== "bowling").map((p) => ({ kind: "product", ...p }));
|
|
1233
|
+
const eventOffers = (events.data ?? []).map((e) => ({
|
|
1234
|
+
kind: "event",
|
|
1235
|
+
id: e.id,
|
|
1236
|
+
name: e.name,
|
|
1237
|
+
date: e.date,
|
|
1238
|
+
description: e.description
|
|
1239
|
+
}));
|
|
1240
|
+
const packageOffers = (packages.data ?? []).map((p) => ({
|
|
1241
|
+
kind: "package",
|
|
1242
|
+
id: p.id,
|
|
1243
|
+
name: p.name,
|
|
1244
|
+
priceCents: p.basePriceCents,
|
|
1245
|
+
description: p.description
|
|
1246
|
+
}));
|
|
1247
|
+
const membershipOffers = (memberships.data ?? []).map((m) => ({
|
|
1248
|
+
kind: "membership",
|
|
1249
|
+
id: m.id,
|
|
1250
|
+
name: m.name,
|
|
1251
|
+
priceCents: m.recurringPriceCents,
|
|
1252
|
+
description: m.description
|
|
1253
|
+
}));
|
|
1254
|
+
const gameCardOffers = (gameCards.data ?? []).map((g) => ({
|
|
1255
|
+
kind: "gamecard",
|
|
1256
|
+
id: g.id,
|
|
1257
|
+
name: g.name,
|
|
1258
|
+
priceCents: g.priceCents,
|
|
1259
|
+
description: g.description
|
|
1260
|
+
}));
|
|
1261
|
+
const sections = [
|
|
1262
|
+
{ title: t.bowling, offers: bowling },
|
|
1263
|
+
{ title: t.otherAttractions, offers: other },
|
|
1264
|
+
{ title: t.events, offers: eventOffers },
|
|
1265
|
+
{ title: t.packages, offers: packageOffers },
|
|
1266
|
+
{ title: t.memberships, offers: membershipOffers },
|
|
1267
|
+
{ title: t.gamePasses, offers: gameCardOffers }
|
|
1268
|
+
].filter((sec) => sec.offers.length > 0);
|
|
1269
|
+
let body;
|
|
1270
|
+
if (anyLoading) {
|
|
1271
|
+
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading });
|
|
1272
|
+
} else if (sections.length === 0) {
|
|
1273
|
+
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.empty });
|
|
1274
|
+
} else {
|
|
1275
|
+
body = sections.map((sec) => /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
|
|
1276
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: sec.title }),
|
|
1277
|
+
sec.offers.map((offer) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.listItem, children: [
|
|
1278
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1279
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: offer.name }),
|
|
1280
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: subtitle(offer, t) })
|
|
1281
|
+
] }),
|
|
1282
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(offer), children: t.select })
|
|
1283
|
+
] }, `${offer.kind}:${offer.id}`))
|
|
1284
|
+
] }, sec.title));
|
|
1285
|
+
}
|
|
1286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
1287
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.heading }),
|
|
1288
|
+
body
|
|
1289
|
+
] });
|
|
1290
|
+
}
|
|
1291
|
+
function subtitle(offer, t) {
|
|
1292
|
+
switch (offer.kind) {
|
|
1293
|
+
case "product":
|
|
1294
|
+
return `${offer.attractionName} \xB7 ${offer.durationMinutes} ${t.minutesAbbrev}`;
|
|
1295
|
+
case "event":
|
|
1296
|
+
return offer.date;
|
|
1297
|
+
case "membership":
|
|
1298
|
+
return `${formatCents(offer.priceCents)}${t.perMonth}`;
|
|
1299
|
+
case "package":
|
|
1300
|
+
case "gamecard":
|
|
1301
|
+
return formatCents(offer.priceCents);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1191
1304
|
|
|
1192
1305
|
exports.AccountDashboard = AccountDashboard;
|
|
1193
1306
|
exports.AccountMenu = AccountMenu;
|
|
1194
1307
|
exports.AuthForm = AuthForm;
|
|
1195
1308
|
exports.AuthGate = AuthGate;
|
|
1196
1309
|
exports.BOWLOS_DEFAULT_THEME = BOWLOS_DEFAULT_THEME;
|
|
1310
|
+
exports.BookingCatalog = BookingCatalog;
|
|
1197
1311
|
exports.BookingFlow = BookingFlow;
|
|
1198
1312
|
exports.BowlosTheme = BowlosTheme;
|
|
1199
1313
|
exports.FlashSale = FlashSale;
|