@bowlos/reservations 0.23.0 → 0.24.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 +39 -0
- package/README.md +8 -0
- package/dist/{catalog-BxyPJdBL.d.ts → catalog-BPh01sfG.d.ts} +9 -0
- package/dist/{catalog-D1VoVaNe.d.cts → catalog-I7Lpar3V.d.cts} +9 -0
- package/dist/components.cjs +134 -18
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +30 -24
- package/dist/components.d.ts +30 -24
- package/dist/components.js +134 -18
- package/dist/components.js.map +1 -1
- 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.map +1 -1
- package/dist/{react--BT8olOw.d.cts → react--584Q9zx.d.cts} +1 -1
- package/dist/{react-BvuU4nzT.d.ts → react-C0c5k3Tt.d.ts} +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/package.json +1 -1
- package/templates/center-site/package.json +1 -1
package/HEADLESS.md
CHANGED
|
@@ -889,6 +889,43 @@ as done and re-read the list.
|
|
|
889
889
|
`getMyGameCards(client, { brandId })`, etc. (generate the key with
|
|
890
890
|
`generateIdempotencyKey()`).
|
|
891
891
|
|
|
892
|
+
## Date-first booking (v0.24.0)
|
|
893
|
+
|
|
894
|
+
A Center can default its booking entry to **date-first** ("pick a day → see
|
|
895
|
+
what's bookable") instead of product-first ("pick an activity → pick a day").
|
|
896
|
+
The catalog read tells you which, and the customer can toggle either way.
|
|
897
|
+
|
|
898
|
+
**Read the default off `useCatalog`:**
|
|
899
|
+
```tsx
|
|
900
|
+
const catalog = useCatalog<CatalogResult>({ brandId, centerId, surface });
|
|
901
|
+
const entry = catalog.data?.bookingEntryDefault ?? "product_first"; // your initial mode
|
|
902
|
+
const today = catalog.data?.todayISO; // Center-local YYYY-MM-DD — date-picker default/min
|
|
903
|
+
```
|
|
904
|
+
Render a **toggle** (Browse by activity / Browse by date) seeded with `entry`;
|
|
905
|
+
the customer's choice overrides it. `bookingEntryDefault` + `todayISO` are
|
|
906
|
+
optional (older gateways omit them → treat as `product_first`).
|
|
907
|
+
|
|
908
|
+
**Date-first list — reuse `useStartTimes`, no new endpoint.** For the chosen
|
|
909
|
+
day, the date-bound items are the `book_reservation` catalog items (categories
|
|
910
|
+
`bowling`, `other_attractions`); check each with the existing per-product read:
|
|
911
|
+
```tsx
|
|
912
|
+
const times = useStartTimes({ productId, dateISO }); // [] = nothing bookable that day
|
|
913
|
+
const available = (times.data?.length ?? 0) > 0; // show "See times & pricing" + Book, else dim
|
|
914
|
+
```
|
|
915
|
+
- **Products carry no price** (`priceLabel` is null) — show "See times & pricing";
|
|
916
|
+
the binding price comes from `useBookingPreview` / checkout on drill-in (the
|
|
917
|
+
date-first row is non-binding).
|
|
918
|
+
- **Events** are date-tied but their bookable date lives on the event landing
|
|
919
|
+
page — render the `events` section as its own list (don't try to filter it by
|
|
920
|
+
the picked day; the offer's slug is what you route on).
|
|
921
|
+
- **Memberships / game passes / packages** are buy-anytime — render them in an
|
|
922
|
+
"Available any day" strip, not under the date.
|
|
923
|
+
|
|
924
|
+
The drop-in `<BookingCatalog>` does all of this when the Center default is
|
|
925
|
+
date-first (or pass `defaultEntry="date_first"`); `showEntryToggle` (default
|
|
926
|
+
true) renders the toggle. Drill-in still routes through `onSelect` → your
|
|
927
|
+
booking flow exactly as before.
|
|
928
|
+
|
|
892
929
|
## Adopting changes by version
|
|
893
930
|
|
|
894
931
|
What each SDK release changed in `<BookingFlow>` and the headless steps to match.
|
|
@@ -917,5 +954,7 @@ Headless sites do **not** get these from a version bump — apply them by hand.
|
|
|
917
954
|
|
|
918
955
|
| **0.23.0** | **Self-serve cancel parity** — preview + cancel hooks for all four types (`useReservationCancelPreview`/`useCancelMyReservation`, `useEventOrderCancelPreview`/`useCancelMyEventOrder`, `usePackageOrderCancelPreview`/`useCancelMyPackageOrder`, `useGameCardCancelPreview`/`useCancelMyGameCard`) + `useMyGameCards`; framework-free core fns mirror them. `listMyReservations` now returns `version`. | New "Self-serve cancel" section. Build a preview → confirm → cancel screen per type in your own design. Store credit only (card refunds stay staff-only); game cards cancel only while fully unused. Pass the reservation `version` as `expectedVersion`. Re-read the preview right before confirming. |
|
|
919
956
|
|
|
957
|
+
| **0.24.0** | **Date-first booking** — `useCatalog`/`CatalogResult` now carry `bookingEntryDefault` (Center default entry point) + `todayISO` (Center-local). `<BookingCatalog>` opens on the Center default, renders a by-activity/by-date toggle (`showEntryToggle`, `defaultEntry` override), and in date-first mode lists products bookable that day (per-product `useStartTimes`) + an Events section + an "Available any day" strip. | New "Date-first booking" section. Read `bookingEntryDefault`/`todayISO` off `useCatalog`; seed a toggle; for the chosen day check each `book_reservation` item with `useStartTimes` (empty = unavailable). Products show "See times & pricing" (no price; drill-in re-quotes); events get their own section (not per-day filtered); memberships/game-passes/packages are the "any day" strip. The drop-in does all of this automatically. |
|
|
958
|
+
|
|
920
959
|
When you add the next release here, add its row **and** any new capability-map
|
|
921
960
|
section in the same PR.
|
package/README.md
CHANGED
|
@@ -210,6 +210,14 @@ Public Catalog toggles apply to the drop-in too. Each pick hands off a
|
|
|
210
210
|
`item.action.payload` (same routing table as a headless site — HEADLESS.md →
|
|
211
211
|
"The canonical catalog").
|
|
212
212
|
|
|
213
|
+
**Date-first booking (v0.24.0):** the catalog read now returns the Center's
|
|
214
|
+
`bookingEntryDefault` (+ Center-local `todayISO`). `<BookingCatalog>` opens on
|
|
215
|
+
that default and shows a "browse by activity / by date" toggle the customer can
|
|
216
|
+
flip (`showEntryToggle`, or force with `defaultEntry`). Date-first lists what's
|
|
217
|
+
bookable on a chosen day (per-product `useStartTimes`), an Events section, and an
|
|
218
|
+
"Available any day" strip. Headless sites build the same from `useCatalog` +
|
|
219
|
+
`useStartTimes` — see HEADLESS.md → "Date-first booking".
|
|
220
|
+
|
|
213
221
|
```tsx
|
|
214
222
|
import { BookingCatalog } from "@bowlos/reservations/components";
|
|
215
223
|
|
|
@@ -102,6 +102,15 @@ interface CatalogSection {
|
|
|
102
102
|
}
|
|
103
103
|
interface CatalogResult {
|
|
104
104
|
sections: CatalogSection[];
|
|
105
|
+
/**
|
|
106
|
+
* Date-first booking (v0.24.0): the Center's default booking entry point.
|
|
107
|
+
* Open your funnel on this; let the customer toggle to the other. Optional —
|
|
108
|
+
* older gateways omit it (treat absent as `"product_first"`).
|
|
109
|
+
*/
|
|
110
|
+
bookingEntryDefault?: "product_first" | "date_first";
|
|
111
|
+
/** Center-local "today" (YYYY-MM-DD) — default + minimum for a date-first
|
|
112
|
+
* date picker, so you don't guess the Center's timezone. Optional. */
|
|
113
|
+
todayISO?: string;
|
|
105
114
|
}
|
|
106
115
|
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
107
116
|
* rules the backend applies. */
|
|
@@ -102,6 +102,15 @@ interface CatalogSection {
|
|
|
102
102
|
}
|
|
103
103
|
interface CatalogResult {
|
|
104
104
|
sections: CatalogSection[];
|
|
105
|
+
/**
|
|
106
|
+
* Date-first booking (v0.24.0): the Center's default booking entry point.
|
|
107
|
+
* Open your funnel on this; let the customer toggle to the other. Optional —
|
|
108
|
+
* older gateways omit it (treat absent as `"product_first"`).
|
|
109
|
+
*/
|
|
110
|
+
bookingEntryDefault?: "product_first" | "date_first";
|
|
111
|
+
/** Center-local "today" (YYYY-MM-DD) — default + minimum for a date-first
|
|
112
|
+
* date picker, so you don't guess the Center's timezone. Optional. */
|
|
113
|
+
todayISO?: string;
|
|
105
114
|
}
|
|
106
115
|
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
107
116
|
* rules the backend applies. */
|
package/dist/components.cjs
CHANGED
|
@@ -1359,8 +1359,18 @@ var DEFAULT_LABELS7 = {
|
|
|
1359
1359
|
heading: "What would you like to book?",
|
|
1360
1360
|
loading: "Loading\u2026",
|
|
1361
1361
|
empty: "Nothing is available to book online right now.",
|
|
1362
|
-
select: "Select"
|
|
1362
|
+
select: "Select",
|
|
1363
|
+
byActivity: "Browse by activity",
|
|
1364
|
+
byDate: "Browse by date",
|
|
1365
|
+
pickDay: "Pick a day",
|
|
1366
|
+
bookableOnPrefix: "Bookable on ",
|
|
1367
|
+
events: "Events",
|
|
1368
|
+
anyDay: "Available any day",
|
|
1369
|
+
noTimesThatDay: "No times this day",
|
|
1370
|
+
nothingThatDay: "Nothing date-specific that day \u2014 try another date or see what's available any day.",
|
|
1371
|
+
checking: "Checking\u2026"
|
|
1363
1372
|
};
|
|
1373
|
+
var DATE_BOUND_KEYS = ["bowling", "other_attractions"];
|
|
1364
1374
|
function BookingCatalog({
|
|
1365
1375
|
brandId,
|
|
1366
1376
|
centerId,
|
|
@@ -1368,44 +1378,150 @@ function BookingCatalog({
|
|
|
1368
1378
|
onSelect,
|
|
1369
1379
|
labels,
|
|
1370
1380
|
sectionLabels,
|
|
1381
|
+
defaultEntry,
|
|
1382
|
+
showEntryToggle = true,
|
|
1371
1383
|
className
|
|
1372
1384
|
}) {
|
|
1373
1385
|
const t = { ...DEFAULT_LABELS7, ...labels };
|
|
1374
1386
|
const s = styles();
|
|
1375
1387
|
const catalog = useCatalog({ brandId, centerId, surface });
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
);
|
|
1388
|
+
const [modeOverride, setModeOverride] = react.useState(null);
|
|
1389
|
+
const [date, setDate] = react.useState(null);
|
|
1390
|
+
const sections = (catalog.data?.sections ?? []).filter((sec) => sec.items.length > 0);
|
|
1391
|
+
const mode = modeOverride ?? defaultEntry ?? catalog.data?.bookingEntryDefault ?? "product_first";
|
|
1392
|
+
const today = catalog.data?.todayISO ?? browserTodayISO();
|
|
1393
|
+
const effDate = date ?? today;
|
|
1394
|
+
const renderItemRow = (item, meta, disabled) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...s.listItem, opacity: 1 }, children: [
|
|
1395
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1396
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: item.title }),
|
|
1397
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: item.priceLabel ?? item.subtitle ?? "" })
|
|
1398
|
+
] }),
|
|
1399
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(item), children: t.select })
|
|
1400
|
+
] }, item.id);
|
|
1379
1401
|
let body;
|
|
1380
1402
|
if (catalog.loading && !catalog.data) {
|
|
1381
1403
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading });
|
|
1382
1404
|
} else if (sections.length === 0) {
|
|
1383
1405
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.empty });
|
|
1384
|
-
} else {
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
] }),
|
|
1406
|
+
} else if (mode === "date_first") {
|
|
1407
|
+
const productItems = sections.filter((sec) => DATE_BOUND_KEYS.includes(sec.key)).flatMap((sec) => sec.items).filter((i) => i.action.type === "book_reservation");
|
|
1408
|
+
const eventItems = sections.find((sec) => sec.key === "events")?.items ?? [];
|
|
1409
|
+
const anytimeItems = sections.filter((sec) => !DATE_BOUND_KEYS.includes(sec.key) && sec.key !== "events").flatMap((sec) => sec.items);
|
|
1410
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1411
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", maxWidth: "16rem" }, children: [
|
|
1412
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: s.listMeta, children: t.pickDay }),
|
|
1392
1413
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1393
|
-
"
|
|
1414
|
+
"input",
|
|
1394
1415
|
{
|
|
1395
|
-
type: "
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1416
|
+
type: "date",
|
|
1417
|
+
value: effDate,
|
|
1418
|
+
min: today,
|
|
1419
|
+
onChange: (e) => setDate(e.target.value || today),
|
|
1420
|
+
style: s.input
|
|
1399
1421
|
}
|
|
1400
1422
|
)
|
|
1401
|
-
] },
|
|
1423
|
+
] }),
|
|
1424
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.75rem" }, children: [
|
|
1425
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h4", { style: s.sectionTitle, children: [
|
|
1426
|
+
t.bookableOnPrefix,
|
|
1427
|
+
formatDay(effDate)
|
|
1428
|
+
] }),
|
|
1429
|
+
productItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.nothingThatDay }) : productItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1430
|
+
ProductDateRow,
|
|
1431
|
+
{
|
|
1432
|
+
item,
|
|
1433
|
+
dateISO: effDate,
|
|
1434
|
+
onSelect,
|
|
1435
|
+
labels: t,
|
|
1436
|
+
s
|
|
1437
|
+
},
|
|
1438
|
+
item.id
|
|
1439
|
+
))
|
|
1440
|
+
] }),
|
|
1441
|
+
eventItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
|
|
1442
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: t.events }),
|
|
1443
|
+
eventItems.map((item) => renderItemRow(item))
|
|
1444
|
+
] }),
|
|
1445
|
+
anytimeItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
|
|
1446
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: t.anyDay }),
|
|
1447
|
+
anytimeItems.map((item) => renderItemRow(item))
|
|
1448
|
+
] })
|
|
1449
|
+
] });
|
|
1450
|
+
} else {
|
|
1451
|
+
body = sections.map((sec) => /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
|
|
1452
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: sectionLabels?.[sec.key] ?? sec.label }),
|
|
1453
|
+
sec.items.map((item) => renderItemRow(item))
|
|
1402
1454
|
] }, sec.key));
|
|
1403
1455
|
}
|
|
1404
1456
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
1405
1457
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.heading }),
|
|
1458
|
+
showEntryToggle && catalog.data && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "0.5rem" }, children: [
|
|
1459
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryButton, { active: mode === "product_first", onClick: () => setModeOverride("product_first"), s, children: t.byActivity }),
|
|
1460
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryButton, { active: mode === "date_first", onClick: () => setModeOverride("date_first"), s, children: t.byDate })
|
|
1461
|
+
] }),
|
|
1406
1462
|
body
|
|
1407
1463
|
] });
|
|
1408
1464
|
}
|
|
1465
|
+
function EntryButton({
|
|
1466
|
+
active,
|
|
1467
|
+
onClick,
|
|
1468
|
+
s,
|
|
1469
|
+
children
|
|
1470
|
+
}) {
|
|
1471
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1472
|
+
"button",
|
|
1473
|
+
{
|
|
1474
|
+
type: "button",
|
|
1475
|
+
onClick,
|
|
1476
|
+
"aria-pressed": active,
|
|
1477
|
+
style: {
|
|
1478
|
+
...s.primaryBtn,
|
|
1479
|
+
opacity: active ? 1 : 0.5,
|
|
1480
|
+
cursor: "pointer"
|
|
1481
|
+
},
|
|
1482
|
+
children
|
|
1483
|
+
}
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
function ProductDateRow({
|
|
1487
|
+
item,
|
|
1488
|
+
dateISO,
|
|
1489
|
+
onSelect,
|
|
1490
|
+
labels,
|
|
1491
|
+
s
|
|
1492
|
+
}) {
|
|
1493
|
+
const productId = item.action.type === "book_reservation" ? item.action.payload.productId : "";
|
|
1494
|
+
const times = useStartTimes(
|
|
1495
|
+
{ productId, dateISO },
|
|
1496
|
+
{ enabled: productId !== "" }
|
|
1497
|
+
);
|
|
1498
|
+
const loading = times.loading && times.data === null;
|
|
1499
|
+
const available = (times.data?.length ?? 0) > 0;
|
|
1500
|
+
const meta = loading ? labels.checking : available ? item.priceLabel ?? "See times & pricing" : labels.noTimesThatDay;
|
|
1501
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...s.listItem, opacity: !loading && !available ? 0.55 : 1 }, children: [
|
|
1502
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1503
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: item.title }),
|
|
1504
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: meta })
|
|
1505
|
+
] }),
|
|
1506
|
+
available && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", style: s.primaryBtn, onClick: () => onSelect(item), children: labels.select })
|
|
1507
|
+
] });
|
|
1508
|
+
}
|
|
1509
|
+
function browserTodayISO() {
|
|
1510
|
+
const d = /* @__PURE__ */ new Date();
|
|
1511
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(
|
|
1512
|
+
d.getDate()
|
|
1513
|
+
).padStart(2, "0")}`;
|
|
1514
|
+
}
|
|
1515
|
+
function formatDay(iso) {
|
|
1516
|
+
const [y, m, d] = iso.split("-").map(Number);
|
|
1517
|
+
if (!y || !m || !d) return iso;
|
|
1518
|
+
return new Date(Date.UTC(y, m - 1, d)).toLocaleDateString(void 0, {
|
|
1519
|
+
weekday: "long",
|
|
1520
|
+
month: "long",
|
|
1521
|
+
day: "numeric",
|
|
1522
|
+
timeZone: "UTC"
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1409
1525
|
|
|
1410
1526
|
exports.AccountDashboard = AccountDashboard;
|
|
1411
1527
|
exports.AccountMenu = AccountMenu;
|