@semics-tech/emdash-events 1.0.0-rc.5 → 1.0.0-rc.7
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/dist/index.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/dist/plugin.mjs +6 -6
- package/dist/ts/astro/lib/page.d.ts +4 -2
- package/dist/ts/astro/lib/page.js +40 -10
- package/package.json +3 -1
- package/src/astro/BookingPage.astro +19 -4
- package/src/astro/BookingStatus.astro +136 -43
- package/src/astro/BookingWidget.astro +115 -46
- package/src/astro/CancelBooking.astro +80 -0
- package/src/astro/PageOrganiser.astro +22 -0
- package/src/astro/TicketPass.astro +45 -15
- package/src/astro/lib/list.ts +14 -13
- package/src/astro/lib/page.ts +41 -11
- package/src/astro/lib/payment.ts +2 -0
- package/src/astro/lib/widget.ts +29 -4
- package/src/client/forget-form.ts +16 -0
- package/src/client/picker.ts +20 -9
- package/src/client/print.ts +12 -0
- package/src/i18n/ar.ts +8 -0
- package/src/i18n/en.ts +8 -0
package/src/astro/lib/payment.ts
CHANGED
|
@@ -41,6 +41,8 @@ const final = (state: PaymentState, locale: string): PaymentView => ({
|
|
|
41
41
|
/** The payment section for a booking, or `null` when there is nothing to say about money. */
|
|
42
42
|
export function paymentView(booking: BookingView, locale = "en-GB"): PaymentView | null {
|
|
43
43
|
const paid = booking.totals.totalMinor > 0;
|
|
44
|
+
// Ran out waiting for the organiser: not about a payment (`endedNotes` says what happened).
|
|
45
|
+
if (booking.status === "expired" && booking.undecided) return null;
|
|
44
46
|
switch (booking.status) {
|
|
45
47
|
case "awaiting_payment":
|
|
46
48
|
return {
|
package/src/astro/lib/widget.ts
CHANGED
|
@@ -76,12 +76,14 @@ export interface BookingView {
|
|
|
76
76
|
lines: Array<{ ticketTypeId: string; qty: number }>;
|
|
77
77
|
totals: { totalMinor: number; currency: string };
|
|
78
78
|
holdExpiresAt?: string;
|
|
79
|
-
/** The event's public info (`timezone`
|
|
80
|
-
event?: { title?: string; startsAt?: string; timezone?: string | null; slug?: string | null };
|
|
79
|
+
/** The event's public info: the booked session (`startsAt`, in `timezone`) and `venue` lead the page (T157); `slug` for "Book again". */
|
|
80
|
+
event?: { title?: string; startsAt?: string; timezone?: string | null; venue?: string | null; slug?: string | null };
|
|
81
81
|
/** Why the organiser declined (`status: "declined"`), when they said. */
|
|
82
82
|
declineReason?: string | null;
|
|
83
83
|
/** Declined, a price was due and no money was taken (`closeBooking`). */
|
|
84
84
|
notCharged?: boolean;
|
|
85
|
+
/** Expired, this means it ran out waiting for the organiser's decision (Pro: not one approved but left unpaid). */
|
|
86
|
+
undecided?: boolean;
|
|
85
87
|
/** `qr`: Events Pro's QR matrix of `code` (T082), drawn by `<TicketPass>`; Free sends none. */
|
|
86
88
|
attendees: Array<{ name: string; ticketTypeId?: string; status: string; code?: string; qr?: unknown }>;
|
|
87
89
|
canCancel: boolean;
|
|
@@ -311,9 +313,32 @@ export const statusLabel = (status: string, locale?: string) =>
|
|
|
311
313
|
/** English status labels (the 1.0 API; components use `statusLabel`). */
|
|
312
314
|
export const STATUS_LABELS: Record<string, string> = Object.fromEntries(STATUSES.map((s) => [s, statusLabel(s, "en")]));
|
|
313
315
|
|
|
316
|
+
/**
|
|
317
|
+
* The booking as it stands at `now`: a hold past its deadline has lapsed even before the sweeper moves it (the core
|
|
318
|
+
* refuses anything on it, and the waiver page already says so), so the page shows it as expired.
|
|
319
|
+
*/
|
|
320
|
+
export function asOfNow<T extends Pick<BookingView, "status" | "holdExpiresAt" | "canCancel">>(
|
|
321
|
+
booking: T,
|
|
322
|
+
now: number,
|
|
323
|
+
): T {
|
|
324
|
+
const until = booking.holdExpiresAt ? Date.parse(booking.holdExpiresAt) : Number.NaN;
|
|
325
|
+
if (!(until <= now)) return booking;
|
|
326
|
+
const { holdExpiresAt: _gone, ...rest } = booking;
|
|
327
|
+
return { ...rest, status: "expired", canCancel: false } as T;
|
|
328
|
+
}
|
|
329
|
+
|
|
314
330
|
/** What a booking that ended without going ahead should say beyond its status (declined, or lapsed). */
|
|
315
|
-
export function endedNotes(
|
|
316
|
-
|
|
331
|
+
export function endedNotes(
|
|
332
|
+
booking: Pick<BookingView, "status" | "declineReason" | "notCharged" | "undecided"> & {
|
|
333
|
+
totals?: BookingView["totals"];
|
|
334
|
+
},
|
|
335
|
+
locale?: string,
|
|
336
|
+
) {
|
|
337
|
+
if (booking.status === "expired") {
|
|
338
|
+
if (booking.undecided) return [t(locale, "booking.undecided")];
|
|
339
|
+
// A paid one has the payment section's "This booking expired": only what that does not say.
|
|
340
|
+
return [t(locale, booking.totals?.totalMinor ? "booking.signAgain" : "booking.lapsed")];
|
|
341
|
+
}
|
|
317
342
|
if (booking.status !== "declined") return [];
|
|
318
343
|
return [
|
|
319
344
|
...(booking.declineReason ? [t(locale, "booking.declinedReason", { reason: booking.declineReason })] : []),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forgets what the suite's booking form kept for a refusal (`keep-form.ts` in the suite): a person who reaches the
|
|
3
|
+
* booking page has got past the form, and on a shared device their details must not linger. Self-contained.
|
|
4
|
+
*/
|
|
5
|
+
export function forgetKeptForms(storage: Pick<Storage, "length" | "key" | "removeItem">): void {
|
|
6
|
+
for (let i = storage.length - 1; i >= 0; i--) {
|
|
7
|
+
const key = storage.key(i);
|
|
8
|
+
if (key?.startsWith("semics-waiver-form:")) storage.removeItem(key);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
if (typeof document !== "undefined") forgetKeptForms(sessionStorage);
|
|
14
|
+
} catch {
|
|
15
|
+
// Storage is blocked: nothing was kept either.
|
|
16
|
+
}
|
package/src/client/picker.ts
CHANGED
|
@@ -60,10 +60,14 @@ export function enhancePicker(picker: HTMLElement): void {
|
|
|
60
60
|
const radios = (group: HTMLElement) => Array.from(group.querySelectorAll<HTMLButtonElement>('[role="radio"]'));
|
|
61
61
|
const isOpen = (b: HTMLElement) => b.getAttribute("aria-disabled") !== "true";
|
|
62
62
|
|
|
63
|
+
// The picker's own changes, which `showSelected` (below) need not follow.
|
|
64
|
+
let own = false;
|
|
63
65
|
const setSelect = (value: string) => {
|
|
64
66
|
if (select.value === value) return;
|
|
65
67
|
select.value = value;
|
|
68
|
+
own = true;
|
|
66
69
|
select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
70
|
+
own = false;
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
const chooseTime = (button: HTMLButtonElement, focus: boolean) => {
|
|
@@ -127,15 +131,22 @@ export function enhancePicker(picker: HTMLElement): void {
|
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
// A value the browser kept (back/forward, a failed submit): show its day and time.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
// A value the browser kept (back/forward, a failed submit): show its day and time. Also when a script sets
|
|
135
|
+
// the select later and says so with `change` (the suite's refused-form restore, whose script may run after
|
|
136
|
+
// this one, T157); the picker's own changes are skipped.
|
|
137
|
+
const showSelected = () => {
|
|
138
|
+
if (own) return;
|
|
139
|
+
const kept =
|
|
140
|
+
select.value && picker.querySelector<HTMLButtonElement>(`[data-occurrence="${CSS.escape(select.value)}"]`);
|
|
141
|
+
const keptDay =
|
|
142
|
+
kept && dayButtons.find((b) => b.dataset.day === kept.closest<HTMLElement>("[data-times]")?.dataset.times);
|
|
143
|
+
if (kept && keptDay) {
|
|
144
|
+
showDay(keptDay, false);
|
|
145
|
+
chooseTime(kept, false);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
select.addEventListener("change", showSelected);
|
|
149
|
+
showSelected();
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
if (typeof document !== "undefined") {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Print or save as PDF" on the booking page (T157): the button stays hidden without JavaScript (it could do
|
|
3
|
+
* nothing there; the browser's own Print still uses the page's print stylesheet). Self-contained; no text.
|
|
4
|
+
*/
|
|
5
|
+
export function wirePrint(doc: Document, print: () => void): void {
|
|
6
|
+
for (const button of doc.querySelectorAll<HTMLButtonElement>("button[data-print]")) {
|
|
7
|
+
button.hidden = false;
|
|
8
|
+
button.addEventListener("click", () => print());
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (typeof document !== "undefined") wirePrint(document, () => window.print());
|
package/src/i18n/ar.ts
CHANGED
|
@@ -104,6 +104,9 @@ export const ar: Messages = {
|
|
|
104
104
|
"booking.notCharged": "لم يُخصم أي مبلغ من بطاقتك.",
|
|
105
105
|
"booking.lapsed":
|
|
106
106
|
"انتهت صلاحية هذا الحجز لأنه لم يكتمل في الوقت المحدد، لذا أُتيحت أماكنه للآخرين. للمتابعة، ابدأ حجزًا جديدًا؛ وإذا كان هناك إقرار تنازل فستوقّعه مرة أخرى.",
|
|
107
|
+
"booking.undecided":
|
|
108
|
+
"لم يبتّ المنظّم في هذا الطلب في الوقت المحدد، لذا انتهت صلاحيته وأُتيحت أماكنه للآخرين. للمتابعة، ابدأ حجزًا جديدًا؛ وإذا كان هناك إقرار تنازل فستوقّعه مرة أخرى.",
|
|
109
|
+
"booking.signAgain": "إذا كان هناك إقرار تنازل، فستوقّعه مرة أخرى عند الحجز.",
|
|
107
110
|
"booking.bookAgain": "احجز مرة أخرى",
|
|
108
111
|
"booking.decideBy": "سيوافق المنظّم على طلبك أو يرفضه بحلول {time}، وسنراسلك بالبريد الإلكتروني.",
|
|
109
112
|
"booking.line": "{qty} × {name}",
|
|
@@ -111,6 +114,11 @@ export const ar: Messages = {
|
|
|
111
114
|
"booking.cancelUntil": "يمكنك الإلغاء حتى {time}.",
|
|
112
115
|
"booking.cancel": "إلغاء الحجز",
|
|
113
116
|
"booking.cancelFailed": "تعذّر علينا إلغاء هذا الحجز.",
|
|
117
|
+
"booking.cancelConfirm": "يؤدي الإلغاء إلى تحرير أماكنك، ولا يمكن التراجع عنه.",
|
|
118
|
+
"booking.cancelYes": "نعم، ألغِ هذا الحجز",
|
|
119
|
+
"booking.attendeesHeading": "الحضور",
|
|
120
|
+
"booking.print": "اطبع أو احفظ بصيغة PDF",
|
|
121
|
+
"booking.organiser": "المنظِّم: {name}",
|
|
114
122
|
"booking.offer.intro": "التذاكر من قائمة الانتظار محجوزة لك. استلمها على هذا الجهاز؛ يعمل الرابط مرة واحدة.",
|
|
115
123
|
"booking.offer.button": "استلم تذاكري",
|
|
116
124
|
"booking.open.intro": "افتح حجزك على هذا الجهاز. يعمل الرابط مرة واحدة، وبعدها يتذكر هذا المتصفح حجزك.",
|
package/src/i18n/en.ts
CHANGED
|
@@ -107,12 +107,20 @@ export const en = {
|
|
|
107
107
|
"booking.notCharged": "Your card was not charged.",
|
|
108
108
|
"booking.lapsed":
|
|
109
109
|
"This booking lapsed because it was not finished in time, so its places were released. To go ahead, start a new booking; if there is a waiver, you will sign it again.",
|
|
110
|
+
"booking.undecided":
|
|
111
|
+
"The organiser did not decide this request in time, so it lapsed and its places were released. To go ahead, start a new booking; if there is a waiver, you will sign it again.",
|
|
112
|
+
"booking.signAgain": "If there is a waiver, you will sign it again when you book.",
|
|
110
113
|
"booking.bookAgain": "Book again",
|
|
111
114
|
"booking.line": "{qty} × {name}",
|
|
112
115
|
"booking.total": "Total",
|
|
113
116
|
"booking.cancelUntil": "You can cancel until {time}.",
|
|
114
117
|
"booking.cancel": "Cancel booking",
|
|
115
118
|
"booking.cancelFailed": "We could not cancel this booking.",
|
|
119
|
+
"booking.cancelConfirm": "Cancelling releases your places. This cannot be undone.",
|
|
120
|
+
"booking.cancelYes": "Yes, cancel this booking",
|
|
121
|
+
"booking.attendeesHeading": "Who is coming",
|
|
122
|
+
"booking.print": "Print or save as PDF",
|
|
123
|
+
"booking.organiser": "Organised by {name}",
|
|
116
124
|
"booking.offer.intro": "Tickets from the waitlist are held for you. Claim them on this device; the link works once.",
|
|
117
125
|
"booking.offer.button": "Claim my tickets",
|
|
118
126
|
"booking.open.intro": "Open your booking on this device. The link works once; after that this browser remembers it.",
|