@bowlos/reservations 0.35.0 → 0.41.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 +300 -0
- package/HEADLESS.md +716 -11
- package/README.md +363 -2
- package/dist/{data-qw8P3JW3.d.cts → account-DEX2Lr78.d.cts} +218 -3
- package/dist/{data-qw8P3JW3.d.ts → account-DEX2Lr78.d.ts} +218 -3
- package/dist/booking-change-4DGu-B08.d.ts +1282 -0
- package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
- package/dist/{chunk-UN5E6UEZ.js → chunk-44WKP6MW.js} +38 -7
- package/dist/chunk-44WKP6MW.js.map +1 -0
- package/dist/{chunk-MMSVM3QS.js → chunk-BWJHRJN6.js} +75 -187
- package/dist/chunk-BWJHRJN6.js.map +1 -0
- package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
- package/dist/chunk-FMFHNBDH.js.map +1 -0
- package/dist/chunk-I37IJNYU.js +139 -0
- package/dist/chunk-I37IJNYU.js.map +1 -0
- package/dist/chunk-VJIS56OO.js +717 -0
- package/dist/chunk-VJIS56OO.js.map +1 -0
- package/dist/{chunk-SMPDCDMB.js → chunk-YAXBZJMI.js} +3 -3
- package/dist/chunk-YAXBZJMI.js.map +1 -0
- package/dist/cli.cjs +34 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +1596 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +208 -7
- package/dist/components.d.ts +208 -7
- package/dist/components.js +1046 -8
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +299 -6
- 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 +77 -5
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +203 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +16 -2
- package/dist/payments.d.ts +16 -2
- package/dist/payments.js +78 -2
- package/dist/payments.js.map +1 -1
- package/dist/{react-C2V1kXnO.d.ts → react-CrRciA7I.d.ts} +2 -2
- package/dist/{react-DtncBQ3b.d.cts → react-QJrsaOnN.d.cts} +2 -2
- package/dist/react.cjs +801 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +150 -7
- package/dist/react.d.ts +150 -7
- package/dist/react.js +72 -4
- package/dist/react.js.map +1 -1
- package/package.json +10 -3
- 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/book/page.tsx +11 -23
- package/templates/center-site/app/catalog/page.tsx +21 -12
- 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-BJ5UjC0r.d.ts +0 -165
- package/dist/account-QoFg8-i1.d.cts +0 -165
- package/dist/catalog-CGitz1PG.d.ts +0 -221
- package/dist/catalog-p9cwB6Qv.d.cts +0 -221
- package/dist/chunk-MMSVM3QS.js.map +0 -1
- package/dist/chunk-SMPDCDMB.js.map +0 -1
- package/dist/chunk-UN5E6UEZ.js.map +0 -1
- package/dist/chunk-Y3YSDO3H.js.map +0 -1
package/dist/react.cjs
CHANGED
|
@@ -12,12 +12,14 @@ var BOWLOS_ERROR_CODES = {
|
|
|
12
12
|
API_KEY_INVALID: "API_KEY_INVALID",
|
|
13
13
|
ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED",
|
|
14
14
|
RATE_LIMITED: "RATE_LIMITED",
|
|
15
|
-
|
|
15
|
+
CURRENT_PASSWORD_INCORRECT: "CURRENT_PASSWORD_INCORRECT",
|
|
16
|
+
CURRENT_PASSWORD_REQUIRED: "CURRENT_PASSWORD_REQUIRED",
|
|
16
17
|
INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
|
|
17
18
|
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
18
19
|
SCOPE_REVOKED: "SCOPE_REVOKED",
|
|
19
20
|
NOT_FOUND: "NOT_FOUND",
|
|
20
21
|
// Client-side
|
|
22
|
+
ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
|
|
21
23
|
NETWORK_ERROR: "NETWORK_ERROR",
|
|
22
24
|
UNKNOWN: "ERROR"
|
|
23
25
|
};
|
|
@@ -26,6 +28,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
|
|
|
26
28
|
code;
|
|
27
29
|
/** HTTP status (0 for a network failure before any response). */
|
|
28
30
|
status;
|
|
31
|
+
details;
|
|
29
32
|
/** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
|
|
30
33
|
retryAfterSeconds;
|
|
31
34
|
constructor(code, message, status, options = {}) {
|
|
@@ -33,6 +36,7 @@ var BowlosApiError = class _BowlosApiError extends Error {
|
|
|
33
36
|
this.name = "BowlosApiError";
|
|
34
37
|
this.code = code;
|
|
35
38
|
this.status = status;
|
|
39
|
+
this.details = options.details;
|
|
36
40
|
this.retryAfterSeconds = options.retryAfterSeconds;
|
|
37
41
|
Object.setPrototypeOf(this, _BowlosApiError.prototype);
|
|
38
42
|
}
|
|
@@ -65,7 +69,8 @@ function isConfigErrorCode(code) {
|
|
|
65
69
|
return code === BOWLOS_ERROR_CODES.API_KEY_MISSING || code === BOWLOS_ERROR_CODES.API_KEY_INVALID || code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED || code === BOWLOS_ERROR_CODES.RATE_LIMITED;
|
|
66
70
|
}
|
|
67
71
|
function looksLikeExpiredSession(status, code) {
|
|
68
|
-
if (isConfigErrorCode(code)
|
|
72
|
+
if (isConfigErrorCode(code) || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_INCORRECT || code === BOWLOS_ERROR_CODES.CURRENT_PASSWORD_REQUIRED)
|
|
73
|
+
return false;
|
|
69
74
|
return status === 401 || code === BOWLOS_ERROR_CODES.PERMISSION_DENIED || code === BOWLOS_ERROR_CODES.SCOPE_REVOKED;
|
|
70
75
|
}
|
|
71
76
|
var BowlosClient = class {
|
|
@@ -110,7 +115,10 @@ var BowlosClient = class {
|
|
|
110
115
|
code,
|
|
111
116
|
env.error?.message ?? `Health ping failed (HTTP ${status}).`,
|
|
112
117
|
status,
|
|
113
|
-
{
|
|
118
|
+
{
|
|
119
|
+
details: errorDetails(env.error?.details),
|
|
120
|
+
retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
|
|
121
|
+
}
|
|
114
122
|
);
|
|
115
123
|
}
|
|
116
124
|
// ── low-level transport ────────────────────────────────────────────────
|
|
@@ -141,9 +149,18 @@ var BowlosClient = class {
|
|
|
141
149
|
try {
|
|
142
150
|
body = JSON.parse(text);
|
|
143
151
|
} catch {
|
|
144
|
-
body = {
|
|
152
|
+
body = {
|
|
153
|
+
ok: false,
|
|
154
|
+
error: {
|
|
155
|
+
code: res.status === 404 ? BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN,
|
|
156
|
+
message: text.slice(0, 200)
|
|
157
|
+
}
|
|
158
|
+
};
|
|
145
159
|
}
|
|
146
160
|
}
|
|
161
|
+
if (!text && res.status === 404) {
|
|
162
|
+
body = { ok: false, error: { code: BOWLOS_ERROR_CODES.ROUTE_NOT_FOUND } };
|
|
163
|
+
}
|
|
147
164
|
return { status: res.status, body, retryAfterSeconds };
|
|
148
165
|
}
|
|
149
166
|
/**
|
|
@@ -166,7 +183,8 @@ var BowlosClient = class {
|
|
|
166
183
|
throw new BowlosApiError(
|
|
167
184
|
inner.error?.code ?? BOWLOS_ERROR_CODES.UNKNOWN,
|
|
168
185
|
inner.error?.message ?? `Request to "${name}" failed.`,
|
|
169
|
-
status
|
|
186
|
+
status,
|
|
187
|
+
{ details: errorDetails(inner.error?.details) }
|
|
170
188
|
);
|
|
171
189
|
}
|
|
172
190
|
return inner.data;
|
|
@@ -175,11 +193,12 @@ var BowlosClient = class {
|
|
|
175
193
|
}
|
|
176
194
|
const code = env.error?.code ?? (status === 429 ? BOWLOS_ERROR_CODES.RATE_LIMITED : status === 404 ? BOWLOS_ERROR_CODES.NOT_FOUND : BOWLOS_ERROR_CODES.UNKNOWN);
|
|
177
195
|
const message = env.error?.message ?? `Request to "${name}" failed (HTTP ${status}).`;
|
|
178
|
-
if (auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
|
|
196
|
+
if (name !== "changeMyPassword" && auth && !retried && this.store.get() && looksLikeExpiredSession(status, code)) {
|
|
179
197
|
const refreshed = await this.tryRefresh();
|
|
180
198
|
if (refreshed) return this.callInternal(name, args, auth, true, method);
|
|
181
199
|
}
|
|
182
200
|
throw new BowlosApiError(code, message, status, {
|
|
201
|
+
details: errorDetails(env.error?.details),
|
|
183
202
|
retryAfterSeconds: code === BOWLOS_ERROR_CODES.RATE_LIMITED ? retryAfterSeconds : void 0
|
|
184
203
|
});
|
|
185
204
|
}
|
|
@@ -299,6 +318,13 @@ var defaultFetch = (input, init) => {
|
|
|
299
318
|
function createBowlosClient(config) {
|
|
300
319
|
return new BowlosClient(config);
|
|
301
320
|
}
|
|
321
|
+
function errorDetails(value) {
|
|
322
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
323
|
+
const entries = Object.entries(value).filter(
|
|
324
|
+
([, v]) => typeof v === "string" || typeof v === "boolean" || typeof v === "number" && Number.isFinite(v)
|
|
325
|
+
);
|
|
326
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
327
|
+
}
|
|
302
328
|
var BowlosContext = react.createContext(null);
|
|
303
329
|
var AccountContext = react.createContext(null);
|
|
304
330
|
function BowlosProvider({ client, config, children }) {
|
|
@@ -558,6 +584,41 @@ function abandonCheckout(client, refToken) {
|
|
|
558
584
|
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
559
585
|
}
|
|
560
586
|
|
|
587
|
+
// src/idempotent-mutation.ts
|
|
588
|
+
function useIdempotentMutation(name, options = {}) {
|
|
589
|
+
const mutation = useBowlosMutation(name, options);
|
|
590
|
+
const pending = react.useRef(null);
|
|
591
|
+
const run = react.useCallback(
|
|
592
|
+
async (args) => {
|
|
593
|
+
const fingerprint = JSON.stringify(args, (_key, value) => {
|
|
594
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
595
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)));
|
|
596
|
+
}
|
|
597
|
+
return value;
|
|
598
|
+
});
|
|
599
|
+
if (!pending.current || pending.current.fingerprint !== fingerprint) {
|
|
600
|
+
pending.current = { fingerprint, key: generateIdempotencyKey() };
|
|
601
|
+
}
|
|
602
|
+
const action = pending.current;
|
|
603
|
+
try {
|
|
604
|
+
const result = await mutation.run({ ...args, idempotencyKey: action.key });
|
|
605
|
+
if (pending.current === action) pending.current = null;
|
|
606
|
+
return result;
|
|
607
|
+
} catch (error) {
|
|
608
|
+
const retryable = !(error instanceof BowlosApiError) || error.status === 0 || error.status === 408 || error.status === 429 || error.status >= 500;
|
|
609
|
+
if (!retryable && pending.current === action) pending.current = null;
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
[mutation.run]
|
|
614
|
+
);
|
|
615
|
+
const reset = react.useCallback(() => {
|
|
616
|
+
pending.current = null;
|
|
617
|
+
mutation.reset();
|
|
618
|
+
}, [mutation.reset]);
|
|
619
|
+
return { ...mutation, run, reset };
|
|
620
|
+
}
|
|
621
|
+
|
|
561
622
|
// src/hooks.tsx
|
|
562
623
|
function useAvailability(args, options) {
|
|
563
624
|
return useBowlosQuery("checkAvailability", args, options);
|
|
@@ -614,38 +675,22 @@ function useGameCardCancelPreview(args, options) {
|
|
|
614
675
|
return useBowlosQuery("previewMyGameCardCancellation", args, { ...options, auth: true });
|
|
615
676
|
}
|
|
616
677
|
function useCancelMyReservation() {
|
|
617
|
-
|
|
678
|
+
return useIdempotentMutation("cancelMyReservation", {
|
|
618
679
|
auth: true
|
|
619
680
|
});
|
|
620
|
-
const run = react.useCallback(
|
|
621
|
-
(args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
|
|
622
|
-
[m]
|
|
623
|
-
);
|
|
624
|
-
return { ...m, run };
|
|
625
681
|
}
|
|
626
682
|
function useCancelMyEventOrder() {
|
|
627
|
-
|
|
628
|
-
const run = react.useCallback(
|
|
629
|
-
(args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
|
|
630
|
-
[m]
|
|
631
|
-
);
|
|
632
|
-
return { ...m, run };
|
|
683
|
+
return useIdempotentMutation("cancelMyEventOrder", { auth: true });
|
|
633
684
|
}
|
|
634
685
|
function useCancelMyPackageOrder() {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
[m]
|
|
639
|
-
);
|
|
640
|
-
return { ...m, run };
|
|
686
|
+
return useIdempotentMutation("cancelMyPackageOrder", {
|
|
687
|
+
auth: true
|
|
688
|
+
});
|
|
641
689
|
}
|
|
642
690
|
function useCancelMyGameCard() {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
[m]
|
|
647
|
-
);
|
|
648
|
-
return { ...m, run };
|
|
691
|
+
return useIdempotentMutation("cancelMyGameCard", {
|
|
692
|
+
auth: true
|
|
693
|
+
});
|
|
649
694
|
}
|
|
650
695
|
function useFlashSale(args, options) {
|
|
651
696
|
return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
|
|
@@ -714,6 +759,39 @@ function useMembershipSubscriptionPreview(args, options) {
|
|
|
714
759
|
auth: true
|
|
715
760
|
});
|
|
716
761
|
}
|
|
762
|
+
function useSavedCards(args, options) {
|
|
763
|
+
return useBowlosQuery("listMyPaymentMethods", args, { ...options, auth: true });
|
|
764
|
+
}
|
|
765
|
+
function useCreateCardSetup() {
|
|
766
|
+
return useBowlosMutation("createSetupIntentForAddingCard", {
|
|
767
|
+
auth: true
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function useRemoveCard() {
|
|
771
|
+
return useBowlosMutation("detachPaymentMethod", {
|
|
772
|
+
auth: true
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
function useSetDefaultCard() {
|
|
776
|
+
return useBowlosMutation("setDefaultPaymentMethod", {
|
|
777
|
+
auth: true
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function useChangePassword() {
|
|
781
|
+
const client = useBowlosClient();
|
|
782
|
+
const mutation = useBowlosMutation("changeMyPassword", {
|
|
783
|
+
auth: true
|
|
784
|
+
});
|
|
785
|
+
const run = react.useCallback(
|
|
786
|
+
async (args) => {
|
|
787
|
+
const result = await mutation.run(args);
|
|
788
|
+
await client.signOut();
|
|
789
|
+
return result;
|
|
790
|
+
},
|
|
791
|
+
[client, mutation.run]
|
|
792
|
+
);
|
|
793
|
+
return { ...mutation, run };
|
|
794
|
+
}
|
|
717
795
|
var DEFAULT_POLL_MS = 2500;
|
|
718
796
|
function useBookingFlow() {
|
|
719
797
|
const client = useBowlosClient();
|
|
@@ -1122,60 +1200,753 @@ function useMembershipSubscriptionCheckout() {
|
|
|
1122
1200
|
}, []);
|
|
1123
1201
|
return { status, subscriptionIntent, error, start, reset };
|
|
1124
1202
|
}
|
|
1203
|
+
function useUpdateMyProfile() {
|
|
1204
|
+
return useBowlosMutation("updateMyProfile", {
|
|
1205
|
+
auth: true
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
function useMyCommunicationPrefs(args, options) {
|
|
1209
|
+
return useBowlosQuery("listMyMarketingPrefs", args, {
|
|
1210
|
+
...options,
|
|
1211
|
+
auth: true
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
function useSetMyCommunicationPref() {
|
|
1215
|
+
return useBowlosMutation(
|
|
1216
|
+
"setMyMarketingPref",
|
|
1217
|
+
{ auth: true }
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
function useSetMyMobile() {
|
|
1221
|
+
return useBowlosMutation("setMyMobile", { auth: true });
|
|
1222
|
+
}
|
|
1223
|
+
function useSubmitSupportRequest() {
|
|
1224
|
+
return useBowlosMutation(
|
|
1225
|
+
"submitMySupportRequest",
|
|
1226
|
+
{ auth: true }
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
function useDeleteMyAccount() {
|
|
1230
|
+
const client = useBowlosClient();
|
|
1231
|
+
const mutation = useBowlosMutation(
|
|
1232
|
+
"deleteMyAccount",
|
|
1233
|
+
{ auth: true }
|
|
1234
|
+
);
|
|
1235
|
+
const run = react.useCallback(
|
|
1236
|
+
async (args) => {
|
|
1237
|
+
const result = await mutation.run(args);
|
|
1238
|
+
await client.signOut();
|
|
1239
|
+
return result;
|
|
1240
|
+
},
|
|
1241
|
+
[client, mutation.run]
|
|
1242
|
+
);
|
|
1243
|
+
return { ...mutation, run };
|
|
1244
|
+
}
|
|
1245
|
+
function useExportMyData() {
|
|
1246
|
+
return useBowlosMutation("exportMyData", {
|
|
1247
|
+
auth: true
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
function useMyPackageOrders(args, options) {
|
|
1251
|
+
return useBowlosQuery("listMyPackageOrders", args, {
|
|
1252
|
+
...options,
|
|
1253
|
+
auth: true
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
function useMyPackageOrder(args, options) {
|
|
1257
|
+
return useBowlosQuery("getMyPackageOrder", args, {
|
|
1258
|
+
...options,
|
|
1259
|
+
auth: true
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function useMyMembershipMembers(args, options) {
|
|
1263
|
+
return useBowlosQuery("listMyMembershipMembers", args, {
|
|
1264
|
+
...options,
|
|
1265
|
+
auth: true
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
function useAddMyMembershipMember() {
|
|
1269
|
+
return useBowlosMutation(
|
|
1270
|
+
"addMyMembershipMember",
|
|
1271
|
+
{ auth: true }
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
function useMyLoyaltyHistory(args, options) {
|
|
1275
|
+
return useBowlosQuery("listMyLoyaltyHistory", args, {
|
|
1276
|
+
...options,
|
|
1277
|
+
auth: true
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
function useReceipt(args, options) {
|
|
1281
|
+
return useBowlosQuery("getReservationByDisplayId", args, {
|
|
1282
|
+
...options,
|
|
1283
|
+
auth: false
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
function useProduct(args, options) {
|
|
1287
|
+
return useBowlosQuery("getPublicProduct", args, { ...options, auth: false });
|
|
1288
|
+
}
|
|
1289
|
+
function useMembership(args, options) {
|
|
1290
|
+
return useBowlosQuery("getPublicMembership", args, {
|
|
1291
|
+
...options,
|
|
1292
|
+
auth: false
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
function useGameCard(args, options) {
|
|
1296
|
+
return useBowlosQuery("getPublicGameCard", args, {
|
|
1297
|
+
...options,
|
|
1298
|
+
auth: false
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
function useProductSubtypes(args, options) {
|
|
1302
|
+
return useBowlosQuery("listSubtypesForProduct", args, {
|
|
1303
|
+
...options,
|
|
1304
|
+
auth: false
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
function useBrandMemberships(args, options) {
|
|
1308
|
+
return useBowlosQuery("listBrandMemberships", args, {
|
|
1309
|
+
...options,
|
|
1310
|
+
auth: false
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
function usePackagesLabel(args, options) {
|
|
1314
|
+
return useBowlosQuery("getBrandPackagesLabelPublic", args, {
|
|
1315
|
+
...options,
|
|
1316
|
+
auth: false
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function useSlotPrices(args, options) {
|
|
1320
|
+
return useBowlosQuery("previewSlotPrices", args, {
|
|
1321
|
+
...options,
|
|
1322
|
+
auth: false
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
function useHours(args, options) {
|
|
1326
|
+
return useBowlosQuery("listPublicHours", args, { ...options, auth: false });
|
|
1327
|
+
}
|
|
1328
|
+
function useOperatingHours(args, options) {
|
|
1329
|
+
return useBowlosQuery("getOperatingHours", args, {
|
|
1330
|
+
...options,
|
|
1331
|
+
auth: false
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
function useCenterOperatingHoursForType(args, options) {
|
|
1335
|
+
return useBowlosQuery(
|
|
1336
|
+
"getCenterOperatingHoursForType",
|
|
1337
|
+
args,
|
|
1338
|
+
{ ...options, auth: false }
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
function useCenters(args, options) {
|
|
1342
|
+
return useBowlosQuery("listPublicCenters", args, {
|
|
1343
|
+
...options,
|
|
1344
|
+
auth: false
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
function useCancelMyMembership() {
|
|
1348
|
+
return useIdempotentMutation(
|
|
1349
|
+
"cancelMyMembership",
|
|
1350
|
+
{ auth: true }
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
function useApplyMyModification() {
|
|
1354
|
+
return useIdempotentMutation(
|
|
1355
|
+
"applyMyModification",
|
|
1356
|
+
{ auth: true }
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// src/routes.ts
|
|
1361
|
+
async function deleteMyAccount(client, args) {
|
|
1362
|
+
const result = await client.call("deleteMyAccount", args, {
|
|
1363
|
+
auth: true
|
|
1364
|
+
});
|
|
1365
|
+
await client.signOut();
|
|
1366
|
+
return result;
|
|
1367
|
+
}
|
|
1368
|
+
function previewAccountDeletion(client, args) {
|
|
1369
|
+
return client.call("previewMyAccountDeletion", args, { auth: true });
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// src/use-account-deletion.ts
|
|
1373
|
+
function useAccountDeletion(args) {
|
|
1374
|
+
const client = useBowlosClient();
|
|
1375
|
+
const [preview, setPreview] = react.useState();
|
|
1376
|
+
const [status, setStatus] = react.useState("loading");
|
|
1377
|
+
const [error, setError] = react.useState();
|
|
1378
|
+
const generation = react.useRef(0);
|
|
1379
|
+
const busy = react.useRef(false);
|
|
1380
|
+
const phrase = react.useRef(void 0);
|
|
1381
|
+
const timer = react.useRef(void 0);
|
|
1382
|
+
const wake = react.useRef(void 0);
|
|
1383
|
+
const reload = react.useCallback(async () => {
|
|
1384
|
+
const current = generation.current;
|
|
1385
|
+
const value = await previewAccountDeletion(client, { brandId: args.brandId });
|
|
1386
|
+
if (generation.current === current) setPreview(value);
|
|
1387
|
+
return value;
|
|
1388
|
+
}, [client, args.brandId]);
|
|
1389
|
+
react.useEffect(() => {
|
|
1390
|
+
const current = ++generation.current;
|
|
1391
|
+
busy.current = false;
|
|
1392
|
+
phrase.current = void 0;
|
|
1393
|
+
setPreview(void 0);
|
|
1394
|
+
setError(void 0);
|
|
1395
|
+
setStatus("loading");
|
|
1396
|
+
void previewAccountDeletion(client, { brandId: args.brandId }).then(
|
|
1397
|
+
(value) => {
|
|
1398
|
+
if (generation.current === current) {
|
|
1399
|
+
setPreview(value);
|
|
1400
|
+
setStatus("ready");
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
(e) => {
|
|
1404
|
+
if (generation.current === current) {
|
|
1405
|
+
setError(e);
|
|
1406
|
+
setStatus("error");
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
);
|
|
1410
|
+
return () => {
|
|
1411
|
+
generation.current++;
|
|
1412
|
+
clearTimeout(timer.current);
|
|
1413
|
+
wake.current?.();
|
|
1414
|
+
};
|
|
1415
|
+
}, [client, args.brandId]);
|
|
1416
|
+
const confirm = react.useCallback(
|
|
1417
|
+
async (typedPhrase) => {
|
|
1418
|
+
if (busy.current || !preview) return;
|
|
1419
|
+
if (typedPhrase !== preview.confirmPhrase) {
|
|
1420
|
+
setError(
|
|
1421
|
+
new BowlosApiError("VALIDATION_FAILED", "Enter the confirmation phrase exactly.", 400)
|
|
1422
|
+
);
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
busy.current = true;
|
|
1426
|
+
phrase.current = typedPhrase;
|
|
1427
|
+
const current = generation.current;
|
|
1428
|
+
setError(void 0);
|
|
1429
|
+
setStatus("deleting");
|
|
1430
|
+
try {
|
|
1431
|
+
for (let attempt = 0; attempt <= 5; attempt++) {
|
|
1432
|
+
if (generation.current !== current) return;
|
|
1433
|
+
try {
|
|
1434
|
+
await deleteMyAccount(client, {
|
|
1435
|
+
brandId: args.brandId,
|
|
1436
|
+
confirmPhrase: typedPhrase,
|
|
1437
|
+
previewToken: preview.previewToken
|
|
1438
|
+
});
|
|
1439
|
+
if (generation.current === current) setStatus("deleted");
|
|
1440
|
+
return;
|
|
1441
|
+
} catch (e) {
|
|
1442
|
+
if (generation.current !== current) return;
|
|
1443
|
+
if (e instanceof BowlosApiError && e.code === "DELETION_PREVIEW_STALE") {
|
|
1444
|
+
await reload();
|
|
1445
|
+
if (generation.current === current) {
|
|
1446
|
+
setError(e);
|
|
1447
|
+
setStatus("stale");
|
|
1448
|
+
}
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
if (!(e instanceof BowlosApiError) || e.code !== "DELETION_PENDING_STRIPE") throw e;
|
|
1452
|
+
setStatus("pending");
|
|
1453
|
+
if (attempt === 5) {
|
|
1454
|
+
setError(e);
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
const seconds = e.details?.retryAfterSec;
|
|
1458
|
+
const delay = typeof seconds === "number" && seconds >= 0 ? seconds * 1e3 : 1e3;
|
|
1459
|
+
await new Promise((resolve) => {
|
|
1460
|
+
wake.current = resolve;
|
|
1461
|
+
timer.current = setTimeout(resolve, Math.min(delay * 2 ** attempt, 2147483647));
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
} catch (e) {
|
|
1466
|
+
if (generation.current === current) {
|
|
1467
|
+
setError(e);
|
|
1468
|
+
setStatus("error");
|
|
1469
|
+
}
|
|
1470
|
+
} finally {
|
|
1471
|
+
if (generation.current === current) busy.current = false;
|
|
1472
|
+
}
|
|
1473
|
+
},
|
|
1474
|
+
[client, args.brandId, preview, reload]
|
|
1475
|
+
);
|
|
1476
|
+
const retry = react.useCallback(async () => {
|
|
1477
|
+
if (phrase.current && preview && status !== "stale") await confirm(phrase.current);
|
|
1478
|
+
else {
|
|
1479
|
+
try {
|
|
1480
|
+
await reload();
|
|
1481
|
+
setError(void 0);
|
|
1482
|
+
setStatus("ready");
|
|
1483
|
+
} catch (e) {
|
|
1484
|
+
setError(e);
|
|
1485
|
+
setStatus("error");
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}, [confirm, preview, reload, status]);
|
|
1489
|
+
return {
|
|
1490
|
+
preview,
|
|
1491
|
+
consequences: preview,
|
|
1492
|
+
confirmPhrase: preview?.confirmPhrase,
|
|
1493
|
+
status,
|
|
1494
|
+
error,
|
|
1495
|
+
confirm,
|
|
1496
|
+
retry
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// src/toolkit-hooks.tsx
|
|
1501
|
+
function useBrandEventOffers(args, options) {
|
|
1502
|
+
return useBowlosQuery("listPublicEventOffersForBrand", args, {
|
|
1503
|
+
...options,
|
|
1504
|
+
auth: false
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
function useMyGameCard(args, options) {
|
|
1508
|
+
return useBowlosQuery("getMyGameCard", args, { ...options, auth: true });
|
|
1509
|
+
}
|
|
1510
|
+
function useMyGameCardRedemptions(args, options) {
|
|
1511
|
+
return useBowlosQuery("getMyGameCardRedemptions", args, {
|
|
1512
|
+
...options,
|
|
1513
|
+
auth: true
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
function useMyGameCardHistory(args, options) {
|
|
1517
|
+
return useBowlosQuery("getMyGameCardRedemptionsPage", args, {
|
|
1518
|
+
...options,
|
|
1519
|
+
auth: true
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function useWalletPassUrl() {
|
|
1523
|
+
return useBowlosMutation("getMyWalletPassUrl", {
|
|
1524
|
+
auth: true
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function useMyHold(args, options) {
|
|
1528
|
+
return useBowlosQuery("getMyHoldGroup", args, { ...options, auth: true });
|
|
1529
|
+
}
|
|
1530
|
+
function useExtendMyHold() {
|
|
1531
|
+
return useBowlosMutation("customerExtendMyHold", {
|
|
1532
|
+
auth: true
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
function useReleaseMyHold() {
|
|
1536
|
+
return useBowlosMutation("customerReleaseMyHold", { auth: true });
|
|
1537
|
+
}
|
|
1538
|
+
function useRequestEmailVerification() {
|
|
1539
|
+
return useBowlosMutation(
|
|
1540
|
+
"requestEmailVerification",
|
|
1541
|
+
{ auth: true }
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
function useConfirmEmailVerification() {
|
|
1545
|
+
return useBowlosMutation("confirmEmailVerification", {
|
|
1546
|
+
auth: true
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
function useEmailVerificationStatus(args, options) {
|
|
1550
|
+
return useBowlosQuery("getEmailVerificationStatus", args, {
|
|
1551
|
+
...options,
|
|
1552
|
+
auth: true
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
function useEmailVerificationSendState(args, options) {
|
|
1556
|
+
return useBowlosQuery("getEmailVerificationSendState", args, {
|
|
1557
|
+
...options,
|
|
1558
|
+
auth: true
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
function useCancellationPolicy(args, options) {
|
|
1562
|
+
return useBowlosQuery("getCancellationPolicy", args, {
|
|
1563
|
+
...options,
|
|
1564
|
+
auth: false
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
function useCancelMyPendingBooking() {
|
|
1568
|
+
return useBowlosMutation(
|
|
1569
|
+
"cancelMyPendingReservation",
|
|
1570
|
+
{ auth: true }
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
function useHoldCountdown(args, options) {
|
|
1574
|
+
const hold = useMyHold(args, options);
|
|
1575
|
+
const extension = useExtendMyHold();
|
|
1576
|
+
const release = useReleaseMyHold();
|
|
1577
|
+
const [remainingMs, setRemainingMs] = react.useState(0);
|
|
1578
|
+
react.useEffect(() => {
|
|
1579
|
+
const data = hold.data;
|
|
1580
|
+
if (!data || data.status !== "active") {
|
|
1581
|
+
setRemainingMs(0);
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
const receivedAt = Date.now();
|
|
1585
|
+
const tick = () => setRemainingMs(Math.max(0, data.expiresAt - data.serverNowMs - (Date.now() - receivedAt)));
|
|
1586
|
+
tick();
|
|
1587
|
+
const timer = setInterval(tick, 250);
|
|
1588
|
+
return () => clearInterval(timer);
|
|
1589
|
+
}, [hold.data]);
|
|
1590
|
+
return {
|
|
1591
|
+
...hold,
|
|
1592
|
+
remainingMs,
|
|
1593
|
+
expired: hold.data !== null && remainingMs === 0,
|
|
1594
|
+
extendable: hold.data?.status === "active" && !hold.data.extensionUsed && remainingMs > 0 && remainingMs <= 3e5,
|
|
1595
|
+
extension,
|
|
1596
|
+
release,
|
|
1597
|
+
extend: async () => {
|
|
1598
|
+
const result = await extension.run(args);
|
|
1599
|
+
await hold.refetch();
|
|
1600
|
+
return result;
|
|
1601
|
+
},
|
|
1602
|
+
releaseHold: async () => {
|
|
1603
|
+
const result = await release.run(args);
|
|
1604
|
+
await hold.refetch();
|
|
1605
|
+
return result;
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function useEmailVerification(args, options) {
|
|
1610
|
+
const [verifyId, setVerifyId] = react.useState(null);
|
|
1611
|
+
const request = useRequestEmailVerification();
|
|
1612
|
+
const confirm = useConfirmEmailVerification();
|
|
1613
|
+
const status = useEmailVerificationStatus(
|
|
1614
|
+
{ brandId: args.brandId, token: args.token ?? "" },
|
|
1615
|
+
{ ...options, enabled: options?.enabled !== false && !!args.token }
|
|
1616
|
+
);
|
|
1617
|
+
const sendState = useEmailVerificationSendState(
|
|
1618
|
+
{ brandId: args.brandId, verifyId: verifyId ?? "" },
|
|
1619
|
+
{ ...options, enabled: options?.enabled !== false && !!verifyId }
|
|
1620
|
+
);
|
|
1621
|
+
return {
|
|
1622
|
+
request,
|
|
1623
|
+
confirm,
|
|
1624
|
+
status,
|
|
1625
|
+
sendState,
|
|
1626
|
+
requestVerification: async () => {
|
|
1627
|
+
const result = await request.run({ brandId: args.brandId });
|
|
1628
|
+
setVerifyId(result.verifyId ?? null);
|
|
1629
|
+
return result;
|
|
1630
|
+
},
|
|
1631
|
+
confirmVerification: async (token = args.token ?? "") => {
|
|
1632
|
+
const result = await confirm.run({ brandId: args.brandId, token });
|
|
1633
|
+
if (args.token) await status.refetch();
|
|
1634
|
+
return result;
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
// src/booking-change.ts
|
|
1640
|
+
function previewBookingChange(client, args) {
|
|
1641
|
+
return client.call("previewMyModification", args, { auth: true });
|
|
1642
|
+
}
|
|
1643
|
+
function getPendingBookingChange(client, args) {
|
|
1644
|
+
return client.call("getMyPendingModification", args, { auth: true });
|
|
1645
|
+
}
|
|
1646
|
+
function createBookingChangePayment(client, args) {
|
|
1647
|
+
const { pendingModificationId, brandId, centerId } = args;
|
|
1648
|
+
return client.call(
|
|
1649
|
+
"createModificationPaymentIntent",
|
|
1650
|
+
{ pendingModificationId, brandId, centerId },
|
|
1651
|
+
{ auth: true }
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
// src/use-booking-change.ts
|
|
1656
|
+
function useOpenMembershipBillingPortal() {
|
|
1657
|
+
return useBowlosMutation(
|
|
1658
|
+
"createBillingPortalSession",
|
|
1659
|
+
{ auth: true }
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
function usePayLink(args, options) {
|
|
1663
|
+
return useBowlosQuery("getPayLinkInfo", args, { ...options, auth: false });
|
|
1664
|
+
}
|
|
1665
|
+
function useCreatePayLinkPayment() {
|
|
1666
|
+
const mutation = useBowlosMutation(
|
|
1667
|
+
"createPayIntentForPayLinkToken",
|
|
1668
|
+
{ auth: false }
|
|
1669
|
+
);
|
|
1670
|
+
const run = react.useCallback(
|
|
1671
|
+
(args) => mutation.run({ token: args.token, brandId: args.brandId, centerId: args.centerId }),
|
|
1672
|
+
[mutation.run]
|
|
1673
|
+
);
|
|
1674
|
+
return { ...mutation, run };
|
|
1675
|
+
}
|
|
1676
|
+
function useBookingChange(scope) {
|
|
1677
|
+
const client = useBowlosClient();
|
|
1678
|
+
const applyMutation = useIdempotentMutation(
|
|
1679
|
+
"applyMyModification",
|
|
1680
|
+
{ auth: true }
|
|
1681
|
+
);
|
|
1682
|
+
const [status, setStatus] = react.useState("idle");
|
|
1683
|
+
const [preview, setPreview] = react.useState();
|
|
1684
|
+
const [payment, setPayment] = react.useState();
|
|
1685
|
+
const [pending, setPending] = react.useState();
|
|
1686
|
+
const [pendingId, setPendingId] = react.useState();
|
|
1687
|
+
const [error, setError] = react.useState();
|
|
1688
|
+
const generation = react.useRef(0);
|
|
1689
|
+
const busy = react.useRef(false);
|
|
1690
|
+
const reset = react.useCallback(() => {
|
|
1691
|
+
generation.current++;
|
|
1692
|
+
busy.current = false;
|
|
1693
|
+
setStatus("idle");
|
|
1694
|
+
setPreview(void 0);
|
|
1695
|
+
setPayment(void 0);
|
|
1696
|
+
setPending(void 0);
|
|
1697
|
+
setPendingId(void 0);
|
|
1698
|
+
setError(void 0);
|
|
1699
|
+
applyMutation.reset();
|
|
1700
|
+
}, [applyMutation.reset]);
|
|
1701
|
+
react.useEffect(() => {
|
|
1702
|
+
reset();
|
|
1703
|
+
return () => {
|
|
1704
|
+
generation.current++;
|
|
1705
|
+
};
|
|
1706
|
+
}, [scope.brandId, scope.centerId, reset]);
|
|
1707
|
+
const loadPreview = react.useCallback(
|
|
1708
|
+
async (args) => {
|
|
1709
|
+
if (busy.current) return;
|
|
1710
|
+
busy.current = true;
|
|
1711
|
+
const current = ++generation.current;
|
|
1712
|
+
setStatus("previewing");
|
|
1713
|
+
setError(void 0);
|
|
1714
|
+
setPayment(void 0);
|
|
1715
|
+
setPendingId(void 0);
|
|
1716
|
+
try {
|
|
1717
|
+
const value = await previewBookingChange(client, { ...args, ...scope });
|
|
1718
|
+
if (generation.current === current) {
|
|
1719
|
+
setPreview(value);
|
|
1720
|
+
setStatus("preview");
|
|
1721
|
+
}
|
|
1722
|
+
return value;
|
|
1723
|
+
} catch (e) {
|
|
1724
|
+
if (generation.current === current) {
|
|
1725
|
+
setError(e);
|
|
1726
|
+
setStatus("error");
|
|
1727
|
+
}
|
|
1728
|
+
throw e;
|
|
1729
|
+
} finally {
|
|
1730
|
+
if (generation.current === current) busy.current = false;
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1733
|
+
[client, scope.brandId, scope.centerId]
|
|
1734
|
+
);
|
|
1735
|
+
const apply = react.useCallback(
|
|
1736
|
+
async (args) => {
|
|
1737
|
+
if (busy.current) return;
|
|
1738
|
+
busy.current = true;
|
|
1739
|
+
const current = generation.current;
|
|
1740
|
+
setError(void 0);
|
|
1741
|
+
setStatus("applying");
|
|
1742
|
+
try {
|
|
1743
|
+
const value = await applyMutation.run({ ...args, ...scope });
|
|
1744
|
+
if (generation.current !== current) return value;
|
|
1745
|
+
if (value.requiresPayment) {
|
|
1746
|
+
setPendingId(value.pendingModificationId);
|
|
1747
|
+
setStatus("pay");
|
|
1748
|
+
} else setStatus("done");
|
|
1749
|
+
return value;
|
|
1750
|
+
} catch (e) {
|
|
1751
|
+
if (generation.current === current) {
|
|
1752
|
+
setError(e);
|
|
1753
|
+
setStatus("error");
|
|
1754
|
+
}
|
|
1755
|
+
throw e;
|
|
1756
|
+
} finally {
|
|
1757
|
+
if (generation.current === current) busy.current = false;
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
[applyMutation.run, scope.brandId, scope.centerId]
|
|
1761
|
+
);
|
|
1762
|
+
const createPayment = react.useCallback(async () => {
|
|
1763
|
+
if (!pendingId || busy.current || status !== "pay") return;
|
|
1764
|
+
busy.current = true;
|
|
1765
|
+
const current = generation.current;
|
|
1766
|
+
setError(void 0);
|
|
1767
|
+
try {
|
|
1768
|
+
const value = await createBookingChangePayment(client, {
|
|
1769
|
+
...scope,
|
|
1770
|
+
pendingModificationId: pendingId
|
|
1771
|
+
});
|
|
1772
|
+
if (generation.current === current) setPayment(value);
|
|
1773
|
+
return value;
|
|
1774
|
+
} catch (e) {
|
|
1775
|
+
if (generation.current === current) setError(e);
|
|
1776
|
+
throw e;
|
|
1777
|
+
} finally {
|
|
1778
|
+
if (generation.current === current) busy.current = false;
|
|
1779
|
+
}
|
|
1780
|
+
}, [client, pendingId, scope.brandId, scope.centerId, status]);
|
|
1781
|
+
const resume = react.useCallback((args) => {
|
|
1782
|
+
generation.current++;
|
|
1783
|
+
busy.current = false;
|
|
1784
|
+
setPayment(void 0);
|
|
1785
|
+
setError(void 0);
|
|
1786
|
+
setPendingId(args.pendingModificationId);
|
|
1787
|
+
setStatus("pay");
|
|
1788
|
+
}, []);
|
|
1789
|
+
react.useEffect(() => {
|
|
1790
|
+
if (!pendingId || status !== "polling" && status !== "pay") return;
|
|
1791
|
+
let cancelled = false;
|
|
1792
|
+
let timer;
|
|
1793
|
+
const poll = async () => {
|
|
1794
|
+
try {
|
|
1795
|
+
const value = await getPendingBookingChange(client, {
|
|
1796
|
+
...scope,
|
|
1797
|
+
pendingModificationId: pendingId
|
|
1798
|
+
});
|
|
1799
|
+
if (cancelled) return;
|
|
1800
|
+
setPending(value);
|
|
1801
|
+
setError(void 0);
|
|
1802
|
+
if (value.status === "applied") {
|
|
1803
|
+
setStatus("done");
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
if (value.status !== "pending_payment") {
|
|
1807
|
+
setStatus(value.status);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if (value.expiresAt <= Date.now()) {
|
|
1811
|
+
setStatus("expired");
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
} catch (e) {
|
|
1815
|
+
if (cancelled) return;
|
|
1816
|
+
setError(e);
|
|
1817
|
+
}
|
|
1818
|
+
timer = setTimeout(() => void poll(), 1500);
|
|
1819
|
+
};
|
|
1820
|
+
void poll();
|
|
1821
|
+
return () => {
|
|
1822
|
+
cancelled = true;
|
|
1823
|
+
clearTimeout(timer);
|
|
1824
|
+
};
|
|
1825
|
+
}, [client, scope.brandId, scope.centerId, pendingId, status]);
|
|
1826
|
+
const paymentConfirmed = react.useCallback(() => {
|
|
1827
|
+
if (pendingId) setStatus("polling");
|
|
1828
|
+
}, [pendingId]);
|
|
1829
|
+
return {
|
|
1830
|
+
status,
|
|
1831
|
+
preview,
|
|
1832
|
+
payment,
|
|
1833
|
+
pending,
|
|
1834
|
+
pendingModificationId: pendingId,
|
|
1835
|
+
error,
|
|
1836
|
+
loadPreview,
|
|
1837
|
+
apply,
|
|
1838
|
+
createPayment,
|
|
1839
|
+
paymentConfirmed,
|
|
1840
|
+
resume,
|
|
1841
|
+
reset
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1125
1844
|
|
|
1126
1845
|
exports.BowlosProvider = BowlosProvider;
|
|
1127
1846
|
exports.useAccount = useAccount;
|
|
1847
|
+
exports.useAccountDeletion = useAccountDeletion;
|
|
1848
|
+
exports.useAddMyMembershipMember = useAddMyMembershipMember;
|
|
1128
1849
|
exports.useAddons = useAddons;
|
|
1850
|
+
exports.useApplyMyModification = useApplyMyModification;
|
|
1129
1851
|
exports.useAvailability = useAvailability;
|
|
1852
|
+
exports.useBookingChange = useBookingChange;
|
|
1130
1853
|
exports.useBookingFlow = useBookingFlow;
|
|
1131
1854
|
exports.useBookingPreview = useBookingPreview;
|
|
1132
1855
|
exports.useBowlosClient = useBowlosClient;
|
|
1133
1856
|
exports.useBowlosMutation = useBowlosMutation;
|
|
1134
1857
|
exports.useBowlosQuery = useBowlosQuery;
|
|
1858
|
+
exports.useBrandEventOffers = useBrandEventOffers;
|
|
1859
|
+
exports.useBrandMemberships = useBrandMemberships;
|
|
1135
1860
|
exports.useCancelMyEventOrder = useCancelMyEventOrder;
|
|
1136
1861
|
exports.useCancelMyGameCard = useCancelMyGameCard;
|
|
1862
|
+
exports.useCancelMyMembership = useCancelMyMembership;
|
|
1137
1863
|
exports.useCancelMyPackageOrder = useCancelMyPackageOrder;
|
|
1864
|
+
exports.useCancelMyPendingBooking = useCancelMyPendingBooking;
|
|
1138
1865
|
exports.useCancelMyReservation = useCancelMyReservation;
|
|
1866
|
+
exports.useCancellationPolicy = useCancellationPolicy;
|
|
1139
1867
|
exports.useCatalog = useCatalog;
|
|
1140
1868
|
exports.useCenterHours = useCenterHours;
|
|
1869
|
+
exports.useCenterOperatingHoursForType = useCenterOperatingHoursForType;
|
|
1870
|
+
exports.useCenters = useCenters;
|
|
1871
|
+
exports.useChangePassword = useChangePassword;
|
|
1872
|
+
exports.useConfirmEmailVerification = useConfirmEmailVerification;
|
|
1873
|
+
exports.useCreateCardSetup = useCreateCardSetup;
|
|
1874
|
+
exports.useCreatePayLinkPayment = useCreatePayLinkPayment;
|
|
1875
|
+
exports.useDeleteMyAccount = useDeleteMyAccount;
|
|
1876
|
+
exports.useEmailVerification = useEmailVerification;
|
|
1877
|
+
exports.useEmailVerificationSendState = useEmailVerificationSendState;
|
|
1878
|
+
exports.useEmailVerificationStatus = useEmailVerificationStatus;
|
|
1141
1879
|
exports.useEventOffer = useEventOffer;
|
|
1142
1880
|
exports.useEventOffers = useEventOffers;
|
|
1143
1881
|
exports.useEventOrderCancelPreview = useEventOrderCancelPreview;
|
|
1144
1882
|
exports.useEventTicketPreview = useEventTicketPreview;
|
|
1145
1883
|
exports.useEventTicketPurchase = useEventTicketPurchase;
|
|
1146
1884
|
exports.useEvents = useEvents;
|
|
1885
|
+
exports.useExportMyData = useExportMyData;
|
|
1886
|
+
exports.useExtendMyHold = useExtendMyHold;
|
|
1147
1887
|
exports.useFlashSale = useFlashSale;
|
|
1148
1888
|
exports.useFlashSaleBookingOptions = useFlashSaleBookingOptions;
|
|
1149
1889
|
exports.useFlashSales = useFlashSales;
|
|
1890
|
+
exports.useGameCard = useGameCard;
|
|
1150
1891
|
exports.useGameCardCancelPreview = useGameCardCancelPreview;
|
|
1151
1892
|
exports.useGameCardPreview = useGameCardPreview;
|
|
1152
1893
|
exports.useGameCardPurchase = useGameCardPurchase;
|
|
1153
1894
|
exports.useGameCards = useGameCards;
|
|
1895
|
+
exports.useHoldCountdown = useHoldCountdown;
|
|
1896
|
+
exports.useHours = useHours;
|
|
1897
|
+
exports.useMembership = useMembership;
|
|
1154
1898
|
exports.useMembershipPreview = useMembershipPreview;
|
|
1155
1899
|
exports.useMembershipPurchase = useMembershipPurchase;
|
|
1156
1900
|
exports.useMembershipSubscriptionCheckout = useMembershipSubscriptionCheckout;
|
|
1157
1901
|
exports.useMembershipSubscriptionPreview = useMembershipSubscriptionPreview;
|
|
1902
|
+
exports.useMyCommunicationPrefs = useMyCommunicationPrefs;
|
|
1158
1903
|
exports.useMyCredits = useMyCredits;
|
|
1159
1904
|
exports.useMyEventOrder = useMyEventOrder;
|
|
1160
1905
|
exports.useMyEventOrders = useMyEventOrders;
|
|
1906
|
+
exports.useMyGameCard = useMyGameCard;
|
|
1907
|
+
exports.useMyGameCardHistory = useMyGameCardHistory;
|
|
1908
|
+
exports.useMyGameCardRedemptions = useMyGameCardRedemptions;
|
|
1161
1909
|
exports.useMyGameCards = useMyGameCards;
|
|
1910
|
+
exports.useMyHold = useMyHold;
|
|
1162
1911
|
exports.useMyLoyalty = useMyLoyalty;
|
|
1912
|
+
exports.useMyLoyaltyHistory = useMyLoyaltyHistory;
|
|
1163
1913
|
exports.useMyMembershipDetail = useMyMembershipDetail;
|
|
1914
|
+
exports.useMyMembershipMembers = useMyMembershipMembers;
|
|
1164
1915
|
exports.useMyMemberships = useMyMemberships;
|
|
1916
|
+
exports.useMyPackageOrder = useMyPackageOrder;
|
|
1917
|
+
exports.useMyPackageOrders = useMyPackageOrders;
|
|
1165
1918
|
exports.useMyPasses = useMyPasses;
|
|
1166
1919
|
exports.useMyReservationDetail = useMyReservationDetail;
|
|
1167
1920
|
exports.useMyReservations = useMyReservations;
|
|
1921
|
+
exports.useOpenMembershipBillingPortal = useOpenMembershipBillingPortal;
|
|
1922
|
+
exports.useOperatingHours = useOperatingHours;
|
|
1168
1923
|
exports.usePackage = usePackage;
|
|
1169
1924
|
exports.usePackageOrderCancelPreview = usePackageOrderCancelPreview;
|
|
1170
1925
|
exports.usePackagePreview = usePackagePreview;
|
|
1171
1926
|
exports.usePackagePurchase = usePackagePurchase;
|
|
1172
1927
|
exports.usePackages = usePackages;
|
|
1928
|
+
exports.usePackagesLabel = usePackagesLabel;
|
|
1929
|
+
exports.usePayLink = usePayLink;
|
|
1930
|
+
exports.useProduct = useProduct;
|
|
1931
|
+
exports.useProductSubtypes = useProductSubtypes;
|
|
1173
1932
|
exports.useProducts = useProducts;
|
|
1174
1933
|
exports.usePublicMemberships = usePublicMemberships;
|
|
1175
1934
|
exports.usePurchase = usePurchase;
|
|
1935
|
+
exports.useReceipt = useReceipt;
|
|
1936
|
+
exports.useReleaseMyHold = useReleaseMyHold;
|
|
1937
|
+
exports.useRemoveCard = useRemoveCard;
|
|
1938
|
+
exports.useRequestEmailVerification = useRequestEmailVerification;
|
|
1176
1939
|
exports.useReservationCancelPreview = useReservationCancelPreview;
|
|
1177
1940
|
exports.useRetailPricing = useRetailPricing;
|
|
1941
|
+
exports.useSavedCards = useSavedCards;
|
|
1942
|
+
exports.useSetDefaultCard = useSetDefaultCard;
|
|
1943
|
+
exports.useSetMyCommunicationPref = useSetMyCommunicationPref;
|
|
1944
|
+
exports.useSetMyMobile = useSetMyMobile;
|
|
1945
|
+
exports.useSlotPrices = useSlotPrices;
|
|
1178
1946
|
exports.useStartTimes = useStartTimes;
|
|
1947
|
+
exports.useSubmitSupportRequest = useSubmitSupportRequest;
|
|
1179
1948
|
exports.useTestMode = useTestMode;
|
|
1949
|
+
exports.useUpdateMyProfile = useUpdateMyProfile;
|
|
1950
|
+
exports.useWalletPassUrl = useWalletPassUrl;
|
|
1180
1951
|
//# sourceMappingURL=react.cjs.map
|
|
1181
1952
|
//# sourceMappingURL=react.cjs.map
|