@bowlos/reservations 0.36.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +306 -0
- package/HEADLESS.md +595 -10
- package/README.md +303 -2
- package/dist/account-B4sZBmPI.d.cts +1837 -0
- package/dist/account-B4sZBmPI.d.ts +1837 -0
- package/dist/booking-change-Dd4PVgd3.d.cts +487 -0
- package/dist/booking-change-DzYs9133.d.ts +487 -0
- package/dist/chunk-4JMGS4YB.js +808 -0
- package/dist/chunk-4JMGS4YB.js.map +1 -0
- package/dist/chunk-I37IJNYU.js +139 -0
- package/dist/chunk-I37IJNYU.js.map +1 -0
- package/dist/{chunk-Y3YSDO3H.js → chunk-T2E6AEC7.js} +150 -6
- package/dist/chunk-T2E6AEC7.js.map +1 -0
- package/dist/{chunk-3JSVEOKG.js → chunk-V4JRDYW4.js} +61 -6
- package/dist/chunk-V4JRDYW4.js.map +1 -0
- package/dist/{chunk-TEHRROVY.js → chunk-YQRTBGXU.js} +47 -192
- package/dist/chunk-YQRTBGXU.js.map +1 -0
- package/dist/cli.cjs +34 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +2059 -153
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +214 -7
- package/dist/components.d.ts +214 -7
- package/dist/components.js +1148 -7
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +303 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -5
- package/dist/index.d.ts +56 -5
- package/dist/index.js +58 -3
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +225 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +24 -2
- package/dist/payments.d.ts +24 -2
- package/dist/payments.js +4 -1
- package/dist/payments.js.map +1 -1
- package/dist/{react-CWAG4cW0.d.cts → react-C6NWC80d.d.cts} +2 -2
- package/dist/{react-0MyyTtE4.d.ts → react-DVdtpw5n.d.ts} +2 -2
- package/dist/react.cjs +870 -27
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +155 -12
- package/dist/react.d.ts +155 -12
- package/dist/react.js +72 -4
- package/dist/react.js.map +1 -1
- package/package.json +8 -2
- package/templates/center-site/README.md +5 -0
- package/templates/center-site/app/account/game-cards/page.tsx +17 -0
- package/templates/center-site/app/account/layout.tsx +16 -0
- package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
- package/templates/center-site/app/account/memberships/page.tsx +33 -0
- package/templates/center-site/app/account/orders/page.tsx +17 -0
- package/templates/center-site/app/account/page.tsx +14 -0
- package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
- package/templates/center-site/app/account/privacy/page.tsx +17 -0
- package/templates/center-site/app/account/profile/page.tsx +45 -0
- package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
- package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
- package/templates/center-site/app/account/reservations/page.tsx +35 -0
- package/templates/center-site/app/account/security/page.tsx +17 -0
- package/templates/center-site/app/events/[slug]/page.tsx +130 -0
- package/templates/center-site/app/events/page.tsx +57 -0
- package/templates/center-site/app/pay/[token]/page.tsx +53 -0
- package/templates/center-site/app/site-header.tsx +1 -0
- package/templates/center-site/lib/reservation.ts +14 -0
- package/templates/center-site/package.json +1 -1
- package/templates/center-site/tsconfig.json +7 -9
- package/dist/account-DfM2COaz.d.ts +0 -210
- package/dist/account-oCvYWmO9.d.cts +0 -210
- package/dist/catalog-DbhdwmnX.d.cts +0 -224
- package/dist/catalog-XkjgPI5C.d.ts +0 -224
- package/dist/chunk-3JSVEOKG.js.map +0 -1
- package/dist/chunk-TEHRROVY.js.map +0 -1
- package/dist/chunk-Y3YSDO3H.js.map +0 -1
- package/dist/data-BJkB-tvM.d.cts +0 -778
- package/dist/data-BJkB-tvM.d.ts +0 -778
package/dist/react.cjs
CHANGED
|
@@ -19,6 +19,7 @@ var BOWLOS_ERROR_CODES = {
|
|
|
19
19
|
SCOPE_REVOKED: "SCOPE_REVOKED",
|
|
20
20
|
NOT_FOUND: "NOT_FOUND",
|
|
21
21
|
// Client-side
|
|
22
|
+
ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
|
|
22
23
|
NETWORK_ERROR: "NETWORK_ERROR",
|
|
23
24
|
UNKNOWN: "ERROR"
|
|
24
25
|
};
|
|
@@ -27,6 +28,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
|
|
|
27
28
|
code;
|
|
28
29
|
/** HTTP status (0 for a network failure before any response). */
|
|
29
30
|
status;
|
|
31
|
+
details;
|
|
30
32
|
/** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
|
|
31
33
|
retryAfterSeconds;
|
|
32
34
|
constructor(code, message, status, options = {}) {
|
|
@@ -34,9 +36,15 @@ var BowlosApiError = class _BowlosApiError extends Error {
|
|
|
34
36
|
this.name = "BowlosApiError";
|
|
35
37
|
this.code = code;
|
|
36
38
|
this.status = status;
|
|
39
|
+
this.details = options.details;
|
|
37
40
|
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
38
41
|
Object.setPrototypeOf(this, _BowlosApiError.prototype);
|
|
39
42
|
}
|
|
43
|
+
/** Typed additive createAnonymousBooking slot-full details, when present. */
|
|
44
|
+
get slotFullDetails() {
|
|
45
|
+
const d = this.details;
|
|
46
|
+
return this.code === "VALIDATION_FAILED" && d?.reason === "slot_full" && typeof d.waitlistAvailable === "boolean" && typeof d.requested === "number" && typeof d.available === "number" ? d : void 0;
|
|
47
|
+
}
|
|
40
48
|
/** Too many requests — caller should back off `retryAfterSeconds`. */
|
|
41
49
|
get isRateLimited() {
|
|
42
50
|
return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;
|
|
@@ -112,7 +120,10 @@ var BowlosClient = class {
|
|
|
112
120
|
code,
|
|
113
121
|
env.error?.message ?? `Health ping failed (HTTP ${status}).`,
|
|
114
122
|
status,
|
|
115
|
-
{
|
|
123
|
+
{
|
|
124
|
+
details: errorDetails(env.error?.details),
|
|
125
|
+
retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
|
|
126
|
+
}
|
|
116
127
|
);
|
|
117
128
|
}
|
|
118
129
|
// ── low-level transport ────────────────────────────────────────────────
|
|
@@ -143,9 +154,18 @@ var BowlosClient = class {
|
|
|
143
154
|
try {
|
|
144
155
|
body = JSON.parse(text);
|
|
145
156
|
} catch {
|
|
146
|
-
body = {
|
|
157
|
+
body = {
|
|
158
|
+
ok: false,
|
|
159
|
+
error: {
|
|
160
|
+
code: res.status === 404 ? BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN,
|
|
161
|
+
message: text.slice(0, 200)
|
|
162
|
+
}
|
|
163
|
+
};
|
|
147
164
|
}
|
|
148
165
|
}
|
|
166
|
+
if (!text && res.status === 404) {
|
|
167
|
+
body = { ok: false, error: { code: BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND } };
|
|
168
|
+
}
|
|
149
169
|
return { status: res.status, body, retryAfterSeconds };
|
|
150
170
|
}
|
|
151
171
|
/**
|
|
@@ -168,7 +188,8 @@ var BowlosClient = class {
|
|
|
168
188
|
throw new BowlosApiError(
|
|
169
189
|
inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,
|
|
170
190
|
inner.error?.message ?? `Request to "${name}" failed.`,
|
|
171
|
-
status
|
|
191
|
+
status,
|
|
192
|
+
{ details: errorDetails(inner.error?.details) }
|
|
172
193
|
);
|
|
173
194
|
}
|
|
174
195
|
return inner.data;
|
|
@@ -182,6 +203,7 @@ var BowlosClient = class {
|
|
|
182
203
|
if (refreshed) return this.callInternal(name, args, auth, true, method);
|
|
183
204
|
}
|
|
184
205
|
throw new BowlosApiError(code, message, status, {
|
|
206
|
+
details: errorDetails(env.error?.details),
|
|
185
207
|
retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
|
|
186
208
|
});
|
|
187
209
|
}
|
|
@@ -301,6 +323,13 @@ var defaultFetch = (input, init) => {
|
|
|
301
323
|
function createBowlosClient(config) {
|
|
302
324
|
return new BowlosClient(config);
|
|
303
325
|
}
|
|
326
|
+
function errorDetails(value) {
|
|
327
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
328
|
+
const entries = Object.entries(value).filter(
|
|
329
|
+
([, v]) => typeof v === "string" || typeof v === "boolean" || typeof v === "number" && Number.isFinite(v)
|
|
330
|
+
);
|
|
331
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
332
|
+
}
|
|
304
333
|
var BowlosContext = react.createContext(null);
|
|
305
334
|
var AccountContext = react.createContext(null);
|
|
306
335
|
function BowlosProvider({ client, config, children }) {
|
|
@@ -559,6 +588,56 @@ function getCheckoutStatus(client, refToken) {
|
|
|
559
588
|
function abandonCheckout(client, refToken) {
|
|
560
589
|
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
561
590
|
}
|
|
591
|
+
function joinWaitlist(client, args) {
|
|
592
|
+
return client.call("joinWaitlist", args, {
|
|
593
|
+
auth: true
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
function createWaitlistSetupIntent(client, args) {
|
|
597
|
+
return client.call(
|
|
598
|
+
"createWaitlistSetupIntent",
|
|
599
|
+
args,
|
|
600
|
+
{ auth: true }
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
function confirmWaitlistCard(client, args) {
|
|
604
|
+
return client.call("confirmWaitlistCard", args, { auth: true });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/idempotent-mutation.ts
|
|
608
|
+
function useIdempotentMutation(name, options = {}) {
|
|
609
|
+
const mutation = useBowlosMutation(name, options);
|
|
610
|
+
const pending = react.useRef(null);
|
|
611
|
+
const run = react.useCallback(
|
|
612
|
+
async (args) => {
|
|
613
|
+
const fingerprint = JSON.stringify(args, (_key, value) => {
|
|
614
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
615
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)));
|
|
616
|
+
}
|
|
617
|
+
return value;
|
|
618
|
+
});
|
|
619
|
+
if (!pending.current || pending.current.fingerprint !== fingerprint) {
|
|
620
|
+
pending.current = { fingerprint, key: generateIdempotencyKey() };
|
|
621
|
+
}
|
|
622
|
+
const action = pending.current;
|
|
623
|
+
try {
|
|
624
|
+
const result = await mutation.run({ ...args, idempotencyKey: action.key });
|
|
625
|
+
if (pending.current === action) pending.current = null;
|
|
626
|
+
return result;
|
|
627
|
+
} catch (error) {
|
|
628
|
+
const retryable = !(error instanceof BowlosApiError) || error.status === 0 || error.status === 408 || error.status === 429 || error.status >= 500;
|
|
629
|
+
if (!retryable && pending.current === action) pending.current = null;
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
[mutation.run]
|
|
634
|
+
);
|
|
635
|
+
const reset = react.useCallback(() => {
|
|
636
|
+
pending.current = null;
|
|
637
|
+
mutation.reset();
|
|
638
|
+
}, [mutation.reset]);
|
|
639
|
+
return { ...mutation, run, reset };
|
|
640
|
+
}
|
|
562
641
|
|
|
563
642
|
// src/hooks.tsx
|
|
564
643
|
function useAvailability(args, options) {
|
|
@@ -616,38 +695,22 @@ function useGameCardCancelPreview(args, options) {
|
|
|
616
695
|
return useBowlosQuery("previewMyGameCardCancellation", args, { ...options, auth: true });
|
|
617
696
|
}
|
|
618
697
|
function useCancelMyReservation() {
|
|
619
|
-
|
|
698
|
+
return useIdempotentMutation("cancelMyReservation", {
|
|
620
699
|
auth: true
|
|
621
700
|
});
|
|
622
|
-
const run = react.useCallback(
|
|
623
|
-
(args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
|
|
624
|
-
[m]
|
|
625
|
-
);
|
|
626
|
-
return { ...m, run };
|
|
627
701
|
}
|
|
628
702
|
function useCancelMyEventOrder() {
|
|
629
|
-
|
|
630
|
-
const run = react.useCallback(
|
|
631
|
-
(args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
|
|
632
|
-
[m]
|
|
633
|
-
);
|
|
634
|
-
return { ...m, run };
|
|
703
|
+
return useIdempotentMutation("cancelMyEventOrder", { auth: true });
|
|
635
704
|
}
|
|
636
705
|
function useCancelMyPackageOrder() {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
[m]
|
|
641
|
-
);
|
|
642
|
-
return { ...m, run };
|
|
706
|
+
return useIdempotentMutation("cancelMyPackageOrder", {
|
|
707
|
+
auth: true
|
|
708
|
+
});
|
|
643
709
|
}
|
|
644
710
|
function useCancelMyGameCard() {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
[m]
|
|
649
|
-
);
|
|
650
|
-
return { ...m, run };
|
|
711
|
+
return useIdempotentMutation("cancelMyGameCard", {
|
|
712
|
+
auth: true
|
|
713
|
+
});
|
|
651
714
|
}
|
|
652
715
|
function useFlashSale(args, options) {
|
|
653
716
|
return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
|
|
@@ -1157,65 +1220,845 @@ function useMembershipSubscriptionCheckout() {
|
|
|
1157
1220
|
}, []);
|
|
1158
1221
|
return { status, subscriptionIntent, error, start, reset };
|
|
1159
1222
|
}
|
|
1223
|
+
function useUpdateMyProfile() {
|
|
1224
|
+
return useBowlosMutation("updateMyProfile", {
|
|
1225
|
+
auth: true
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
function useMyCommunicationPrefs(args, options) {
|
|
1229
|
+
return useBowlosQuery("listMyMarketingPrefs", args, {
|
|
1230
|
+
...options,
|
|
1231
|
+
auth: true
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
function useSetMyCommunicationPref() {
|
|
1235
|
+
return useBowlosMutation(
|
|
1236
|
+
"setMyMarketingPref",
|
|
1237
|
+
{ auth: true }
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
function useSetMyMobile() {
|
|
1241
|
+
return useBowlosMutation("setMyMobile", { auth: true });
|
|
1242
|
+
}
|
|
1243
|
+
function useSubmitSupportRequest() {
|
|
1244
|
+
return useBowlosMutation(
|
|
1245
|
+
"submitMySupportRequest",
|
|
1246
|
+
{ auth: true }
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
function useDeleteMyAccount() {
|
|
1250
|
+
const client = useBowlosClient();
|
|
1251
|
+
const mutation = useBowlosMutation(
|
|
1252
|
+
"deleteMyAccount",
|
|
1253
|
+
{ auth: true }
|
|
1254
|
+
);
|
|
1255
|
+
const run = react.useCallback(
|
|
1256
|
+
async (args) => {
|
|
1257
|
+
const result = await mutation.run(args);
|
|
1258
|
+
await client.signOut();
|
|
1259
|
+
return result;
|
|
1260
|
+
},
|
|
1261
|
+
[client, mutation.run]
|
|
1262
|
+
);
|
|
1263
|
+
return { ...mutation, run };
|
|
1264
|
+
}
|
|
1265
|
+
function useExportMyData() {
|
|
1266
|
+
return useBowlosMutation("exportMyData", {
|
|
1267
|
+
auth: true
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
function useMyPackageOrders(args, options) {
|
|
1271
|
+
return useBowlosQuery("listMyPackageOrders", args, {
|
|
1272
|
+
...options,
|
|
1273
|
+
auth: true
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
function useMyPackageOrder(args, options) {
|
|
1277
|
+
return useBowlosQuery("getMyPackageOrder", args, {
|
|
1278
|
+
...options,
|
|
1279
|
+
auth: true
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
function useMyMembershipMembers(args, options) {
|
|
1283
|
+
return useBowlosQuery("listMyMembershipMembers", args, {
|
|
1284
|
+
...options,
|
|
1285
|
+
auth: true
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
function useAddMyMembershipMember() {
|
|
1289
|
+
return useBowlosMutation(
|
|
1290
|
+
"addMyMembershipMember",
|
|
1291
|
+
{ auth: true }
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
function useMyLoyaltyHistory(args, options) {
|
|
1295
|
+
return useBowlosQuery("listMyLoyaltyHistory", args, {
|
|
1296
|
+
...options,
|
|
1297
|
+
auth: true
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
function useReceipt(args, options) {
|
|
1301
|
+
return useBowlosQuery("getReservationByDisplayId", args, {
|
|
1302
|
+
...options,
|
|
1303
|
+
auth: false
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
function useProduct(args, options) {
|
|
1307
|
+
return useBowlosQuery("getPublicProduct", args, { ...options, auth: false });
|
|
1308
|
+
}
|
|
1309
|
+
function useMembership(args, options) {
|
|
1310
|
+
return useBowlosQuery("getPublicMembership", args, {
|
|
1311
|
+
...options,
|
|
1312
|
+
auth: false
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
function useGameCard(args, options) {
|
|
1316
|
+
return useBowlosQuery("getPublicGameCard", args, {
|
|
1317
|
+
...options,
|
|
1318
|
+
auth: false
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
function useProductSubtypes(args, options) {
|
|
1322
|
+
return useBowlosQuery("listSubtypesForProduct", args, {
|
|
1323
|
+
...options,
|
|
1324
|
+
auth: false
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
function useBrandMemberships(args, options) {
|
|
1328
|
+
return useBowlosQuery("listBrandMemberships", args, {
|
|
1329
|
+
...options,
|
|
1330
|
+
auth: false
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function usePackagesLabel(args, options) {
|
|
1334
|
+
return useBowlosQuery("getBrandPackagesLabelPublic", args, {
|
|
1335
|
+
...options,
|
|
1336
|
+
auth: false
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
function useSlotPrices(args, options) {
|
|
1340
|
+
return useBowlosQuery("previewSlotPrices", args, {
|
|
1341
|
+
...options,
|
|
1342
|
+
auth: false
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
function useHours(args, options) {
|
|
1346
|
+
return useBowlosQuery("listPublicHours", args, { ...options, auth: false });
|
|
1347
|
+
}
|
|
1348
|
+
function useOperatingHours(args, options) {
|
|
1349
|
+
return useBowlosQuery("getOperatingHours", args, {
|
|
1350
|
+
...options,
|
|
1351
|
+
auth: false
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
function useCenterOperatingHoursForType(args, options) {
|
|
1355
|
+
return useBowlosQuery(
|
|
1356
|
+
"getCenterOperatingHoursForType",
|
|
1357
|
+
args,
|
|
1358
|
+
{ ...options, auth: false }
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
function useCenters(args, options) {
|
|
1362
|
+
return useBowlosQuery("listPublicCenters", args, {
|
|
1363
|
+
...options,
|
|
1364
|
+
auth: false
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
function useCancelMyMembership() {
|
|
1368
|
+
return useIdempotentMutation(
|
|
1369
|
+
"cancelMyMembership",
|
|
1370
|
+
{ auth: true }
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
function useApplyMyModification() {
|
|
1374
|
+
return useIdempotentMutation(
|
|
1375
|
+
"applyMyModification",
|
|
1376
|
+
{ auth: true }
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// src/routes.ts
|
|
1381
|
+
async function deleteMyAccount(client, args) {
|
|
1382
|
+
const result = await client.call("deleteMyAccount", args, {
|
|
1383
|
+
auth: true
|
|
1384
|
+
});
|
|
1385
|
+
await client.signOut();
|
|
1386
|
+
return result;
|
|
1387
|
+
}
|
|
1388
|
+
function previewAccountDeletion(client, args) {
|
|
1389
|
+
return client.call("previewMyAccountDeletion", args, { auth: true });
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/use-account-deletion.ts
|
|
1393
|
+
function useAccountDeletion(args) {
|
|
1394
|
+
const client = useBowlosClient();
|
|
1395
|
+
const [preview, setPreview] = react.useState();
|
|
1396
|
+
const [status, setStatus] = react.useState("loading");
|
|
1397
|
+
const [error, setError] = react.useState();
|
|
1398
|
+
const generation = react.useRef(0);
|
|
1399
|
+
const busy = react.useRef(false);
|
|
1400
|
+
const phrase = react.useRef(void 0);
|
|
1401
|
+
const timer = react.useRef(void 0);
|
|
1402
|
+
const wake = react.useRef(void 0);
|
|
1403
|
+
const reload = react.useCallback(async () => {
|
|
1404
|
+
const current = generation.current;
|
|
1405
|
+
const value = await previewAccountDeletion(client, { brandId: args.brandId });
|
|
1406
|
+
if (generation.current === current) setPreview(value);
|
|
1407
|
+
return value;
|
|
1408
|
+
}, [client, args.brandId]);
|
|
1409
|
+
react.useEffect(() => {
|
|
1410
|
+
const current = ++generation.current;
|
|
1411
|
+
busy.current = false;
|
|
1412
|
+
phrase.current = void 0;
|
|
1413
|
+
setPreview(void 0);
|
|
1414
|
+
setError(void 0);
|
|
1415
|
+
setStatus("loading");
|
|
1416
|
+
void previewAccountDeletion(client, { brandId: args.brandId }).then(
|
|
1417
|
+
(value) => {
|
|
1418
|
+
if (generation.current === current) {
|
|
1419
|
+
setPreview(value);
|
|
1420
|
+
setStatus("ready");
|
|
1421
|
+
}
|
|
1422
|
+
},
|
|
1423
|
+
(e) => {
|
|
1424
|
+
if (generation.current === current) {
|
|
1425
|
+
setError(e);
|
|
1426
|
+
setStatus("error");
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
);
|
|
1430
|
+
return () => {
|
|
1431
|
+
generation.current++;
|
|
1432
|
+
clearTimeout(timer.current);
|
|
1433
|
+
wake.current?.();
|
|
1434
|
+
};
|
|
1435
|
+
}, [client, args.brandId]);
|
|
1436
|
+
const confirm = react.useCallback(
|
|
1437
|
+
async (typedPhrase) => {
|
|
1438
|
+
if (busy.current || !preview) return;
|
|
1439
|
+
if (typedPhrase !== preview.confirmPhrase) {
|
|
1440
|
+
setError(
|
|
1441
|
+
new BowlosApiError("VALIDATION_FAILED", "Enter the confirmation phrase exactly.", 400)
|
|
1442
|
+
);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
busy.current = true;
|
|
1446
|
+
phrase.current = typedPhrase;
|
|
1447
|
+
const current = generation.current;
|
|
1448
|
+
setError(void 0);
|
|
1449
|
+
setStatus("deleting");
|
|
1450
|
+
try {
|
|
1451
|
+
for (let attempt = 0; attempt <= 5; attempt++) {
|
|
1452
|
+
if (generation.current !== current) return;
|
|
1453
|
+
try {
|
|
1454
|
+
await deleteMyAccount(client, {
|
|
1455
|
+
brandId: args.brandId,
|
|
1456
|
+
confirmPhrase: typedPhrase,
|
|
1457
|
+
previewToken: preview.previewToken
|
|
1458
|
+
});
|
|
1459
|
+
if (generation.current === current) setStatus("deleted");
|
|
1460
|
+
return;
|
|
1461
|
+
} catch (e) {
|
|
1462
|
+
if (generation.current !== current) return;
|
|
1463
|
+
if (e instanceof BowlosApiError && e.code === "DELETION_PREVIEW_STALE") {
|
|
1464
|
+
await reload();
|
|
1465
|
+
if (generation.current === current) {
|
|
1466
|
+
setError(e);
|
|
1467
|
+
setStatus("stale");
|
|
1468
|
+
}
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
if (!(e instanceof BowlosApiError) || e.code !== "DELETION_PENDING_STRIPE") throw e;
|
|
1472
|
+
setStatus("pending");
|
|
1473
|
+
if (attempt === 5) {
|
|
1474
|
+
setError(e);
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const seconds = e.details?.retryAfterSec;
|
|
1478
|
+
const delay = typeof seconds === "number" && seconds >= 0 ? seconds * 1e3 : 1e3;
|
|
1479
|
+
await new Promise((resolve) => {
|
|
1480
|
+
wake.current = resolve;
|
|
1481
|
+
timer.current = setTimeout(resolve, Math.min(delay * 2 ** attempt, 2147483647));
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
} catch (e) {
|
|
1486
|
+
if (generation.current === current) {
|
|
1487
|
+
setError(e);
|
|
1488
|
+
setStatus("error");
|
|
1489
|
+
}
|
|
1490
|
+
} finally {
|
|
1491
|
+
if (generation.current === current) busy.current = false;
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
[client, args.brandId, preview, reload]
|
|
1495
|
+
);
|
|
1496
|
+
const retry = react.useCallback(async () => {
|
|
1497
|
+
if (phrase.current && preview && status !== "stale") await confirm(phrase.current);
|
|
1498
|
+
else {
|
|
1499
|
+
try {
|
|
1500
|
+
await reload();
|
|
1501
|
+
setError(void 0);
|
|
1502
|
+
setStatus("ready");
|
|
1503
|
+
} catch (e) {
|
|
1504
|
+
setError(e);
|
|
1505
|
+
setStatus("error");
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}, [confirm, preview, reload, status]);
|
|
1509
|
+
return {
|
|
1510
|
+
preview,
|
|
1511
|
+
consequences: preview,
|
|
1512
|
+
confirmPhrase: preview?.confirmPhrase,
|
|
1513
|
+
status,
|
|
1514
|
+
error,
|
|
1515
|
+
confirm,
|
|
1516
|
+
retry
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
// src/toolkit-hooks.tsx
|
|
1521
|
+
function useBrandEventOffers(args, options) {
|
|
1522
|
+
return useBowlosQuery("listPublicEventOffersForBrand", args, {
|
|
1523
|
+
...options,
|
|
1524
|
+
auth: false
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function useMyGameCard(args, options) {
|
|
1528
|
+
return useBowlosQuery("getMyGameCard", args, { ...options, auth: true });
|
|
1529
|
+
}
|
|
1530
|
+
function useMyGameCardRedemptions(args, options) {
|
|
1531
|
+
return useBowlosQuery("getMyGameCardRedemptions", args, {
|
|
1532
|
+
...options,
|
|
1533
|
+
auth: true
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
function useMyGameCardHistory(args, options) {
|
|
1537
|
+
return useBowlosQuery("getMyGameCardRedemptionsPage", args, {
|
|
1538
|
+
...options,
|
|
1539
|
+
auth: true
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
function useWalletPassUrl() {
|
|
1543
|
+
return useBowlosMutation("getMyWalletPassUrl", {
|
|
1544
|
+
auth: true
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
function useMyHold(args, options) {
|
|
1548
|
+
return useBowlosQuery("getMyHoldGroup", args, { ...options, auth: true });
|
|
1549
|
+
}
|
|
1550
|
+
function useExtendMyHold() {
|
|
1551
|
+
return useBowlosMutation("customerExtendMyHold", {
|
|
1552
|
+
auth: true
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
function useReleaseMyHold() {
|
|
1556
|
+
return useBowlosMutation("customerReleaseMyHold", { auth: true });
|
|
1557
|
+
}
|
|
1558
|
+
function useRequestEmailVerification() {
|
|
1559
|
+
return useBowlosMutation(
|
|
1560
|
+
"requestEmailVerification",
|
|
1561
|
+
{ auth: true }
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
function useConfirmEmailVerification() {
|
|
1565
|
+
return useBowlosMutation("confirmEmailVerification", {
|
|
1566
|
+
auth: true
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
function useEmailVerificationStatus(args, options) {
|
|
1570
|
+
return useBowlosQuery("getEmailVerificationStatus", args, {
|
|
1571
|
+
...options,
|
|
1572
|
+
auth: true
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
function useEmailVerificationSendState(args, options) {
|
|
1576
|
+
return useBowlosQuery("getEmailVerificationSendState", args, {
|
|
1577
|
+
...options,
|
|
1578
|
+
auth: true
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
function useCancellationPolicy(args, options) {
|
|
1582
|
+
return useBowlosQuery("getCancellationPolicy", args, {
|
|
1583
|
+
...options,
|
|
1584
|
+
auth: false
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
function useCancelMyPendingBooking() {
|
|
1588
|
+
return useBowlosMutation(
|
|
1589
|
+
"cancelMyPendingReservation",
|
|
1590
|
+
{ auth: true }
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1593
|
+
function useHoldCountdown(args, options) {
|
|
1594
|
+
const hold = useMyHold(args, options);
|
|
1595
|
+
const extension = useExtendMyHold();
|
|
1596
|
+
const release = useReleaseMyHold();
|
|
1597
|
+
const [remainingMs, setRemainingMs] = react.useState(0);
|
|
1598
|
+
react.useEffect(() => {
|
|
1599
|
+
const data = hold.data;
|
|
1600
|
+
if (!data || data.status !== "active") {
|
|
1601
|
+
setRemainingMs(0);
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
const receivedAt = Date.now();
|
|
1605
|
+
const tick = () => setRemainingMs(Math.max(0, data.expiresAt - data.serverNowMs - (Date.now() - receivedAt)));
|
|
1606
|
+
tick();
|
|
1607
|
+
const timer = setInterval(tick, 250);
|
|
1608
|
+
return () => clearInterval(timer);
|
|
1609
|
+
}, [hold.data]);
|
|
1610
|
+
return {
|
|
1611
|
+
...hold,
|
|
1612
|
+
remainingMs,
|
|
1613
|
+
expired: hold.data !== null && remainingMs === 0,
|
|
1614
|
+
extendable: hold.data?.status === "active" && !hold.data.extensionUsed && remainingMs > 0 && remainingMs <= 3e5,
|
|
1615
|
+
extension,
|
|
1616
|
+
release,
|
|
1617
|
+
extend: async () => {
|
|
1618
|
+
const result = await extension.run(args);
|
|
1619
|
+
await hold.refetch();
|
|
1620
|
+
return result;
|
|
1621
|
+
},
|
|
1622
|
+
releaseHold: async () => {
|
|
1623
|
+
const result = await release.run(args);
|
|
1624
|
+
await hold.refetch();
|
|
1625
|
+
return result;
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
function useEmailVerification(args, options) {
|
|
1630
|
+
const [verifyId, setVerifyId] = react.useState(null);
|
|
1631
|
+
const request = useRequestEmailVerification();
|
|
1632
|
+
const confirm = useConfirmEmailVerification();
|
|
1633
|
+
const status = useEmailVerificationStatus(
|
|
1634
|
+
{ brandId: args.brandId, token: args.token ?? "" },
|
|
1635
|
+
{ ...options, enabled: options?.enabled !== false && !!args.token }
|
|
1636
|
+
);
|
|
1637
|
+
const sendState = useEmailVerificationSendState(
|
|
1638
|
+
{ brandId: args.brandId, verifyId: verifyId ?? "" },
|
|
1639
|
+
{ ...options, enabled: options?.enabled !== false && !!verifyId }
|
|
1640
|
+
);
|
|
1641
|
+
return {
|
|
1642
|
+
request,
|
|
1643
|
+
confirm,
|
|
1644
|
+
status,
|
|
1645
|
+
sendState,
|
|
1646
|
+
requestVerification: async () => {
|
|
1647
|
+
const result = await request.run({ brandId: args.brandId });
|
|
1648
|
+
setVerifyId(result.verifyId ?? null);
|
|
1649
|
+
return result;
|
|
1650
|
+
},
|
|
1651
|
+
confirmVerification: async (token = args.token ?? "") => {
|
|
1652
|
+
const result = await confirm.run({ brandId: args.brandId, token });
|
|
1653
|
+
if (args.token) await status.refetch();
|
|
1654
|
+
return result;
|
|
1655
|
+
}
|
|
1656
|
+
};
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
// src/booking-change.ts
|
|
1660
|
+
function previewBookingChange(client, args) {
|
|
1661
|
+
return client.call("previewMyModification", args, { auth: true });
|
|
1662
|
+
}
|
|
1663
|
+
function getPendingBookingChange(client, args) {
|
|
1664
|
+
return client.call("getMyPendingModification", args, { auth: true });
|
|
1665
|
+
}
|
|
1666
|
+
function createBookingChangePayment(client, args) {
|
|
1667
|
+
const { pendingModificationId, brandId, centerId } = args;
|
|
1668
|
+
return client.call(
|
|
1669
|
+
"createModificationPaymentIntent",
|
|
1670
|
+
{ pendingModificationId, brandId, centerId },
|
|
1671
|
+
{ auth: true }
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// src/use-booking-change.ts
|
|
1676
|
+
function useOpenMembershipBillingPortal() {
|
|
1677
|
+
return useBowlosMutation(
|
|
1678
|
+
"createBillingPortalSession",
|
|
1679
|
+
{ auth: true }
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
function usePayLink(args, options) {
|
|
1683
|
+
return useBowlosQuery("getPayLinkInfo", args, { ...options, auth: false });
|
|
1684
|
+
}
|
|
1685
|
+
function useCreatePayLinkPayment() {
|
|
1686
|
+
const mutation = useBowlosMutation(
|
|
1687
|
+
"createPayIntentForPayLinkToken",
|
|
1688
|
+
{ auth: false }
|
|
1689
|
+
);
|
|
1690
|
+
const run = react.useCallback(
|
|
1691
|
+
(args) => mutation.run({ token: args.token, brandId: args.brandId, centerId: args.centerId }),
|
|
1692
|
+
[mutation.run]
|
|
1693
|
+
);
|
|
1694
|
+
return { ...mutation, run };
|
|
1695
|
+
}
|
|
1696
|
+
function useBookingChange(scope) {
|
|
1697
|
+
const client = useBowlosClient();
|
|
1698
|
+
const applyMutation = useIdempotentMutation(
|
|
1699
|
+
"applyMyModification",
|
|
1700
|
+
{ auth: true }
|
|
1701
|
+
);
|
|
1702
|
+
const [status, setStatus] = react.useState("idle");
|
|
1703
|
+
const [preview, setPreview] = react.useState();
|
|
1704
|
+
const [payment, setPayment] = react.useState();
|
|
1705
|
+
const [pending, setPending] = react.useState();
|
|
1706
|
+
const [pendingId, setPendingId] = react.useState();
|
|
1707
|
+
const [error, setError] = react.useState();
|
|
1708
|
+
const generation = react.useRef(0);
|
|
1709
|
+
const busy = react.useRef(false);
|
|
1710
|
+
const reset = react.useCallback(() => {
|
|
1711
|
+
generation.current++;
|
|
1712
|
+
busy.current = false;
|
|
1713
|
+
setStatus("idle");
|
|
1714
|
+
setPreview(void 0);
|
|
1715
|
+
setPayment(void 0);
|
|
1716
|
+
setPending(void 0);
|
|
1717
|
+
setPendingId(void 0);
|
|
1718
|
+
setError(void 0);
|
|
1719
|
+
applyMutation.reset();
|
|
1720
|
+
}, [applyMutation.reset]);
|
|
1721
|
+
react.useEffect(() => {
|
|
1722
|
+
reset();
|
|
1723
|
+
return () => {
|
|
1724
|
+
generation.current++;
|
|
1725
|
+
};
|
|
1726
|
+
}, [scope.brandId, scope.centerId, reset]);
|
|
1727
|
+
const loadPreview = react.useCallback(
|
|
1728
|
+
async (args) => {
|
|
1729
|
+
if (busy.current) return;
|
|
1730
|
+
busy.current = true;
|
|
1731
|
+
const current = ++generation.current;
|
|
1732
|
+
setStatus("previewing");
|
|
1733
|
+
setError(void 0);
|
|
1734
|
+
setPayment(void 0);
|
|
1735
|
+
setPendingId(void 0);
|
|
1736
|
+
try {
|
|
1737
|
+
const value = await previewBookingChange(client, { ...args, ...scope });
|
|
1738
|
+
if (generation.current === current) {
|
|
1739
|
+
setPreview(value);
|
|
1740
|
+
setStatus("preview");
|
|
1741
|
+
}
|
|
1742
|
+
return value;
|
|
1743
|
+
} catch (e) {
|
|
1744
|
+
if (generation.current === current) {
|
|
1745
|
+
setError(e);
|
|
1746
|
+
setStatus("error");
|
|
1747
|
+
}
|
|
1748
|
+
throw e;
|
|
1749
|
+
} finally {
|
|
1750
|
+
if (generation.current === current) busy.current = false;
|
|
1751
|
+
}
|
|
1752
|
+
},
|
|
1753
|
+
[client, scope.brandId, scope.centerId]
|
|
1754
|
+
);
|
|
1755
|
+
const apply = react.useCallback(
|
|
1756
|
+
async (args) => {
|
|
1757
|
+
if (busy.current) return;
|
|
1758
|
+
busy.current = true;
|
|
1759
|
+
const current = generation.current;
|
|
1760
|
+
setError(void 0);
|
|
1761
|
+
setStatus("applying");
|
|
1762
|
+
try {
|
|
1763
|
+
const value = await applyMutation.run({ ...args, ...scope });
|
|
1764
|
+
if (generation.current !== current) return value;
|
|
1765
|
+
if (value.requiresPayment) {
|
|
1766
|
+
setPendingId(value.pendingModificationId);
|
|
1767
|
+
setStatus("pay");
|
|
1768
|
+
} else setStatus("done");
|
|
1769
|
+
return value;
|
|
1770
|
+
} catch (e) {
|
|
1771
|
+
if (generation.current === current) {
|
|
1772
|
+
setError(e);
|
|
1773
|
+
setStatus("error");
|
|
1774
|
+
}
|
|
1775
|
+
throw e;
|
|
1776
|
+
} finally {
|
|
1777
|
+
if (generation.current === current) busy.current = false;
|
|
1778
|
+
}
|
|
1779
|
+
},
|
|
1780
|
+
[applyMutation.run, scope.brandId, scope.centerId]
|
|
1781
|
+
);
|
|
1782
|
+
const createPayment = react.useCallback(async () => {
|
|
1783
|
+
if (!pendingId || busy.current || status !== "pay") return;
|
|
1784
|
+
busy.current = true;
|
|
1785
|
+
const current = generation.current;
|
|
1786
|
+
setError(void 0);
|
|
1787
|
+
try {
|
|
1788
|
+
const value = await createBookingChangePayment(client, {
|
|
1789
|
+
...scope,
|
|
1790
|
+
pendingModificationId: pendingId
|
|
1791
|
+
});
|
|
1792
|
+
if (generation.current === current) setPayment(value);
|
|
1793
|
+
return value;
|
|
1794
|
+
} catch (e) {
|
|
1795
|
+
if (generation.current === current) setError(e);
|
|
1796
|
+
throw e;
|
|
1797
|
+
} finally {
|
|
1798
|
+
if (generation.current === current) busy.current = false;
|
|
1799
|
+
}
|
|
1800
|
+
}, [client, pendingId, scope.brandId, scope.centerId, status]);
|
|
1801
|
+
const resume = react.useCallback((args) => {
|
|
1802
|
+
generation.current++;
|
|
1803
|
+
busy.current = false;
|
|
1804
|
+
setPayment(void 0);
|
|
1805
|
+
setError(void 0);
|
|
1806
|
+
setPendingId(args.pendingModificationId);
|
|
1807
|
+
setStatus("pay");
|
|
1808
|
+
}, []);
|
|
1809
|
+
react.useEffect(() => {
|
|
1810
|
+
if (!pendingId || status !== "polling" && status !== "pay") return;
|
|
1811
|
+
let cancelled = false;
|
|
1812
|
+
let timer;
|
|
1813
|
+
const poll = async () => {
|
|
1814
|
+
try {
|
|
1815
|
+
const value = await getPendingBookingChange(client, {
|
|
1816
|
+
...scope,
|
|
1817
|
+
pendingModificationId: pendingId
|
|
1818
|
+
});
|
|
1819
|
+
if (cancelled) return;
|
|
1820
|
+
setPending(value);
|
|
1821
|
+
setError(void 0);
|
|
1822
|
+
if (value.status === "applied") {
|
|
1823
|
+
setStatus("done");
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
if (value.status !== "pending_payment") {
|
|
1827
|
+
setStatus(value.status);
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
if (value.expiresAt <= Date.now()) {
|
|
1831
|
+
setStatus("expired");
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
} catch (e) {
|
|
1835
|
+
if (cancelled) return;
|
|
1836
|
+
setError(e);
|
|
1837
|
+
}
|
|
1838
|
+
timer = setTimeout(() => void poll(), 1500);
|
|
1839
|
+
};
|
|
1840
|
+
void poll();
|
|
1841
|
+
return () => {
|
|
1842
|
+
cancelled = true;
|
|
1843
|
+
clearTimeout(timer);
|
|
1844
|
+
};
|
|
1845
|
+
}, [client, scope.brandId, scope.centerId, pendingId, status]);
|
|
1846
|
+
const paymentConfirmed = react.useCallback(() => {
|
|
1847
|
+
if (pendingId) setStatus("polling");
|
|
1848
|
+
}, [pendingId]);
|
|
1849
|
+
return {
|
|
1850
|
+
status,
|
|
1851
|
+
preview,
|
|
1852
|
+
payment,
|
|
1853
|
+
pending,
|
|
1854
|
+
pendingModificationId: pendingId,
|
|
1855
|
+
error,
|
|
1856
|
+
loadPreview,
|
|
1857
|
+
apply,
|
|
1858
|
+
createPayment,
|
|
1859
|
+
paymentConfirmed,
|
|
1860
|
+
resume,
|
|
1861
|
+
reset
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
function useWaitlistJoin() {
|
|
1865
|
+
const client = useBowlosClient();
|
|
1866
|
+
const [status, setStatus] = react.useState("idle");
|
|
1867
|
+
const [entry, setEntry] = react.useState();
|
|
1868
|
+
const [setupIntent, setSetupIntent] = react.useState();
|
|
1869
|
+
const [error, setError] = react.useState();
|
|
1870
|
+
const generation = react.useRef(0);
|
|
1871
|
+
const busy = react.useRef(false);
|
|
1872
|
+
react.useEffect(
|
|
1873
|
+
() => () => {
|
|
1874
|
+
generation.current++;
|
|
1875
|
+
},
|
|
1876
|
+
[client]
|
|
1877
|
+
);
|
|
1878
|
+
function reset() {
|
|
1879
|
+
generation.current++;
|
|
1880
|
+
busy.current = false;
|
|
1881
|
+
setStatus("idle");
|
|
1882
|
+
setEntry(void 0);
|
|
1883
|
+
setSetupIntent(void 0);
|
|
1884
|
+
setError(void 0);
|
|
1885
|
+
}
|
|
1886
|
+
async function join(args) {
|
|
1887
|
+
if (busy.current) return;
|
|
1888
|
+
busy.current = true;
|
|
1889
|
+
const current = ++generation.current;
|
|
1890
|
+
setStatus("quoting");
|
|
1891
|
+
setError(void 0);
|
|
1892
|
+
setEntry(void 0);
|
|
1893
|
+
setSetupIntent(void 0);
|
|
1894
|
+
try {
|
|
1895
|
+
const value = await joinWaitlist(client, args);
|
|
1896
|
+
if (current === generation.current) {
|
|
1897
|
+
setEntry(value);
|
|
1898
|
+
setStatus("card");
|
|
1899
|
+
}
|
|
1900
|
+
return value;
|
|
1901
|
+
} catch (e) {
|
|
1902
|
+
if (current === generation.current) {
|
|
1903
|
+
setError(e);
|
|
1904
|
+
setStatus("error");
|
|
1905
|
+
}
|
|
1906
|
+
throw e;
|
|
1907
|
+
} finally {
|
|
1908
|
+
if (current === generation.current) busy.current = false;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
async function createCardSetup() {
|
|
1912
|
+
if (!entry || busy.current || status !== "card") return;
|
|
1913
|
+
busy.current = true;
|
|
1914
|
+
const current = generation.current;
|
|
1915
|
+
try {
|
|
1916
|
+
const value = await createWaitlistSetupIntent(client, { entryId: entry.entryId });
|
|
1917
|
+
if (current === generation.current) setSetupIntent(value);
|
|
1918
|
+
return value;
|
|
1919
|
+
} catch (e) {
|
|
1920
|
+
if (current === generation.current) {
|
|
1921
|
+
setError(e);
|
|
1922
|
+
setStatus("error");
|
|
1923
|
+
}
|
|
1924
|
+
throw e;
|
|
1925
|
+
} finally {
|
|
1926
|
+
if (current === generation.current) busy.current = false;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
async function cardConfirmed(intent) {
|
|
1930
|
+
if (!entry || busy.current || status !== "card") return;
|
|
1931
|
+
if (intent.status !== "succeeded") return;
|
|
1932
|
+
busy.current = true;
|
|
1933
|
+
const current = generation.current;
|
|
1934
|
+
setStatus("confirming");
|
|
1935
|
+
setError(void 0);
|
|
1936
|
+
try {
|
|
1937
|
+
const result = await confirmWaitlistCard(client, {
|
|
1938
|
+
entryId: entry.entryId,
|
|
1939
|
+
setupIntentId: intent.id
|
|
1940
|
+
});
|
|
1941
|
+
if (result.status !== "waiting") throw new Error("Waitlist card confirmation incomplete.");
|
|
1942
|
+
if (current === generation.current) setStatus("joined");
|
|
1943
|
+
} catch (e) {
|
|
1944
|
+
if (current === generation.current) {
|
|
1945
|
+
setError(e);
|
|
1946
|
+
setStatus("error");
|
|
1947
|
+
}
|
|
1948
|
+
throw e;
|
|
1949
|
+
} finally {
|
|
1950
|
+
if (current === generation.current) busy.current = false;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
return { status, entry, setupIntent, error, join, createCardSetup, cardConfirmed, reset };
|
|
1954
|
+
}
|
|
1160
1955
|
|
|
1161
1956
|
exports.BowlosProvider = BowlosProvider;
|
|
1162
1957
|
exports.useAccount = useAccount;
|
|
1958
|
+
exports.useAccountDeletion = useAccountDeletion;
|
|
1959
|
+
exports.useAddMyMembershipMember = useAddMyMembershipMember;
|
|
1163
1960
|
exports.useAddons = useAddons;
|
|
1961
|
+
exports.useApplyMyModification = useApplyMyModification;
|
|
1164
1962
|
exports.useAvailability = useAvailability;
|
|
1963
|
+
exports.useBookingChange = useBookingChange;
|
|
1165
1964
|
exports.useBookingFlow = useBookingFlow;
|
|
1166
1965
|
exports.useBookingPreview = useBookingPreview;
|
|
1167
1966
|
exports.useBowlosClient = useBowlosClient;
|
|
1168
1967
|
exports.useBowlosMutation = useBowlosMutation;
|
|
1169
1968
|
exports.useBowlosQuery = useBowlosQuery;
|
|
1969
|
+
exports.useBrandEventOffers = useBrandEventOffers;
|
|
1970
|
+
exports.useBrandMemberships = useBrandMemberships;
|
|
1170
1971
|
exports.useCancelMyEventOrder = useCancelMyEventOrder;
|
|
1171
1972
|
exports.useCancelMyGameCard = useCancelMyGameCard;
|
|
1973
|
+
exports.useCancelMyMembership = useCancelMyMembership;
|
|
1172
1974
|
exports.useCancelMyPackageOrder = useCancelMyPackageOrder;
|
|
1975
|
+
exports.useCancelMyPendingBooking = useCancelMyPendingBooking;
|
|
1173
1976
|
exports.useCancelMyReservation = useCancelMyReservation;
|
|
1977
|
+
exports.useCancellationPolicy = useCancellationPolicy;
|
|
1174
1978
|
exports.useCatalog = useCatalog;
|
|
1175
1979
|
exports.useCenterHours = useCenterHours;
|
|
1980
|
+
exports.useCenterOperatingHoursForType = useCenterOperatingHoursForType;
|
|
1981
|
+
exports.useCenters = useCenters;
|
|
1176
1982
|
exports.useChangePassword = useChangePassword;
|
|
1983
|
+
exports.useConfirmEmailVerification = useConfirmEmailVerification;
|
|
1177
1984
|
exports.useCreateCardSetup = useCreateCardSetup;
|
|
1985
|
+
exports.useCreatePayLinkPayment = useCreatePayLinkPayment;
|
|
1986
|
+
exports.useDeleteMyAccount = useDeleteMyAccount;
|
|
1987
|
+
exports.useEmailVerification = useEmailVerification;
|
|
1988
|
+
exports.useEmailVerificationSendState = useEmailVerificationSendState;
|
|
1989
|
+
exports.useEmailVerificationStatus = useEmailVerificationStatus;
|
|
1178
1990
|
exports.useEventOffer = useEventOffer;
|
|
1179
1991
|
exports.useEventOffers = useEventOffers;
|
|
1180
1992
|
exports.useEventOrderCancelPreview = useEventOrderCancelPreview;
|
|
1181
1993
|
exports.useEventTicketPreview = useEventTicketPreview;
|
|
1182
1994
|
exports.useEventTicketPurchase = useEventTicketPurchase;
|
|
1183
1995
|
exports.useEvents = useEvents;
|
|
1996
|
+
exports.useExportMyData = useExportMyData;
|
|
1997
|
+
exports.useExtendMyHold = useExtendMyHold;
|
|
1184
1998
|
exports.useFlashSale = useFlashSale;
|
|
1185
1999
|
exports.useFlashSaleBookingOptions = useFlashSaleBookingOptions;
|
|
1186
2000
|
exports.useFlashSales = useFlashSales;
|
|
2001
|
+
exports.useGameCard = useGameCard;
|
|
1187
2002
|
exports.useGameCardCancelPreview = useGameCardCancelPreview;
|
|
1188
2003
|
exports.useGameCardPreview = useGameCardPreview;
|
|
1189
2004
|
exports.useGameCardPurchase = useGameCardPurchase;
|
|
1190
2005
|
exports.useGameCards = useGameCards;
|
|
2006
|
+
exports.useHoldCountdown = useHoldCountdown;
|
|
2007
|
+
exports.useHours = useHours;
|
|
2008
|
+
exports.useMembership = useMembership;
|
|
1191
2009
|
exports.useMembershipPreview = useMembershipPreview;
|
|
1192
2010
|
exports.useMembershipPurchase = useMembershipPurchase;
|
|
1193
2011
|
exports.useMembershipSubscriptionCheckout = useMembershipSubscriptionCheckout;
|
|
1194
2012
|
exports.useMembershipSubscriptionPreview = useMembershipSubscriptionPreview;
|
|
2013
|
+
exports.useMyCommunicationPrefs = useMyCommunicationPrefs;
|
|
1195
2014
|
exports.useMyCredits = useMyCredits;
|
|
1196
2015
|
exports.useMyEventOrder = useMyEventOrder;
|
|
1197
2016
|
exports.useMyEventOrders = useMyEventOrders;
|
|
2017
|
+
exports.useMyGameCard = useMyGameCard;
|
|
2018
|
+
exports.useMyGameCardHistory = useMyGameCardHistory;
|
|
2019
|
+
exports.useMyGameCardRedemptions = useMyGameCardRedemptions;
|
|
1198
2020
|
exports.useMyGameCards = useMyGameCards;
|
|
2021
|
+
exports.useMyHold = useMyHold;
|
|
1199
2022
|
exports.useMyLoyalty = useMyLoyalty;
|
|
2023
|
+
exports.useMyLoyaltyHistory = useMyLoyaltyHistory;
|
|
1200
2024
|
exports.useMyMembershipDetail = useMyMembershipDetail;
|
|
2025
|
+
exports.useMyMembershipMembers = useMyMembershipMembers;
|
|
1201
2026
|
exports.useMyMemberships = useMyMemberships;
|
|
2027
|
+
exports.useMyPackageOrder = useMyPackageOrder;
|
|
2028
|
+
exports.useMyPackageOrders = useMyPackageOrders;
|
|
1202
2029
|
exports.useMyPasses = useMyPasses;
|
|
1203
2030
|
exports.useMyReservationDetail = useMyReservationDetail;
|
|
1204
2031
|
exports.useMyReservations = useMyReservations;
|
|
2032
|
+
exports.useOpenMembershipBillingPortal = useOpenMembershipBillingPortal;
|
|
2033
|
+
exports.useOperatingHours = useOperatingHours;
|
|
1205
2034
|
exports.usePackage = usePackage;
|
|
1206
2035
|
exports.usePackageOrderCancelPreview = usePackageOrderCancelPreview;
|
|
1207
2036
|
exports.usePackagePreview = usePackagePreview;
|
|
1208
2037
|
exports.usePackagePurchase = usePackagePurchase;
|
|
1209
2038
|
exports.usePackages = usePackages;
|
|
2039
|
+
exports.usePackagesLabel = usePackagesLabel;
|
|
2040
|
+
exports.usePayLink = usePayLink;
|
|
2041
|
+
exports.useProduct = useProduct;
|
|
2042
|
+
exports.useProductSubtypes = useProductSubtypes;
|
|
1210
2043
|
exports.useProducts = useProducts;
|
|
1211
2044
|
exports.usePublicMemberships = usePublicMemberships;
|
|
1212
2045
|
exports.usePurchase = usePurchase;
|
|
2046
|
+
exports.useReceipt = useReceipt;
|
|
2047
|
+
exports.useReleaseMyHold = useReleaseMyHold;
|
|
1213
2048
|
exports.useRemoveCard = useRemoveCard;
|
|
2049
|
+
exports.useRequestEmailVerification = useRequestEmailVerification;
|
|
1214
2050
|
exports.useReservationCancelPreview = useReservationCancelPreview;
|
|
1215
2051
|
exports.useRetailPricing = useRetailPricing;
|
|
1216
2052
|
exports.useSavedCards = useSavedCards;
|
|
1217
2053
|
exports.useSetDefaultCard = useSetDefaultCard;
|
|
2054
|
+
exports.useSetMyCommunicationPref = useSetMyCommunicationPref;
|
|
2055
|
+
exports.useSetMyMobile = useSetMyMobile;
|
|
2056
|
+
exports.useSlotPrices = useSlotPrices;
|
|
1218
2057
|
exports.useStartTimes = useStartTimes;
|
|
2058
|
+
exports.useSubmitSupportRequest = useSubmitSupportRequest;
|
|
1219
2059
|
exports.useTestMode = useTestMode;
|
|
2060
|
+
exports.useUpdateMyProfile = useUpdateMyProfile;
|
|
2061
|
+
exports.useWaitlistJoin = useWaitlistJoin;
|
|
2062
|
+
exports.useWalletPassUrl = useWalletPassUrl;
|
|
1220
2063
|
//# sourceMappingURL=react.cjs.map
|
|
1221
2064
|
//# sourceMappingURL=react.cjs.map
|