@semics-tech/emdash-events 0.0.0-stage → 1.0.0-rc.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/LICENSE +21 -0
- package/README.md +82 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +392 -0
- package/dist/manifest.json +401 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.mjs +7 -0
- package/dist/ts/astro/lib/call.d.ts +54 -0
- package/dist/ts/astro/lib/call.js +121 -0
- package/dist/ts/integration/index.d.ts +48 -0
- package/dist/ts/integration/index.js +76 -0
- package/dist/ts/ui/index.d.ts +6 -0
- package/dist/ts/ui/index.js +46 -0
- package/emdash-plugin.jsonc +206 -0
- package/package.json +77 -3
- package/src/astro/AddToCalendar.astro +47 -0
- package/src/astro/BookingBlock.astro +30 -0
- package/src/astro/BookingPage.astro +193 -0
- package/src/astro/BookingStatus.astro +106 -0
- package/src/astro/BookingWidget.astro +581 -0
- package/src/astro/CheckIn.astro +186 -0
- package/src/astro/DoorSignPage.astro +62 -0
- package/src/astro/EventCard.astro +81 -0
- package/src/astro/EventList.astro +83 -0
- package/src/astro/OptOutPage.astro +58 -0
- package/src/astro/PaymentReturn.astro +96 -0
- package/src/astro/TicketPass.astro +95 -0
- package/src/astro/checkout-endpoint.ts +11 -0
- package/src/astro/index.js +18 -0
- package/src/astro/lib/call.ts +185 -0
- package/src/astro/lib/checkout-form.ts +271 -0
- package/src/astro/lib/list.ts +99 -0
- package/src/astro/lib/opt-out.ts +49 -0
- package/src/astro/lib/pass.ts +35 -0
- package/src/astro/lib/payment.ts +73 -0
- package/src/astro/lib/promo.ts +162 -0
- package/src/astro/lib/questions.ts +107 -0
- package/src/astro/lib/receipt.ts +132 -0
- package/src/astro/lib/waitlist.ts +72 -0
- package/src/astro/lib/widget.ts +278 -0
- package/src/astro/promo-endpoint.ts +11 -0
- package/src/astro/virtual.d.ts +16 -0
- package/src/astro/waitlist-endpoint.ts +12 -0
- package/src/client/booking.ts +188 -0
- package/src/client/checkin.ts +260 -0
- package/src/client/payment.ts +76 -0
- package/src/client/receipt.ts +75 -0
- package/src/i18n/ar.ts +213 -0
- package/src/i18n/en.ts +219 -0
- package/src/i18n/index.ts +121 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Injected at `/_events/check-in` by the integration: the staff check-in screen for phones at the
|
|
3
|
+
// door (EV-FR-11, EV-FR-12, T082). Staff pick the event, then type the code from a ticket or scan its
|
|
4
|
+
// QR with the camera (where the browser has `BarcodeDetector`). `src/client/checkin.ts` posts each
|
|
5
|
+
// code to the core's private `checkin/code` route with the staff member's admin session, so only
|
|
6
|
+
// signed-in staff can check anyone in; the route is Events Pro's (Free answers 404 and the screen
|
|
7
|
+
// says so; the admin's Attendees page checks people in on every edition). The page itself shows no
|
|
8
|
+
// booking data: it lists the events from `public/events` only.
|
|
9
|
+
import { pluginId } from "virtual:semics-events/config";
|
|
10
|
+
|
|
11
|
+
import { clientMessages, pickLocale, translator } from "../i18n/index";
|
|
12
|
+
import { callPublicRoute } from "./lib/call";
|
|
13
|
+
import type { PublicEventSummary } from "./lib/list";
|
|
14
|
+
|
|
15
|
+
export const prerender = false;
|
|
16
|
+
|
|
17
|
+
Astro.response.headers.set("Referrer-Policy", "no-referrer");
|
|
18
|
+
Astro.response.headers.set("Cache-Control", "private, no-store");
|
|
19
|
+
|
|
20
|
+
const listed = await callPublicRoute<{ events?: PublicEventSummary[] }>(
|
|
21
|
+
{ locals: Astro.locals, url: Astro.url, request: Astro.request },
|
|
22
|
+
{ path: "public/events" },
|
|
23
|
+
);
|
|
24
|
+
const events = listed.ok ? (listed.data.events ?? []).slice(0, 100) : [];
|
|
25
|
+
const wanted = (Astro.url.searchParams.get("event") ?? "").slice(0, 200);
|
|
26
|
+
const options = events.map((e) => ({ id: e.eventId, title: e.title || e.eventId }));
|
|
27
|
+
if (wanted && !options.some((o) => o.id === wanted)) options.unshift({ id: wanted, title: wanted });
|
|
28
|
+
const api = `/_emdash/api/plugins/${encodeURIComponent(pluginId)}/checkin/code`;
|
|
29
|
+
const locale = pickLocale(Astro.currentLocale);
|
|
30
|
+
const { t, lang, dir } = translator(locale);
|
|
31
|
+
// The script's messages, in the page's language (T102): it has none of its own.
|
|
32
|
+
const messages = JSON.stringify(clientMessages(locale, "checkin.", "status."));
|
|
33
|
+
---
|
|
34
|
+
<!doctype html>
|
|
35
|
+
<html lang={lang} dir={dir}>
|
|
36
|
+
<head>
|
|
37
|
+
<meta charset="utf-8" />
|
|
38
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
39
|
+
<meta name="robots" content="noindex" />
|
|
40
|
+
<meta name="referrer" content="no-referrer" />
|
|
41
|
+
<title>{t("checkin.title")}</title>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<main class="semics-events semics-checkin" data-testid="checkin-page">
|
|
45
|
+
<h1>{t("checkin.title")}</h1>
|
|
46
|
+
<form class="semics-checkin-form" data-semics-checkin data-api={api} data-messages={messages} autocomplete="off">
|
|
47
|
+
<label for="semics-checkin-event">{t("checkin.event")}</label>
|
|
48
|
+
<select id="semics-checkin-event" name="eventId">
|
|
49
|
+
<option value="">{t("checkin.anyEvent")}</option>
|
|
50
|
+
{options.map((o) => <option value={o.id} selected={o.id === wanted}>{o.title}</option>)}
|
|
51
|
+
</select>
|
|
52
|
+
<label for="semics-checkin-code">{t("checkin.code")}</label>
|
|
53
|
+
<input
|
|
54
|
+
id="semics-checkin-code"
|
|
55
|
+
name="code"
|
|
56
|
+
type="text"
|
|
57
|
+
inputmode="text"
|
|
58
|
+
autocapitalize="off"
|
|
59
|
+
spellcheck="false"
|
|
60
|
+
maxlength="200"
|
|
61
|
+
required
|
|
62
|
+
autofocus
|
|
63
|
+
/>
|
|
64
|
+
<button type="submit">{t("checkin.submit")}</button>
|
|
65
|
+
</form>
|
|
66
|
+
<button type="button" class="semics-checkin-camera" data-semics-checkin-camera hidden>{t("checkin.camera")}</button>
|
|
67
|
+
<video class="semics-checkin-video" data-semics-checkin-video playsinline muted hidden></video>
|
|
68
|
+
<p class="semics-checkin-note" data-semics-checkin-nocamera hidden>{t("checkin.noCamera")}</p>
|
|
69
|
+
<div class="semics-checkin-result" role="status" aria-live="polite" data-semics-checkin-result data-testid="checkin-result"></div>
|
|
70
|
+
<noscript>
|
|
71
|
+
<p class="semics-checkin-note">{t("checkin.needsJs")}</p>
|
|
72
|
+
</noscript>
|
|
73
|
+
</main>
|
|
74
|
+
<script>
|
|
75
|
+
import "../client/checkin.ts";
|
|
76
|
+
</script>
|
|
77
|
+
</body>
|
|
78
|
+
</html>
|
|
79
|
+
|
|
80
|
+
<style>
|
|
81
|
+
.semics-checkin {
|
|
82
|
+
box-sizing: border-box;
|
|
83
|
+
max-inline-size: 32rem;
|
|
84
|
+
margin: 0 auto;
|
|
85
|
+
padding: 1rem;
|
|
86
|
+
font-family: system-ui, sans-serif;
|
|
87
|
+
color: var(--events-fg, #1a1a1a);
|
|
88
|
+
background: var(--events-bg, #ffffff);
|
|
89
|
+
overflow-wrap: anywhere;
|
|
90
|
+
}
|
|
91
|
+
.semics-checkin h1 {
|
|
92
|
+
margin: 0 0 1rem;
|
|
93
|
+
font-size: 1.5rem;
|
|
94
|
+
}
|
|
95
|
+
.semics-checkin-form {
|
|
96
|
+
display: grid;
|
|
97
|
+
gap: 0.5rem;
|
|
98
|
+
}
|
|
99
|
+
.semics-checkin label {
|
|
100
|
+
font-weight: 600;
|
|
101
|
+
}
|
|
102
|
+
.semics-checkin select,
|
|
103
|
+
.semics-checkin input,
|
|
104
|
+
.semics-checkin button {
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
inline-size: 100%;
|
|
107
|
+
min-block-size: 44px;
|
|
108
|
+
padding: 0.5rem 0.75rem;
|
|
109
|
+
font: inherit;
|
|
110
|
+
font-size: 1.125rem;
|
|
111
|
+
border-radius: var(--events-radius, 6px);
|
|
112
|
+
}
|
|
113
|
+
.semics-checkin select,
|
|
114
|
+
.semics-checkin input {
|
|
115
|
+
border: 2px solid var(--events-border, #6b6b6b);
|
|
116
|
+
background: #ffffff;
|
|
117
|
+
color: #1a1a1a;
|
|
118
|
+
}
|
|
119
|
+
.semics-checkin input {
|
|
120
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
121
|
+
}
|
|
122
|
+
.semics-checkin button {
|
|
123
|
+
border: 0;
|
|
124
|
+
background: var(--events-accent, #0b57d0);
|
|
125
|
+
color: #ffffff;
|
|
126
|
+
font-weight: 700;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
}
|
|
129
|
+
.semics-checkin .semics-checkin-camera {
|
|
130
|
+
margin-block-start: 0.75rem;
|
|
131
|
+
background: #ffffff;
|
|
132
|
+
color: var(--events-accent, #0b57d0);
|
|
133
|
+
border: 2px solid currentColor;
|
|
134
|
+
}
|
|
135
|
+
.semics-checkin-video {
|
|
136
|
+
display: block;
|
|
137
|
+
inline-size: 100%;
|
|
138
|
+
margin-block-start: 0.75rem;
|
|
139
|
+
border-radius: var(--events-radius, 6px);
|
|
140
|
+
background: #000000;
|
|
141
|
+
}
|
|
142
|
+
.semics-checkin-video[hidden],
|
|
143
|
+
.semics-checkin [hidden] {
|
|
144
|
+
display: none;
|
|
145
|
+
}
|
|
146
|
+
.semics-checkin-note {
|
|
147
|
+
color: var(--events-muted, #4a4a4a);
|
|
148
|
+
}
|
|
149
|
+
.semics-checkin-result {
|
|
150
|
+
margin-block-start: 1rem;
|
|
151
|
+
border-radius: var(--events-radius, 6px);
|
|
152
|
+
}
|
|
153
|
+
.semics-checkin-result[data-tone] {
|
|
154
|
+
padding: 1rem;
|
|
155
|
+
border: 3px solid;
|
|
156
|
+
}
|
|
157
|
+
.semics-checkin-result[data-tone="ok"] {
|
|
158
|
+
background: #e7f6ec;
|
|
159
|
+
border-color: #1e7a3c;
|
|
160
|
+
color: #0f3d1e;
|
|
161
|
+
}
|
|
162
|
+
.semics-checkin-result[data-tone="warn"] {
|
|
163
|
+
background: #fff4d6;
|
|
164
|
+
border-color: #8a5a00;
|
|
165
|
+
color: #4a3000;
|
|
166
|
+
}
|
|
167
|
+
.semics-checkin-result[data-tone="error"] {
|
|
168
|
+
background: #fde8e8;
|
|
169
|
+
border-color: #b3261e;
|
|
170
|
+
color: #5c0f0a;
|
|
171
|
+
}
|
|
172
|
+
.semics-checkin-result :global(p) {
|
|
173
|
+
margin: 0 0 0.5rem;
|
|
174
|
+
}
|
|
175
|
+
.semics-checkin-result :global(.semics-checkin-title) {
|
|
176
|
+
font-size: 1.375rem;
|
|
177
|
+
font-weight: 700;
|
|
178
|
+
}
|
|
179
|
+
.semics-checkin-result :global(.semics-checkin-link) {
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
min-block-size: 44px;
|
|
183
|
+
color: inherit;
|
|
184
|
+
font-weight: 700;
|
|
185
|
+
}
|
|
186
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Injected at `/_events/sign` by the integration: the door signing page (EV-FR-12). Check-in refuses
|
|
3
|
+
// an attendee whose waiver is pending and shows staff a link `/_events/sign#intent=<token>` (minted
|
|
4
|
+
// by the Pro core for that attendee, signing for themselves). The intent stays in the fragment:
|
|
5
|
+
// `src/client/receipt.ts` clears it and posts it here; this page redeems it with e-sign in-process
|
|
6
|
+
// (`public/envelopes/from-intent`) and sends the browser to e-sign's signing page. Afterwards e-sign
|
|
7
|
+
// returns to `/booking?ref=…#receipt=…`, which records the receipt.
|
|
8
|
+
import { esignPluginId, pluginId } from "virtual:semics-events/config";
|
|
9
|
+
|
|
10
|
+
import { type MessageKey, pickLocale, translator } from "../i18n/index";
|
|
11
|
+
import { crossSiteResponse, isCrossSiteRequest } from "./lib/checkout-form";
|
|
12
|
+
import { startDoorSigning } from "./lib/receipt";
|
|
13
|
+
|
|
14
|
+
export const prerender = false;
|
|
15
|
+
|
|
16
|
+
Astro.response.headers.set("Referrer-Policy", "no-referrer");
|
|
17
|
+
Astro.response.headers.set("Cache-Control", "private, no-store");
|
|
18
|
+
|
|
19
|
+
const { t, lang, dir } = translator(pickLocale(Astro.currentLocale));
|
|
20
|
+
const CODES = ["ESIGN_NOT_CONFIGURED", "INTENT_INVALID", "TOKEN_EXPIRED", "TOKEN_REPLAYED", "SIGNING_UNAVAILABLE"];
|
|
21
|
+
|
|
22
|
+
const ctx = { locals: Astro.locals, url: Astro.url, request: Astro.request };
|
|
23
|
+
if (isCrossSiteRequest(Astro.request, Astro.url)) return crossSiteResponse();
|
|
24
|
+
let error = "";
|
|
25
|
+
let signed = false;
|
|
26
|
+
if (Astro.request.method === "POST") {
|
|
27
|
+
const form = await Astro.request.formData().catch(() => new FormData());
|
|
28
|
+
const result = await startDoorSigning(ctx, form.get("intent"), { esignPluginId, pluginId }, form.get("lookup"));
|
|
29
|
+
if ("location" in result) return Astro.redirect(result.location, 303);
|
|
30
|
+
if ("signed" in result) signed = true;
|
|
31
|
+
else error = t(`door.error.${CODES.includes(result.error) ? result.error : "INTERNAL"}` as MessageKey);
|
|
32
|
+
}
|
|
33
|
+
---
|
|
34
|
+
<!doctype html>
|
|
35
|
+
<html lang={lang} dir={dir}>
|
|
36
|
+
<head>
|
|
37
|
+
<meta charset="utf-8" />
|
|
38
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
39
|
+
<meta name="robots" content="noindex" />
|
|
40
|
+
<meta name="referrer" content="no-referrer" />
|
|
41
|
+
<title>{t("door.title")}</title>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<main class="semics-booking" data-testid="door-sign-page">
|
|
45
|
+
<h1>{t("door.title")}</h1>
|
|
46
|
+
{signed ? (
|
|
47
|
+
<p role="status" data-testid="door-sign-signed">{t("door.signed")}</p>
|
|
48
|
+
) : error ? (
|
|
49
|
+
<p role="alert" data-testid="door-sign-error">{error}</p>
|
|
50
|
+
) : (
|
|
51
|
+
<p>{t("door.opening")}</p>
|
|
52
|
+
)}
|
|
53
|
+
<form method="post" action="/_events/sign" data-semics-fragment="intent" hidden>
|
|
54
|
+
<input type="hidden" name="intent" value="" />
|
|
55
|
+
<input type="hidden" name="lookup" value="" />
|
|
56
|
+
</form>
|
|
57
|
+
</main>
|
|
58
|
+
<script>
|
|
59
|
+
import "../client/receipt.ts";
|
|
60
|
+
</script>
|
|
61
|
+
</body>
|
|
62
|
+
</html>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <EventCard event>: one event from `public/events`, server-rendered, no client JavaScript. The start
|
|
3
|
+
// is shown in the event's own time zone. Text only (Astro escapes every expression). Themed with
|
|
4
|
+
// `--events-*` custom properties.
|
|
5
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
6
|
+
import { cardView, type PublicEventSummary } from "./lib/list";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
event: PublicEventSummary;
|
|
10
|
+
/** Where the title links to (the event's page); the title is plain text without it. */
|
|
11
|
+
href?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
/** Heading level of the title, so the card fits under the page's own headings. */
|
|
14
|
+
headingLevel?: 2 | 3 | 4;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { event, href, headingLevel = 3 } = Astro.props;
|
|
18
|
+
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
19
|
+
const { lang, dir } = translator(locale);
|
|
20
|
+
const view = cardView(event, locale);
|
|
21
|
+
const Heading = `h${headingLevel}` as "h3";
|
|
22
|
+
---
|
|
23
|
+
<article class="semics-events semics-event-card" lang={lang} dir={dir} data-testid="event-card" data-event-id={view.eventId}>
|
|
24
|
+
<Heading class="semics-event-title">{href ? <a href={href}>{view.title}</a> : view.title}</Heading>
|
|
25
|
+
<p class="semics-event-when" data-testid="event-when">
|
|
26
|
+
<time datetime={view.datetime}>{view.when}</time>
|
|
27
|
+
</p>
|
|
28
|
+
{view.venue && <p class="semics-event-venue" data-testid="event-venue">{view.venue}</p>}
|
|
29
|
+
{
|
|
30
|
+
(view.price || view.badge) && (
|
|
31
|
+
<p class="semics-event-meta">
|
|
32
|
+
{view.price && <span class="semics-event-price" data-testid="event-price">{view.price}</span>}
|
|
33
|
+
{view.badge && <span class="semics-event-badge" data-testid="event-badge">{view.badge}</span>}
|
|
34
|
+
</p>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
</article>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.semics-event-card {
|
|
41
|
+
--_fg: var(--events-fg, #1a1a1a);
|
|
42
|
+
--_muted: var(--events-muted, #4a4a4a);
|
|
43
|
+
--_bg: var(--events-bg, #ffffff);
|
|
44
|
+
--_border: var(--events-border, #6b6b6b);
|
|
45
|
+
--_accent: var(--events-accent, #0b57d0);
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
padding: 1rem;
|
|
48
|
+
border: 1px solid var(--_border);
|
|
49
|
+
border-radius: var(--events-radius, 6px);
|
|
50
|
+
background: var(--_bg);
|
|
51
|
+
color: var(--_fg);
|
|
52
|
+
font-family: var(--events-font, system-ui, sans-serif);
|
|
53
|
+
}
|
|
54
|
+
.semics-event-title {
|
|
55
|
+
margin: 0 0 0.25rem;
|
|
56
|
+
font-size: 1.125rem;
|
|
57
|
+
}
|
|
58
|
+
.semics-event-title a {
|
|
59
|
+
color: var(--_accent);
|
|
60
|
+
}
|
|
61
|
+
.semics-event-when,
|
|
62
|
+
.semics-event-venue {
|
|
63
|
+
margin: 0.125rem 0;
|
|
64
|
+
color: var(--_muted);
|
|
65
|
+
}
|
|
66
|
+
.semics-event-meta {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-wrap: wrap;
|
|
69
|
+
gap: 0.5rem;
|
|
70
|
+
margin: 0.5rem 0 0;
|
|
71
|
+
}
|
|
72
|
+
.semics-event-price {
|
|
73
|
+
font-weight: 600;
|
|
74
|
+
}
|
|
75
|
+
.semics-event-badge {
|
|
76
|
+
padding: 0 0.5rem;
|
|
77
|
+
border: 1px solid var(--_border);
|
|
78
|
+
border-radius: 999px;
|
|
79
|
+
color: var(--_muted);
|
|
80
|
+
}
|
|
81
|
+
</style>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <EventList> and the `events-list` Portable Text block (EU-FR-03): upcoming events from the core's
|
|
3
|
+
// `public/events` route (cached 60 s), server-rendered with no client JavaScript. Portable Text
|
|
4
|
+
// passes the block as `node`; templates pass props. `events` skips the route when the page already
|
|
5
|
+
// has the answer. Every failure renders a defined state.
|
|
6
|
+
import { pluginId as configuredId } from "virtual:semics-events/config";
|
|
7
|
+
|
|
8
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
9
|
+
import EventCard from "./EventCard.astro";
|
|
10
|
+
import { callPublicRoute } from "./lib/call";
|
|
11
|
+
import { eventHref, listView, type PublicEventSummary } from "./lib/list";
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
node?: { heading?: string; limit?: number };
|
|
15
|
+
heading?: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
locale?: string;
|
|
18
|
+
events?: PublicEventSummary[];
|
|
19
|
+
/** The core's plugin id; defaults to the integration's. */
|
|
20
|
+
pluginId?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Link target for each event. Defaults to `/events/<slug>` (the entry's slug from
|
|
23
|
+
* `public/events`); return `undefined` for a plain-text title.
|
|
24
|
+
*/
|
|
25
|
+
hrefFor?: (event: PublicEventSummary) => string | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const props = Astro.props as Props;
|
|
29
|
+
// The language: the `locale` prop, else the page's (Astro i18n), else British English (T102).
|
|
30
|
+
const locale = pickLocale(props.locale, Astro.currentLocale);
|
|
31
|
+
const { t, lang, dir } = translator(locale);
|
|
32
|
+
const heading = props.node?.heading ?? props.heading ?? t("list.heading");
|
|
33
|
+
const limit = Number(props.node?.limit ?? props.limit ?? 3);
|
|
34
|
+
|
|
35
|
+
let events = props.events;
|
|
36
|
+
let failed = false;
|
|
37
|
+
if (!events) {
|
|
38
|
+
const result = await callPublicRoute<{ events?: PublicEventSummary[] }>(Astro, {
|
|
39
|
+
path: "public/events",
|
|
40
|
+
pluginId: props.pluginId ?? configuredId,
|
|
41
|
+
});
|
|
42
|
+
if (result.ok) events = result.data.events ?? [];
|
|
43
|
+
else failed = true;
|
|
44
|
+
}
|
|
45
|
+
const cards = listView(events ?? [], { limit: Number.isFinite(limit) ? limit : 3, locale });
|
|
46
|
+
const byId = new Map((events ?? []).map((e) => [e.eventId, e]));
|
|
47
|
+
const state = failed ? "error" : cards.length === 0 ? "empty" : "ok";
|
|
48
|
+
---
|
|
49
|
+
<section class="semics-events semics-event-list" data-testid="event-list" data-state={state} lang={lang} dir={dir} aria-labelledby="semics-event-list-title">
|
|
50
|
+
<h2 id="semics-event-list-title">{heading}</h2>
|
|
51
|
+
{
|
|
52
|
+
failed ? (
|
|
53
|
+
<p role="alert" data-testid="event-list-error">{t("list.error")}</p>
|
|
54
|
+
) : cards.length === 0 ? (
|
|
55
|
+
<p data-testid="event-list-empty">{t("list.empty")}</p>
|
|
56
|
+
) : (
|
|
57
|
+
<ul class="semics-event-items">
|
|
58
|
+
{cards.map((card) => {
|
|
59
|
+
const event = byId.get(card.eventId) as PublicEventSummary;
|
|
60
|
+
return (
|
|
61
|
+
<li>
|
|
62
|
+
<EventCard event={event} href={(props.hrefFor ?? eventHref)(event)} locale={locale} headingLevel={3} />
|
|
63
|
+
</li>
|
|
64
|
+
);
|
|
65
|
+
})}
|
|
66
|
+
</ul>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
</section>
|
|
70
|
+
|
|
71
|
+
<style>
|
|
72
|
+
.semics-event-list {
|
|
73
|
+
color: var(--events-fg, #1a1a1a);
|
|
74
|
+
font-family: var(--events-font, system-ui, sans-serif);
|
|
75
|
+
}
|
|
76
|
+
.semics-event-items {
|
|
77
|
+
display: grid;
|
|
78
|
+
gap: 0.75rem;
|
|
79
|
+
margin: 0;
|
|
80
|
+
padding: 0;
|
|
81
|
+
list-style: none;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Injected at `/_events/opt-out` by the integration: stop reminder and update emails for one booking
|
|
3
|
+
// at one address (EV-FR-08, T083). Opening the emailed link changes nothing; the button's POST asks the
|
|
4
|
+
// core's `public/mail/opt-out` (Events Pro's route; a Free core answers NOT_FOUND, shown as an invalid link).
|
|
5
|
+
import { pluginId } from "virtual:semics-events/config";
|
|
6
|
+
|
|
7
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
8
|
+
import { crossSiteResponse, isCrossSiteRequest } from "./lib/checkout-form";
|
|
9
|
+
import { OPT_OUT_MESSAGES, OPT_OUT_PATH, optOut, readOptOutLink } from "./lib/opt-out";
|
|
10
|
+
|
|
11
|
+
export const prerender = false;
|
|
12
|
+
|
|
13
|
+
Astro.response.headers.set("Referrer-Policy", "no-referrer");
|
|
14
|
+
Astro.response.headers.set("Cache-Control", "private, no-store");
|
|
15
|
+
|
|
16
|
+
if (isCrossSiteRequest(Astro.request, Astro.url)) return crossSiteResponse();
|
|
17
|
+
// The page's language is the site's (Astro i18n), else British English (T102).
|
|
18
|
+
const { t, lang, dir } = translator(pickLocale(Astro.currentLocale));
|
|
19
|
+
let link = readOptOutLink(Astro.url.searchParams);
|
|
20
|
+
let outcome: keyof typeof OPT_OUT_MESSAGES | null = link ? null : "invalid";
|
|
21
|
+
if (Astro.request.method === "POST") {
|
|
22
|
+
const form = await Astro.request.formData().catch(() => new FormData());
|
|
23
|
+
link = readOptOutLink(form);
|
|
24
|
+
outcome = link
|
|
25
|
+
? await optOut({ locals: Astro.locals, url: Astro.url, request: Astro.request }, link, { pluginId })
|
|
26
|
+
: "invalid";
|
|
27
|
+
}
|
|
28
|
+
---
|
|
29
|
+
<!doctype html>
|
|
30
|
+
<html lang={lang} dir={dir}>
|
|
31
|
+
<head>
|
|
32
|
+
<meta charset="utf-8" />
|
|
33
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
34
|
+
<meta name="robots" content="noindex" />
|
|
35
|
+
<meta name="referrer" content="no-referrer" />
|
|
36
|
+
<title>{t("optOut.title")}</title>
|
|
37
|
+
</head>
|
|
38
|
+
<body>
|
|
39
|
+
<main class="semics-events semics-opt-out" data-testid="opt-out-page">
|
|
40
|
+
<h1>{t("optOut.title")}</h1>
|
|
41
|
+
{outcome ? (
|
|
42
|
+
<p role={outcome === "done" ? "status" : "alert"} data-testid={`opt-out-${outcome}`}>
|
|
43
|
+
{t(`optOut.${outcome}`)}
|
|
44
|
+
</p>
|
|
45
|
+
) : (
|
|
46
|
+
link && (
|
|
47
|
+
<form method="post" action={OPT_OUT_PATH} data-testid="opt-out-form">
|
|
48
|
+
<p>{t("optOut.question", { ref: link.bookingRef })}</p>
|
|
49
|
+
<input type="hidden" name="ref" value={link.bookingRef} />
|
|
50
|
+
<input type="hidden" name="w" value={link.who} />
|
|
51
|
+
<input type="hidden" name="s" value={link.sig} />
|
|
52
|
+
<button type="submit">{t("optOut.button")}</button>
|
|
53
|
+
</form>
|
|
54
|
+
)
|
|
55
|
+
)}
|
|
56
|
+
</main>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <PaymentReturn>: what the booking page says after Stripe sends the buyer back (EU-FR-09).
|
|
3
|
+
// Rendered by `/booking` from the core's `public/booking` answer; the state is never taken from the
|
|
4
|
+
// URL (Stripe's return URL carries nothing to trust). While a payment waits for the webhook
|
|
5
|
+
// (`pending`), `src/client/payment.ts` re-reads the page politely; without JavaScript the "Check
|
|
6
|
+
// again" link does the same by hand. "Pay now" is a plain form post back to the booking page.
|
|
7
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
8
|
+
import type { PaymentView } from "./lib/payment";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
view: PaymentView;
|
|
12
|
+
bookingRef: string;
|
|
13
|
+
/** Where the "Pay now" form posts (the booking page itself). */
|
|
14
|
+
action: string;
|
|
15
|
+
/** The view's language; build `view` with the same locale (`paymentView(booking, locale)`). */
|
|
16
|
+
locale?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { view, bookingRef, action } = Astro.props;
|
|
20
|
+
const { t, lang, dir } = translator(pickLocale(Astro.props.locale, Astro.currentLocale));
|
|
21
|
+
---
|
|
22
|
+
<section
|
|
23
|
+
class="semics-events semics-payment"
|
|
24
|
+
data-semics-payment
|
|
25
|
+
data-testid="payment-return"
|
|
26
|
+
data-state={view.state}
|
|
27
|
+
lang={lang}
|
|
28
|
+
dir={dir}
|
|
29
|
+
aria-labelledby="semics-payment-title"
|
|
30
|
+
>
|
|
31
|
+
<h2 id="semics-payment-title">{view.heading}</h2>
|
|
32
|
+
<div role="status" aria-live="polite" aria-atomic="true">
|
|
33
|
+
<p data-testid="payment-message">{view.body}</p>
|
|
34
|
+
{
|
|
35
|
+
view.poll && (
|
|
36
|
+
<>
|
|
37
|
+
<p data-semics-payment-checking data-testid="payment-checking" hidden>{t("payment.checking")}</p>
|
|
38
|
+
<p data-semics-payment-slow data-testid="payment-slow" hidden>{t("payment.slow")}</p>
|
|
39
|
+
</>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
<p data-semics-payment-live data-message={t("payment.updated")} class="semics-visually-hidden"></p>
|
|
43
|
+
</div>
|
|
44
|
+
{
|
|
45
|
+
view.poll && (
|
|
46
|
+
<div class="semics-payment-actions">
|
|
47
|
+
<form method="post" action={action}>
|
|
48
|
+
<input type="hidden" name="intent" value="resume" />
|
|
49
|
+
<button type="submit" data-testid="payment-resume">{t("payment.payNow")}</button>
|
|
50
|
+
</form>
|
|
51
|
+
<a href={`/booking?ref=${encodeURIComponent(bookingRef)}`} data-testid="payment-check">{t("payment.checkAgain")}</a>
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
</section>
|
|
56
|
+
|
|
57
|
+
<style>
|
|
58
|
+
.semics-payment {
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
max-inline-size: 36rem;
|
|
61
|
+
margin-block: 1rem;
|
|
62
|
+
padding: 1rem;
|
|
63
|
+
border: 1px solid currentColor;
|
|
64
|
+
border-radius: var(--events-radius, 6px);
|
|
65
|
+
color: var(--events-fg, #1a1a1a);
|
|
66
|
+
overflow-wrap: anywhere;
|
|
67
|
+
}
|
|
68
|
+
.semics-payment h2 {
|
|
69
|
+
margin-block-start: 0;
|
|
70
|
+
}
|
|
71
|
+
.semics-payment[data-state="confirmed"] h2 {
|
|
72
|
+
color: var(--events-success, #146c2e);
|
|
73
|
+
}
|
|
74
|
+
.semics-payment-actions {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-wrap: wrap;
|
|
77
|
+
gap: 1rem;
|
|
78
|
+
align-items: center;
|
|
79
|
+
}
|
|
80
|
+
.semics-payment button,
|
|
81
|
+
.semics-payment-actions a {
|
|
82
|
+
font: inherit;
|
|
83
|
+
min-block-size: 2.75rem;
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
padding: 0.5rem 1rem;
|
|
87
|
+
}
|
|
88
|
+
.semics-visually-hidden {
|
|
89
|
+
position: absolute;
|
|
90
|
+
inline-size: 1px;
|
|
91
|
+
block-size: 1px;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
clip-path: inset(50%);
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
// <TicketPass>: one attendee's ticket with the check-in code as text (EU-FR-07). With Events Pro the
|
|
3
|
+
// core also sends the code's QR matrix (`qr`, T082), drawn here as an SVG for the door's camera; the
|
|
4
|
+
// text code stays for typing it in. The code is grouped in fours for reading aloud; screen readers
|
|
5
|
+
// get it character by character.
|
|
6
|
+
import { pickLocale, translator } from "../i18n/index";
|
|
7
|
+
import { qrPath } from "./lib/pass";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
name: string;
|
|
11
|
+
code: string;
|
|
12
|
+
ticket?: string;
|
|
13
|
+
event?: string;
|
|
14
|
+
status?: string;
|
|
15
|
+
/** `{ size, bits }` from Events Pro's `public/booking`; anything else draws no QR. */
|
|
16
|
+
qr?: unknown;
|
|
17
|
+
locale?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { name, code, ticket, event, status, qr } = Astro.props;
|
|
21
|
+
const { t, lang, dir } = translator(pickLocale(Astro.props.locale, Astro.currentLocale));
|
|
22
|
+
const statusText =
|
|
23
|
+
status === "pending" ? t("pass.status.pending") : status === "cancelled" ? t("pass.status.cancelled") : status;
|
|
24
|
+
const spoken = code.replace(/[^A-Za-z0-9]/g, "").split("").join(" ");
|
|
25
|
+
const matrix = qrPath(qr);
|
|
26
|
+
const box = matrix ? matrix.size + 8 : 0;
|
|
27
|
+
---
|
|
28
|
+
<article class="semics-events semics-ticket-pass" lang={lang} dir={dir} data-testid="ticket-pass" data-status={status}>
|
|
29
|
+
{event && <p class="semics-pass-event">{event}</p>}
|
|
30
|
+
<h3 class="semics-pass-name">{name}</h3>
|
|
31
|
+
{ticket && <p class="semics-pass-ticket">{ticket}</p>}
|
|
32
|
+
{matrix && (
|
|
33
|
+
<svg
|
|
34
|
+
class="semics-pass-qr"
|
|
35
|
+
data-testid="ticket-qr"
|
|
36
|
+
role="img"
|
|
37
|
+
aria-label={t("pass.qr")}
|
|
38
|
+
viewBox={`-4 -4 ${box} ${box}`}
|
|
39
|
+
shape-rendering="crispEdges"
|
|
40
|
+
>
|
|
41
|
+
<rect x="-4" y="-4" width={box} height={box} fill="#ffffff" />
|
|
42
|
+
<path d={matrix.d} fill="#000000" />
|
|
43
|
+
</svg>
|
|
44
|
+
)}
|
|
45
|
+
<p class="semics-pass-code-label">{t("pass.code")}</p>
|
|
46
|
+
<p class="semics-pass-code">
|
|
47
|
+
<span aria-hidden="true" data-testid="ticket-code">{code}</span>
|
|
48
|
+
<span class="semics-visually-hidden">{spoken}</span>
|
|
49
|
+
</p>
|
|
50
|
+
{status && status !== "valid" && <p class="semics-pass-status">{statusText}</p>}
|
|
51
|
+
</article>
|
|
52
|
+
|
|
53
|
+
<style>
|
|
54
|
+
.semics-ticket-pass {
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
max-inline-size: 24rem;
|
|
57
|
+
padding: 1rem;
|
|
58
|
+
border: 2px dashed var(--events-border, #6b6b6b);
|
|
59
|
+
border-radius: var(--events-radius, 6px);
|
|
60
|
+
background: var(--events-bg, #ffffff);
|
|
61
|
+
color: var(--events-fg, #1a1a1a);
|
|
62
|
+
overflow-wrap: anywhere;
|
|
63
|
+
}
|
|
64
|
+
.semics-ticket-pass p,
|
|
65
|
+
.semics-ticket-pass h3 {
|
|
66
|
+
margin: 0 0 0.25rem;
|
|
67
|
+
}
|
|
68
|
+
.semics-pass-event,
|
|
69
|
+
.semics-pass-ticket,
|
|
70
|
+
.semics-pass-code-label {
|
|
71
|
+
color: var(--events-muted, #4a4a4a);
|
|
72
|
+
}
|
|
73
|
+
/* Black on white in every theme: phone cameras read dark modules on a light ground. */
|
|
74
|
+
.semics-pass-qr {
|
|
75
|
+
display: block;
|
|
76
|
+
inline-size: min(100%, 14rem);
|
|
77
|
+
block-size: auto;
|
|
78
|
+
aspect-ratio: 1;
|
|
79
|
+
margin: 0.5rem 0;
|
|
80
|
+
}
|
|
81
|
+
.semics-pass-code {
|
|
82
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
83
|
+
font-size: 1.75rem;
|
|
84
|
+
letter-spacing: 0.1em;
|
|
85
|
+
font-weight: 700;
|
|
86
|
+
}
|
|
87
|
+
.semics-visually-hidden {
|
|
88
|
+
position: absolute;
|
|
89
|
+
inline-size: 1px;
|
|
90
|
+
block-size: 1px;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
clip-path: inset(50%);
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Injected at `/_events/checkout` by the integration. A plain form post (no JavaScript needed).
|
|
2
|
+
// Cross-site posts get a 403 before anything runs (`isCrossSiteRequest`, T057).
|
|
3
|
+
import { pluginId } from "virtual:semics-events/config";
|
|
4
|
+
|
|
5
|
+
import { type CheckoutEndpointContext, handleCheckoutRequest } from "./lib/checkout-form";
|
|
6
|
+
|
|
7
|
+
export const prerender = false;
|
|
8
|
+
|
|
9
|
+
export function POST(ctx: CheckoutEndpointContext): Promise<Response> {
|
|
10
|
+
return handleCheckoutRequest(ctx, { pluginId });
|
|
11
|
+
}
|