@semics-tech/emdash-events 1.0.0-rc.0 → 1.0.0-rc.2
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/README.md +3 -2
- package/dist/index.mjs +25 -1
- package/dist/manifest.json +25 -1
- package/dist/plugin.mjs +6 -6
- package/emdash-plugin.jsonc +16 -0
- package/package.json +3 -2
- package/src/astro/AttendeeList.astro +157 -0
- package/src/astro/BookingPage.astro +42 -4
- package/src/astro/BookingStatus.astro +8 -2
- package/src/astro/BookingWidget.astro +199 -4
- package/src/astro/lib/attendees.ts +170 -0
- package/src/astro/lib/picker.ts +245 -0
- package/src/astro/lib/widget.ts +28 -2
- package/src/client/booking.ts +3 -1
- package/src/client/picker.ts +143 -0
- package/src/i18n/ar.ts +38 -0
- package/src/i18n/en.ts +36 -0
package/emdash-plugin.jsonc
CHANGED
|
@@ -196,6 +196,22 @@
|
|
|
196
196
|
"default": 365,
|
|
197
197
|
"min": 30
|
|
198
198
|
},
|
|
199
|
+
// Admin notifications (T131): sent through the outbox; the email links into the admin.
|
|
200
|
+
"adminNotifyEmails": {
|
|
201
|
+
"type": "string",
|
|
202
|
+
"label": "Admin notification emails",
|
|
203
|
+
"description": "Up to 5 addresses, separated by commas, told about booking requests (and bookings, if chosen below)."
|
|
204
|
+
},
|
|
205
|
+
"notifyAdminOn": {
|
|
206
|
+
"type": "select",
|
|
207
|
+
"label": "Notify admins about",
|
|
208
|
+
"options": [
|
|
209
|
+
{ "value": "requests", "label": "Booking requests that need approval" },
|
|
210
|
+
{ "value": "all", "label": "All bookings" },
|
|
211
|
+
{ "value": "off", "label": "Nothing" }
|
|
212
|
+
],
|
|
213
|
+
"default": "requests"
|
|
214
|
+
},
|
|
199
215
|
"emailSenderName": {
|
|
200
216
|
"type": "string",
|
|
201
217
|
"label": "Email sender name",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semics-tech/emdash-events",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"typescript": "^5.9.0",
|
|
56
56
|
"vitest": "^4.1.12",
|
|
57
57
|
"zod": "4.6.5",
|
|
58
|
-
"@semics-tech/shared": "0.0
|
|
58
|
+
"@semics-tech/shared": "0.1.0-rc.1"
|
|
59
59
|
},
|
|
60
60
|
"description": "Events bookings and ticketing for EmDash",
|
|
61
61
|
"license": "MIT",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"test": "emdash-plugin validate && vitest run",
|
|
76
76
|
"bundle": "emdash-plugin bundle",
|
|
77
77
|
"login": "emdash-plugin login",
|
|
78
|
+
"registry:publish": "emdash-plugin publish",
|
|
78
79
|
"release:setup": "emdash-plugin release setup"
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <AttendeeList>: a waiver booking's attendees with Signed / Waiting (T133, R95; Suite Pro). Rendered
|
|
3
|
+
// by the `/booking` page only when Events Pro's `public/booking` carries a signing list. Every button
|
|
4
|
+
// is a plain form POST back to the page (no JavaScript): Sign now opens that attendee's signing on
|
|
5
|
+
// this device, Resend asks e-sign to email an invited adult again, and the edit form corrects names
|
|
6
|
+
// and emails of attendees who have not signed, until the cutoff. Rows come from `signingRows`.
|
|
7
|
+
import { around, pickLocale, translator } from "../i18n/index";
|
|
8
|
+
import type { SigningRow } from "./lib/attendees";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
rows: SigningRow[];
|
|
12
|
+
/** Where the forms post (`/booking?ref=…`). */
|
|
13
|
+
action: string;
|
|
14
|
+
/** While names may be changed: the deadline (ISO). */
|
|
15
|
+
editUntil?: string;
|
|
16
|
+
locale?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { rows, action, editUntil } = Astro.props;
|
|
20
|
+
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
21
|
+
const { t, lang, dir } = translator(locale);
|
|
22
|
+
const editable = rows.filter((r) => r.canEdit);
|
|
23
|
+
const [untilBefore, untilAfter] = around(t("booking.attendees.editUntil"), "time");
|
|
24
|
+
const [emailedBefore, emailedAfter] = around(t("booking.attendees.emailed"), "email");
|
|
25
|
+
const at = (iso: string) => {
|
|
26
|
+
try {
|
|
27
|
+
const time = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(
|
|
28
|
+
new Date(iso),
|
|
29
|
+
);
|
|
30
|
+
return t("time.utc", { time });
|
|
31
|
+
} catch {
|
|
32
|
+
return iso;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
---
|
|
36
|
+
<section class="semics-events semics-attendee-list" data-testid="attendee-list" lang={lang} dir={dir} aria-labelledby="semics-attendees-title">
|
|
37
|
+
<h2 id="semics-attendees-title">{t("booking.attendees.title")}</h2>
|
|
38
|
+
<ul>
|
|
39
|
+
{
|
|
40
|
+
rows.map((row) => (
|
|
41
|
+
<li data-testid="attendee-row" data-seat={row.seat} data-signing={row.signed ? "signed" : "waiting"}>
|
|
42
|
+
<span class="semics-attendee-name" id={`semics-attendee-${row.seat}`}>{row.name}</span>
|
|
43
|
+
<span class="semics-status-badge">{row.signed ? t("booking.attendees.signed") : t("booking.attendees.waiting")}</span>
|
|
44
|
+
{row.minor && <p class="semics-attendee-note">{t("booking.attendees.minor")}</p>}
|
|
45
|
+
{row.canResend && row.email && (
|
|
46
|
+
<p class="semics-attendee-note">
|
|
47
|
+
{emailedBefore}<span>{row.email}</span>{emailedAfter}
|
|
48
|
+
</p>
|
|
49
|
+
)}
|
|
50
|
+
{(row.canSign || row.canResend) && (
|
|
51
|
+
<div class="semics-attendee-actions">
|
|
52
|
+
{row.canSign && (
|
|
53
|
+
<form method="post" action={action}>
|
|
54
|
+
<input type="hidden" name="intent" value="sign-now" />
|
|
55
|
+
<input type="hidden" name="seat" value={row.seat} />
|
|
56
|
+
<button type="submit" aria-describedby={`semics-attendee-${row.seat}`} data-testid="attendee-sign-now">
|
|
57
|
+
{t("booking.attendees.signNow")}
|
|
58
|
+
</button>
|
|
59
|
+
</form>
|
|
60
|
+
)}
|
|
61
|
+
{row.canResend && (
|
|
62
|
+
<form method="post" action={action}>
|
|
63
|
+
<input type="hidden" name="intent" value="resend" />
|
|
64
|
+
<input type="hidden" name="seat" value={row.seat} />
|
|
65
|
+
<button type="submit" aria-describedby={`semics-attendee-${row.seat}`} data-testid="attendee-resend">
|
|
66
|
+
{t("booking.attendees.resend")}
|
|
67
|
+
</button>
|
|
68
|
+
</form>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</li>
|
|
73
|
+
))
|
|
74
|
+
}
|
|
75
|
+
</ul>
|
|
76
|
+
{
|
|
77
|
+
editable.length > 0 && (
|
|
78
|
+
<form method="post" action={action} class="semics-attendee-edit" data-testid="attendee-edit">
|
|
79
|
+
<input type="hidden" name="intent" value="attendees" />
|
|
80
|
+
<h3>{t("booking.attendees.edit")}</h3>
|
|
81
|
+
{editUntil && (
|
|
82
|
+
<p>
|
|
83
|
+
{untilBefore}<time datetime={editUntil}>{at(editUntil)}</time>{untilAfter}
|
|
84
|
+
</p>
|
|
85
|
+
)}
|
|
86
|
+
{editable.map((row) => (
|
|
87
|
+
<fieldset>
|
|
88
|
+
<legend>{row.name}</legend>
|
|
89
|
+
<label for={`semics-attendee-name-${row.seat}`}>{t("booking.attendees.name")}</label>
|
|
90
|
+
<input id={`semics-attendee-name-${row.seat}`} name={`name:${row.seat}`} value={row.name} required maxlength={200} autocomplete="off" />
|
|
91
|
+
{!row.minor && (
|
|
92
|
+
<>
|
|
93
|
+
<label for={`semics-attendee-email-${row.seat}`}>{t("booking.attendees.email")}</label>
|
|
94
|
+
<input id={`semics-attendee-email-${row.seat}`} name={`email:${row.seat}`} type="email" value={row.email} required maxlength={254} autocomplete="off" />
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
</fieldset>
|
|
98
|
+
))}
|
|
99
|
+
<button type="submit" data-testid="attendee-save">{t("booking.attendees.save")}</button>
|
|
100
|
+
</form>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
</section>
|
|
104
|
+
|
|
105
|
+
<style>
|
|
106
|
+
.semics-attendee-list {
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
max-inline-size: 36rem;
|
|
109
|
+
color: var(--events-fg, #1a1a1a);
|
|
110
|
+
overflow-wrap: anywhere;
|
|
111
|
+
}
|
|
112
|
+
.semics-attendee-list ul {
|
|
113
|
+
list-style: none;
|
|
114
|
+
padding: 0;
|
|
115
|
+
}
|
|
116
|
+
.semics-attendee-list li {
|
|
117
|
+
padding-block: 0.5rem;
|
|
118
|
+
border-block-end: 1px solid var(--events-border, #6b6b6b);
|
|
119
|
+
}
|
|
120
|
+
.semics-attendee-name {
|
|
121
|
+
font-weight: 600;
|
|
122
|
+
margin-inline-end: 0.5rem;
|
|
123
|
+
}
|
|
124
|
+
.semics-status-badge {
|
|
125
|
+
display: inline-block;
|
|
126
|
+
padding: 0.125rem 0.5rem;
|
|
127
|
+
border: 1px solid currentColor;
|
|
128
|
+
border-radius: var(--events-radius, 6px);
|
|
129
|
+
}
|
|
130
|
+
[data-signing="signed"] .semics-status-badge {
|
|
131
|
+
color: var(--events-success, #146c2e);
|
|
132
|
+
}
|
|
133
|
+
.semics-attendee-actions {
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-wrap: wrap;
|
|
136
|
+
gap: 0.5rem;
|
|
137
|
+
margin-block-start: 0.5rem;
|
|
138
|
+
}
|
|
139
|
+
.semics-attendee-list button,
|
|
140
|
+
.semics-attendee-list input {
|
|
141
|
+
font: inherit;
|
|
142
|
+
min-block-size: 2.75rem;
|
|
143
|
+
}
|
|
144
|
+
.semics-attendee-list button {
|
|
145
|
+
padding: 0.5rem 1rem;
|
|
146
|
+
}
|
|
147
|
+
.semics-attendee-edit fieldset {
|
|
148
|
+
display: grid;
|
|
149
|
+
gap: 0.25rem;
|
|
150
|
+
margin-block: 0.5rem;
|
|
151
|
+
}
|
|
152
|
+
.semics-attendee-edit input {
|
|
153
|
+
box-sizing: border-box;
|
|
154
|
+
inline-size: 100%;
|
|
155
|
+
padding: 0.25rem 0.5rem;
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -26,9 +26,11 @@ import {
|
|
|
26
26
|
redeemBookingLink,
|
|
27
27
|
resumePayment,
|
|
28
28
|
} from "./lib/checkout-form";
|
|
29
|
+
import AttendeeList from "./AttendeeList.astro";
|
|
30
|
+
import { handleAttendeeAction, signingRows } from "./lib/attendees";
|
|
29
31
|
import { paymentView } from "./lib/payment";
|
|
30
32
|
import { forwardReceipt } from "./lib/receipt";
|
|
31
|
-
import type
|
|
33
|
+
import { type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
|
|
32
34
|
import TicketPass from "./TicketPass.astro";
|
|
33
35
|
|
|
34
36
|
export const prerender = false;
|
|
@@ -48,8 +50,19 @@ const CODES = [
|
|
|
48
50
|
"BAD_REQUEST",
|
|
49
51
|
LINK_INVALID,
|
|
50
52
|
OFFER_INVALID,
|
|
53
|
+
// The attendee signing list (T133, Events Pro).
|
|
54
|
+
"ATTENDEE_SIGNED",
|
|
55
|
+
"ATTENDEES_LOCKED",
|
|
56
|
+
"ATTENDEE_INVALID",
|
|
57
|
+
"ATTENDEES_UNSENT",
|
|
58
|
+
"WAIVER_EMAIL_REQUIRED",
|
|
59
|
+
"WAIVER_TOO_MANY_EMAILS",
|
|
60
|
+
"RATE_LIMITED",
|
|
61
|
+
"SIGNING_UNAVAILABLE",
|
|
62
|
+
"ESIGN_NOT_CONFIGURED",
|
|
51
63
|
];
|
|
52
64
|
const WAIVER_OUTCOMES = ["signed", "declined", "voided", "expired", "failed"];
|
|
65
|
+
const ATTENDEE_OUTCOMES = ["saved", "resent"];
|
|
53
66
|
const errorText = (code: string, fallback: MessageKey) =>
|
|
54
67
|
CODES.includes(code) ? t(`booking.error.${code}` as MessageKey) : t(fallback);
|
|
55
68
|
|
|
@@ -59,7 +72,11 @@ const ref = /^[0-9A-HJKMNP-TV-Z]{10}$/.test(rawRef) ? rawRef : "";
|
|
|
59
72
|
const errorCode = url.searchParams.get("error") ?? "";
|
|
60
73
|
const waiver = url.searchParams.get("waiver") ?? "";
|
|
61
74
|
const waiverNotice = WAIVER_OUTCOMES.includes(waiver) ? t(`booking.waiver.${waiver}` as MessageKey) : "";
|
|
62
|
-
|
|
75
|
+
const attendeesOutcome = url.searchParams.get("attendees") ?? "";
|
|
76
|
+
const attendeesNotice = ATTENDEE_OUTCOMES.includes(attendeesOutcome)
|
|
77
|
+
? t(`booking.attendees.${attendeesOutcome}` as MessageKey)
|
|
78
|
+
: "";
|
|
79
|
+
let notice = errorCode ? errorText(errorCode, "booking.error.INTERNAL") : waiverNotice || attendeesNotice;
|
|
63
80
|
const code = url.searchParams.get("k") ?? "";
|
|
64
81
|
const ctx = { locals: Astro.locals, url, request: Astro.request };
|
|
65
82
|
// The cancel and redeem forms post here: refuse another site's posts (CSRF) before reading them.
|
|
@@ -121,7 +138,8 @@ if (ref && token) {
|
|
|
121
138
|
else missing = true;
|
|
122
139
|
// A booking waiting for signatures is reconciled with e-sign (the suite supplies `reconcile`): a signer who
|
|
123
140
|
// closed the tab or signed by email has a receipt this page forwards, then it shows the booking afresh.
|
|
124
|
-
|
|
141
|
+
// An ended booking's open envelopes are voided the same way (Pro's void intents, T152).
|
|
142
|
+
if (reconcileWanted(booking) && reconcile && esignPluginId) {
|
|
125
143
|
const done = await reconcile(ctx, { booking, pluginId, esignPluginId });
|
|
126
144
|
if (done.forwarded > 0) {
|
|
127
145
|
const fresh = await callPublicRoute<BookingView>(ctx, {
|
|
@@ -136,6 +154,18 @@ if (ref && token) {
|
|
|
136
154
|
} else if (ref && !opening) {
|
|
137
155
|
missing = true;
|
|
138
156
|
}
|
|
157
|
+
// The attendee signing list's forms (T133): Sign now, Resend and Save, against the fresh answer.
|
|
158
|
+
if (booking && form && ref && token) {
|
|
159
|
+
const done = await handleAttendeeAction(ctx, form, { ref, token }, { pluginId, esignPluginId }, booking);
|
|
160
|
+
if (done) return Astro.redirect(done.location, 303);
|
|
161
|
+
}
|
|
162
|
+
// The lines name their ticket types from the event (T134): the booking itself carries only ids.
|
|
163
|
+
let names: Record<string, string> = {};
|
|
164
|
+
if (booking?.eventId) {
|
|
165
|
+
const event = await callPublicRoute<PublicEvent>(ctx, { path: "public/event", pluginId, body: { eventId: booking.eventId } });
|
|
166
|
+
if (event.ok) names = ticketNames(event.data);
|
|
167
|
+
}
|
|
168
|
+
const signingList = booking && !cancelled ? signingRows(booking) : null;
|
|
139
169
|
const payment = booking && !cancelled ? paymentView(booking, locale) : null;
|
|
140
170
|
const passes = booking && !cancelled && booking.status === "confirmed" ? booking.attendees.filter((a) => a.code) : [];
|
|
141
171
|
---
|
|
@@ -166,8 +196,16 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
|
|
|
166
196
|
</form>
|
|
167
197
|
) : booking ? (
|
|
168
198
|
<>
|
|
169
|
-
<BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} locale={locale} />
|
|
199
|
+
<BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} locale={locale} />
|
|
170
200
|
{payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
|
|
201
|
+
{signingList && (
|
|
202
|
+
<AttendeeList
|
|
203
|
+
rows={signingList}
|
|
204
|
+
action={`/booking?ref=${ref}`}
|
|
205
|
+
editUntil={booking.signingList?.editable ? booking.signingList.editUntil : undefined}
|
|
206
|
+
locale={locale}
|
|
207
|
+
/>
|
|
208
|
+
)}
|
|
171
209
|
{passes.length > 0 && (
|
|
172
210
|
<section aria-labelledby="semics-passes-title">
|
|
173
211
|
<h2 id="semics-passes-title">{t("booking.passes")}</h2>
|
|
@@ -18,7 +18,11 @@ interface Props {
|
|
|
18
18
|
const { booking, cancelled = false, cancelAction, ticketNames = {} } = Astro.props;
|
|
19
19
|
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
20
20
|
const { t, plural, lang, dir } = translator(locale);
|
|
21
|
-
|
|
21
|
+
// A request awaiting approval (T131) holds its places until the organiser's deadline.
|
|
22
|
+
const [heldBefore, heldAfter] = around(
|
|
23
|
+
t(booking.status === "awaiting_approval" ? "booking.decideBy" : "booking.heldUntil"),
|
|
24
|
+
"time",
|
|
25
|
+
);
|
|
22
26
|
const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
|
|
23
27
|
const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
|
|
24
28
|
const status = cancelled ? "cancelled" : booking.status;
|
|
@@ -52,7 +56,9 @@ const at = (iso: string) => {
|
|
|
52
56
|
{
|
|
53
57
|
booking.lines.map((line) => (
|
|
54
58
|
<li>
|
|
55
|
-
{
|
|
59
|
+
{ticketNames[line.ticketTypeId]
|
|
60
|
+
? t("booking.line", { qty: new Intl.NumberFormat(locale).format(line.qty), name: ticketNames[line.ticketTypeId] })
|
|
61
|
+
: plural("booking.lines", line.qty)}
|
|
56
62
|
</li>
|
|
57
63
|
))
|
|
58
64
|
}
|
|
@@ -8,6 +8,7 @@ import { pluginId } from "virtual:semics-events/config";
|
|
|
8
8
|
import { pickLocale, translator } from "../i18n/index";
|
|
9
9
|
import { callPublicRoute } from "./lib/call";
|
|
10
10
|
import { CHECKOUT_PATH, QTY_PREFIX } from "./lib/checkout-form";
|
|
11
|
+
import { pickerFetchFrom, pickerHref, pickerParam, pickerView, usesPicker } from "./lib/picker";
|
|
11
12
|
import { PROMO_PATH, type PromoView, promoCookieName, promoView } from "./lib/promo";
|
|
12
13
|
import { QUESTIONS_MARKER, questionControls } from "./lib/questions";
|
|
13
14
|
import { readWaitlistState, WAITLIST_PATH, waitlistMessage } from "./lib/waitlist";
|
|
@@ -43,11 +44,15 @@ const { t, lang, dir } = translator(locale);
|
|
|
43
44
|
const heading = Astro.props.heading ?? t("widget.heading");
|
|
44
45
|
const fieldText = (field: Parameters<typeof fieldMessage>[0]) => fieldMessage(field, locale);
|
|
45
46
|
let data = Astro.props.data;
|
|
47
|
+
// The day-then-time picker's page (T130): the first local day it shows, from this widget's own
|
|
48
|
+
// `booking_from.<eventId>` (T134: another picker on the page keeps its month).
|
|
49
|
+
const pickerStart = Astro.url.searchParams.get(pickerParam(eventId));
|
|
46
50
|
if (!data) {
|
|
51
|
+
const from = pickerFetchFrom(pickerStart);
|
|
47
52
|
const result = await callPublicRoute<PublicEvent>(Astro, {
|
|
48
53
|
path: "public/event",
|
|
49
54
|
pluginId,
|
|
50
|
-
body: { eventId },
|
|
55
|
+
body: { eventId, ...(from ? { from } : {}) },
|
|
51
56
|
});
|
|
52
57
|
if (result.ok) data = result.data;
|
|
53
58
|
}
|
|
@@ -78,13 +83,23 @@ const ticketTypes = [
|
|
|
78
83
|
...(takesCodes ? (promo?.hiddenTypes ?? []) : []).filter((t) => !listed.has(t.id)),
|
|
79
84
|
] as PublicEvent["ticketTypes"];
|
|
80
85
|
const onSale = data?.status === "on_sale" && ticketTypes.length > 0;
|
|
86
|
+
// Many dates a day, or a slot schedule (T130): a month calendar of days, then the day's times. Without
|
|
87
|
+
// JavaScript the same month's dates show as a select grouped by day.
|
|
88
|
+
const zone = data?.timezone ?? "UTC";
|
|
89
|
+
const picker = usesPicker(data, zone)
|
|
90
|
+
? pickerView(occurrences, { zone, locale, start: pickerStart, now: Date.now(), more: data?.more === true })
|
|
91
|
+
: null;
|
|
92
|
+
const pickerIds = new Set(picker?.days.flatMap((d) => d.slots.map((s) => s.id)));
|
|
93
|
+
const monthId = `${id}-month`;
|
|
81
94
|
// The waitlist (T081): offered when the core takes one and the tickets, or some dates, are sold out.
|
|
82
|
-
const fullDates = occurrences.filter((o) => o.available === 0);
|
|
95
|
+
const fullDates = occurrences.filter((o) => o.available === 0 && (!picker || pickerIds.has(o.id)));
|
|
83
96
|
const waitlist =
|
|
84
97
|
onSale &&
|
|
85
98
|
data?.waitlist === true &&
|
|
86
99
|
(ticketTypes.every((t) => t.available === 0) || fullDates.length > 0);
|
|
87
|
-
const waitlistDates = ticketTypes.every((t) => t.available === 0)
|
|
100
|
+
const waitlistDates = ticketTypes.every((t) => t.available === 0)
|
|
101
|
+
? occurrences.filter((o) => !picker || pickerIds.has(o.id))
|
|
102
|
+
: fullDates;
|
|
88
103
|
const waitlistOutcome = readWaitlistState(Astro.url, eventId);
|
|
89
104
|
// Custom attendee questions are Events Pro's (T080): `public/event` lists them only on a Pro core.
|
|
90
105
|
const questions = questionControls(data?.questions, id, state.fields, locale);
|
|
@@ -129,7 +144,105 @@ const when = (iso: string) => {
|
|
|
129
144
|
<input type="hidden" name="returnTo" value={returnTo} />
|
|
130
145
|
<input type="hidden" name="idempotencyKey" value={newIdempotencyKey()} />
|
|
131
146
|
|
|
132
|
-
{
|
|
147
|
+
{picker && (
|
|
148
|
+
<div class="semics-field semics-picker-field">
|
|
149
|
+
<input type="hidden" name="needsOccurrence" value="1" />
|
|
150
|
+
<div class="semics-field" data-picker-fallback>
|
|
151
|
+
<label for={`${id}-occurrence`}>{t("widget.date")}</label>
|
|
152
|
+
<select
|
|
153
|
+
id={`${id}-occurrence`}
|
|
154
|
+
name="occurrenceId"
|
|
155
|
+
required
|
|
156
|
+
aria-invalid={invalid("occurrence")}
|
|
157
|
+
aria-describedby={[monthId, errId("occurrence")].join(" ")}
|
|
158
|
+
>
|
|
159
|
+
<option value="">{t("widget.chooseDate")}</option>
|
|
160
|
+
{picker.days.map((day) => (
|
|
161
|
+
<optgroup label={day.label}>
|
|
162
|
+
{day.slots.map((s) => (
|
|
163
|
+
<option value={s.id} disabled={s.full}>{s.label}</option>
|
|
164
|
+
))}
|
|
165
|
+
</optgroup>
|
|
166
|
+
))}
|
|
167
|
+
</select>
|
|
168
|
+
</div>
|
|
169
|
+
<nav class="semics-picker-nav" aria-labelledby={monthId}>
|
|
170
|
+
<p id={monthId} class="semics-picker-month">{picker.month.label}</p>
|
|
171
|
+
{picker.prev && <a href={pickerHref(Astro.url, picker.prev, eventId)} rel="nofollow">{t("widget.picker.earlier")}</a>}
|
|
172
|
+
{picker.next && <a href={pickerHref(Astro.url, picker.next, eventId)} rel="nofollow">{t("widget.picker.later")}</a>}
|
|
173
|
+
</nav>
|
|
174
|
+
{picker.days.length === 0 && <p data-testid="picker-none">{t("widget.picker.none")}</p>}
|
|
175
|
+
<fieldset
|
|
176
|
+
class="semics-picker"
|
|
177
|
+
data-picker
|
|
178
|
+
data-field="occurrence"
|
|
179
|
+
data-testid="booking-picker"
|
|
180
|
+
hidden
|
|
181
|
+
aria-invalid={invalid("occurrence")}
|
|
182
|
+
aria-describedby={errId("occurrence")}
|
|
183
|
+
>
|
|
184
|
+
<legend>{t("widget.date")}</legend>
|
|
185
|
+
<table role="grid" class="semics-calendar" aria-labelledby={monthId}>
|
|
186
|
+
<thead>
|
|
187
|
+
<tr>
|
|
188
|
+
{picker.weekdays.map((w) => (
|
|
189
|
+
<th scope="col" abbr={w.long}>{w.short}</th>
|
|
190
|
+
))}
|
|
191
|
+
</tr>
|
|
192
|
+
</thead>
|
|
193
|
+
<tbody>
|
|
194
|
+
{picker.weeks.map((week) => (
|
|
195
|
+
<tr>
|
|
196
|
+
{week.map((cell) => (
|
|
197
|
+
<td>
|
|
198
|
+
{cell && cell.slots.length > 0 ? (
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
class={cell.open ? undefined : "semics-day-full"}
|
|
202
|
+
data-day={cell.key}
|
|
203
|
+
data-n={String(cell.day)}
|
|
204
|
+
aria-label={cell.buttonLabel}
|
|
205
|
+
aria-pressed="false"
|
|
206
|
+
tabindex={cell.key === picker.focusDay ? "0" : "-1"}
|
|
207
|
+
>
|
|
208
|
+
{cell.day}
|
|
209
|
+
</button>
|
|
210
|
+
) : cell ? (
|
|
211
|
+
<span class="semics-day-none">{cell.day}</span>
|
|
212
|
+
) : null}
|
|
213
|
+
</td>
|
|
214
|
+
))}
|
|
215
|
+
</tr>
|
|
216
|
+
))}
|
|
217
|
+
</tbody>
|
|
218
|
+
</table>
|
|
219
|
+
<p class="semics-hint" data-picker-hint>{t("widget.picker.hint")}</p>
|
|
220
|
+
{picker.days.map((day) => (
|
|
221
|
+
<div class="semics-times" role="radiogroup" data-times={day.key} aria-label={t("widget.picker.times", { date: day.label })} hidden>
|
|
222
|
+
{day.slots.map((s, i) => (
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
role="radio"
|
|
226
|
+
aria-checked="false"
|
|
227
|
+
aria-disabled={s.full ? "true" : undefined}
|
|
228
|
+
aria-label={s.label}
|
|
229
|
+
data-occurrence={s.id}
|
|
230
|
+
tabindex={i === day.slots.findIndex((x) => !x.full) ? "0" : "-1"}
|
|
231
|
+
>
|
|
232
|
+
<span>{s.time}</span>
|
|
233
|
+
{s.places && <span class="semics-places">{s.places}</span>}
|
|
234
|
+
</button>
|
|
235
|
+
))}
|
|
236
|
+
</div>
|
|
237
|
+
))}
|
|
238
|
+
</fieldset>
|
|
239
|
+
<p class="semics-field-error" id={errId("occurrence")} data-error-for="occurrence" data-message={fieldText("occurrence")}>
|
|
240
|
+
{bad("occurrence") ? fieldText("occurrence") : ""}
|
|
241
|
+
</p>
|
|
242
|
+
</div>
|
|
243
|
+
)}
|
|
244
|
+
|
|
245
|
+
{!picker && occurrences.length > 0 && (
|
|
133
246
|
<div class="semics-field">
|
|
134
247
|
<input type="hidden" name="needsOccurrence" value="1" />
|
|
135
248
|
<label for={`${id}-occurrence`}>{t("widget.date")}</label>
|
|
@@ -394,6 +507,7 @@ const when = (iso: string) => {
|
|
|
394
507
|
|
|
395
508
|
<script>
|
|
396
509
|
import "../client/booking.ts";
|
|
510
|
+
import "../client/picker.ts";
|
|
397
511
|
</script>
|
|
398
512
|
|
|
399
513
|
<style>
|
|
@@ -470,6 +584,87 @@ const when = (iso: string) => {
|
|
|
470
584
|
.semics-hint {
|
|
471
585
|
color: var(--_muted);
|
|
472
586
|
}
|
|
587
|
+
.semics-picker-nav {
|
|
588
|
+
display: flex;
|
|
589
|
+
flex-wrap: wrap;
|
|
590
|
+
align-items: baseline;
|
|
591
|
+
gap: 0.25rem 1rem;
|
|
592
|
+
}
|
|
593
|
+
.semics-picker-month {
|
|
594
|
+
margin: 0;
|
|
595
|
+
margin-inline-end: auto;
|
|
596
|
+
font-weight: 600;
|
|
597
|
+
}
|
|
598
|
+
.semics-picker-nav a {
|
|
599
|
+
color: var(--_accent);
|
|
600
|
+
min-block-size: 1.5rem;
|
|
601
|
+
}
|
|
602
|
+
.semics-picker {
|
|
603
|
+
display: grid;
|
|
604
|
+
gap: 0.5rem;
|
|
605
|
+
margin: 0;
|
|
606
|
+
padding: 0.5rem 0.75rem 0.75rem;
|
|
607
|
+
border: 1px solid var(--_border);
|
|
608
|
+
border-radius: var(--_radius);
|
|
609
|
+
min-inline-size: 0;
|
|
610
|
+
}
|
|
611
|
+
.semics-picker p {
|
|
612
|
+
margin: 0;
|
|
613
|
+
}
|
|
614
|
+
.semics-calendar {
|
|
615
|
+
inline-size: 100%;
|
|
616
|
+
border-collapse: collapse;
|
|
617
|
+
table-layout: fixed;
|
|
618
|
+
text-align: center;
|
|
619
|
+
}
|
|
620
|
+
.semics-calendar th {
|
|
621
|
+
padding-block: 0.25rem;
|
|
622
|
+
font-weight: 400;
|
|
623
|
+
font-size: 0.875rem;
|
|
624
|
+
color: var(--_muted);
|
|
625
|
+
}
|
|
626
|
+
.semics-calendar td {
|
|
627
|
+
padding: 1px;
|
|
628
|
+
}
|
|
629
|
+
.semics-booking-widget .semics-calendar button,
|
|
630
|
+
.semics-booking-widget .semics-times button {
|
|
631
|
+
inline-size: 100%;
|
|
632
|
+
padding: 0.25rem;
|
|
633
|
+
border: 1px solid var(--_accent);
|
|
634
|
+
background: var(--_bg);
|
|
635
|
+
color: var(--_accent);
|
|
636
|
+
}
|
|
637
|
+
.semics-booking-widget .semics-calendar button.semics-day-full,
|
|
638
|
+
.semics-booking-widget .semics-times button[aria-disabled="true"] {
|
|
639
|
+
border-color: var(--_border);
|
|
640
|
+
color: var(--_muted);
|
|
641
|
+
text-decoration: line-through;
|
|
642
|
+
}
|
|
643
|
+
.semics-booking-widget .semics-times button[aria-disabled="true"] {
|
|
644
|
+
cursor: not-allowed;
|
|
645
|
+
}
|
|
646
|
+
.semics-booking-widget .semics-calendar button[aria-pressed="true"],
|
|
647
|
+
.semics-booking-widget .semics-times button[aria-checked="true"] {
|
|
648
|
+
background: var(--_accent);
|
|
649
|
+
color: var(--_accent-fg);
|
|
650
|
+
}
|
|
651
|
+
.semics-day-none {
|
|
652
|
+
display: block;
|
|
653
|
+
padding-block: 0.75rem;
|
|
654
|
+
color: var(--_muted);
|
|
655
|
+
}
|
|
656
|
+
.semics-times {
|
|
657
|
+
display: grid;
|
|
658
|
+
grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
|
|
659
|
+
gap: 0.5rem;
|
|
660
|
+
}
|
|
661
|
+
.semics-booking-widget .semics-times button {
|
|
662
|
+
display: grid;
|
|
663
|
+
justify-items: center;
|
|
664
|
+
}
|
|
665
|
+
.semics-places {
|
|
666
|
+
font-size: 0.875rem;
|
|
667
|
+
}
|
|
473
668
|
.semics-ticket {
|
|
474
669
|
display: flex;
|
|
475
670
|
flex-wrap: wrap;
|