@msm-platform/customer-react 0.1.0 → 0.3.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/CHANGELOG.md +16 -0
- package/README.md +25 -34
- package/dist/booking.d.ts +19 -0
- package/dist/client.d.ts +3 -0
- package/dist/context.d.ts +12 -2
- package/dist/i18n.d.ts +44 -1
- package/dist/index.d.ts +11 -7
- package/dist/index.js +797 -281
- package/dist/layout.d.ts +8 -1
- package/dist/screens/bookings.d.ts +5 -0
- package/dist/screens/business.d.ts +11 -0
- package/dist/screens/businesses.d.ts +2 -0
- package/dist/server/index.d.ts +8 -29
- package/dist/server.js +125 -252
- package/dist/sign-in.d.ts +3 -0
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/dist/server/limits.d.ts +0 -44
- package/dist/server/turnstile.d.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -4,44 +4,23 @@ import { createCustomerClient as c, isCustomerApiError as l } from "@msm-platfor
|
|
|
4
4
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
5
|
import { Metadata as p, getCountries as m, getCountryCallingCode as h, parsePhoneNumberFromString as g, validatePhoneNumberLength as _ } from "libphonenumber-js";
|
|
6
6
|
import v from "libphonenumber-js/min/metadata";
|
|
7
|
-
// src/client.ts
|
|
8
|
-
var y = (e, t) => {
|
|
9
|
-
let n = new Request(e, t);
|
|
10
|
-
return n.headers.set("X-MSM-BFF", "1"), fetch(n);
|
|
11
|
-
};
|
|
12
|
-
function b(e, t, n) {
|
|
13
|
-
return y(`${e}${t}`, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: { "content-type": "application/json" },
|
|
16
|
-
body: JSON.stringify(n ?? {})
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function x(e, t) {
|
|
20
|
-
let n = c({ baseUrl: `${e}/engine` });
|
|
21
|
-
return n.use({
|
|
22
|
-
onRequest({ request: e }) {
|
|
23
|
-
return e.headers.set("X-MSM-BFF", "1"), e;
|
|
24
|
-
},
|
|
25
|
-
onResponse({ response: e }) {
|
|
26
|
-
e.status === 401 && t();
|
|
27
|
-
}
|
|
28
|
-
}), n;
|
|
29
|
-
}
|
|
30
7
|
// src/context.ts
|
|
31
|
-
var
|
|
32
|
-
function
|
|
33
|
-
let e = n(
|
|
8
|
+
var y = e(null);
|
|
9
|
+
function b() {
|
|
10
|
+
let e = n(y);
|
|
34
11
|
if (!e) throw Error("usePortal needs MsmCustomer.");
|
|
35
12
|
return e;
|
|
36
13
|
}
|
|
37
14
|
// src/i18n.ts
|
|
38
|
-
var
|
|
15
|
+
var x = {
|
|
39
16
|
"app.loading": "Loading…",
|
|
40
17
|
"app.loadFailed": "Something went wrong loading this page. Try again.",
|
|
41
18
|
"app.retry": "Try again",
|
|
42
19
|
"app.signedOut": "You were signed out because your session ended. Sign in again.",
|
|
43
20
|
"app.signedOutEverywhere": "You were signed out on every device.",
|
|
44
|
-
"nav.label": "
|
|
21
|
+
"nav.label": "Booking and my account",
|
|
22
|
+
"nav.book": "Book",
|
|
23
|
+
"nav.signIn": "Sign in",
|
|
45
24
|
"nav.bookings": "Bookings",
|
|
46
25
|
"nav.passes": "Passes",
|
|
47
26
|
"nav.details": "My details",
|
|
@@ -106,6 +85,45 @@ var w = {
|
|
|
106
85
|
"bookings.doneLate": "Your booking is cancelled. It counts as a late cancellation.",
|
|
107
86
|
"bookings.cancelFailed": "The booking could not be cancelled. Try again.",
|
|
108
87
|
"bookings.gone": "This booking no longer exists.",
|
|
88
|
+
"businesses.heading": "Book",
|
|
89
|
+
"businesses.intro": "Choose where you'd like to book.",
|
|
90
|
+
"businesses.empty": "No businesses take bookings here yet.",
|
|
91
|
+
"businesses.open": "See times",
|
|
92
|
+
"business.all": "All businesses",
|
|
93
|
+
"business.notFound": "This business isn't taking bookings here.",
|
|
94
|
+
"business.types": "Services",
|
|
95
|
+
"business.allTypes": "Everything",
|
|
96
|
+
"business.typeMissing": "This service can't be booked here.",
|
|
97
|
+
"business.minutes": "{minutes} min",
|
|
98
|
+
"business.week": "Which week",
|
|
99
|
+
"business.previousWeek": "Previous week",
|
|
100
|
+
"business.nextWeek": "Next week",
|
|
101
|
+
"business.weekOf": "{from} – {to}",
|
|
102
|
+
"business.empty": "Nothing is open in these days.",
|
|
103
|
+
"business.seatsLeft.one": "{count} seat left",
|
|
104
|
+
"business.seatsLeft.other": "{count} seats left",
|
|
105
|
+
"business.full": "Full",
|
|
106
|
+
"business.openTime": "Open time",
|
|
107
|
+
"business.with": "With {resource}",
|
|
108
|
+
"business.book": "Book",
|
|
109
|
+
"book.heading": "Your booking",
|
|
110
|
+
"book.signInFirst": "Sign in or create an account to book this time.",
|
|
111
|
+
"book.back": "Choose another time",
|
|
112
|
+
"book.reserving": "Holding this time for you…",
|
|
113
|
+
"book.heldUntil": "We're holding this time for you until {time}.",
|
|
114
|
+
"book.confirm": "Confirm booking",
|
|
115
|
+
"book.confirming": "Confirming…",
|
|
116
|
+
"book.booked": "You're booked.",
|
|
117
|
+
"book.toBookings": "See all my bookings",
|
|
118
|
+
"book.reserveAgain": "Hold this time again",
|
|
119
|
+
"book.full": "This class is full now. Choose another time.",
|
|
120
|
+
"book.slotTaken": "Someone has just taken this time. Choose another.",
|
|
121
|
+
"book.limit": "You already hold the most unconfirmed bookings allowed. Confirm one, or wait a few minutes for an unconfirmed one to lapse, then try again.",
|
|
122
|
+
"book.expired": "We held this time for as long as we could, and it has lapsed. Hold it again if it's still free.",
|
|
123
|
+
"book.notAllowed": "Booking this needs a membership or pass that covers it. Ask the business.",
|
|
124
|
+
"book.unavailable": "This time can no longer be booked. Choose another.",
|
|
125
|
+
"book.refused": "This business can't take your booking. Contact them.",
|
|
126
|
+
"book.failed": "The booking could not be made. Try again.",
|
|
109
127
|
"passes.heading": "Memberships and passes",
|
|
110
128
|
"passes.empty": "You have no memberships or passes.",
|
|
111
129
|
"passes.unlimited": "Unlimited",
|
|
@@ -126,110 +144,73 @@ var w = {
|
|
|
126
144
|
"details.signOutEverywhere": "Sign out everywhere",
|
|
127
145
|
"details.signOutEverywhereHint": "Ends your sessions on every phone and computer, including this one.",
|
|
128
146
|
"details.signOutEverywhereFailed": "Could not sign out everywhere. Try again."
|
|
129
|
-
},
|
|
130
|
-
function
|
|
131
|
-
return
|
|
147
|
+
}, S = "en-GB", C = x;
|
|
148
|
+
function w(e, t = {}) {
|
|
149
|
+
return C[e].replace(/\{(\w+)\}/g, (e, n) => {
|
|
132
150
|
let r = t[n];
|
|
133
|
-
return r === void 0 ? e : typeof r == "number" ?
|
|
151
|
+
return r === void 0 ? e : typeof r == "number" ? D(r) : r;
|
|
134
152
|
});
|
|
135
153
|
}
|
|
136
|
-
var
|
|
137
|
-
function
|
|
138
|
-
let r = `${e}.${
|
|
139
|
-
return
|
|
154
|
+
var T = new Intl.PluralRules(S);
|
|
155
|
+
function E(e, t, n = {}) {
|
|
156
|
+
let r = `${e}.${T.select(t)}`;
|
|
157
|
+
return w(r in C ? r : `${e}.other`, {
|
|
140
158
|
count: t,
|
|
141
159
|
...n
|
|
142
160
|
});
|
|
143
161
|
}
|
|
144
|
-
function
|
|
145
|
-
return new Intl.NumberFormat(
|
|
162
|
+
function D(e) {
|
|
163
|
+
return new Intl.NumberFormat(S).format(e);
|
|
146
164
|
}
|
|
147
|
-
function
|
|
148
|
-
return new Intl.DateTimeFormat(
|
|
165
|
+
function O(e, t) {
|
|
166
|
+
return new Intl.DateTimeFormat(S, {
|
|
149
167
|
dateStyle: "medium",
|
|
150
168
|
timeStyle: "short",
|
|
151
169
|
...t && { timeZone: t }
|
|
152
170
|
}).format(new Date(e));
|
|
153
171
|
}
|
|
154
|
-
function
|
|
155
|
-
return new Intl.DateTimeFormat(
|
|
172
|
+
function k(e, t) {
|
|
173
|
+
return new Intl.DateTimeFormat(S, {
|
|
156
174
|
timeStyle: "short",
|
|
157
175
|
...t && { timeZone: t }
|
|
158
176
|
}).format(new Date(e));
|
|
159
177
|
}
|
|
160
|
-
function
|
|
161
|
-
return new Intl.DateTimeFormat(
|
|
178
|
+
function A(e, t) {
|
|
179
|
+
return new Intl.DateTimeFormat(S, {
|
|
162
180
|
dateStyle: "medium",
|
|
163
181
|
...t && { timeZone: t }
|
|
164
182
|
}).format(new Date(e));
|
|
165
183
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
function j(e, t) {
|
|
185
|
+
return new Intl.DateTimeFormat(S, {
|
|
186
|
+
weekday: "long",
|
|
187
|
+
day: "numeric",
|
|
188
|
+
month: "long",
|
|
189
|
+
...t && { timeZone: t }
|
|
190
|
+
}).format(new Date(e));
|
|
191
|
+
}
|
|
192
|
+
function M(e, t, n) {
|
|
193
|
+
let r = A(e, n) === A(t, n);
|
|
194
|
+
return w("bookings.when", {
|
|
195
|
+
start: O(e, n),
|
|
196
|
+
end: r ? k(t, n) : O(t, n)
|
|
171
197
|
});
|
|
172
198
|
}
|
|
173
|
-
function
|
|
174
|
-
if (e < 60) return
|
|
199
|
+
function N(e) {
|
|
200
|
+
if (e < 60) return E("wait.seconds", e);
|
|
175
201
|
let t = Math.round(e / 60);
|
|
176
|
-
return t < 60 ?
|
|
177
|
-
}
|
|
178
|
-
// src/layout.tsx
|
|
179
|
-
function F({ brand: e }) {
|
|
180
|
-
return e ? /* @__PURE__ */ f("div", {
|
|
181
|
-
className: "cp-brand",
|
|
182
|
-
children: [e.logo && /* @__PURE__ */ d("img", {
|
|
183
|
-
src: e.logo,
|
|
184
|
-
alt: ""
|
|
185
|
-
}), /* @__PURE__ */ d("span", { children: e.name })]
|
|
186
|
-
}) : null;
|
|
187
|
-
}
|
|
188
|
-
var te = [
|
|
189
|
-
["bookings", "nav.bookings"],
|
|
190
|
-
["passes", "nav.passes"],
|
|
191
|
-
["details", "nav.details"]
|
|
192
|
-
];
|
|
193
|
-
function I(e) {
|
|
194
|
-
return /* @__PURE__ */ f("div", {
|
|
195
|
-
className: "cp-shell",
|
|
196
|
-
children: [
|
|
197
|
-
/* @__PURE__ */ f("header", {
|
|
198
|
-
className: "cp-header",
|
|
199
|
-
children: [/* @__PURE__ */ d(F, { brand: e.brand }), /* @__PURE__ */ d("button", {
|
|
200
|
-
type: "button",
|
|
201
|
-
className: "cp-link",
|
|
202
|
-
onClick: e.onSignOut,
|
|
203
|
-
children: D("nav.signOut")
|
|
204
|
-
})]
|
|
205
|
-
}),
|
|
206
|
-
/* @__PURE__ */ d("nav", {
|
|
207
|
-
className: "cp-nav",
|
|
208
|
-
"aria-label": D("nav.label"),
|
|
209
|
-
children: te.map(([t, n]) => /* @__PURE__ */ d("button", {
|
|
210
|
-
type: "button",
|
|
211
|
-
"aria-current": e.screen === t ? "page" : void 0,
|
|
212
|
-
onClick: () => e.onNavigate(t),
|
|
213
|
-
children: D(n)
|
|
214
|
-
}, t))
|
|
215
|
-
}),
|
|
216
|
-
/* @__PURE__ */ d("main", {
|
|
217
|
-
className: "cp-main",
|
|
218
|
-
children: e.children
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
});
|
|
202
|
+
return t < 60 ? E("wait.minutes", t) : E("wait.hours", Math.round(e / 3600));
|
|
222
203
|
}
|
|
223
204
|
// src/cancellation.ts
|
|
224
|
-
function
|
|
205
|
+
function P(e, t) {
|
|
225
206
|
if (e.status === "cancelled") return "cancelled";
|
|
226
207
|
let n = t.getTime();
|
|
227
208
|
return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
|
|
228
209
|
}
|
|
229
210
|
// src/screens/bookings.tsx
|
|
230
|
-
var
|
|
231
|
-
function
|
|
232
|
-
let { client: e } =
|
|
211
|
+
var F = "/web/businesses/{businessId}/bookings/{bookingId}/cancel";
|
|
212
|
+
function ee() {
|
|
213
|
+
let { client: e } = b(), [n, i] = s("upcoming"), [a, o] = s(), [c, l] = s(null), [u, p] = s(!1), [m, h] = s(), g = t(async (t) => {
|
|
233
214
|
p(!1);
|
|
234
215
|
try {
|
|
235
216
|
let { data: r } = await e.GET("/web/me/bookings", { params: { query: {
|
|
@@ -247,28 +228,28 @@ function ne() {
|
|
|
247
228
|
}, [g]), /* @__PURE__ */ f("section", {
|
|
248
229
|
className: "cp-screen",
|
|
249
230
|
children: [
|
|
250
|
-
/* @__PURE__ */ d("h1", { children:
|
|
231
|
+
/* @__PURE__ */ d("h1", { children: w("bookings.heading") }),
|
|
251
232
|
/* @__PURE__ */ d("fieldset", {
|
|
252
233
|
className: "cp-tabs",
|
|
253
|
-
"aria-label":
|
|
234
|
+
"aria-label": w("bookings.period"),
|
|
254
235
|
children: ["upcoming", "past"].map((e) => /* @__PURE__ */ d("button", {
|
|
255
236
|
type: "button",
|
|
256
237
|
"aria-pressed": n === e,
|
|
257
238
|
onClick: () => i(e),
|
|
258
|
-
children:
|
|
239
|
+
children: w(e === "upcoming" ? "bookings.upcoming" : "bookings.past")
|
|
259
240
|
}, e))
|
|
260
241
|
}),
|
|
261
242
|
m && /* @__PURE__ */ d("p", {
|
|
262
243
|
role: "status",
|
|
263
244
|
className: "cp-notice",
|
|
264
|
-
children:
|
|
245
|
+
children: w(m)
|
|
265
246
|
}),
|
|
266
|
-
u ? /* @__PURE__ */ d(
|
|
247
|
+
u ? /* @__PURE__ */ d(I, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ d("p", {
|
|
267
248
|
className: "cp-empty",
|
|
268
|
-
children:
|
|
249
|
+
children: w(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
|
|
269
250
|
}) : /* @__PURE__ */ d("ul", {
|
|
270
251
|
className: "cp-list",
|
|
271
|
-
children: a.map((e) => /* @__PURE__ */ d(
|
|
252
|
+
children: a.map((e) => /* @__PURE__ */ d(L, {
|
|
272
253
|
booking: e,
|
|
273
254
|
onCancelled: (e, t) => {
|
|
274
255
|
o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
|
|
@@ -276,35 +257,35 @@ function ne() {
|
|
|
276
257
|
}, e.id))
|
|
277
258
|
}) : /* @__PURE__ */ d("p", {
|
|
278
259
|
role: "status",
|
|
279
|
-
children:
|
|
260
|
+
children: w("app.loading")
|
|
280
261
|
}),
|
|
281
262
|
a && c && !u && /* @__PURE__ */ d("button", {
|
|
282
263
|
type: "button",
|
|
283
264
|
className: "cp-secondary",
|
|
284
265
|
onClick: () => g(c),
|
|
285
|
-
children:
|
|
266
|
+
children: w("bookings.more")
|
|
286
267
|
})
|
|
287
268
|
]
|
|
288
269
|
});
|
|
289
270
|
}
|
|
290
|
-
function
|
|
271
|
+
function I({ onRetry: e }) {
|
|
291
272
|
return /* @__PURE__ */ f("div", {
|
|
292
273
|
role: "alert",
|
|
293
274
|
className: "cp-error",
|
|
294
|
-
children: [/* @__PURE__ */ d("p", { children:
|
|
275
|
+
children: [/* @__PURE__ */ d("p", { children: w("app.loadFailed") }), /* @__PURE__ */ d("button", {
|
|
295
276
|
type: "button",
|
|
296
277
|
className: "cp-secondary",
|
|
297
278
|
onClick: e,
|
|
298
|
-
children:
|
|
279
|
+
children: w("app.retry")
|
|
299
280
|
})]
|
|
300
281
|
});
|
|
301
282
|
}
|
|
302
|
-
function
|
|
303
|
-
let { client: t, businesses: n } =
|
|
283
|
+
function L(e) {
|
|
284
|
+
let { client: t, businesses: n } = b(), { booking: r } = e, i = n.get(r.businessId)?.timezone, [a, o] = s(!1), [c, u] = s(!1), [p, m] = s(), [h, g] = s(!1), _ = h ? "closed" : P(r, /* @__PURE__ */ new Date()), v = r.creditMembershipId !== null && r.creditRestoredAt === null;
|
|
304
285
|
async function y() {
|
|
305
286
|
u(!0), m(void 0);
|
|
306
287
|
try {
|
|
307
|
-
let { data: n } = await t.POST(
|
|
288
|
+
let { data: n } = await t.POST(F, { params: { path: {
|
|
308
289
|
businessId: r.businessId,
|
|
309
290
|
bookingId: r.id
|
|
310
291
|
} } });
|
|
@@ -315,7 +296,7 @@ function re(e) {
|
|
|
315
296
|
lateCancellationFrom: null
|
|
316
297
|
}, n.cancelledLate === !0));
|
|
317
298
|
} catch (e) {
|
|
318
|
-
if (l(e, "post",
|
|
299
|
+
if (l(e, "post", F)) {
|
|
319
300
|
if (e.code === "EventStarted") {
|
|
320
301
|
g(!0), o(!1);
|
|
321
302
|
return;
|
|
@@ -338,37 +319,37 @@ function re(e) {
|
|
|
338
319
|
className: "cp-card-head",
|
|
339
320
|
children: [/* @__PURE__ */ d("h2", { children: r.event.eventTypeName }), r.status === "cancelled" ? /* @__PURE__ */ d("span", {
|
|
340
321
|
className: "cp-badge",
|
|
341
|
-
children:
|
|
322
|
+
children: w(r.cancelledLate ? "bookings.cancelledLate" : "bookings.cancelled")
|
|
342
323
|
}) : r.attendance ? /* @__PURE__ */ d("span", {
|
|
343
324
|
className: "cp-badge",
|
|
344
|
-
children:
|
|
325
|
+
children: w(r.attendance === "attended" ? "bookings.attended" : "bookings.noShow")
|
|
345
326
|
}) : null]
|
|
346
327
|
}),
|
|
347
328
|
/* @__PURE__ */ d("p", { children: r.businessName }),
|
|
348
|
-
/* @__PURE__ */ d("p", { children:
|
|
329
|
+
/* @__PURE__ */ d("p", { children: M(r.event.startsAt, r.event.endsAt, i) }),
|
|
349
330
|
(_ === "open" || _ === "late") && r.lateCancellationFrom && /* @__PURE__ */ d("p", {
|
|
350
331
|
className: "cp-hint",
|
|
351
|
-
children:
|
|
332
|
+
children: w("bookings.lateFrom", { time: O(r.lateCancellationFrom, i) })
|
|
352
333
|
}),
|
|
353
334
|
_ === "closed" && r.status === "confirmed" && !r.attendance && /* @__PURE__ */ d("p", {
|
|
354
335
|
className: "cp-hint",
|
|
355
|
-
children:
|
|
336
|
+
children: w("bookings.started")
|
|
356
337
|
}),
|
|
357
338
|
p && /* @__PURE__ */ d("p", {
|
|
358
339
|
role: "alert",
|
|
359
|
-
children:
|
|
340
|
+
children: w(p)
|
|
360
341
|
}),
|
|
361
342
|
(_ === "open" || _ === "late") && (a ? /* @__PURE__ */ f("fieldset", {
|
|
362
343
|
className: "cp-confirm",
|
|
363
344
|
children: [
|
|
364
|
-
/* @__PURE__ */ d("legend", { children:
|
|
345
|
+
/* @__PURE__ */ d("legend", { children: w("bookings.confirmHeading") }),
|
|
365
346
|
_ === "late" && /* @__PURE__ */ d("p", {
|
|
366
347
|
className: "cp-warning",
|
|
367
|
-
children:
|
|
348
|
+
children: w("bookings.confirmLate")
|
|
368
349
|
}),
|
|
369
350
|
_ === "late" && v && /* @__PURE__ */ d("p", {
|
|
370
351
|
className: "cp-warning",
|
|
371
|
-
children:
|
|
352
|
+
children: w("bookings.confirmCredit")
|
|
372
353
|
}),
|
|
373
354
|
/* @__PURE__ */ f("div", {
|
|
374
355
|
className: "cp-actions",
|
|
@@ -376,13 +357,13 @@ function re(e) {
|
|
|
376
357
|
type: "button",
|
|
377
358
|
disabled: c,
|
|
378
359
|
onClick: y,
|
|
379
|
-
children:
|
|
360
|
+
children: w(c ? "bookings.cancelling" : "bookings.confirm")
|
|
380
361
|
}), /* @__PURE__ */ d("button", {
|
|
381
362
|
type: "button",
|
|
382
363
|
className: "cp-secondary",
|
|
383
364
|
disabled: c,
|
|
384
365
|
onClick: () => o(!1),
|
|
385
|
-
children:
|
|
366
|
+
children: w("bookings.keep")
|
|
386
367
|
})]
|
|
387
368
|
})
|
|
388
369
|
]
|
|
@@ -390,14 +371,508 @@ function re(e) {
|
|
|
390
371
|
type: "button",
|
|
391
372
|
className: "cp-secondary",
|
|
392
373
|
onClick: () => o(!0),
|
|
393
|
-
children:
|
|
374
|
+
children: w("bookings.cancel")
|
|
394
375
|
}))
|
|
395
376
|
]
|
|
396
377
|
});
|
|
397
378
|
}
|
|
379
|
+
// src/booking.tsx
|
|
380
|
+
var R = "/web/businesses/{businessId}/reservations", z = "/web/businesses/{businessId}/reservations/{reservationId}/confirm";
|
|
381
|
+
function B({ choice: e }) {
|
|
382
|
+
let { business: t, candidate: n } = e;
|
|
383
|
+
return /* @__PURE__ */ f("div", {
|
|
384
|
+
className: "cp-summary",
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ d("h2", { children: n.title }),
|
|
387
|
+
/* @__PURE__ */ d("p", { children: t.displayName }),
|
|
388
|
+
/* @__PURE__ */ d("p", { children: M(n.startsAt, n.endsAt, n.timezone) }),
|
|
389
|
+
n.resource && /* @__PURE__ */ d("p", {
|
|
390
|
+
className: "cp-hint",
|
|
391
|
+
children: w("business.with", { resource: n.resource.displayName })
|
|
392
|
+
})
|
|
393
|
+
]
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
function te(e) {
|
|
397
|
+
let { client: n, navigate: i } = b(), { business: a, candidate: c } = e.choice, [p, m] = s({ step: "reserving" }), [h, g] = s(), _ = t(async () => {
|
|
398
|
+
m({ step: "reserving" });
|
|
399
|
+
try {
|
|
400
|
+
let { data: e } = await n.POST(R, {
|
|
401
|
+
params: { path: { businessId: a.id } },
|
|
402
|
+
body: c.eventId ? { eventId: c.eventId } : {
|
|
403
|
+
eventTypeId: c.eventTypeId,
|
|
404
|
+
startsAt: c.startsAt,
|
|
405
|
+
...c.resource && { resourceId: c.resource.id }
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
e && m({
|
|
409
|
+
step: "held",
|
|
410
|
+
reservationId: e.id,
|
|
411
|
+
expiresAt: e.expiresAt
|
|
412
|
+
});
|
|
413
|
+
} catch (e) {
|
|
414
|
+
let t = l(e, "post", R) ? e.code : void 0;
|
|
415
|
+
m({
|
|
416
|
+
step: "refused",
|
|
417
|
+
message: ne(t),
|
|
418
|
+
again: !1
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}, [
|
|
422
|
+
n,
|
|
423
|
+
a.id,
|
|
424
|
+
c
|
|
425
|
+
]), v = o(!1);
|
|
426
|
+
r(() => {
|
|
427
|
+
v.current || (v.current = !0, _());
|
|
428
|
+
}, [_]);
|
|
429
|
+
async function y(e, t) {
|
|
430
|
+
m({
|
|
431
|
+
step: "confirming",
|
|
432
|
+
reservationId: e,
|
|
433
|
+
expiresAt: t
|
|
434
|
+
});
|
|
435
|
+
try {
|
|
436
|
+
let { data: t } = await n.POST(z, { params: { path: {
|
|
437
|
+
businessId: a.id,
|
|
438
|
+
reservationId: e
|
|
439
|
+
} } });
|
|
440
|
+
if (!t) return;
|
|
441
|
+
let r = await n.GET("/web/businesses/{businessId}/bookings/{bookingId}", { params: { path: {
|
|
442
|
+
businessId: a.id,
|
|
443
|
+
bookingId: t.id
|
|
444
|
+
} } }).then(({ data: e }) => e ?? null).catch(() => null);
|
|
445
|
+
m({
|
|
446
|
+
step: "booked",
|
|
447
|
+
booking: r
|
|
448
|
+
});
|
|
449
|
+
} catch (e) {
|
|
450
|
+
let t = l(e, "post", z) ? e.code : void 0;
|
|
451
|
+
m(t === "ReservationExpired" || t === "ReservationNotFound" ? {
|
|
452
|
+
step: "refused",
|
|
453
|
+
message: "book.expired",
|
|
454
|
+
again: !0
|
|
455
|
+
} : {
|
|
456
|
+
step: "refused",
|
|
457
|
+
message: re(t),
|
|
458
|
+
again: !1
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
let x = /* @__PURE__ */ d("button", {
|
|
463
|
+
type: "button",
|
|
464
|
+
className: "cp-secondary",
|
|
465
|
+
onClick: e.onBack,
|
|
466
|
+
children: w("book.back")
|
|
467
|
+
});
|
|
468
|
+
return /* @__PURE__ */ f("section", {
|
|
469
|
+
className: "cp-screen",
|
|
470
|
+
children: [/* @__PURE__ */ d("h1", { children: w("book.heading") }), p.step === "booked" ? /* @__PURE__ */ f(u, { children: [
|
|
471
|
+
/* @__PURE__ */ d("p", {
|
|
472
|
+
role: "status",
|
|
473
|
+
className: "cp-notice",
|
|
474
|
+
children: w(h ?? "book.booked")
|
|
475
|
+
}),
|
|
476
|
+
p.booking ? /* @__PURE__ */ d("ul", {
|
|
477
|
+
className: "cp-list",
|
|
478
|
+
children: /* @__PURE__ */ d(L, {
|
|
479
|
+
booking: p.booking,
|
|
480
|
+
onCancelled: (e, t) => {
|
|
481
|
+
m({
|
|
482
|
+
step: "booked",
|
|
483
|
+
booking: e
|
|
484
|
+
}), g(t ? "bookings.doneLate" : "bookings.doneOnTime");
|
|
485
|
+
}
|
|
486
|
+
})
|
|
487
|
+
}) : /* @__PURE__ */ d(B, { choice: e.choice }),
|
|
488
|
+
/* @__PURE__ */ d("button", {
|
|
489
|
+
type: "button",
|
|
490
|
+
className: "cp-secondary",
|
|
491
|
+
onClick: () => i("bookings"),
|
|
492
|
+
children: w("book.toBookings")
|
|
493
|
+
})
|
|
494
|
+
] }) : /* @__PURE__ */ f(u, { children: [
|
|
495
|
+
/* @__PURE__ */ d(B, { choice: e.choice }),
|
|
496
|
+
p.step === "reserving" && /* @__PURE__ */ d("p", {
|
|
497
|
+
role: "status",
|
|
498
|
+
children: w("book.reserving")
|
|
499
|
+
}),
|
|
500
|
+
(p.step === "held" || p.step === "confirming") && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("p", {
|
|
501
|
+
className: "cp-hint",
|
|
502
|
+
children: w("book.heldUntil", { time: k(p.expiresAt, c.timezone) })
|
|
503
|
+
}), /* @__PURE__ */ f("div", {
|
|
504
|
+
className: "cp-actions",
|
|
505
|
+
children: [/* @__PURE__ */ d("button", {
|
|
506
|
+
type: "button",
|
|
507
|
+
disabled: p.step === "confirming",
|
|
508
|
+
onClick: () => y(p.reservationId, p.expiresAt),
|
|
509
|
+
children: p.step === "confirming" ? w("book.confirming") : w("book.confirm")
|
|
510
|
+
}), x]
|
|
511
|
+
})] }),
|
|
512
|
+
p.step === "refused" && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("p", {
|
|
513
|
+
role: "alert",
|
|
514
|
+
children: w(p.message)
|
|
515
|
+
}), /* @__PURE__ */ f("div", {
|
|
516
|
+
className: "cp-actions",
|
|
517
|
+
children: [p.again && /* @__PURE__ */ d("button", {
|
|
518
|
+
type: "button",
|
|
519
|
+
onClick: _,
|
|
520
|
+
children: w("book.reserveAgain")
|
|
521
|
+
}), x]
|
|
522
|
+
})] })
|
|
523
|
+
] })]
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
function ne(e) {
|
|
527
|
+
switch (e) {
|
|
528
|
+
case "EventFull": return "book.full";
|
|
529
|
+
case "SlotTaken": return "book.slotTaken";
|
|
530
|
+
case "ReservationLimitReached": return "book.limit";
|
|
531
|
+
case "NotAuthorized": return "book.notAllowed";
|
|
532
|
+
case "EventStarted":
|
|
533
|
+
case "EventNotBookable":
|
|
534
|
+
case "NotATimeSlot":
|
|
535
|
+
case "EventNotFound":
|
|
536
|
+
case "EventTypeNotFound":
|
|
537
|
+
case "BusinessNotFound": return "book.unavailable";
|
|
538
|
+
default: return "book.failed";
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function re(e) {
|
|
542
|
+
switch (e) {
|
|
543
|
+
case "NotAuthorized": return "book.notAllowed";
|
|
544
|
+
case "EventStarted":
|
|
545
|
+
case "EventNotBookable":
|
|
546
|
+
case "BusinessNotFound": return "book.unavailable";
|
|
547
|
+
case "CustomerOutsideBusiness": return "book.refused";
|
|
548
|
+
default: return "book.failed";
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
// src/client.ts
|
|
552
|
+
var V = (e, t) => {
|
|
553
|
+
let n = new Request(e, t);
|
|
554
|
+
return n.headers.set("X-MSM-BFF", "1"), fetch(n);
|
|
555
|
+
};
|
|
556
|
+
function H(e, t, n) {
|
|
557
|
+
return V(`${e}${t}`, {
|
|
558
|
+
method: "POST",
|
|
559
|
+
headers: { "content-type": "application/json" },
|
|
560
|
+
body: JSON.stringify(n ?? {})
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
function ie(e, t) {
|
|
564
|
+
let n = c({ baseUrl: `${e}/engine` });
|
|
565
|
+
return n.use({
|
|
566
|
+
onRequest({ request: e }) {
|
|
567
|
+
return e.headers.set("X-MSM-BFF", "1"), e;
|
|
568
|
+
},
|
|
569
|
+
onResponse({ response: e }) {
|
|
570
|
+
e.status === 401 && t();
|
|
571
|
+
}
|
|
572
|
+
}), n;
|
|
573
|
+
}
|
|
574
|
+
// src/layout.tsx
|
|
575
|
+
function U({ brand: e }) {
|
|
576
|
+
return e ? /* @__PURE__ */ f("div", {
|
|
577
|
+
className: "cp-brand",
|
|
578
|
+
children: [e.logo && /* @__PURE__ */ d("img", {
|
|
579
|
+
src: e.logo,
|
|
580
|
+
alt: ""
|
|
581
|
+
}), /* @__PURE__ */ d("span", { children: e.name })]
|
|
582
|
+
}) : null;
|
|
583
|
+
}
|
|
584
|
+
var ae = [
|
|
585
|
+
["businesses", "nav.book"],
|
|
586
|
+
["bookings", "nav.bookings"],
|
|
587
|
+
["passes", "nav.passes"],
|
|
588
|
+
["details", "nav.details"]
|
|
589
|
+
];
|
|
590
|
+
function oe(e) {
|
|
591
|
+
let t = typeof e.screen == "string" ? e.screen : "businesses";
|
|
592
|
+
return /* @__PURE__ */ f("div", {
|
|
593
|
+
className: "cp-shell",
|
|
594
|
+
children: [
|
|
595
|
+
/* @__PURE__ */ f("header", {
|
|
596
|
+
className: "cp-header",
|
|
597
|
+
children: [/* @__PURE__ */ d(U, { brand: e.brand }), e.signedIn ? /* @__PURE__ */ d("button", {
|
|
598
|
+
type: "button",
|
|
599
|
+
className: "cp-link",
|
|
600
|
+
onClick: e.onSignOut,
|
|
601
|
+
children: w("nav.signOut")
|
|
602
|
+
}) : !e.signingIn && /* @__PURE__ */ d("button", {
|
|
603
|
+
type: "button",
|
|
604
|
+
className: "cp-link",
|
|
605
|
+
onClick: () => e.onNavigate("bookings"),
|
|
606
|
+
children: w("nav.signIn")
|
|
607
|
+
})]
|
|
608
|
+
}),
|
|
609
|
+
/* @__PURE__ */ d("nav", {
|
|
610
|
+
className: "cp-nav",
|
|
611
|
+
"aria-label": w("nav.label"),
|
|
612
|
+
children: ae.map(([n, r]) => /* @__PURE__ */ d("button", {
|
|
613
|
+
type: "button",
|
|
614
|
+
"aria-current": t === n ? "page" : void 0,
|
|
615
|
+
onClick: () => e.onNavigate(n),
|
|
616
|
+
children: w(r)
|
|
617
|
+
}, n))
|
|
618
|
+
}),
|
|
619
|
+
/* @__PURE__ */ d("main", {
|
|
620
|
+
className: "cp-main",
|
|
621
|
+
children: e.children
|
|
622
|
+
})
|
|
623
|
+
]
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
// src/screens/business.tsx
|
|
627
|
+
var se = "/web/businesses/{businessId}", ce = /* @__PURE__ */ new Set([
|
|
628
|
+
"BusinessNotFound",
|
|
629
|
+
"OutsideClientScope",
|
|
630
|
+
"ValidationFailed"
|
|
631
|
+
]), W = 7;
|
|
632
|
+
function le(e) {
|
|
633
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
634
|
+
timeZone: e,
|
|
635
|
+
year: "numeric",
|
|
636
|
+
month: "2-digit",
|
|
637
|
+
day: "2-digit"
|
|
638
|
+
}).format(/* @__PURE__ */ new Date());
|
|
639
|
+
}
|
|
640
|
+
function G(e, t) {
|
|
641
|
+
let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
642
|
+
return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
|
|
643
|
+
}
|
|
644
|
+
function ue(e) {
|
|
645
|
+
let { client: n, navigate: i } = b(), { businessId: a, eventTypeId: o } = e, [c, p] = s(), [m, h] = s(), [g, _] = s(!1), v = t(async () => {
|
|
646
|
+
_(!1), p(void 0);
|
|
647
|
+
try {
|
|
648
|
+
let [e, t] = await Promise.all([n.GET(se, { params: { path: { businessId: a } } }), n.GET("/web/businesses/{businessId}/event-types", { params: { path: { businessId: a } } })]);
|
|
649
|
+
p(e.data ?? null), h(t.data?.items ?? []);
|
|
650
|
+
} catch (e) {
|
|
651
|
+
l(e) && ce.has(e.code ?? "") ? p(null) : _(!0);
|
|
652
|
+
}
|
|
653
|
+
}, [n, a]);
|
|
654
|
+
r(() => {
|
|
655
|
+
v();
|
|
656
|
+
}, [v]);
|
|
657
|
+
let y = /* @__PURE__ */ d("button", {
|
|
658
|
+
type: "button",
|
|
659
|
+
className: "cp-link cp-back",
|
|
660
|
+
onClick: () => i("businesses"),
|
|
661
|
+
children: w("business.all")
|
|
662
|
+
});
|
|
663
|
+
if (g) return /* @__PURE__ */ f("section", {
|
|
664
|
+
className: "cp-screen",
|
|
665
|
+
children: [y, /* @__PURE__ */ d(I, { onRetry: v })]
|
|
666
|
+
});
|
|
667
|
+
if (c === null) return /* @__PURE__ */ f("section", {
|
|
668
|
+
className: "cp-screen",
|
|
669
|
+
children: [y, /* @__PURE__ */ d("p", {
|
|
670
|
+
className: "cp-empty",
|
|
671
|
+
children: w("business.notFound")
|
|
672
|
+
})]
|
|
673
|
+
});
|
|
674
|
+
if (c === void 0 || !m) return /* @__PURE__ */ f("section", {
|
|
675
|
+
className: "cp-screen",
|
|
676
|
+
children: [y, /* @__PURE__ */ d("p", {
|
|
677
|
+
role: "status",
|
|
678
|
+
children: w("app.loading")
|
|
679
|
+
})]
|
|
680
|
+
});
|
|
681
|
+
let x = m.find((e) => e.id === o);
|
|
682
|
+
return /* @__PURE__ */ f("section", {
|
|
683
|
+
className: "cp-screen",
|
|
684
|
+
children: [
|
|
685
|
+
y,
|
|
686
|
+
/* @__PURE__ */ f("header", {
|
|
687
|
+
className: "cp-business-head",
|
|
688
|
+
children: [/* @__PURE__ */ d("h1", { children: c.displayName }), c.address && /* @__PURE__ */ d("p", {
|
|
689
|
+
className: "cp-hint",
|
|
690
|
+
children: c.address
|
|
691
|
+
})]
|
|
692
|
+
}),
|
|
693
|
+
m.length > 0 && /* @__PURE__ */ f("fieldset", {
|
|
694
|
+
className: "cp-chips",
|
|
695
|
+
"aria-label": w("business.types"),
|
|
696
|
+
children: [/* @__PURE__ */ d("button", {
|
|
697
|
+
type: "button",
|
|
698
|
+
"aria-pressed": !o,
|
|
699
|
+
onClick: () => i({ businessId: a }),
|
|
700
|
+
children: w("business.allTypes")
|
|
701
|
+
}), m.map((e) => /* @__PURE__ */ d("button", {
|
|
702
|
+
type: "button",
|
|
703
|
+
"aria-pressed": e.id === o,
|
|
704
|
+
onClick: () => i({
|
|
705
|
+
businessId: a,
|
|
706
|
+
eventTypeId: e.id
|
|
707
|
+
}),
|
|
708
|
+
children: e.displayName
|
|
709
|
+
}, e.id))]
|
|
710
|
+
}),
|
|
711
|
+
o && !x ? /* @__PURE__ */ d("p", {
|
|
712
|
+
className: "cp-empty",
|
|
713
|
+
children: w("business.typeMissing")
|
|
714
|
+
}) : /* @__PURE__ */ f(u, { children: [x && /* @__PURE__ */ f("div", {
|
|
715
|
+
className: "cp-type",
|
|
716
|
+
children: [
|
|
717
|
+
/* @__PURE__ */ d("h2", { children: x.displayName }),
|
|
718
|
+
x.description && /* @__PURE__ */ d("p", { children: x.description }),
|
|
719
|
+
/* @__PURE__ */ d("p", {
|
|
720
|
+
className: "cp-hint",
|
|
721
|
+
children: w("business.minutes", { minutes: x.durationMinutes })
|
|
722
|
+
})
|
|
723
|
+
]
|
|
724
|
+
}), /* @__PURE__ */ d(de, {
|
|
725
|
+
business: c,
|
|
726
|
+
eventTypeId: o,
|
|
727
|
+
onChoose: (t) => e.onChoose(c, t)
|
|
728
|
+
})] })
|
|
729
|
+
]
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function de(e) {
|
|
733
|
+
let { client: n } = b(), { business: i, eventTypeId: a } = e, o = i.timezone, [c, l] = s(0), [p, m] = s(), [h, g] = s(!1), _ = G(le(o), c * W), v = G(_, W), y = t(async () => {
|
|
734
|
+
g(!1), m(void 0);
|
|
735
|
+
try {
|
|
736
|
+
let { data: e } = await n.GET("/web/businesses/{businessId}/availability", { params: {
|
|
737
|
+
path: { businessId: i.id },
|
|
738
|
+
query: {
|
|
739
|
+
from: `${_}T00:00`,
|
|
740
|
+
to: `${v}T00:00`,
|
|
741
|
+
...a && { eventTypeId: a }
|
|
742
|
+
}
|
|
743
|
+
} });
|
|
744
|
+
m(e?.items ?? []);
|
|
745
|
+
} catch {
|
|
746
|
+
g(!0);
|
|
747
|
+
}
|
|
748
|
+
}, [
|
|
749
|
+
n,
|
|
750
|
+
i.id,
|
|
751
|
+
a,
|
|
752
|
+
_,
|
|
753
|
+
v
|
|
754
|
+
]);
|
|
755
|
+
r(() => {
|
|
756
|
+
y();
|
|
757
|
+
}, [y]);
|
|
758
|
+
let x = Date.now(), S = /* @__PURE__ */ new Map();
|
|
759
|
+
for (let e of p ?? []) {
|
|
760
|
+
if (Date.parse(e.startsAt) <= x) continue;
|
|
761
|
+
let t = j(e.startsAt, e.timezone);
|
|
762
|
+
S.set(t, [...S.get(t) ?? [], e]);
|
|
763
|
+
}
|
|
764
|
+
let C = w("business.weekOf", {
|
|
765
|
+
from: A(`${_}T12:00:00Z`, "UTC"),
|
|
766
|
+
to: A(`${G(v, -1)}T12:00:00Z`, "UTC")
|
|
767
|
+
});
|
|
768
|
+
return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("fieldset", {
|
|
769
|
+
className: "cp-week",
|
|
770
|
+
"aria-label": w("business.week"),
|
|
771
|
+
children: [
|
|
772
|
+
/* @__PURE__ */ d("button", {
|
|
773
|
+
type: "button",
|
|
774
|
+
className: "cp-secondary",
|
|
775
|
+
disabled: c === 0,
|
|
776
|
+
onClick: () => l((e) => e - 1),
|
|
777
|
+
"aria-label": w("business.previousWeek"),
|
|
778
|
+
children: "‹"
|
|
779
|
+
}),
|
|
780
|
+
/* @__PURE__ */ d("span", { children: C }),
|
|
781
|
+
/* @__PURE__ */ d("button", {
|
|
782
|
+
type: "button",
|
|
783
|
+
className: "cp-secondary",
|
|
784
|
+
onClick: () => l((e) => e + 1),
|
|
785
|
+
"aria-label": w("business.nextWeek"),
|
|
786
|
+
children: "›"
|
|
787
|
+
})
|
|
788
|
+
]
|
|
789
|
+
}), h ? /* @__PURE__ */ d(I, { onRetry: y }) : p ? S.size === 0 ? /* @__PURE__ */ d("p", {
|
|
790
|
+
className: "cp-empty",
|
|
791
|
+
children: w("business.empty")
|
|
792
|
+
}) : [...S].map(([t, n]) => /* @__PURE__ */ f("div", {
|
|
793
|
+
className: "cp-day",
|
|
794
|
+
children: [/* @__PURE__ */ d("h2", { children: t }), /* @__PURE__ */ d("ul", {
|
|
795
|
+
className: "cp-list",
|
|
796
|
+
children: n.map((t) => /* @__PURE__ */ d(fe, {
|
|
797
|
+
candidate: t,
|
|
798
|
+
onChoose: () => e.onChoose(t)
|
|
799
|
+
}, `${t.eventId ?? t.eventTypeId}-${t.resource?.id ?? ""}-${t.startsAt}`))
|
|
800
|
+
})]
|
|
801
|
+
}, t)) : /* @__PURE__ */ d("p", {
|
|
802
|
+
role: "status",
|
|
803
|
+
children: w("app.loading")
|
|
804
|
+
})] });
|
|
805
|
+
}
|
|
806
|
+
function fe(e) {
|
|
807
|
+
let { candidate: t } = e, n = t.kind === "slot";
|
|
808
|
+
return /* @__PURE__ */ f("li", {
|
|
809
|
+
className: "cp-card cp-candidate",
|
|
810
|
+
"data-kind": t.kind,
|
|
811
|
+
children: [
|
|
812
|
+
/* @__PURE__ */ f("p", {
|
|
813
|
+
className: "cp-time",
|
|
814
|
+
children: [
|
|
815
|
+
k(t.startsAt, t.timezone),
|
|
816
|
+
" – ",
|
|
817
|
+
k(t.endsAt, t.timezone)
|
|
818
|
+
]
|
|
819
|
+
}),
|
|
820
|
+
/* @__PURE__ */ f("div", {
|
|
821
|
+
className: "cp-candidate-body",
|
|
822
|
+
children: [
|
|
823
|
+
/* @__PURE__ */ d("h3", { children: t.title }),
|
|
824
|
+
t.resource && /* @__PURE__ */ d("p", {
|
|
825
|
+
className: "cp-hint",
|
|
826
|
+
children: w("business.with", { resource: t.resource.displayName })
|
|
827
|
+
}),
|
|
828
|
+
/* @__PURE__ */ d("p", {
|
|
829
|
+
className: "cp-hint",
|
|
830
|
+
children: n ? w("business.openTime") : t.full ? w("business.full") : E("business.seatsLeft", t.seatsLeft)
|
|
831
|
+
})
|
|
832
|
+
]
|
|
833
|
+
}),
|
|
834
|
+
!t.full && /* @__PURE__ */ d("button", {
|
|
835
|
+
type: "button",
|
|
836
|
+
onClick: e.onChoose,
|
|
837
|
+
children: w("business.book")
|
|
838
|
+
})
|
|
839
|
+
]
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
// src/screens/businesses.tsx
|
|
843
|
+
function pe() {
|
|
844
|
+
let { businesses: e, businessesStatus: t, reloadBusinesses: n, navigate: r } = b(), i = [...e.values()];
|
|
845
|
+
return /* @__PURE__ */ f("section", {
|
|
846
|
+
className: "cp-screen",
|
|
847
|
+
children: [/* @__PURE__ */ d("h1", { children: w("businesses.heading") }), t === "failed" ? /* @__PURE__ */ d(I, { onRetry: n }) : t === "loading" ? /* @__PURE__ */ d("p", {
|
|
848
|
+
role: "status",
|
|
849
|
+
children: w("app.loading")
|
|
850
|
+
}) : i.length === 0 ? /* @__PURE__ */ d("p", {
|
|
851
|
+
className: "cp-empty",
|
|
852
|
+
children: w("businesses.empty")
|
|
853
|
+
}) : /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("p", {
|
|
854
|
+
className: "cp-hint",
|
|
855
|
+
children: w("businesses.intro")
|
|
856
|
+
}), /* @__PURE__ */ d("ul", {
|
|
857
|
+
className: "cp-list",
|
|
858
|
+
children: i.map((e) => /* @__PURE__ */ f("li", {
|
|
859
|
+
className: "cp-card cp-business",
|
|
860
|
+
children: [
|
|
861
|
+
/* @__PURE__ */ d("h2", { children: e.displayName }),
|
|
862
|
+
e.address && /* @__PURE__ */ d("p", { children: e.address }),
|
|
863
|
+
/* @__PURE__ */ d("button", {
|
|
864
|
+
type: "button",
|
|
865
|
+
onClick: () => r({ businessId: e.id }),
|
|
866
|
+
children: w("businesses.open")
|
|
867
|
+
})
|
|
868
|
+
]
|
|
869
|
+
}, e.id))
|
|
870
|
+
})] })]
|
|
871
|
+
});
|
|
872
|
+
}
|
|
398
873
|
// src/screens/details.tsx
|
|
399
|
-
function
|
|
400
|
-
let { client: e, signOut: n } =
|
|
874
|
+
function me() {
|
|
875
|
+
let { client: e, signOut: n } = b(), [i, a] = s(), [o, c] = s(""), [l, p] = s(!1), [m, h] = s(!1), [g, _] = s(), v = t(async () => {
|
|
401
876
|
p(!1);
|
|
402
877
|
try {
|
|
403
878
|
let { data: t } = await e.GET("/web/me");
|
|
@@ -428,7 +903,7 @@ function B() {
|
|
|
428
903
|
h(!1);
|
|
429
904
|
}
|
|
430
905
|
}
|
|
431
|
-
async function
|
|
906
|
+
async function x() {
|
|
432
907
|
h(!0), _(void 0);
|
|
433
908
|
try {
|
|
434
909
|
await e.DELETE("/web/me/sessions"), await n("app.signedOutEverywhere");
|
|
@@ -441,12 +916,12 @@ function B() {
|
|
|
441
916
|
}
|
|
442
917
|
return /* @__PURE__ */ f("section", {
|
|
443
918
|
className: "cp-screen",
|
|
444
|
-
children: [/* @__PURE__ */ d("h1", { children:
|
|
919
|
+
children: [/* @__PURE__ */ d("h1", { children: w("details.heading") }), l ? /* @__PURE__ */ d(I, { onRetry: v }) : i ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("form", {
|
|
445
920
|
className: "cp-card cp-form",
|
|
446
921
|
onSubmit: y,
|
|
447
922
|
"aria-busy": m,
|
|
448
923
|
children: [
|
|
449
|
-
/* @__PURE__ */ f("label", { children: [
|
|
924
|
+
/* @__PURE__ */ f("label", { children: [w("details.name"), /* @__PURE__ */ d("input", {
|
|
450
925
|
value: o,
|
|
451
926
|
onChange: (e) => c(e.target.value),
|
|
452
927
|
autoComplete: "name",
|
|
@@ -454,46 +929,46 @@ function B() {
|
|
|
454
929
|
required: !0
|
|
455
930
|
})] }),
|
|
456
931
|
/* @__PURE__ */ f("dl", { children: [
|
|
457
|
-
/* @__PURE__ */ d("dt", { children:
|
|
458
|
-
/* @__PURE__ */ d("dd", { children: i.phone ??
|
|
459
|
-
/* @__PURE__ */ d("dt", { children:
|
|
460
|
-
/* @__PURE__ */ d("dd", { children: i.email ??
|
|
932
|
+
/* @__PURE__ */ d("dt", { children: w("details.phone") }),
|
|
933
|
+
/* @__PURE__ */ d("dd", { children: i.phone ?? w("details.none") }),
|
|
934
|
+
/* @__PURE__ */ d("dt", { children: w("details.email") }),
|
|
935
|
+
/* @__PURE__ */ d("dd", { children: i.email ?? w("details.none") })
|
|
461
936
|
] }),
|
|
462
937
|
/* @__PURE__ */ d("p", {
|
|
463
938
|
className: "cp-hint",
|
|
464
|
-
children:
|
|
939
|
+
children: w("details.readOnly")
|
|
465
940
|
}),
|
|
466
941
|
g && /* @__PURE__ */ d("p", {
|
|
467
942
|
role: g.alert ? "alert" : "status",
|
|
468
|
-
children:
|
|
943
|
+
children: w(g.key)
|
|
469
944
|
}),
|
|
470
945
|
/* @__PURE__ */ d("button", {
|
|
471
946
|
type: "submit",
|
|
472
947
|
disabled: m || !o.trim() || o.trim() === i.name,
|
|
473
|
-
children:
|
|
948
|
+
children: w(m ? "details.saving" : "details.save")
|
|
474
949
|
})
|
|
475
950
|
]
|
|
476
951
|
}), /* @__PURE__ */ f("div", {
|
|
477
952
|
className: "cp-card cp-form",
|
|
478
953
|
children: [/* @__PURE__ */ d("p", {
|
|
479
954
|
className: "cp-hint",
|
|
480
|
-
children:
|
|
955
|
+
children: w("details.signOutEverywhereHint")
|
|
481
956
|
}), /* @__PURE__ */ d("button", {
|
|
482
957
|
type: "button",
|
|
483
958
|
className: "cp-secondary",
|
|
484
959
|
disabled: m,
|
|
485
|
-
onClick:
|
|
486
|
-
children:
|
|
960
|
+
onClick: x,
|
|
961
|
+
children: w("details.signOutEverywhere")
|
|
487
962
|
})]
|
|
488
963
|
})] }) : /* @__PURE__ */ d("p", {
|
|
489
964
|
role: "status",
|
|
490
|
-
children:
|
|
965
|
+
children: w("app.loading")
|
|
491
966
|
})]
|
|
492
967
|
});
|
|
493
968
|
}
|
|
494
969
|
// src/screens/passes.tsx
|
|
495
|
-
function
|
|
496
|
-
let { client: e, businesses: n } =
|
|
970
|
+
function he() {
|
|
971
|
+
let { client: e, businesses: n } = b(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
|
|
497
972
|
c(!1);
|
|
498
973
|
try {
|
|
499
974
|
let { data: t } = await e.GET("/web/me/memberships");
|
|
@@ -506,9 +981,9 @@ function V() {
|
|
|
506
981
|
l();
|
|
507
982
|
}, [l]), /* @__PURE__ */ f("section", {
|
|
508
983
|
className: "cp-screen",
|
|
509
|
-
children: [/* @__PURE__ */ d("h1", { children:
|
|
984
|
+
children: [/* @__PURE__ */ d("h1", { children: w("passes.heading") }), o ? /* @__PURE__ */ d(I, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ d("p", {
|
|
510
985
|
className: "cp-empty",
|
|
511
|
-
children:
|
|
986
|
+
children: w("passes.empty")
|
|
512
987
|
}) : /* @__PURE__ */ d("ul", {
|
|
513
988
|
className: "cp-list",
|
|
514
989
|
children: i.map((e) => {
|
|
@@ -520,41 +995,41 @@ function V() {
|
|
|
520
995
|
className: "cp-card-head",
|
|
521
996
|
children: [/* @__PURE__ */ d("h2", { children: e.displayName }), i && /* @__PURE__ */ d("span", {
|
|
522
997
|
className: "cp-badge",
|
|
523
|
-
children:
|
|
998
|
+
children: w("passes.expired")
|
|
524
999
|
})]
|
|
525
1000
|
}),
|
|
526
1001
|
t && /* @__PURE__ */ d("p", { children: t.displayName }),
|
|
527
1002
|
/* @__PURE__ */ d("p", {
|
|
528
1003
|
className: "cp-credits",
|
|
529
|
-
children: e.creditsRemaining === null || e.creditsTotal === null ?
|
|
1004
|
+
children: e.creditsRemaining === null || e.creditsTotal === null ? w("passes.unlimited") : w("passes.credits", {
|
|
530
1005
|
remaining: e.creditsRemaining,
|
|
531
1006
|
total: e.creditsTotal
|
|
532
1007
|
})
|
|
533
1008
|
}),
|
|
534
1009
|
/* @__PURE__ */ d("p", {
|
|
535
1010
|
className: "cp-hint",
|
|
536
|
-
children: e.validUntil ?
|
|
537
|
-
from:
|
|
538
|
-
until:
|
|
539
|
-
}) :
|
|
1011
|
+
children: e.validUntil ? w("passes.validRange", {
|
|
1012
|
+
from: A(e.validFrom, r),
|
|
1013
|
+
until: A(e.validUntil, r)
|
|
1014
|
+
}) : w("passes.validFrom", { date: A(e.validFrom, r) })
|
|
540
1015
|
})
|
|
541
1016
|
]
|
|
542
1017
|
}, e.id);
|
|
543
1018
|
})
|
|
544
1019
|
}) : /* @__PURE__ */ d("p", {
|
|
545
1020
|
role: "status",
|
|
546
|
-
children:
|
|
1021
|
+
children: w("app.loading")
|
|
547
1022
|
})]
|
|
548
1023
|
});
|
|
549
1024
|
}
|
|
550
1025
|
// ../ui/dist/index.js
|
|
551
|
-
var
|
|
1026
|
+
var ge = new Intl.DisplayNames(["en"], { type: "region" }), K = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), q = m().map((e) => ({
|
|
552
1027
|
code: e,
|
|
553
|
-
name:
|
|
1028
|
+
name: ge.of(e) ?? e,
|
|
554
1029
|
callingCode: h(e),
|
|
555
1030
|
flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
|
|
556
|
-
})).sort((e, t) => e.name.localeCompare(t.name)),
|
|
557
|
-
function
|
|
1031
|
+
})).sort((e, t) => e.name.localeCompare(t.name)), _e = new Map(q.map((e) => [e.code, e])), J = (e) => _e.get(e);
|
|
1032
|
+
function ve(e) {
|
|
558
1033
|
let t = i(), n = o(null), a = o(null), c = o(null), [l, u] = s(""), p = e.search(l), m = () => n.current?.close(), h = (t) => {
|
|
559
1034
|
m(), e.onPick(t);
|
|
560
1035
|
};
|
|
@@ -628,10 +1103,10 @@ function G(e) {
|
|
|
628
1103
|
]
|
|
629
1104
|
});
|
|
630
1105
|
}
|
|
631
|
-
var
|
|
632
|
-
function
|
|
1106
|
+
var Y = new p(), X = (e) => J(e);
|
|
1107
|
+
function Z(e) {
|
|
633
1108
|
for (let t = 1; t <= 3 && t <= e.length; t++) {
|
|
634
|
-
let n = e.slice(0, t), r = (v.country_calling_codes[n] ?? []).filter((e) =>
|
|
1109
|
+
let n = e.slice(0, t), r = (v.country_calling_codes[n] ?? []).filter((e) => J(e) !== void 0), [i] = r;
|
|
635
1110
|
if (i) return {
|
|
636
1111
|
code: n,
|
|
637
1112
|
first: i,
|
|
@@ -640,10 +1115,10 @@ function J(e) {
|
|
|
640
1115
|
}
|
|
641
1116
|
return null;
|
|
642
1117
|
}
|
|
643
|
-
function
|
|
1118
|
+
function Q(e, t) {
|
|
644
1119
|
let n = /^\s*(\+|00)/.exec(e);
|
|
645
1120
|
if (!n) return null;
|
|
646
|
-
let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a =
|
|
1121
|
+
let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Z(i);
|
|
647
1122
|
if (!a) return null;
|
|
648
1123
|
let o = g(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
|
|
649
1124
|
for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
|
|
@@ -652,45 +1127,45 @@ function Y(e, t) {
|
|
|
652
1127
|
text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
|
|
653
1128
|
};
|
|
654
1129
|
}
|
|
655
|
-
function
|
|
1130
|
+
function ye(e, t) {
|
|
656
1131
|
let n = t.replace(/\D/g, "");
|
|
657
|
-
return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : g(t, e)?.number ?? `+${
|
|
1132
|
+
return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : g(t, e)?.number ?? `+${X(e).callingCode}${n}`;
|
|
658
1133
|
}
|
|
659
|
-
function
|
|
660
|
-
return
|
|
1134
|
+
function be(e) {
|
|
1135
|
+
return Y.selectNumberingPlan(e), Y.numberingPlan?.possibleLengths() ?? [];
|
|
661
1136
|
}
|
|
662
|
-
function
|
|
1137
|
+
function xe(e, t, n) {
|
|
663
1138
|
if (e === "") return t ? "Enter a phone number." : "";
|
|
664
1139
|
let r = g(e);
|
|
665
1140
|
if (r?.isValid()) return "";
|
|
666
|
-
let i = e.replace(/\D/g, ""), a =
|
|
1141
|
+
let i = e.replace(/\D/g, ""), a = Z(i);
|
|
667
1142
|
if (!a) return "Unknown country code. Choose the country from the list.";
|
|
668
|
-
let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s =
|
|
1143
|
+
let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c = _(i.slice(a.code.length), o);
|
|
669
1144
|
if (c && c !== "NOT_A_NUMBER") {
|
|
670
|
-
let e =
|
|
1145
|
+
let e = be(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
|
|
671
1146
|
return e.length === 1 ? `Enter a ${t}-digit number for ${s}.` : e.length > 2 && n - t === e.length - 1 ? `Enter ${t} to ${n} digits for ${s}.` : `Enter ${e.slice(0, -1).join(", ")} or ${n} digits for ${s}.`;
|
|
672
1147
|
}
|
|
673
1148
|
return `This is not a valid number for ${s}.`;
|
|
674
1149
|
}
|
|
675
|
-
function
|
|
676
|
-
return
|
|
1150
|
+
function Se(e, t = !1) {
|
|
1151
|
+
return xe(e, t);
|
|
677
1152
|
}
|
|
678
|
-
function
|
|
679
|
-
return
|
|
1153
|
+
function Ce(e, t) {
|
|
1154
|
+
return Q(e, t) ?? {
|
|
680
1155
|
country: t,
|
|
681
1156
|
text: e
|
|
682
1157
|
};
|
|
683
1158
|
}
|
|
684
|
-
function
|
|
1159
|
+
function we(e) {
|
|
685
1160
|
let t = i(), n = o(null), [a, c] = s(() => ({
|
|
686
1161
|
value: e.value,
|
|
687
|
-
...
|
|
1162
|
+
...Ce(e.value, "IS")
|
|
688
1163
|
})), l = a;
|
|
689
1164
|
e.value !== a.value && (l = {
|
|
690
1165
|
value: e.value,
|
|
691
|
-
...
|
|
1166
|
+
...Ce(e.value, a.country)
|
|
692
1167
|
}, c(l));
|
|
693
|
-
let [u, p] = s(!1), [m, h] = s(!1), g =
|
|
1168
|
+
let [u, p] = s(!1), [m, h] = s(!1), g = X(l.country), _ = xe(l.value, e.required ?? !1, l.country), v = u && _ !== "" ? _ : e.error ?? "", y = v !== "";
|
|
694
1169
|
r(() => {
|
|
695
1170
|
let e = n.current?.form;
|
|
696
1171
|
if (!e) return;
|
|
@@ -700,7 +1175,7 @@ function le(e) {
|
|
|
700
1175
|
return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
|
|
701
1176
|
}, []);
|
|
702
1177
|
let b = (t, n) => {
|
|
703
|
-
let r =
|
|
1178
|
+
let r = ye(t, n);
|
|
704
1179
|
c({
|
|
705
1180
|
value: r,
|
|
706
1181
|
country: t,
|
|
@@ -743,7 +1218,7 @@ function le(e) {
|
|
|
743
1218
|
"aria-invalid": y || void 0,
|
|
744
1219
|
"aria-describedby": y ? `${t}-problem` : void 0,
|
|
745
1220
|
onChange: (e) => {
|
|
746
|
-
let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n =
|
|
1221
|
+
let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Q(t, l.country);
|
|
747
1222
|
b(n?.country ?? l.country, n?.text ?? t);
|
|
748
1223
|
},
|
|
749
1224
|
onBlur: () => {
|
|
@@ -757,12 +1232,12 @@ function le(e) {
|
|
|
757
1232
|
role: "alert",
|
|
758
1233
|
children: v
|
|
759
1234
|
}),
|
|
760
|
-
m && /* @__PURE__ */ d(
|
|
1235
|
+
m && /* @__PURE__ */ d(ve, {
|
|
761
1236
|
title: "Country code",
|
|
762
1237
|
searchLabel: "Search by country or code",
|
|
763
1238
|
listLabel: "Countries",
|
|
764
1239
|
empty: (e) => `No country matches “${e}”.`,
|
|
765
|
-
search:
|
|
1240
|
+
search: Te,
|
|
766
1241
|
selected: l.country,
|
|
767
1242
|
onClose: () => h(!1),
|
|
768
1243
|
onPick: (e) => {
|
|
@@ -772,9 +1247,9 @@ function le(e) {
|
|
|
772
1247
|
]
|
|
773
1248
|
});
|
|
774
1249
|
}
|
|
775
|
-
function
|
|
776
|
-
let t =
|
|
777
|
-
return (t === "" ?
|
|
1250
|
+
function Te(e) {
|
|
1251
|
+
let t = K(e).replace(/^(\+|00)/, "");
|
|
1252
|
+
return (t === "" ? q : /^\d+$/.test(t) ? q.filter((e) => e.callingCode.startsWith(t)) : q.filter((e) => K(e.name).includes(t) || e.code.toLowerCase() === t)).map((e) => ({
|
|
778
1253
|
value: e.code,
|
|
779
1254
|
label: e.name,
|
|
780
1255
|
hint: `+${e.callingCode}`,
|
|
@@ -782,31 +1257,31 @@ function ue(e) {
|
|
|
782
1257
|
}));
|
|
783
1258
|
}
|
|
784
1259
|
// src/bot-check.tsx
|
|
785
|
-
var
|
|
786
|
-
function
|
|
787
|
-
let e =
|
|
1260
|
+
var Ee = () => window.turnstile, De = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", $;
|
|
1261
|
+
function Oe() {
|
|
1262
|
+
let e = Ee();
|
|
788
1263
|
return e ? Promise.resolve(e) : ($ ??= new Promise((e, t) => {
|
|
789
1264
|
let n = document.createElement("script");
|
|
790
|
-
n.src =
|
|
1265
|
+
n.src = De, n.async = !0;
|
|
791
1266
|
let r = () => {
|
|
792
1267
|
$ = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
|
|
793
1268
|
};
|
|
794
1269
|
n.onload = () => {
|
|
795
|
-
let t =
|
|
1270
|
+
let t = Ee();
|
|
796
1271
|
t ? e(t) : r();
|
|
797
1272
|
}, n.onerror = r, document.head.append(n);
|
|
798
1273
|
}), $);
|
|
799
1274
|
}
|
|
800
|
-
function
|
|
1275
|
+
function ke(e) {
|
|
801
1276
|
return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
|
|
802
1277
|
}
|
|
803
|
-
function
|
|
1278
|
+
function Ae(e) {
|
|
804
1279
|
let t = o(null), n = o(void 0), i = o(e);
|
|
805
1280
|
i.current = e;
|
|
806
1281
|
let { siteKey: a } = e.botCheck;
|
|
807
1282
|
r(() => {
|
|
808
1283
|
let e = !0;
|
|
809
|
-
return
|
|
1284
|
+
return Oe().then((r) => {
|
|
810
1285
|
let o = t.current;
|
|
811
1286
|
if (!e || !o) return;
|
|
812
1287
|
let s = r.render(o, {
|
|
@@ -838,66 +1313,67 @@ function me(e) {
|
|
|
838
1313
|
});
|
|
839
1314
|
}
|
|
840
1315
|
// src/sign-in.tsx
|
|
841
|
-
function
|
|
842
|
-
let [t, n] = s("sign-in"), [i, a] = s(""), [o, c] = s(""), [l, p] = s(""), [m, h] = s(), [g, _] = s(), [v, y] = s(!1), [
|
|
1316
|
+
function je(e) {
|
|
1317
|
+
let [t, n] = s("sign-in"), [i, a] = s(""), [o, c] = s(""), [l, p] = s(""), [m, h] = s(), [g, _] = s(), [v, y] = s(!1), [b, x] = s(), [S, C] = s(0), T = ke(e.botCheck) ? e.botCheck : void 0, [E, D] = s();
|
|
843
1318
|
r(() => {
|
|
844
1319
|
if (!E) return;
|
|
845
1320
|
let e = setTimeout(() => {
|
|
846
|
-
|
|
1321
|
+
D(void 0), _((e) => e === E.message ? void 0 : e);
|
|
847
1322
|
}, E.seconds * 1e3);
|
|
848
1323
|
return () => clearTimeout(e);
|
|
849
1324
|
}, [E]);
|
|
850
|
-
let
|
|
851
|
-
async function
|
|
852
|
-
if (t.preventDefault(), m || !
|
|
1325
|
+
let O = t === "register";
|
|
1326
|
+
async function k(t) {
|
|
1327
|
+
if (t.preventDefault(), m || !Se(o, !0) && T && b) {
|
|
853
1328
|
y(!0), _(void 0);
|
|
854
1329
|
try {
|
|
855
|
-
let t = m ? await
|
|
1330
|
+
let t = m ? await H(e.basePath, O ? "/auth/register" : "/auth/login", {
|
|
856
1331
|
challenge: m,
|
|
857
1332
|
code: l
|
|
858
|
-
}) :
|
|
1333
|
+
}) : O ? await H(e.basePath, "/auth/register/initiate", {
|
|
859
1334
|
phone: o,
|
|
860
1335
|
name: i.trim(),
|
|
861
|
-
botCheckToken:
|
|
862
|
-
}) : await
|
|
1336
|
+
botCheckToken: b
|
|
1337
|
+
}) : await H(e.basePath, "/auth/initiate", {
|
|
863
1338
|
phone: o,
|
|
864
|
-
botCheckToken:
|
|
1339
|
+
botCheckToken: b
|
|
865
1340
|
});
|
|
866
1341
|
if (t.ok) {
|
|
867
1342
|
let n = await t.json();
|
|
868
1343
|
m ? e.onSignedIn(n.sessionKey) : h(n.challenge);
|
|
869
1344
|
return;
|
|
870
1345
|
}
|
|
871
|
-
let n = await t.json().catch(() => void 0), r = Number(t.headers.get("retry-after")), a = Number.isInteger(r) && r > 0 ? r : void 0, s =
|
|
872
|
-
t.status === 429 && a && !m &&
|
|
1346
|
+
let n = await t.json().catch(() => void 0), r = Number(t.headers.get("retry-after")), a = Number.isInteger(r) && r > 0 ? r : void 0, s = Me(t.status, n?.code, a, !!m, O);
|
|
1347
|
+
t.status === 429 && a && !m && D({
|
|
873
1348
|
phone: o,
|
|
874
1349
|
seconds: a,
|
|
875
1350
|
message: s
|
|
876
1351
|
}), _(s);
|
|
877
1352
|
} catch {
|
|
878
|
-
_(
|
|
1353
|
+
_(w("signIn.error.unreachable"));
|
|
879
1354
|
} finally {
|
|
880
|
-
y(!1), m ||
|
|
1355
|
+
y(!1), m || C((e) => e + 1);
|
|
881
1356
|
}
|
|
882
1357
|
}
|
|
883
1358
|
}
|
|
884
|
-
function
|
|
1359
|
+
function A(e) {
|
|
885
1360
|
n(e), h(void 0), p(""), _(void 0);
|
|
886
1361
|
}
|
|
887
1362
|
return /* @__PURE__ */ d("div", {
|
|
888
1363
|
className: "cp-sign-in",
|
|
889
1364
|
children: /* @__PURE__ */ f("form", {
|
|
890
|
-
onSubmit:
|
|
1365
|
+
onSubmit: k,
|
|
891
1366
|
"aria-busy": v,
|
|
892
1367
|
children: [
|
|
893
|
-
/* @__PURE__ */ d(
|
|
894
|
-
/* @__PURE__ */ d("h1", { children:
|
|
1368
|
+
/* @__PURE__ */ d(U, { brand: e.brand }),
|
|
1369
|
+
/* @__PURE__ */ d("h1", { children: w(O ? "register.heading" : "signIn.heading") }),
|
|
1370
|
+
e.children,
|
|
895
1371
|
e.notice && !m && /* @__PURE__ */ d("p", {
|
|
896
1372
|
role: "status",
|
|
897
1373
|
className: "cp-notice",
|
|
898
|
-
children:
|
|
1374
|
+
children: w(e.notice)
|
|
899
1375
|
}),
|
|
900
|
-
m ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("p", { children:
|
|
1376
|
+
m ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("p", { children: w("signIn.codeSent", { phone: o }) }), /* @__PURE__ */ f("label", { children: [w("signIn.code"), /* @__PURE__ */ d("input", {
|
|
901
1377
|
value: l,
|
|
902
1378
|
onChange: (e) => p(e.target.value),
|
|
903
1379
|
inputMode: "numeric",
|
|
@@ -905,30 +1381,30 @@ function he(e) {
|
|
|
905
1381
|
required: !0,
|
|
906
1382
|
autoFocus: !0
|
|
907
1383
|
})] })] }) : /* @__PURE__ */ f(u, { children: [
|
|
908
|
-
/* @__PURE__ */ d("p", { children:
|
|
909
|
-
|
|
1384
|
+
/* @__PURE__ */ d("p", { children: w(O ? "register.intro" : "signIn.intro") }),
|
|
1385
|
+
O && /* @__PURE__ */ f("label", { children: [w("register.name"), /* @__PURE__ */ d("input", {
|
|
910
1386
|
value: i,
|
|
911
1387
|
onChange: (e) => a(e.target.value),
|
|
912
1388
|
autoComplete: "name",
|
|
913
1389
|
maxLength: 200,
|
|
914
1390
|
required: !0
|
|
915
1391
|
})] }),
|
|
916
|
-
/* @__PURE__ */ d(
|
|
917
|
-
label:
|
|
1392
|
+
/* @__PURE__ */ d(we, {
|
|
1393
|
+
label: w("signIn.phone"),
|
|
918
1394
|
value: o,
|
|
919
1395
|
onChange: c,
|
|
920
1396
|
required: !0
|
|
921
1397
|
}),
|
|
922
|
-
T && /* @__PURE__ */ d(
|
|
1398
|
+
T && /* @__PURE__ */ d(Ae, {
|
|
923
1399
|
botCheck: T,
|
|
924
|
-
attempt:
|
|
925
|
-
onToken:
|
|
926
|
-
onUnavailable: () => _(
|
|
1400
|
+
attempt: S,
|
|
1401
|
+
onToken: x,
|
|
1402
|
+
onUnavailable: () => _(w("signIn.error.botCheckUnavailable"))
|
|
927
1403
|
})
|
|
928
1404
|
] }),
|
|
929
1405
|
!m && !T && /* @__PURE__ */ d("p", {
|
|
930
1406
|
role: "alert",
|
|
931
|
-
children:
|
|
1407
|
+
children: w("signIn.error.notConfigured")
|
|
932
1408
|
}),
|
|
933
1409
|
g && /* @__PURE__ */ d("p", {
|
|
934
1410
|
role: "alert",
|
|
@@ -936,93 +1412,133 @@ function he(e) {
|
|
|
936
1412
|
}),
|
|
937
1413
|
/* @__PURE__ */ d("button", {
|
|
938
1414
|
type: "submit",
|
|
939
|
-
disabled: v || !m && (!T || !
|
|
940
|
-
children:
|
|
1415
|
+
disabled: v || !m && (!T || !b || E?.phone === o),
|
|
1416
|
+
children: w(v ? "signIn.wait" : m ? O ? "register.submit" : "signIn.submit" : "signIn.sendCode")
|
|
941
1417
|
}),
|
|
942
1418
|
m ? /* @__PURE__ */ d("button", {
|
|
943
1419
|
type: "button",
|
|
944
1420
|
className: "cp-secondary",
|
|
945
|
-
onClick: () =>
|
|
946
|
-
children:
|
|
1421
|
+
onClick: () => A(t),
|
|
1422
|
+
children: w("signIn.differentNumber")
|
|
947
1423
|
}) : /* @__PURE__ */ d("button", {
|
|
948
1424
|
type: "button",
|
|
949
1425
|
className: "cp-link",
|
|
950
|
-
onClick: () =>
|
|
951
|
-
children:
|
|
1426
|
+
onClick: () => A(O ? "sign-in" : "register"),
|
|
1427
|
+
children: w(O ? "register.toSignIn" : "signIn.toRegister")
|
|
952
1428
|
})
|
|
953
1429
|
]
|
|
954
1430
|
})
|
|
955
1431
|
});
|
|
956
1432
|
}
|
|
957
|
-
function
|
|
958
|
-
return e === 429 ? n ?
|
|
1433
|
+
function Me(e, t, n, r, i) {
|
|
1434
|
+
return e === 429 ? n ? w("signIn.error.tooMany", { wait: N(n) }) : w("signIn.error.tooManyLater") : !r && e === 403 && t === "BotCheckFailed" ? w("signIn.error.botCheck") : !r && e === 503 && t === "BotCheckUnavailable" ? w("signIn.error.botCheckUnavailable") : !r && e === 503 && (t === "LimiterUnavailable" || t === "ClientIpUnavailable") ? w("signIn.error.failed") : !r && e === 503 ? n ? w("signIn.error.paused", { wait: N(n) }) : w("signIn.error.pausedLater") : !r && e === 422 && t === "PhoneDestinationNotAllowed" ? w("signIn.error.destination") : r && [
|
|
959
1435
|
400,
|
|
960
1436
|
401,
|
|
961
1437
|
403,
|
|
962
1438
|
404,
|
|
963
1439
|
409
|
|
964
|
-
].includes(e) ?
|
|
1440
|
+
].includes(e) ? w(i ? "register.error.badCode" : "signIn.error.badCode") : w(e === 400 ? "signIn.error.invalid" : e === 403 ? "signIn.error.refused" : "signIn.error.failed");
|
|
965
1441
|
}
|
|
966
1442
|
// src/index.tsx
|
|
967
|
-
function
|
|
968
|
-
let
|
|
969
|
-
|
|
970
|
-
|
|
1443
|
+
function Ne(e) {
|
|
1444
|
+
let n = e.basePath.replace(/\/$/, ""), [i, c] = s(), l = o(!1);
|
|
1445
|
+
l.current = !!i;
|
|
1446
|
+
let [p, m] = s(), [h, g] = s(/* @__PURE__ */ new Map()), [_, v] = s("loading"), [b, x] = s("businesses"), S = e.screen ?? b, C = e.onNavigate ?? x, [T, E] = s(), D = typeof S == "string" ? S : `${S.businessId}/${S.eventTypeId ?? ""}`, [O, k] = s(D);
|
|
1447
|
+
O !== D && (k(D), E(void 0));
|
|
1448
|
+
let A = a(() => ie(n, () => {
|
|
1449
|
+
l.current && m("app.signedOut"), c(null);
|
|
1450
|
+
}), [n]);
|
|
971
1451
|
r(() => {
|
|
972
|
-
|
|
973
|
-
}, [
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
let
|
|
1452
|
+
V(`${n}/auth/session`).then(async (e) => c(e.ok ? (await e.json()).sessionKey : null)).catch(() => c(null));
|
|
1453
|
+
}, [n]);
|
|
1454
|
+
let j = t(async () => {
|
|
1455
|
+
v("loading");
|
|
1456
|
+
try {
|
|
1457
|
+
let e = /* @__PURE__ */ new Map(), t;
|
|
978
1458
|
do {
|
|
979
|
-
let { data:
|
|
1459
|
+
let { data: n } = await A.GET("/web/businesses", { params: { query: {
|
|
980
1460
|
limit: 100,
|
|
981
|
-
...
|
|
1461
|
+
...t && { cursor: t }
|
|
982
1462
|
} } });
|
|
983
|
-
for (let
|
|
984
|
-
|
|
985
|
-
} while (
|
|
986
|
-
e
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
}, [
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1463
|
+
for (let t of n?.items ?? []) e.set(t.id, t);
|
|
1464
|
+
t = n?.nextCursor ?? void 0;
|
|
1465
|
+
} while (t);
|
|
1466
|
+
g(e), v("ready");
|
|
1467
|
+
} catch {
|
|
1468
|
+
v("failed");
|
|
1469
|
+
}
|
|
1470
|
+
}, [A]);
|
|
1471
|
+
r(() => {
|
|
1472
|
+
j();
|
|
1473
|
+
}, [j]);
|
|
1474
|
+
let M = a(() => ({
|
|
1475
|
+
client: A,
|
|
1476
|
+
businesses: h,
|
|
1477
|
+
businessesStatus: _,
|
|
1478
|
+
reloadBusinesses: () => void j(),
|
|
1479
|
+
navigate: C,
|
|
994
1480
|
signOut: async (e) => {
|
|
995
|
-
await
|
|
1481
|
+
await H(n, "/auth/logout").catch(() => {}), m(e), c(null);
|
|
996
1482
|
}
|
|
997
1483
|
}), [
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1484
|
+
A,
|
|
1485
|
+
h,
|
|
1486
|
+
_,
|
|
1487
|
+
j,
|
|
1488
|
+
C,
|
|
1489
|
+
n
|
|
1001
1490
|
]);
|
|
1002
|
-
return /* @__PURE__ */ d("div", {
|
|
1491
|
+
if (i === void 0) return /* @__PURE__ */ d("div", {
|
|
1003
1492
|
className: "msm-customer",
|
|
1004
|
-
children:
|
|
1493
|
+
children: /* @__PURE__ */ d("p", {
|
|
1005
1494
|
className: "cp-status",
|
|
1006
1495
|
role: "status",
|
|
1007
|
-
children:
|
|
1008
|
-
})
|
|
1009
|
-
|
|
1010
|
-
|
|
1496
|
+
children: w("app.loading")
|
|
1497
|
+
})
|
|
1498
|
+
});
|
|
1499
|
+
let N = (t) => /* @__PURE__ */ d(je, {
|
|
1500
|
+
basePath: n,
|
|
1501
|
+
brand: void 0,
|
|
1502
|
+
botCheck: e.botCheck,
|
|
1503
|
+
notice: p,
|
|
1504
|
+
onSignedIn: (e) => {
|
|
1505
|
+
m(void 0), c(e);
|
|
1506
|
+
},
|
|
1507
|
+
children: t
|
|
1508
|
+
});
|
|
1509
|
+
return /* @__PURE__ */ d("div", {
|
|
1510
|
+
className: "msm-customer",
|
|
1511
|
+
children: /* @__PURE__ */ d(y.Provider, {
|
|
1512
|
+
value: M,
|
|
1513
|
+
children: /* @__PURE__ */ d(oe, {
|
|
1011
1514
|
brand: e.brand,
|
|
1012
|
-
screen:
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1515
|
+
screen: S,
|
|
1516
|
+
signedIn: !!i,
|
|
1517
|
+
signingIn: !i && (!!T || typeof S == "string" && S !== "businesses"),
|
|
1518
|
+
onNavigate: C,
|
|
1519
|
+
onSignOut: () => M.signOut(),
|
|
1520
|
+
children: T ? i ? /* @__PURE__ */ d(te, {
|
|
1521
|
+
choice: T,
|
|
1522
|
+
onBack: () => E(void 0)
|
|
1523
|
+
}, `${T.candidate.startsAt}-${T.candidate.eventId ?? T.candidate.eventTypeId}`) : N(/* @__PURE__ */ f(u, { children: [
|
|
1524
|
+
/* @__PURE__ */ d("p", { children: w("book.signInFirst") }),
|
|
1525
|
+
/* @__PURE__ */ d(B, { choice: T }),
|
|
1526
|
+
/* @__PURE__ */ d("button", {
|
|
1527
|
+
type: "button",
|
|
1528
|
+
className: "cp-link",
|
|
1529
|
+
onClick: () => E(void 0),
|
|
1530
|
+
children: w("book.back")
|
|
1531
|
+
})
|
|
1532
|
+
] })) : typeof S == "object" ? /* @__PURE__ */ d(ue, {
|
|
1533
|
+
businessId: S.businessId,
|
|
1534
|
+
eventTypeId: S.eventTypeId,
|
|
1535
|
+
onChoose: (e, t) => E({
|
|
1536
|
+
business: e,
|
|
1537
|
+
candidate: t
|
|
1538
|
+
})
|
|
1539
|
+
}) : S === "businesses" ? /* @__PURE__ */ d(pe, {}) : i ? d(S === "passes" ? he : S === "details" ? me : ee, {}) : N()
|
|
1016
1540
|
})
|
|
1017
|
-
}) : /* @__PURE__ */ d(he, {
|
|
1018
|
-
basePath: t,
|
|
1019
|
-
brand: e.brand,
|
|
1020
|
-
botCheck: e.botCheck,
|
|
1021
|
-
notice: o,
|
|
1022
|
-
onSignedIn: (e) => {
|
|
1023
|
-
c(void 0), i(e);
|
|
1024
|
-
}
|
|
1025
1541
|
})
|
|
1026
1542
|
});
|
|
1027
1543
|
}
|
|
1028
|
-
export {
|
|
1544
|
+
export { Ne as MsmCustomer, P as cancellationState, A as formatDate, O as formatDateTime, D as formatNumber, S as locale, w as t };
|