@msm-platform/customer-react 0.0.0-stage → 0.2.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 +22 -0
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/dist/booking.d.ts +19 -0
- package/dist/bot-check.d.ts +14 -0
- package/dist/cancellation.d.ts +8 -0
- package/dist/client.d.ts +44 -0
- package/dist/context.d.ts +24 -0
- package/dist/i18n.d.ts +160 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +1544 -0
- package/dist/layout.d.ts +21 -0
- package/dist/screens/bookings.d.ts +9 -0
- package/dist/screens/business.d.ts +11 -0
- package/dist/screens/businesses.d.ts +2 -0
- package/dist/screens/details.d.ts +2 -0
- package/dist/screens/passes.d.ts +1 -0
- package/dist/server/index.d.ts +65 -0
- package/dist/server/limits.d.ts +44 -0
- package/dist/server/session.d.ts +37 -0
- package/dist/server/turnstile.d.ts +22 -0
- package/dist/server.js +442 -0
- package/dist/sign-in.d.ts +14 -0
- package/dist/style.css +2 -0
- package/package.json +44 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1544 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
3
|
+
import { createCustomerClient as c, isCustomerApiError as l } from "@msm-platform/customer-sdk";
|
|
4
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
import { Metadata as p, getCountries as m, getCountryCallingCode as h, parsePhoneNumberFromString as g, validatePhoneNumberLength as _ } from "libphonenumber-js";
|
|
6
|
+
import v from "libphonenumber-js/min/metadata";
|
|
7
|
+
// src/context.ts
|
|
8
|
+
var y = e(null);
|
|
9
|
+
function b() {
|
|
10
|
+
let e = n(y);
|
|
11
|
+
if (!e) throw Error("usePortal needs MsmCustomer.");
|
|
12
|
+
return e;
|
|
13
|
+
}
|
|
14
|
+
// src/i18n.ts
|
|
15
|
+
var x = {
|
|
16
|
+
"app.loading": "Loading…",
|
|
17
|
+
"app.loadFailed": "Something went wrong loading this page. Try again.",
|
|
18
|
+
"app.retry": "Try again",
|
|
19
|
+
"app.signedOut": "You were signed out because your session ended. Sign in again.",
|
|
20
|
+
"app.signedOutEverywhere": "You were signed out on every device.",
|
|
21
|
+
"nav.label": "Booking and my account",
|
|
22
|
+
"nav.book": "Book",
|
|
23
|
+
"nav.signIn": "Sign in",
|
|
24
|
+
"nav.bookings": "Bookings",
|
|
25
|
+
"nav.passes": "Passes",
|
|
26
|
+
"nav.details": "My details",
|
|
27
|
+
"nav.signOut": "Sign out",
|
|
28
|
+
"signIn.heading": "Sign in",
|
|
29
|
+
"signIn.intro": "We'll text a one-time code to your phone.",
|
|
30
|
+
"signIn.toRegister": "New here? Create an account",
|
|
31
|
+
"register.heading": "Create an account",
|
|
32
|
+
"register.intro": "Enter your name and phone. We'll text you a code.",
|
|
33
|
+
"register.name": "Your name",
|
|
34
|
+
"register.toSignIn": "Already have an account? Sign in",
|
|
35
|
+
"signIn.phone": "Phone number",
|
|
36
|
+
"signIn.codeSent": "Enter the code we sent to {phone}.",
|
|
37
|
+
"signIn.code": "Verification code",
|
|
38
|
+
"signIn.sendCode": "Send code",
|
|
39
|
+
"signIn.submit": "Sign in",
|
|
40
|
+
"register.submit": "Create account",
|
|
41
|
+
"signIn.wait": "Please wait…",
|
|
42
|
+
"signIn.differentNumber": "Use a different number",
|
|
43
|
+
"signIn.error.tooMany": "Too many codes requested. Try again in about {wait}.",
|
|
44
|
+
"signIn.error.tooManyLater": "Too many codes requested. Try again later.",
|
|
45
|
+
"signIn.error.paused": "Sign-in codes are paused for now. Try again in about {wait}.",
|
|
46
|
+
"signIn.error.pausedLater": "Sign-in codes are paused for now. Try again later.",
|
|
47
|
+
"signIn.error.destination": "This number can't receive sign-in codes.",
|
|
48
|
+
"signIn.error.badCode": "That code is incorrect or has expired, or this number has no account yet.",
|
|
49
|
+
"register.error.badCode": "That code is incorrect or has expired, or this number already has an account.",
|
|
50
|
+
"signIn.error.invalid": "Check the phone number and try again.",
|
|
51
|
+
"signIn.error.refused": "This number can't sign in here.",
|
|
52
|
+
"signIn.error.unreachable": "The sign-in service is unreachable. Try again shortly.",
|
|
53
|
+
"signIn.error.failed": "Sign-in failed. Try again shortly.",
|
|
54
|
+
"signIn.error.botCheck": "We couldn't confirm you're a person. Complete the check and try again.",
|
|
55
|
+
"signIn.error.botCheckUnavailable": "The security check is unavailable. Try again shortly.",
|
|
56
|
+
"signIn.error.notConfigured": "Sign-in isn't set up on this site yet.",
|
|
57
|
+
"wait.seconds.one": "{count} second",
|
|
58
|
+
"wait.seconds.other": "{count} seconds",
|
|
59
|
+
"wait.minutes.one": "{count} minute",
|
|
60
|
+
"wait.minutes.other": "{count} minutes",
|
|
61
|
+
"wait.hours.one": "{count} hour",
|
|
62
|
+
"wait.hours.other": "{count} hours",
|
|
63
|
+
"bookings.heading": "Bookings",
|
|
64
|
+
"bookings.period": "Which bookings",
|
|
65
|
+
"bookings.upcoming": "Upcoming",
|
|
66
|
+
"bookings.past": "Past",
|
|
67
|
+
"bookings.emptyUpcoming": "You have no upcoming bookings.",
|
|
68
|
+
"bookings.emptyPast": "You have no past bookings.",
|
|
69
|
+
"bookings.more": "Show more",
|
|
70
|
+
"bookings.when": "{start} – {end}",
|
|
71
|
+
"bookings.cancelled": "Cancelled",
|
|
72
|
+
"bookings.cancelledLate": "Cancelled late",
|
|
73
|
+
"bookings.attended": "Attended",
|
|
74
|
+
"bookings.noShow": "Missed",
|
|
75
|
+
"bookings.lateFrom": "Late cancellation from {time}",
|
|
76
|
+
"bookings.started": "This booking can no longer be cancelled because the event has started.",
|
|
77
|
+
"bookings.cancel": "Cancel booking",
|
|
78
|
+
"bookings.confirmHeading": "Cancel this booking?",
|
|
79
|
+
"bookings.confirmLate": "This is a late cancellation: the cancellation window has closed.",
|
|
80
|
+
"bookings.confirmCredit": "The pass credit you used for this booking stays spent.",
|
|
81
|
+
"bookings.confirm": "Yes, cancel",
|
|
82
|
+
"bookings.keep": "Keep booking",
|
|
83
|
+
"bookings.cancelling": "Cancelling…",
|
|
84
|
+
"bookings.doneOnTime": "Your booking is cancelled.",
|
|
85
|
+
"bookings.doneLate": "Your booking is cancelled. It counts as a late cancellation.",
|
|
86
|
+
"bookings.cancelFailed": "The booking could not be cancelled. Try again.",
|
|
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.",
|
|
127
|
+
"passes.heading": "Memberships and passes",
|
|
128
|
+
"passes.empty": "You have no memberships or passes.",
|
|
129
|
+
"passes.unlimited": "Unlimited",
|
|
130
|
+
"passes.credits": "Credits left: {remaining} of {total}",
|
|
131
|
+
"passes.validFrom": "Valid from {date}",
|
|
132
|
+
"passes.validRange": "Valid {from} – {until}",
|
|
133
|
+
"passes.expired": "Expired",
|
|
134
|
+
"details.heading": "My details",
|
|
135
|
+
"details.name": "Name",
|
|
136
|
+
"details.phone": "Phone",
|
|
137
|
+
"details.email": "Email",
|
|
138
|
+
"details.none": "Not set",
|
|
139
|
+
"details.readOnly": "Ask the business to change your phone or email.",
|
|
140
|
+
"details.save": "Save",
|
|
141
|
+
"details.saving": "Saving…",
|
|
142
|
+
"details.saved": "Your name is saved.",
|
|
143
|
+
"details.saveFailed": "Your name could not be saved. Try again.",
|
|
144
|
+
"details.signOutEverywhere": "Sign out everywhere",
|
|
145
|
+
"details.signOutEverywhereHint": "Ends your sessions on every phone and computer, including this one.",
|
|
146
|
+
"details.signOutEverywhereFailed": "Could not sign out everywhere. Try again."
|
|
147
|
+
}, S = "en-GB", C = x;
|
|
148
|
+
function w(e, t = {}) {
|
|
149
|
+
return C[e].replace(/\{(\w+)\}/g, (e, n) => {
|
|
150
|
+
let r = t[n];
|
|
151
|
+
return r === void 0 ? e : typeof r == "number" ? D(r) : r;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
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`, {
|
|
158
|
+
count: t,
|
|
159
|
+
...n
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function D(e) {
|
|
163
|
+
return new Intl.NumberFormat(S).format(e);
|
|
164
|
+
}
|
|
165
|
+
function O(e, t) {
|
|
166
|
+
return new Intl.DateTimeFormat(S, {
|
|
167
|
+
dateStyle: "medium",
|
|
168
|
+
timeStyle: "short",
|
|
169
|
+
...t && { timeZone: t }
|
|
170
|
+
}).format(new Date(e));
|
|
171
|
+
}
|
|
172
|
+
function k(e, t) {
|
|
173
|
+
return new Intl.DateTimeFormat(S, {
|
|
174
|
+
timeStyle: "short",
|
|
175
|
+
...t && { timeZone: t }
|
|
176
|
+
}).format(new Date(e));
|
|
177
|
+
}
|
|
178
|
+
function A(e, t) {
|
|
179
|
+
return new Intl.DateTimeFormat(S, {
|
|
180
|
+
dateStyle: "medium",
|
|
181
|
+
...t && { timeZone: t }
|
|
182
|
+
}).format(new Date(e));
|
|
183
|
+
}
|
|
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)
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function N(e) {
|
|
200
|
+
if (e < 60) return E("wait.seconds", e);
|
|
201
|
+
let t = Math.round(e / 60);
|
|
202
|
+
return t < 60 ? E("wait.minutes", t) : E("wait.hours", Math.round(e / 3600));
|
|
203
|
+
}
|
|
204
|
+
// src/cancellation.ts
|
|
205
|
+
function P(e, t) {
|
|
206
|
+
if (e.status === "cancelled") return "cancelled";
|
|
207
|
+
let n = t.getTime();
|
|
208
|
+
return !e.cancellableUntil || n >= Date.parse(e.cancellableUntil) ? "closed" : e.lateCancellationFrom && n >= Date.parse(e.lateCancellationFrom) ? "late" : "open";
|
|
209
|
+
}
|
|
210
|
+
// src/screens/bookings.tsx
|
|
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) => {
|
|
214
|
+
p(!1);
|
|
215
|
+
try {
|
|
216
|
+
let { data: r } = await e.GET("/web/me/bookings", { params: { query: {
|
|
217
|
+
period: n,
|
|
218
|
+
...t && { cursor: t }
|
|
219
|
+
} } });
|
|
220
|
+
if (!r) return;
|
|
221
|
+
o((e) => t ? [...e ?? [], ...r.items] : r.items), l(r.nextCursor);
|
|
222
|
+
} catch {
|
|
223
|
+
p(!0);
|
|
224
|
+
}
|
|
225
|
+
}, [e, n]);
|
|
226
|
+
return r(() => {
|
|
227
|
+
o(void 0), h(void 0), g();
|
|
228
|
+
}, [g]), /* @__PURE__ */ f("section", {
|
|
229
|
+
className: "cp-screen",
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ d("h1", { children: w("bookings.heading") }),
|
|
232
|
+
/* @__PURE__ */ d("fieldset", {
|
|
233
|
+
className: "cp-tabs",
|
|
234
|
+
"aria-label": w("bookings.period"),
|
|
235
|
+
children: ["upcoming", "past"].map((e) => /* @__PURE__ */ d("button", {
|
|
236
|
+
type: "button",
|
|
237
|
+
"aria-pressed": n === e,
|
|
238
|
+
onClick: () => i(e),
|
|
239
|
+
children: w(e === "upcoming" ? "bookings.upcoming" : "bookings.past")
|
|
240
|
+
}, e))
|
|
241
|
+
}),
|
|
242
|
+
m && /* @__PURE__ */ d("p", {
|
|
243
|
+
role: "status",
|
|
244
|
+
className: "cp-notice",
|
|
245
|
+
children: w(m)
|
|
246
|
+
}),
|
|
247
|
+
u ? /* @__PURE__ */ d(I, { onRetry: () => g() }) : a ? a.length === 0 ? /* @__PURE__ */ d("p", {
|
|
248
|
+
className: "cp-empty",
|
|
249
|
+
children: w(n === "upcoming" ? "bookings.emptyUpcoming" : "bookings.emptyPast")
|
|
250
|
+
}) : /* @__PURE__ */ d("ul", {
|
|
251
|
+
className: "cp-list",
|
|
252
|
+
children: a.map((e) => /* @__PURE__ */ d(L, {
|
|
253
|
+
booking: e,
|
|
254
|
+
onCancelled: (e, t) => {
|
|
255
|
+
o((t) => t?.map((t) => t.id === e.id ? e : t)), h(t ? "bookings.doneLate" : "bookings.doneOnTime");
|
|
256
|
+
}
|
|
257
|
+
}, e.id))
|
|
258
|
+
}) : /* @__PURE__ */ d("p", {
|
|
259
|
+
role: "status",
|
|
260
|
+
children: w("app.loading")
|
|
261
|
+
}),
|
|
262
|
+
a && c && !u && /* @__PURE__ */ d("button", {
|
|
263
|
+
type: "button",
|
|
264
|
+
className: "cp-secondary",
|
|
265
|
+
onClick: () => g(c),
|
|
266
|
+
children: w("bookings.more")
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
function I({ onRetry: e }) {
|
|
272
|
+
return /* @__PURE__ */ f("div", {
|
|
273
|
+
role: "alert",
|
|
274
|
+
className: "cp-error",
|
|
275
|
+
children: [/* @__PURE__ */ d("p", { children: w("app.loadFailed") }), /* @__PURE__ */ d("button", {
|
|
276
|
+
type: "button",
|
|
277
|
+
className: "cp-secondary",
|
|
278
|
+
onClick: e,
|
|
279
|
+
children: w("app.retry")
|
|
280
|
+
})]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
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;
|
|
285
|
+
async function y() {
|
|
286
|
+
u(!0), m(void 0);
|
|
287
|
+
try {
|
|
288
|
+
let { data: n } = await t.POST(F, { params: { path: {
|
|
289
|
+
businessId: r.businessId,
|
|
290
|
+
bookingId: r.id
|
|
291
|
+
} } });
|
|
292
|
+
n && (o(!1), e.onCancelled({
|
|
293
|
+
...r,
|
|
294
|
+
...n,
|
|
295
|
+
cancellableUntil: null,
|
|
296
|
+
lateCancellationFrom: null
|
|
297
|
+
}, n.cancelledLate === !0));
|
|
298
|
+
} catch (e) {
|
|
299
|
+
if (l(e, "post", F)) {
|
|
300
|
+
if (e.code === "EventStarted") {
|
|
301
|
+
g(!0), o(!1);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (e.code === "BookingNotFound") {
|
|
305
|
+
m("bookings.gone");
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
m("bookings.cancelFailed");
|
|
310
|
+
} finally {
|
|
311
|
+
u(!1);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return /* @__PURE__ */ f("li", {
|
|
315
|
+
className: "cp-card",
|
|
316
|
+
"data-state": _,
|
|
317
|
+
children: [
|
|
318
|
+
/* @__PURE__ */ f("div", {
|
|
319
|
+
className: "cp-card-head",
|
|
320
|
+
children: [/* @__PURE__ */ d("h2", { children: r.event.eventTypeName }), r.status === "cancelled" ? /* @__PURE__ */ d("span", {
|
|
321
|
+
className: "cp-badge",
|
|
322
|
+
children: w(r.cancelledLate ? "bookings.cancelledLate" : "bookings.cancelled")
|
|
323
|
+
}) : r.attendance ? /* @__PURE__ */ d("span", {
|
|
324
|
+
className: "cp-badge",
|
|
325
|
+
children: w(r.attendance === "attended" ? "bookings.attended" : "bookings.noShow")
|
|
326
|
+
}) : null]
|
|
327
|
+
}),
|
|
328
|
+
/* @__PURE__ */ d("p", { children: r.businessName }),
|
|
329
|
+
/* @__PURE__ */ d("p", { children: M(r.event.startsAt, r.event.endsAt, i) }),
|
|
330
|
+
(_ === "open" || _ === "late") && r.lateCancellationFrom && /* @__PURE__ */ d("p", {
|
|
331
|
+
className: "cp-hint",
|
|
332
|
+
children: w("bookings.lateFrom", { time: O(r.lateCancellationFrom, i) })
|
|
333
|
+
}),
|
|
334
|
+
_ === "closed" && r.status === "confirmed" && !r.attendance && /* @__PURE__ */ d("p", {
|
|
335
|
+
className: "cp-hint",
|
|
336
|
+
children: w("bookings.started")
|
|
337
|
+
}),
|
|
338
|
+
p && /* @__PURE__ */ d("p", {
|
|
339
|
+
role: "alert",
|
|
340
|
+
children: w(p)
|
|
341
|
+
}),
|
|
342
|
+
(_ === "open" || _ === "late") && (a ? /* @__PURE__ */ f("fieldset", {
|
|
343
|
+
className: "cp-confirm",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ d("legend", { children: w("bookings.confirmHeading") }),
|
|
346
|
+
_ === "late" && /* @__PURE__ */ d("p", {
|
|
347
|
+
className: "cp-warning",
|
|
348
|
+
children: w("bookings.confirmLate")
|
|
349
|
+
}),
|
|
350
|
+
_ === "late" && v && /* @__PURE__ */ d("p", {
|
|
351
|
+
className: "cp-warning",
|
|
352
|
+
children: w("bookings.confirmCredit")
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ f("div", {
|
|
355
|
+
className: "cp-actions",
|
|
356
|
+
children: [/* @__PURE__ */ d("button", {
|
|
357
|
+
type: "button",
|
|
358
|
+
disabled: c,
|
|
359
|
+
onClick: y,
|
|
360
|
+
children: w(c ? "bookings.cancelling" : "bookings.confirm")
|
|
361
|
+
}), /* @__PURE__ */ d("button", {
|
|
362
|
+
type: "button",
|
|
363
|
+
className: "cp-secondary",
|
|
364
|
+
disabled: c,
|
|
365
|
+
onClick: () => o(!1),
|
|
366
|
+
children: w("bookings.keep")
|
|
367
|
+
})]
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}) : /* @__PURE__ */ d("button", {
|
|
371
|
+
type: "button",
|
|
372
|
+
className: "cp-secondary",
|
|
373
|
+
onClick: () => o(!0),
|
|
374
|
+
children: w("bookings.cancel")
|
|
375
|
+
}))
|
|
376
|
+
]
|
|
377
|
+
});
|
|
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
|
+
}
|
|
873
|
+
// src/screens/details.tsx
|
|
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 () => {
|
|
876
|
+
p(!1);
|
|
877
|
+
try {
|
|
878
|
+
let { data: t } = await e.GET("/web/me");
|
|
879
|
+
t && (a(t), c(t.name));
|
|
880
|
+
} catch {
|
|
881
|
+
p(!0);
|
|
882
|
+
}
|
|
883
|
+
}, [e]);
|
|
884
|
+
r(() => {
|
|
885
|
+
v();
|
|
886
|
+
}, [v]);
|
|
887
|
+
async function y(t) {
|
|
888
|
+
t.preventDefault(), h(!0), _(void 0);
|
|
889
|
+
try {
|
|
890
|
+
await e.PATCH("/web/me", { body: { name: o.trim() } }), a((e) => e && {
|
|
891
|
+
...e,
|
|
892
|
+
name: o.trim()
|
|
893
|
+
}), c(o.trim()), _({
|
|
894
|
+
key: "details.saved",
|
|
895
|
+
alert: !1
|
|
896
|
+
});
|
|
897
|
+
} catch {
|
|
898
|
+
_({
|
|
899
|
+
key: "details.saveFailed",
|
|
900
|
+
alert: !0
|
|
901
|
+
});
|
|
902
|
+
} finally {
|
|
903
|
+
h(!1);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
async function x() {
|
|
907
|
+
h(!0), _(void 0);
|
|
908
|
+
try {
|
|
909
|
+
await e.DELETE("/web/me/sessions"), await n("app.signedOutEverywhere");
|
|
910
|
+
} catch {
|
|
911
|
+
_({
|
|
912
|
+
key: "details.signOutEverywhereFailed",
|
|
913
|
+
alert: !0
|
|
914
|
+
}), h(!1);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return /* @__PURE__ */ f("section", {
|
|
918
|
+
className: "cp-screen",
|
|
919
|
+
children: [/* @__PURE__ */ d("h1", { children: w("details.heading") }), l ? /* @__PURE__ */ d(I, { onRetry: v }) : i ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("form", {
|
|
920
|
+
className: "cp-card cp-form",
|
|
921
|
+
onSubmit: y,
|
|
922
|
+
"aria-busy": m,
|
|
923
|
+
children: [
|
|
924
|
+
/* @__PURE__ */ f("label", { children: [w("details.name"), /* @__PURE__ */ d("input", {
|
|
925
|
+
value: o,
|
|
926
|
+
onChange: (e) => c(e.target.value),
|
|
927
|
+
autoComplete: "name",
|
|
928
|
+
maxLength: 200,
|
|
929
|
+
required: !0
|
|
930
|
+
})] }),
|
|
931
|
+
/* @__PURE__ */ f("dl", { children: [
|
|
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") })
|
|
936
|
+
] }),
|
|
937
|
+
/* @__PURE__ */ d("p", {
|
|
938
|
+
className: "cp-hint",
|
|
939
|
+
children: w("details.readOnly")
|
|
940
|
+
}),
|
|
941
|
+
g && /* @__PURE__ */ d("p", {
|
|
942
|
+
role: g.alert ? "alert" : "status",
|
|
943
|
+
children: w(g.key)
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ d("button", {
|
|
946
|
+
type: "submit",
|
|
947
|
+
disabled: m || !o.trim() || o.trim() === i.name,
|
|
948
|
+
children: w(m ? "details.saving" : "details.save")
|
|
949
|
+
})
|
|
950
|
+
]
|
|
951
|
+
}), /* @__PURE__ */ f("div", {
|
|
952
|
+
className: "cp-card cp-form",
|
|
953
|
+
children: [/* @__PURE__ */ d("p", {
|
|
954
|
+
className: "cp-hint",
|
|
955
|
+
children: w("details.signOutEverywhereHint")
|
|
956
|
+
}), /* @__PURE__ */ d("button", {
|
|
957
|
+
type: "button",
|
|
958
|
+
className: "cp-secondary",
|
|
959
|
+
disabled: m,
|
|
960
|
+
onClick: x,
|
|
961
|
+
children: w("details.signOutEverywhere")
|
|
962
|
+
})]
|
|
963
|
+
})] }) : /* @__PURE__ */ d("p", {
|
|
964
|
+
role: "status",
|
|
965
|
+
children: w("app.loading")
|
|
966
|
+
})]
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
// src/screens/passes.tsx
|
|
970
|
+
function he() {
|
|
971
|
+
let { client: e, businesses: n } = b(), [i, a] = s(), [o, c] = s(!1), l = t(async () => {
|
|
972
|
+
c(!1);
|
|
973
|
+
try {
|
|
974
|
+
let { data: t } = await e.GET("/web/me/memberships");
|
|
975
|
+
t && a(t);
|
|
976
|
+
} catch {
|
|
977
|
+
c(!0);
|
|
978
|
+
}
|
|
979
|
+
}, [e]);
|
|
980
|
+
return r(() => {
|
|
981
|
+
l();
|
|
982
|
+
}, [l]), /* @__PURE__ */ f("section", {
|
|
983
|
+
className: "cp-screen",
|
|
984
|
+
children: [/* @__PURE__ */ d("h1", { children: w("passes.heading") }), o ? /* @__PURE__ */ d(I, { onRetry: l }) : i ? i.length === 0 ? /* @__PURE__ */ d("p", {
|
|
985
|
+
className: "cp-empty",
|
|
986
|
+
children: w("passes.empty")
|
|
987
|
+
}) : /* @__PURE__ */ d("ul", {
|
|
988
|
+
className: "cp-list",
|
|
989
|
+
children: i.map((e) => {
|
|
990
|
+
let t = n.get(e.businessId), r = t?.timezone, i = e.validUntil !== null && Date.parse(e.validUntil) <= Date.now();
|
|
991
|
+
return /* @__PURE__ */ f("li", {
|
|
992
|
+
className: "cp-card",
|
|
993
|
+
children: [
|
|
994
|
+
/* @__PURE__ */ f("div", {
|
|
995
|
+
className: "cp-card-head",
|
|
996
|
+
children: [/* @__PURE__ */ d("h2", { children: e.displayName }), i && /* @__PURE__ */ d("span", {
|
|
997
|
+
className: "cp-badge",
|
|
998
|
+
children: w("passes.expired")
|
|
999
|
+
})]
|
|
1000
|
+
}),
|
|
1001
|
+
t && /* @__PURE__ */ d("p", { children: t.displayName }),
|
|
1002
|
+
/* @__PURE__ */ d("p", {
|
|
1003
|
+
className: "cp-credits",
|
|
1004
|
+
children: e.creditsRemaining === null || e.creditsTotal === null ? w("passes.unlimited") : w("passes.credits", {
|
|
1005
|
+
remaining: e.creditsRemaining,
|
|
1006
|
+
total: e.creditsTotal
|
|
1007
|
+
})
|
|
1008
|
+
}),
|
|
1009
|
+
/* @__PURE__ */ d("p", {
|
|
1010
|
+
className: "cp-hint",
|
|
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) })
|
|
1015
|
+
})
|
|
1016
|
+
]
|
|
1017
|
+
}, e.id);
|
|
1018
|
+
})
|
|
1019
|
+
}) : /* @__PURE__ */ d("p", {
|
|
1020
|
+
role: "status",
|
|
1021
|
+
children: w("app.loading")
|
|
1022
|
+
})]
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
// ../ui/dist/index.js
|
|
1026
|
+
var ge = new Intl.DisplayNames(["en"], { type: "region" }), K = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), q = m().map((e) => ({
|
|
1027
|
+
code: e,
|
|
1028
|
+
name: ge.of(e) ?? e,
|
|
1029
|
+
callingCode: h(e),
|
|
1030
|
+
flag: String.fromCodePoint(...[...e].map((e) => 127397 + e.charCodeAt(0)))
|
|
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) {
|
|
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) => {
|
|
1034
|
+
m(), e.onPick(t);
|
|
1035
|
+
};
|
|
1036
|
+
return r(() => {
|
|
1037
|
+
n.current?.showModal(), a.current?.focus(), document.getElementById(`${t}-${e.selected}`)?.scrollIntoView({ block: "center" });
|
|
1038
|
+
}, [t, e.selected]), /* @__PURE__ */ f("dialog", {
|
|
1039
|
+
ref: n,
|
|
1040
|
+
className: "msm-picker-dialog",
|
|
1041
|
+
"aria-labelledby": `${t}-title`,
|
|
1042
|
+
onClose: e.onClose,
|
|
1043
|
+
onClick: (e) => {
|
|
1044
|
+
e.target === n.current && m();
|
|
1045
|
+
},
|
|
1046
|
+
children: [
|
|
1047
|
+
/* @__PURE__ */ f("div", {
|
|
1048
|
+
className: "msm-picker-head",
|
|
1049
|
+
children: [/* @__PURE__ */ d("h2", {
|
|
1050
|
+
id: `${t}-title`,
|
|
1051
|
+
children: e.title
|
|
1052
|
+
}), /* @__PURE__ */ d("button", {
|
|
1053
|
+
type: "button",
|
|
1054
|
+
onClick: m,
|
|
1055
|
+
children: "Close"
|
|
1056
|
+
})]
|
|
1057
|
+
}),
|
|
1058
|
+
/* @__PURE__ */ d("input", {
|
|
1059
|
+
ref: a,
|
|
1060
|
+
className: "msm-picker-search",
|
|
1061
|
+
type: "search",
|
|
1062
|
+
"aria-label": e.searchLabel,
|
|
1063
|
+
placeholder: e.searchLabel,
|
|
1064
|
+
autoComplete: "off",
|
|
1065
|
+
enterKeyHint: "done",
|
|
1066
|
+
value: l,
|
|
1067
|
+
onChange: (e) => {
|
|
1068
|
+
u(e.target.value), c.current && (c.current.scrollTop = 0);
|
|
1069
|
+
},
|
|
1070
|
+
onKeyDown: (e) => {
|
|
1071
|
+
e.key === "Enter" && (e.preventDefault(), l.trim() !== "" && p[0] && h(p[0].value));
|
|
1072
|
+
}
|
|
1073
|
+
}),
|
|
1074
|
+
/* @__PURE__ */ d("ul", {
|
|
1075
|
+
ref: c,
|
|
1076
|
+
"aria-label": e.listLabel,
|
|
1077
|
+
children: p.map((n, r) => /* @__PURE__ */ d("li", { children: /* @__PURE__ */ f("button", {
|
|
1078
|
+
type: "button",
|
|
1079
|
+
id: `${t}-${n.value}`,
|
|
1080
|
+
"aria-current": n.value === e.selected || void 0,
|
|
1081
|
+
className: r === 0 && l.trim() !== "" ? "msm-picker-first" : void 0,
|
|
1082
|
+
onClick: () => h(n.value),
|
|
1083
|
+
children: [
|
|
1084
|
+
n.flag && /* @__PURE__ */ d("span", {
|
|
1085
|
+
"aria-hidden": "true",
|
|
1086
|
+
children: n.flag
|
|
1087
|
+
}),
|
|
1088
|
+
/* @__PURE__ */ d("span", {
|
|
1089
|
+
className: "msm-picker-label",
|
|
1090
|
+
children: n.label
|
|
1091
|
+
}),
|
|
1092
|
+
n.hint && /* @__PURE__ */ d("span", {
|
|
1093
|
+
className: "msm-picker-hint",
|
|
1094
|
+
children: n.hint
|
|
1095
|
+
})
|
|
1096
|
+
]
|
|
1097
|
+
}) }, n.value))
|
|
1098
|
+
}),
|
|
1099
|
+
p.length === 0 && /* @__PURE__ */ d("p", {
|
|
1100
|
+
className: "msm-picker-empty",
|
|
1101
|
+
children: e.empty(l)
|
|
1102
|
+
})
|
|
1103
|
+
]
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
var Y = new p(), X = (e) => J(e);
|
|
1107
|
+
function Z(e) {
|
|
1108
|
+
for (let t = 1; t <= 3 && t <= e.length; t++) {
|
|
1109
|
+
let n = e.slice(0, t), r = (v.country_calling_codes[n] ?? []).filter((e) => J(e) !== void 0), [i] = r;
|
|
1110
|
+
if (i) return {
|
|
1111
|
+
code: n,
|
|
1112
|
+
first: i,
|
|
1113
|
+
countries: r
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
return null;
|
|
1117
|
+
}
|
|
1118
|
+
function Q(e, t) {
|
|
1119
|
+
let n = /^\s*(\+|00)/.exec(e);
|
|
1120
|
+
if (!n) return null;
|
|
1121
|
+
let r = e.slice(n[0].length), i = r.replace(/\D/g, ""), a = Z(i);
|
|
1122
|
+
if (!a) return null;
|
|
1123
|
+
let o = g(`+${i}`), s = a.countries.includes(t) ? t : o?.country ?? a.first, c = 0;
|
|
1124
|
+
for (let e = 0; e < a.code.length; c++) /\d/.test(r.charAt(c)) && e++;
|
|
1125
|
+
return {
|
|
1126
|
+
country: s,
|
|
1127
|
+
text: o?.isValid() ? o.formatNational() : r.slice(c).replace(/^[\s\-().]+/, "")
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
function ye(e, t) {
|
|
1131
|
+
let n = t.replace(/\D/g, "");
|
|
1132
|
+
return n === "" ? "" : t.trim().startsWith("+") ? `+${n}` : g(t, e)?.number ?? `+${X(e).callingCode}${n}`;
|
|
1133
|
+
}
|
|
1134
|
+
function be(e) {
|
|
1135
|
+
return Y.selectNumberingPlan(e), Y.numberingPlan?.possibleLengths() ?? [];
|
|
1136
|
+
}
|
|
1137
|
+
function xe(e, t, n) {
|
|
1138
|
+
if (e === "") return t ? "Enter a phone number." : "";
|
|
1139
|
+
let r = g(e);
|
|
1140
|
+
if (r?.isValid()) return "";
|
|
1141
|
+
let i = e.replace(/\D/g, ""), a = Z(i);
|
|
1142
|
+
if (!a) return "Unknown country code. Choose the country from the list.";
|
|
1143
|
+
let o = n && a.countries.includes(n) ? n : r?.country ?? a.first, s = X(o).name, c = _(i.slice(a.code.length), o);
|
|
1144
|
+
if (c && c !== "NOT_A_NUMBER") {
|
|
1145
|
+
let e = be(o), t = e[0] ?? 0, n = e[e.length - 1] ?? 0;
|
|
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}.`;
|
|
1147
|
+
}
|
|
1148
|
+
return `This is not a valid number for ${s}.`;
|
|
1149
|
+
}
|
|
1150
|
+
function Se(e, t = !1) {
|
|
1151
|
+
return xe(e, t);
|
|
1152
|
+
}
|
|
1153
|
+
function Ce(e, t) {
|
|
1154
|
+
return Q(e, t) ?? {
|
|
1155
|
+
country: t,
|
|
1156
|
+
text: e
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function we(e) {
|
|
1160
|
+
let t = i(), n = o(null), [a, c] = s(() => ({
|
|
1161
|
+
value: e.value,
|
|
1162
|
+
...Ce(e.value, "IS")
|
|
1163
|
+
})), l = a;
|
|
1164
|
+
e.value !== a.value && (l = {
|
|
1165
|
+
value: e.value,
|
|
1166
|
+
...Ce(e.value, a.country)
|
|
1167
|
+
}, c(l));
|
|
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 !== "";
|
|
1169
|
+
r(() => {
|
|
1170
|
+
let e = n.current?.form;
|
|
1171
|
+
if (!e) return;
|
|
1172
|
+
let t = () => {
|
|
1173
|
+
p(!0), e.querySelector("[data-msm-phone-problem]") === n.current && n.current?.focus();
|
|
1174
|
+
};
|
|
1175
|
+
return e.addEventListener("submit", t), () => e.removeEventListener("submit", t);
|
|
1176
|
+
}, []);
|
|
1177
|
+
let b = (t, n) => {
|
|
1178
|
+
let r = ye(t, n);
|
|
1179
|
+
c({
|
|
1180
|
+
value: r,
|
|
1181
|
+
country: t,
|
|
1182
|
+
text: n
|
|
1183
|
+
}), r !== e.value && e.onChange(r);
|
|
1184
|
+
};
|
|
1185
|
+
return /* @__PURE__ */ f("div", {
|
|
1186
|
+
className: "msm-phone",
|
|
1187
|
+
children: [
|
|
1188
|
+
/* @__PURE__ */ d("label", {
|
|
1189
|
+
htmlFor: `${t}-number`,
|
|
1190
|
+
children: e.label
|
|
1191
|
+
}),
|
|
1192
|
+
/* @__PURE__ */ f("div", {
|
|
1193
|
+
className: "msm-phone-row",
|
|
1194
|
+
children: [/* @__PURE__ */ f("button", {
|
|
1195
|
+
type: "button",
|
|
1196
|
+
className: "msm-phone-country",
|
|
1197
|
+
"aria-label": `Country code: ${g.name} +${g.callingCode}`,
|
|
1198
|
+
"aria-haspopup": "dialog",
|
|
1199
|
+
onClick: () => h(!0),
|
|
1200
|
+
children: [
|
|
1201
|
+
/* @__PURE__ */ d("span", {
|
|
1202
|
+
"aria-hidden": "true",
|
|
1203
|
+
children: g.flag
|
|
1204
|
+
}),
|
|
1205
|
+
"+",
|
|
1206
|
+
g.callingCode
|
|
1207
|
+
]
|
|
1208
|
+
}), /* @__PURE__ */ d("input", {
|
|
1209
|
+
ref: n,
|
|
1210
|
+
id: `${t}-number`,
|
|
1211
|
+
className: "msm-phone-number",
|
|
1212
|
+
type: "tel",
|
|
1213
|
+
inputMode: "tel",
|
|
1214
|
+
autoComplete: e.autoComplete ?? "tel",
|
|
1215
|
+
value: l.text,
|
|
1216
|
+
"aria-required": e.required,
|
|
1217
|
+
"data-msm-phone-problem": _ === "" ? void 0 : "",
|
|
1218
|
+
"aria-invalid": y || void 0,
|
|
1219
|
+
"aria-describedby": y ? `${t}-problem` : void 0,
|
|
1220
|
+
onChange: (e) => {
|
|
1221
|
+
let t = e.target.value.replace(/[^\d\s\-().+]/g, ""), n = Q(t, l.country);
|
|
1222
|
+
b(n?.country ?? l.country, n?.text ?? t);
|
|
1223
|
+
},
|
|
1224
|
+
onBlur: () => {
|
|
1225
|
+
l.text.trim() !== "" && p(!0);
|
|
1226
|
+
}
|
|
1227
|
+
})]
|
|
1228
|
+
}),
|
|
1229
|
+
y && /* @__PURE__ */ d("p", {
|
|
1230
|
+
id: `${t}-problem`,
|
|
1231
|
+
className: "msm-phone-problem",
|
|
1232
|
+
role: "alert",
|
|
1233
|
+
children: v
|
|
1234
|
+
}),
|
|
1235
|
+
m && /* @__PURE__ */ d(ve, {
|
|
1236
|
+
title: "Country code",
|
|
1237
|
+
searchLabel: "Search by country or code",
|
|
1238
|
+
listLabel: "Countries",
|
|
1239
|
+
empty: (e) => `No country matches “${e}”.`,
|
|
1240
|
+
search: Te,
|
|
1241
|
+
selected: l.country,
|
|
1242
|
+
onClose: () => h(!1),
|
|
1243
|
+
onPick: (e) => {
|
|
1244
|
+
h(!1), b(e, l.text), n.current?.focus();
|
|
1245
|
+
}
|
|
1246
|
+
})
|
|
1247
|
+
]
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
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) => ({
|
|
1253
|
+
value: e.code,
|
|
1254
|
+
label: e.name,
|
|
1255
|
+
hint: `+${e.callingCode}`,
|
|
1256
|
+
flag: e.flag
|
|
1257
|
+
}));
|
|
1258
|
+
}
|
|
1259
|
+
// src/bot-check.tsx
|
|
1260
|
+
var Ee = () => window.turnstile, De = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", $;
|
|
1261
|
+
function Oe() {
|
|
1262
|
+
let e = Ee();
|
|
1263
|
+
return e ? Promise.resolve(e) : ($ ??= new Promise((e, t) => {
|
|
1264
|
+
let n = document.createElement("script");
|
|
1265
|
+
n.src = De, n.async = !0;
|
|
1266
|
+
let r = () => {
|
|
1267
|
+
$ = void 0, n.remove(), t(/* @__PURE__ */ Error("Turnstile did not load."));
|
|
1268
|
+
};
|
|
1269
|
+
n.onload = () => {
|
|
1270
|
+
let t = Ee();
|
|
1271
|
+
t ? e(t) : r();
|
|
1272
|
+
}, n.onerror = r, document.head.append(n);
|
|
1273
|
+
}), $);
|
|
1274
|
+
}
|
|
1275
|
+
function ke(e) {
|
|
1276
|
+
return e?.provider === "turnstile" && typeof e.siteKey == "string" && e.siteKey.trim() !== "";
|
|
1277
|
+
}
|
|
1278
|
+
function Ae(e) {
|
|
1279
|
+
let t = o(null), n = o(void 0), i = o(e);
|
|
1280
|
+
i.current = e;
|
|
1281
|
+
let { siteKey: a } = e.botCheck;
|
|
1282
|
+
r(() => {
|
|
1283
|
+
let e = !0;
|
|
1284
|
+
return Oe().then((r) => {
|
|
1285
|
+
let o = t.current;
|
|
1286
|
+
if (!e || !o) return;
|
|
1287
|
+
let s = r.render(o, {
|
|
1288
|
+
sitekey: a,
|
|
1289
|
+
size: "flexible",
|
|
1290
|
+
callback: (e) => i.current.onToken(e),
|
|
1291
|
+
"refresh-expired": "auto",
|
|
1292
|
+
"expired-callback": () => i.current.onToken(void 0),
|
|
1293
|
+
"error-callback": () => i.current.onToken(void 0)
|
|
1294
|
+
});
|
|
1295
|
+
s && (n.current = {
|
|
1296
|
+
api: r,
|
|
1297
|
+
id: s
|
|
1298
|
+
});
|
|
1299
|
+
}, () => e && i.current.onUnavailable()), () => {
|
|
1300
|
+
e = !1;
|
|
1301
|
+
let t = n.current;
|
|
1302
|
+
n.current = void 0, t?.api.remove(t.id);
|
|
1303
|
+
};
|
|
1304
|
+
}, [a]);
|
|
1305
|
+
let { attempt: s } = e;
|
|
1306
|
+
return r(() => {
|
|
1307
|
+
if (s === 0) return;
|
|
1308
|
+
let e = n.current;
|
|
1309
|
+
i.current.onToken(void 0), e?.api.reset(e.id);
|
|
1310
|
+
}, [s]), /* @__PURE__ */ d("div", {
|
|
1311
|
+
className: "cp-bot-check",
|
|
1312
|
+
ref: t
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
// src/sign-in.tsx
|
|
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();
|
|
1318
|
+
r(() => {
|
|
1319
|
+
if (!E) return;
|
|
1320
|
+
let e = setTimeout(() => {
|
|
1321
|
+
D(void 0), _((e) => e === E.message ? void 0 : e);
|
|
1322
|
+
}, E.seconds * 1e3);
|
|
1323
|
+
return () => clearTimeout(e);
|
|
1324
|
+
}, [E]);
|
|
1325
|
+
let O = t === "register";
|
|
1326
|
+
async function k(t) {
|
|
1327
|
+
if (t.preventDefault(), m || !Se(o, !0) && T && b) {
|
|
1328
|
+
y(!0), _(void 0);
|
|
1329
|
+
try {
|
|
1330
|
+
let t = m ? await H(e.basePath, O ? "/auth/register" : "/auth/login", {
|
|
1331
|
+
challenge: m,
|
|
1332
|
+
code: l
|
|
1333
|
+
}) : O ? await H(e.basePath, "/auth/register/initiate", {
|
|
1334
|
+
phone: o,
|
|
1335
|
+
name: i.trim(),
|
|
1336
|
+
botCheckToken: b
|
|
1337
|
+
}) : await H(e.basePath, "/auth/initiate", {
|
|
1338
|
+
phone: o,
|
|
1339
|
+
botCheckToken: b
|
|
1340
|
+
});
|
|
1341
|
+
if (t.ok) {
|
|
1342
|
+
let n = await t.json();
|
|
1343
|
+
m ? e.onSignedIn(n.sessionKey) : h(n.challenge);
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
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({
|
|
1348
|
+
phone: o,
|
|
1349
|
+
seconds: a,
|
|
1350
|
+
message: s
|
|
1351
|
+
}), _(s);
|
|
1352
|
+
} catch {
|
|
1353
|
+
_(w("signIn.error.unreachable"));
|
|
1354
|
+
} finally {
|
|
1355
|
+
y(!1), m || C((e) => e + 1);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
function A(e) {
|
|
1360
|
+
n(e), h(void 0), p(""), _(void 0);
|
|
1361
|
+
}
|
|
1362
|
+
return /* @__PURE__ */ d("div", {
|
|
1363
|
+
className: "cp-sign-in",
|
|
1364
|
+
children: /* @__PURE__ */ f("form", {
|
|
1365
|
+
onSubmit: k,
|
|
1366
|
+
"aria-busy": v,
|
|
1367
|
+
children: [
|
|
1368
|
+
/* @__PURE__ */ d(U, { brand: e.brand }),
|
|
1369
|
+
/* @__PURE__ */ d("h1", { children: w(O ? "register.heading" : "signIn.heading") }),
|
|
1370
|
+
e.children,
|
|
1371
|
+
e.notice && !m && /* @__PURE__ */ d("p", {
|
|
1372
|
+
role: "status",
|
|
1373
|
+
className: "cp-notice",
|
|
1374
|
+
children: w(e.notice)
|
|
1375
|
+
}),
|
|
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", {
|
|
1377
|
+
value: l,
|
|
1378
|
+
onChange: (e) => p(e.target.value),
|
|
1379
|
+
inputMode: "numeric",
|
|
1380
|
+
autoComplete: "one-time-code",
|
|
1381
|
+
required: !0,
|
|
1382
|
+
autoFocus: !0
|
|
1383
|
+
})] })] }) : /* @__PURE__ */ f(u, { children: [
|
|
1384
|
+
/* @__PURE__ */ d("p", { children: w(O ? "register.intro" : "signIn.intro") }),
|
|
1385
|
+
O && /* @__PURE__ */ f("label", { children: [w("register.name"), /* @__PURE__ */ d("input", {
|
|
1386
|
+
value: i,
|
|
1387
|
+
onChange: (e) => a(e.target.value),
|
|
1388
|
+
autoComplete: "name",
|
|
1389
|
+
maxLength: 200,
|
|
1390
|
+
required: !0
|
|
1391
|
+
})] }),
|
|
1392
|
+
/* @__PURE__ */ d(we, {
|
|
1393
|
+
label: w("signIn.phone"),
|
|
1394
|
+
value: o,
|
|
1395
|
+
onChange: c,
|
|
1396
|
+
required: !0
|
|
1397
|
+
}),
|
|
1398
|
+
T && /* @__PURE__ */ d(Ae, {
|
|
1399
|
+
botCheck: T,
|
|
1400
|
+
attempt: S,
|
|
1401
|
+
onToken: x,
|
|
1402
|
+
onUnavailable: () => _(w("signIn.error.botCheckUnavailable"))
|
|
1403
|
+
})
|
|
1404
|
+
] }),
|
|
1405
|
+
!m && !T && /* @__PURE__ */ d("p", {
|
|
1406
|
+
role: "alert",
|
|
1407
|
+
children: w("signIn.error.notConfigured")
|
|
1408
|
+
}),
|
|
1409
|
+
g && /* @__PURE__ */ d("p", {
|
|
1410
|
+
role: "alert",
|
|
1411
|
+
children: g
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ d("button", {
|
|
1414
|
+
type: "submit",
|
|
1415
|
+
disabled: v || !m && (!T || !b || E?.phone === o),
|
|
1416
|
+
children: w(v ? "signIn.wait" : m ? O ? "register.submit" : "signIn.submit" : "signIn.sendCode")
|
|
1417
|
+
}),
|
|
1418
|
+
m ? /* @__PURE__ */ d("button", {
|
|
1419
|
+
type: "button",
|
|
1420
|
+
className: "cp-secondary",
|
|
1421
|
+
onClick: () => A(t),
|
|
1422
|
+
children: w("signIn.differentNumber")
|
|
1423
|
+
}) : /* @__PURE__ */ d("button", {
|
|
1424
|
+
type: "button",
|
|
1425
|
+
className: "cp-link",
|
|
1426
|
+
onClick: () => A(O ? "sign-in" : "register"),
|
|
1427
|
+
children: w(O ? "register.toSignIn" : "signIn.toRegister")
|
|
1428
|
+
})
|
|
1429
|
+
]
|
|
1430
|
+
})
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
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 && [
|
|
1435
|
+
400,
|
|
1436
|
+
401,
|
|
1437
|
+
403,
|
|
1438
|
+
404,
|
|
1439
|
+
409
|
|
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");
|
|
1441
|
+
}
|
|
1442
|
+
// src/index.tsx
|
|
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]);
|
|
1451
|
+
r(() => {
|
|
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;
|
|
1458
|
+
do {
|
|
1459
|
+
let { data: n } = await A.GET("/web/businesses", { params: { query: {
|
|
1460
|
+
limit: 100,
|
|
1461
|
+
...t && { cursor: t }
|
|
1462
|
+
} } });
|
|
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,
|
|
1480
|
+
signOut: async (e) => {
|
|
1481
|
+
await H(n, "/auth/logout").catch(() => {}), m(e), c(null);
|
|
1482
|
+
}
|
|
1483
|
+
}), [
|
|
1484
|
+
A,
|
|
1485
|
+
h,
|
|
1486
|
+
_,
|
|
1487
|
+
j,
|
|
1488
|
+
C,
|
|
1489
|
+
n
|
|
1490
|
+
]);
|
|
1491
|
+
if (i === void 0) return /* @__PURE__ */ d("div", {
|
|
1492
|
+
className: "msm-customer",
|
|
1493
|
+
children: /* @__PURE__ */ d("p", {
|
|
1494
|
+
className: "cp-status",
|
|
1495
|
+
role: "status",
|
|
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, {
|
|
1514
|
+
brand: e.brand,
|
|
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()
|
|
1540
|
+
})
|
|
1541
|
+
})
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
export { Ne as MsmCustomer, P as cancellationState, A as formatDate, O as formatDateTime, D as formatNumber, S as locale, w as t };
|