@semics-tech/emdash-events 1.0.0-rc.2 → 1.0.0-rc.20
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 +1 -1
- package/dist/index.mjs +6 -1
- package/dist/manifest.json +6 -1
- package/dist/plugin.mjs +7 -6
- package/dist/ts/astro/lib/call.d.ts +2 -0
- package/dist/ts/astro/lib/call.js +2 -0
- package/dist/ts/astro/lib/page.d.ts +44 -0
- package/dist/ts/astro/lib/page.js +123 -0
- package/dist/ts/integration/index.d.ts +13 -0
- package/dist/ts/integration/index.js +13 -0
- package/emdash-plugin.jsonc +5 -0
- package/package.json +6 -2
- package/src/astro/AttendeeList.astro +9 -12
- package/src/astro/BookingPage.astro +71 -10
- package/src/astro/BookingStatus.astro +204 -53
- package/src/astro/BookingWidget.astro +226 -52
- package/src/astro/CancelBooking.astro +80 -0
- package/src/astro/PageBrand.astro +18 -0
- package/src/astro/PageOrganiser.astro +22 -0
- package/src/astro/TicketPass.astro +131 -33
- package/src/astro/checkout-endpoint.ts +21 -3
- package/src/astro/lib/attendees.ts +52 -4
- package/src/astro/lib/book-link.ts +46 -0
- package/src/astro/lib/call.ts +4 -0
- package/src/astro/lib/checkout-form.ts +49 -1
- package/src/astro/lib/list.ts +22 -0
- package/src/astro/lib/page.ts +143 -0
- package/src/astro/lib/pass.ts +9 -0
- package/src/astro/lib/payment.ts +6 -10
- package/src/astro/lib/widget.ts +113 -5
- package/src/astro/virtual.d.ts +25 -1
- 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 +46 -1
- package/src/i18n/en.ts +47 -1
|
@@ -1,80 +1,137 @@
|
|
|
1
1
|
---
|
|
2
|
-
// <BookingStatus>: a booking's
|
|
3
|
-
//
|
|
2
|
+
// <BookingStatus>: a booking's summary card (EU-FR-06). Rendered by the `/booking` page from the
|
|
3
|
+
// `public/booking` answer. It leads with the event and the booked session, in the event's zone, and the
|
|
4
|
+
// place (T157), then the state, the order and its total. With `cancelAction` it ends with the quiet cancel
|
|
5
|
+
// action (`<CancelBooking>`); the booking page instead puts that at its foot. A request awaiting approval with another
|
|
6
|
+
// time the organiser proposed (Events Pro, T174c) shows it with Accept and "That doesn't work": with `proposalAction`,
|
|
7
|
+
// two plain forms (`intent=accept-time` / `refuse-time`) that post there, so they work without JavaScript.
|
|
4
8
|
import { around, pickLocale, translator } from "../i18n/index";
|
|
5
|
-
import
|
|
9
|
+
import CancelBooking from "./CancelBooking.astro";
|
|
10
|
+
import { zonedAt } from "./lib/list";
|
|
11
|
+
import { type BookingView, endedNotes, formatMoney, statusLabel } from "./lib/widget";
|
|
6
12
|
|
|
7
13
|
interface Props {
|
|
8
14
|
booking: BookingView;
|
|
9
15
|
/** Shown as cancelled (the page just cancelled it). */
|
|
10
16
|
cancelled?: boolean;
|
|
11
|
-
/** Where the
|
|
17
|
+
/** Where the Accept / "That doesn't work" forms of a proposed time post; without it they are not shown. */
|
|
18
|
+
proposalAction?: string;
|
|
19
|
+
/** Where the cancel form posts; without it the card has no cancel action. */
|
|
12
20
|
cancelAction?: string;
|
|
13
21
|
/** Ticket type names by id, when the page knows them. */
|
|
14
22
|
ticketNames?: Record<string, string>;
|
|
23
|
+
/** A lapsed booking's way back: the event's page, when known. */
|
|
24
|
+
bookAgain?: string;
|
|
25
|
+
/** List the attendees' names (the page turns it off when Events Pro's signing list shows them). */
|
|
26
|
+
showAttendees?: boolean;
|
|
15
27
|
locale?: string;
|
|
16
28
|
}
|
|
17
29
|
|
|
18
|
-
const { booking, cancelled = false, cancelAction, ticketNames = {} } =
|
|
30
|
+
const { booking, cancelled = false, cancelAction, proposalAction, ticketNames = {}, bookAgain, showAttendees = true } =
|
|
31
|
+
Astro.props;
|
|
19
32
|
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
20
33
|
const { t, plural, lang, dir } = translator(locale);
|
|
34
|
+
// Another time the organiser proposed (Pro, T174c): the buyer's answer is due by the deadline.
|
|
35
|
+
const proposed =
|
|
36
|
+
!cancelled && booking.status === "awaiting_approval" && booking.proposed && Number.isFinite(Date.parse(booking.proposed.startsAt))
|
|
37
|
+
? booking.proposed
|
|
38
|
+
: undefined;
|
|
21
39
|
// A request awaiting approval (T131) holds its places until the organiser's deadline.
|
|
22
40
|
const [heldBefore, heldAfter] = around(
|
|
23
|
-
t(booking.status === "awaiting_approval" ? "booking.decideBy" : "booking.heldUntil"),
|
|
41
|
+
t(proposed ? "booking.proposal.answerBy" : booking.status === "awaiting_approval" ? "booking.decideBy" : "booking.heldUntil"),
|
|
24
42
|
"time",
|
|
25
43
|
);
|
|
26
|
-
const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
|
|
27
44
|
const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
|
|
28
45
|
const status = cancelled ? "cancelled" : booking.status;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
};
|
|
46
|
+
const zone = booking.event?.timezone;
|
|
47
|
+
const at = (iso: string) => zonedAt(iso, zone, locale);
|
|
48
|
+
const notes = endedNotes({ ...booking, status }, locale);
|
|
49
|
+
const event = booking.event;
|
|
50
|
+
const startsAt = event?.startsAt && Number.isFinite(Date.parse(event.startsAt)) ? event.startsAt : undefined;
|
|
51
|
+
// Who is coming, when the booking names different people (a plain booking puts every seat in the buyer's name).
|
|
52
|
+
const named = booking.attendees.map((a) => a.name).filter(Boolean);
|
|
53
|
+
const names = showAttendees && new Set(named).size > 1 ? named : [];
|
|
39
54
|
---
|
|
40
55
|
<section class="semics-events semics-booking-status" data-testid="booking-details" data-status={status} lang={lang} dir={dir} aria-labelledby="semics-booking-status-title">
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
{event?.title ? (
|
|
57
|
+
<h2 id="semics-booking-status-title" class="semics-booking-event" data-testid="booking-event">{event.title}</h2>
|
|
58
|
+
) : (
|
|
59
|
+
<h2 id="semics-booking-status-title" class="semics-visually-hidden">{t("booking.status")}</h2>
|
|
60
|
+
)}
|
|
61
|
+
{(startsAt || event?.venue || booking.requested) && (
|
|
62
|
+
<div class="semics-booking-session" data-testid="booking-session">
|
|
63
|
+
{startsAt && <p class="semics-booking-when"><time datetime={startsAt} data-testid="booking-when">{at(startsAt)}</time></p>}
|
|
64
|
+
{booking.requested && <p class="semics-booking-when" data-testid="booking-requested">{t("booking.requested", { when: booking.requested })}</p>}
|
|
65
|
+
{event?.venue && <p class="semics-booking-venue" data-testid="booking-venue">{event.venue}</p>}
|
|
66
|
+
</div>
|
|
67
|
+
)}
|
|
68
|
+
<div class="semics-booking-meta">
|
|
69
|
+
<p class="semics-status" data-testid="booking-status" data-status={status}>
|
|
70
|
+
<span class="semics-status-badge">{statusLabel(status, locale)}</span>
|
|
71
|
+
</p>
|
|
72
|
+
<p class="semics-booking-ref">
|
|
73
|
+
{t("booking.reference")} <strong data-testid="booking-ref">{booking.bookingRef}</strong>
|
|
74
|
+
</p>
|
|
75
|
+
</div>
|
|
76
|
+
{/* A booking request (T174a) waiting for the organiser to agree a time. */}
|
|
77
|
+
{status === "awaiting_approval" && booking.requested && !proposed && <p class="semics-booking-note" data-testid="booking-request">{t("booking.requestSent")}</p>}
|
|
78
|
+
{proposed && (
|
|
79
|
+
<section class="semics-booking-proposal" data-testid="booking-proposal" aria-labelledby="semics-booking-proposal-title">
|
|
80
|
+
<h3 id="semics-booking-proposal-title">{t("booking.proposal.title")}</h3>
|
|
81
|
+
<p>{t("booking.proposal.lead")}</p>
|
|
82
|
+
<p class="semics-booking-when"><time datetime={proposed.startsAt} data-testid="booking-proposed">{at(proposed.startsAt)}</time></p>
|
|
83
|
+
{proposalAction && (
|
|
84
|
+
<div class="semics-booking-proposal-actions">
|
|
85
|
+
<form method="post" action={proposalAction}>
|
|
86
|
+
<input type="hidden" name="intent" value="accept-time" />
|
|
87
|
+
<button type="submit" data-testid="booking-proposal-accept">{t("booking.proposal.accept")}</button>
|
|
88
|
+
</form>
|
|
89
|
+
<form method="post" action={proposalAction}>
|
|
90
|
+
<input type="hidden" name="intent" value="refuse-time" />
|
|
91
|
+
<button type="submit" class="semics-booking-refuse" data-testid="booking-proposal-refuse">{t("booking.proposal.refuse")}</button>
|
|
92
|
+
</form>
|
|
93
|
+
</div>
|
|
94
|
+
)}
|
|
95
|
+
{proposalAction && <p class="semics-booking-note">{t("booking.proposal.refuseNote")}</p>}
|
|
96
|
+
</section>
|
|
97
|
+
)}
|
|
48
98
|
{
|
|
49
99
|
!cancelled && booking.holdExpiresAt && (
|
|
50
|
-
<p data-testid="booking-hold">
|
|
100
|
+
<p class="semics-booking-note" data-testid="booking-hold">
|
|
51
101
|
{heldBefore}<time datetime={booking.holdExpiresAt}>{at(booking.holdExpiresAt)}</time>{heldAfter}
|
|
52
102
|
</p>
|
|
53
103
|
)
|
|
54
104
|
}
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
105
|
+
{notes.map((note) => <p class="semics-booking-note" data-testid="booking-note">{note}</p>)}
|
|
106
|
+
{status === "expired" && bookAgain && <p><a href={bookAgain} data-testid="booking-book-again">{t("booking.bookAgain")}</a></p>}
|
|
107
|
+
<div class="semics-booking-order">
|
|
108
|
+
<ul class="semics-lines" aria-label={plural("booking.lines", tickets)}>
|
|
109
|
+
{
|
|
110
|
+
booking.lines.map((line) => (
|
|
111
|
+
<li>
|
|
112
|
+
{ticketNames[line.ticketTypeId]
|
|
113
|
+
? t("booking.line", { qty: new Intl.NumberFormat(locale).format(line.qty), name: ticketNames[line.ticketTypeId] })
|
|
114
|
+
: plural("booking.lines", line.qty)}
|
|
115
|
+
</li>
|
|
116
|
+
))
|
|
117
|
+
}
|
|
118
|
+
</ul>
|
|
119
|
+
{names.length > 0 && (
|
|
120
|
+
<div class="semics-booking-people" data-testid="booking-attendees">
|
|
121
|
+
<h3>{t("booking.attendeesHeading")}</h3>
|
|
122
|
+
<ul>{names.map((name) => <li>{name}</li>)}</ul>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
{(booking.totals.voucherMinor ?? 0) > 0 && (
|
|
126
|
+
<p class="semics-booking-voucher" data-testid="booking-voucher">
|
|
127
|
+
{t("booking.voucher")} <span>−{formatMoney(booking.totals.voucherMinor ?? 0, booking.totals.currency, locale)}</span>
|
|
128
|
+
</p>
|
|
129
|
+
)}
|
|
130
|
+
<p class="semics-booking-total">{t("booking.total")} <strong>{formatMoney(booking.totals.totalMinor, booking.totals.currency, locale)}</strong></p>
|
|
131
|
+
</div>
|
|
67
132
|
{
|
|
68
133
|
booking.canCancel && !cancelled && cancelAction && (
|
|
69
|
-
<
|
|
70
|
-
<input type="hidden" name="intent" value="cancel" />
|
|
71
|
-
{booking.cancelBy && (
|
|
72
|
-
<p>
|
|
73
|
-
{cancelBefore}<time datetime={booking.cancelBy}>{at(booking.cancelBy)}</time>{cancelAfter}
|
|
74
|
-
</p>
|
|
75
|
-
)}
|
|
76
|
-
<button type="submit">{t("booking.cancel")}</button>
|
|
77
|
-
</form>
|
|
134
|
+
<CancelBooking action={cancelAction} cancelBy={booking.cancelBy} zone={zone} locale={locale} />
|
|
78
135
|
)
|
|
79
136
|
}
|
|
80
137
|
</section>
|
|
@@ -82,24 +139,118 @@ const at = (iso: string) => {
|
|
|
82
139
|
<style>
|
|
83
140
|
.semics-booking-status {
|
|
84
141
|
box-sizing: border-box;
|
|
85
|
-
max-inline-size: 36rem;
|
|
86
142
|
color: var(--events-fg, #1a1a1a);
|
|
87
143
|
overflow-wrap: anywhere;
|
|
88
144
|
}
|
|
145
|
+
.semics-booking-status p {
|
|
146
|
+
margin: 0 0 0.5rem;
|
|
147
|
+
}
|
|
148
|
+
.semics-booking-status .semics-booking-event {
|
|
149
|
+
margin: 0 0 0.5rem;
|
|
150
|
+
font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
|
|
151
|
+
line-height: 1.2;
|
|
152
|
+
}
|
|
153
|
+
.semics-booking-session {
|
|
154
|
+
margin-block-end: 1.25rem;
|
|
155
|
+
}
|
|
156
|
+
.semics-booking-status .semics-booking-when {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-size: 1.125rem;
|
|
159
|
+
font-weight: 600;
|
|
160
|
+
}
|
|
161
|
+
.semics-booking-status .semics-booking-venue {
|
|
162
|
+
margin: 0;
|
|
163
|
+
color: var(--events-muted, #4a4a4a);
|
|
164
|
+
}
|
|
165
|
+
.semics-booking-meta {
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-wrap: wrap;
|
|
168
|
+
align-items: center;
|
|
169
|
+
gap: 0.5rem 1rem;
|
|
170
|
+
margin-block-end: 0.75rem;
|
|
171
|
+
}
|
|
172
|
+
.semics-booking-meta p {
|
|
173
|
+
margin: 0;
|
|
174
|
+
}
|
|
175
|
+
.semics-booking-ref {
|
|
176
|
+
color: var(--events-muted, #4a4a4a);
|
|
177
|
+
}
|
|
178
|
+
.semics-booking-ref strong {
|
|
179
|
+
color: var(--events-fg, #1a1a1a);
|
|
180
|
+
letter-spacing: 0.04em;
|
|
181
|
+
}
|
|
89
182
|
.semics-status-badge {
|
|
90
183
|
display: inline-block;
|
|
91
|
-
padding: 0.125rem 0.
|
|
184
|
+
padding: 0.125rem 0.625rem;
|
|
92
185
|
border: 1px solid currentColor;
|
|
93
|
-
border-radius:
|
|
186
|
+
border-radius: 999px;
|
|
187
|
+
font-size: 0.875rem;
|
|
94
188
|
font-weight: 600;
|
|
95
189
|
}
|
|
96
190
|
.semics-booking-status[data-status="confirmed"] .semics-status-badge {
|
|
97
191
|
color: var(--events-success, #146c2e);
|
|
98
192
|
}
|
|
99
|
-
.semics-booking-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
193
|
+
.semics-booking-note {
|
|
194
|
+
color: var(--events-muted, #4a4a4a);
|
|
195
|
+
}
|
|
196
|
+
.semics-booking-proposal {
|
|
197
|
+
margin-block: 1rem;
|
|
198
|
+
padding: 0.75rem 1rem;
|
|
199
|
+
border: 1px solid color-mix(in srgb, var(--events-border, #6b6b6b) 40%, transparent);
|
|
200
|
+
border-radius: 0.5rem;
|
|
201
|
+
}
|
|
202
|
+
.semics-booking-proposal h3 {
|
|
203
|
+
margin: 0 0 0.5rem;
|
|
204
|
+
font-size: 1rem;
|
|
205
|
+
}
|
|
206
|
+
.semics-booking-proposal-actions {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-wrap: wrap;
|
|
209
|
+
gap: 0.5rem;
|
|
210
|
+
margin-block: 0.75rem 0.5rem;
|
|
211
|
+
}
|
|
212
|
+
.semics-booking-proposal-actions form {
|
|
213
|
+
margin: 0;
|
|
214
|
+
}
|
|
215
|
+
.semics-booking-proposal-actions .semics-booking-refuse {
|
|
216
|
+
background: transparent;
|
|
217
|
+
color: var(--events-accent, #0b57d0);
|
|
218
|
+
}
|
|
219
|
+
.semics-booking-order {
|
|
220
|
+
margin-block-start: 1.25rem;
|
|
221
|
+
padding-block-start: 1rem;
|
|
222
|
+
border-block-start: 1px solid color-mix(in srgb, var(--events-border, #6b6b6b) 30%, transparent);
|
|
223
|
+
}
|
|
224
|
+
.semics-lines {
|
|
225
|
+
margin: 0 0 0.75rem;
|
|
226
|
+
padding: 0;
|
|
227
|
+
list-style: none;
|
|
228
|
+
}
|
|
229
|
+
.semics-lines li + li {
|
|
230
|
+
margin-block-start: 0.25rem;
|
|
231
|
+
}
|
|
232
|
+
.semics-booking-people h3 {
|
|
233
|
+
margin: 0 0 0.25rem;
|
|
234
|
+
font-size: 0.8125rem;
|
|
235
|
+
letter-spacing: 0.06em;
|
|
236
|
+
text-transform: uppercase;
|
|
237
|
+
color: var(--events-muted, #4a4a4a);
|
|
238
|
+
}
|
|
239
|
+
.semics-booking-people ul {
|
|
240
|
+
margin: 0 0 0.75rem;
|
|
241
|
+
padding-inline-start: 1.25rem;
|
|
242
|
+
}
|
|
243
|
+
.semics-booking-status .semics-booking-total {
|
|
244
|
+
display: flex;
|
|
245
|
+
justify-content: space-between;
|
|
246
|
+
gap: 1rem;
|
|
247
|
+
margin: 0;
|
|
248
|
+
padding-block-start: 0.75rem;
|
|
249
|
+
border-block-start: 1px solid color-mix(in srgb, var(--events-border, #6b6b6b) 30%, transparent);
|
|
250
|
+
font-weight: 600;
|
|
251
|
+
}
|
|
252
|
+
.semics-booking-total strong {
|
|
253
|
+
font-size: 1.125rem;
|
|
103
254
|
}
|
|
104
255
|
.semics-visually-hidden {
|
|
105
256
|
position: absolute;
|