@bowlos/reservations 0.22.1 → 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 +121 -0
- package/README.md +16 -1
- package/dist/{account-Bm2XnaYS.d.ts → account-B9tDfXke.d.ts} +76 -1
- package/dist/{account-CSaBohMT.d.cts → account-C9SvfE3q.d.cts} +76 -1
- 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/{chunk-FV6SROO2.js → chunk-CRETIPLS.js} +83 -6
- package/dist/chunk-CRETIPLS.js.map +1 -0
- package/dist/components.cjs +166 -52
- 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 +135 -19
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +36 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/{react-Bc_6yi9q.d.cts → react--584Q9zx.d.cts} +15 -2
- package/dist/{react-B1uSOozS.d.ts → react-C0c5k3Tt.d.ts} +15 -2
- package/dist/react.cjs +185 -98
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +37 -10
- package/dist/react.d.ts +37 -10
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/templates/center-site/package.json +1 -1
- package/dist/chunk-FV6SROO2.js.map +0 -1
package/dist/components.cjs
CHANGED
|
@@ -136,6 +136,38 @@ function useBowlosQuery(name, args = {}, options = {}) {
|
|
|
136
136
|
return { data, error, loading, refetch };
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// src/data.ts
|
|
140
|
+
function availableUnitCount(availability) {
|
|
141
|
+
return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);
|
|
142
|
+
}
|
|
143
|
+
function generateIdempotencyKey() {
|
|
144
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
145
|
+
return crypto.randomUUID();
|
|
146
|
+
}
|
|
147
|
+
return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
148
|
+
}
|
|
149
|
+
function createBooking(client, args) {
|
|
150
|
+
const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();
|
|
151
|
+
return client.call(
|
|
152
|
+
"createAnonymousBooking",
|
|
153
|
+
{ ...args, idempotencyKey },
|
|
154
|
+
{ auth: true }
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function createCheckoutPaymentIntent(client, refToken) {
|
|
158
|
+
return client.call(
|
|
159
|
+
"createCheckoutPaymentIntent",
|
|
160
|
+
{ refToken },
|
|
161
|
+
{ auth: true }
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function getCheckoutStatus(client, refToken) {
|
|
165
|
+
return client.call("getCheckoutStatus", { refToken }, { auth: true });
|
|
166
|
+
}
|
|
167
|
+
function abandonCheckout(client, refToken) {
|
|
168
|
+
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
169
|
+
}
|
|
170
|
+
|
|
139
171
|
// src/hooks.tsx
|
|
140
172
|
function useAvailability(args, options) {
|
|
141
173
|
return useBowlosQuery("checkAvailability", args, options);
|
|
@@ -173,40 +205,6 @@ function useFlashSales(args, options) {
|
|
|
173
205
|
function useCatalog(args, options) {
|
|
174
206
|
return useBowlosQuery("listPublicCatalog", args, options);
|
|
175
207
|
}
|
|
176
|
-
|
|
177
|
-
// src/data.ts
|
|
178
|
-
function availableUnitCount(availability) {
|
|
179
|
-
return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);
|
|
180
|
-
}
|
|
181
|
-
function generateIdempotencyKey() {
|
|
182
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
183
|
-
return crypto.randomUUID();
|
|
184
|
-
}
|
|
185
|
-
return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
186
|
-
}
|
|
187
|
-
function createBooking(client, args) {
|
|
188
|
-
const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();
|
|
189
|
-
return client.call(
|
|
190
|
-
"createAnonymousBooking",
|
|
191
|
-
{ ...args, idempotencyKey },
|
|
192
|
-
{ auth: true }
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
function createCheckoutPaymentIntent(client, refToken) {
|
|
196
|
-
return client.call(
|
|
197
|
-
"createCheckoutPaymentIntent",
|
|
198
|
-
{ refToken },
|
|
199
|
-
{ auth: true }
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
function getCheckoutStatus(client, refToken) {
|
|
203
|
-
return client.call("getCheckoutStatus", { refToken }, { auth: true });
|
|
204
|
-
}
|
|
205
|
-
function abandonCheckout(client, refToken) {
|
|
206
|
-
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/use-booking-flow.tsx
|
|
210
208
|
var DEFAULT_POLL_MS = 2500;
|
|
211
209
|
function useBookingFlow() {
|
|
212
210
|
const client = useBowlosClient();
|
|
@@ -1361,8 +1359,18 @@ var DEFAULT_LABELS7 = {
|
|
|
1361
1359
|
heading: "What would you like to book?",
|
|
1362
1360
|
loading: "Loading\u2026",
|
|
1363
1361
|
empty: "Nothing is available to book online right now.",
|
|
1364
|
-
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"
|
|
1365
1372
|
};
|
|
1373
|
+
var DATE_BOUND_KEYS = ["bowling", "other_attractions"];
|
|
1366
1374
|
function BookingCatalog({
|
|
1367
1375
|
brandId,
|
|
1368
1376
|
centerId,
|
|
@@ -1370,44 +1378,150 @@ function BookingCatalog({
|
|
|
1370
1378
|
onSelect,
|
|
1371
1379
|
labels,
|
|
1372
1380
|
sectionLabels,
|
|
1381
|
+
defaultEntry,
|
|
1382
|
+
showEntryToggle = true,
|
|
1373
1383
|
className
|
|
1374
1384
|
}) {
|
|
1375
1385
|
const t = { ...DEFAULT_LABELS7, ...labels };
|
|
1376
1386
|
const s = styles();
|
|
1377
1387
|
const catalog = useCatalog({ brandId, centerId, surface });
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
);
|
|
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);
|
|
1381
1401
|
let body;
|
|
1382
1402
|
if (catalog.loading && !catalog.data) {
|
|
1383
1403
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading });
|
|
1384
1404
|
} else if (sections.length === 0) {
|
|
1385
1405
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.empty });
|
|
1386
|
-
} else {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
] }),
|
|
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 }),
|
|
1394
1413
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1395
|
-
"
|
|
1414
|
+
"input",
|
|
1396
1415
|
{
|
|
1397
|
-
type: "
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1416
|
+
type: "date",
|
|
1417
|
+
value: effDate,
|
|
1418
|
+
min: today,
|
|
1419
|
+
onChange: (e) => setDate(e.target.value || today),
|
|
1420
|
+
style: s.input
|
|
1401
1421
|
}
|
|
1402
1422
|
)
|
|
1403
|
-
] },
|
|
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))
|
|
1404
1454
|
] }, sec.key));
|
|
1405
1455
|
}
|
|
1406
1456
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
1407
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
|
+
] }),
|
|
1408
1462
|
body
|
|
1409
1463
|
] });
|
|
1410
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
|
+
}
|
|
1411
1525
|
|
|
1412
1526
|
exports.AccountDashboard = AccountDashboard;
|
|
1413
1527
|
exports.AccountMenu = AccountMenu;
|