@semics-tech/emdash-events 1.0.0-rc.2 → 1.0.0-rc.22

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.
@@ -34,6 +34,8 @@ export interface PublicRouteError {
34
34
  message: string;
35
35
  /** Input validation issues, when the route reported them (`BAD_REQUEST`). */
36
36
  issues?: PublicRouteIssue[];
37
+ /** Any other top-level fields of the route's refusal, e.g. Vouchers' `lookups` (T166). */
38
+ details?: Record<string, unknown>;
37
39
  }
38
40
  export type PublicRouteResult<T> = {
39
41
  ok: true;
@@ -100,10 +100,12 @@ function refusal(data) {
100
100
  const body = data;
101
101
  if (body.ok !== false || typeof body.error?.code !== "string")
102
102
  return undefined;
103
+ const { ok: _ok, error: _error, issues: _issues, ...details } = body;
103
104
  return {
104
105
  code: body.error.code,
105
106
  message: typeof body.error.message === "string" ? body.error.message : "Request failed",
106
107
  ...(Array.isArray(body.issues) ? { issues: body.issues } : {}),
108
+ ...(Object.keys(details).length > 0 ? { details } : {}),
107
109
  };
108
110
  }
109
111
  function toResult(envelope, via) {
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
3
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
4
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
5
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
6
+ *
7
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
8
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
9
+ */
10
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
11
+ export declare const THEME_PROPERTIES: readonly ["fg", "muted", "bg", "border", "accent", "accent-fg", "error", "success", "radius", "font", "page-bg", "heading-font", "heading-fg"];
12
+ export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
13
+ export interface PageBrand {
14
+ /** The site's name: the link's text, or the logo's alternative text. Also the organiser at the page's foot. */
15
+ name: string;
16
+ /** Where it links, a path on this site (default `/`). */
17
+ href?: string;
18
+ /** A logo, a path on this site. */
19
+ logo?: string;
20
+ /** The organiser's postal address, one line, at the page's foot and on a printed booking (T157). */
21
+ address?: string;
22
+ }
23
+ export interface PageOptions {
24
+ /** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
25
+ theme?: Partial<Record<ThemeProperty, string>>;
26
+ /** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
27
+ stylesheet?: string;
28
+ /** The site's name or logo at the top of each page. */
29
+ brand?: PageBrand;
30
+ /** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
31
+ eventPath?: string;
32
+ }
33
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
34
+ export declare function checkPageOptions(page?: PageOptions): PageOptions;
35
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
36
+ export declare function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined;
37
+ /**
38
+ * Works with no site theme at all. Zero specificity on elements, so the components' own rules win; except the card
39
+ * rule for `main`'s sections, which outranks a component's own box (`.semics-payment`, `.semics-attendee-list`) so
40
+ * every card has the same edges, width and look (T158).
41
+ */
42
+ export declare const PAGE_CSS = "*,*::before,*::after{box-sizing:border-box}\nhtml{color-scheme:light;-webkit-text-size-adjust:100%}\nbody.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;\n--esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px);--esign-font:var(--events-font, system-ui, sans-serif)}\n.semics-page-brand{max-inline-size:40rem;margin-inline:auto;padding:1.25rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}\n.semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}\n.semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}\n.semics-page-main{max-inline-size:40rem;margin-inline:auto;padding:1.5rem 1rem 2rem}\n:where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}\n:where(.semics-page) h1{margin-block-end:1.25rem;font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}\n:where(.semics-page) h2{font-size:1.25rem}\n:where(.semics-page) h3{font-size:1.0625rem}\n:where(.semics-page) p{margin:0 0 .75rem}\n:where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}\n:where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}\n.semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){margin-block:0 1.25rem;padding:clamp(1.25rem,.9rem + 1.8vw,1.75rem);background:var(--events-bg, #ffffff);border:1px solid color-mix(in srgb,var(--events-border, #6b6b6b) 30%,transparent);border-radius:calc(var(--events-radius, 6px) + 6px);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 6px 24px rgb(0 0 0 / .05);max-inline-size:none}\n:where(.semics-page-main > section,.semics-page-main > form,.semics-page-main > .semics-ceremony) > :last-child{margin-block-end:0}\n:where(.semics-page) [role=\"alert\"]{padding:.75rem 1rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}\n:where(.semics-page) :is(input:not([type=\"checkbox\"],[type=\"radio\"],[type=\"hidden\"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}\n:where(.semics-page) label{display:block}\n:where(.semics-page) fieldset{min-inline-size:0;margin:0 0 1rem;padding:0;border:0}\n:where(.semics-page) legend{padding:0;margin-block-end:.5rem;font-weight:600}\n:where(.semics-page) button{font:inherit;font-weight:600;min-block-size:2.75rem;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}\n:where(.semics-page) a.semics-page-button{display:inline-block;font-weight:600;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);text-decoration:none}\n.semics-page-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1.25rem;margin-block:0 1.25rem}\n.semics-page-actions .semics-print{background:transparent;color:var(--events-accent, #0b57d0)}\n.semics-page-organiser{max-inline-size:40rem;margin-inline:auto;padding:0 1rem 3rem;color:var(--events-muted, #4a4a4a);font-size:.9375rem}\n.semics-page-organiser p{margin:0}\n.semics-page-organiser address{font-style:normal}\n@media print{\n@page{margin:15mm}\nbody.semics-page{min-block-size:0;background:#ffffff;color:#000000;font-size:11pt}\n.semics-page-brand,.semics-page-actions,.semics-page-main form,.semics-page-main button,.semics-page-main details,.semics-add-to-calendar,[data-semics-payment-live]{display:none !important}\n.semics-page-main{max-inline-size:none;padding:0}\n.semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){box-shadow:none;border-color:#999999;break-inside:avoid}\n.semics-ticket-pass{break-inside:avoid}\n.semics-page-organiser{max-inline-size:none;padding:1rem 0 0;color:#000000}\n}\n";
43
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
44
+ export declare function pageCss(page?: PageOptions): string;
@@ -0,0 +1,123 @@
1
+ // i18n-ignore-file: a stylesheet and its option names, no text for people.
2
+ /**
3
+ * The look of the plugins' own full pages (`/booking`, the suite's `/_events/waiver`), which run outside the
4
+ * site's layout: a default stylesheet built only on the `--events-*` properties, and what a site sets through
5
+ * `eventsIntegration({ page })` / `eventsSuite({ page })`. It is one exact string so the signing page can allow
6
+ * it by hash (its CSP allows nothing else inline, `ceremonyCsp`). Web APIs only (R35).
7
+ *
8
+ * The site's own layout is deliberately not wrapped around these pages: an emailed link's one-time code is in the
9
+ * URL here, and a signing page's CSP would block the layout's scripts and styles anyway.
10
+ */
11
+ /** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
12
+ export const THEME_PROPERTIES = [
13
+ "fg",
14
+ "muted",
15
+ "bg",
16
+ "border",
17
+ "accent",
18
+ "accent-fg",
19
+ "error",
20
+ "success",
21
+ "radius",
22
+ "font",
23
+ "page-bg",
24
+ "heading-font",
25
+ "heading-fg",
26
+ ];
27
+ /** One line of text for people: 1 to 300 characters, no control characters (line breaks included). */
28
+ function oneLine(value) {
29
+ if (typeof value !== "string" || !value.trim() || value.length > 300)
30
+ return false;
31
+ for (let i = 0; i < value.length; i++) {
32
+ const unit = value.charCodeAt(i);
33
+ if (unit <= 0x1f || unit === 0x7f)
34
+ return false;
35
+ }
36
+ return true;
37
+ }
38
+ /** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
39
+ const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
40
+ /** A path on this site; `;` and `,` would end a source in the signing page's CSP header. */
41
+ const SITE_PATH = /^\/(?!\/)[^\s"'<>\\;,]*$/;
42
+ /** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
43
+ export function checkPageOptions(page = {}) {
44
+ const refuse = (what) => {
45
+ throw new Error(`page.${what} is not valid`); // i18n-ignore
46
+ };
47
+ for (const [name, value] of Object.entries(page.theme ?? {})) {
48
+ const known = THEME_PROPERTIES.includes(name);
49
+ if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
50
+ refuse(`theme.${name}`);
51
+ }
52
+ const { brand, stylesheet, eventPath } = page;
53
+ if (stylesheet !== undefined && !SITE_PATH.test(stylesheet))
54
+ refuse("stylesheet");
55
+ if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}")))
56
+ refuse("eventPath");
57
+ if (brand) {
58
+ if (typeof brand.name !== "string" || !brand.name.trim())
59
+ refuse("brand.name");
60
+ if (brand.href !== undefined && !SITE_PATH.test(brand.href))
61
+ refuse("brand.href");
62
+ if (brand.logo !== undefined && !SITE_PATH.test(brand.logo))
63
+ refuse("brand.logo");
64
+ if (brand.address !== undefined && !oneLine(brand.address))
65
+ refuse("brand.address");
66
+ }
67
+ return page;
68
+ }
69
+ /** The event's page for "Book again"; undefined when the booking does not know its slug. */
70
+ export function eventPageHref(slug, eventPath) {
71
+ return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
72
+ }
73
+ /**
74
+ * Works with no site theme at all. Zero specificity on elements, so the components' own rules win; except the card
75
+ * rule for `main`'s sections, which outranks a component's own box (`.semics-payment`, `.semics-attendee-list`) so
76
+ * every card has the same edges, width and look (T158).
77
+ */
78
+ export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
79
+ html{color-scheme:light;-webkit-text-size-adjust:100%}
80
+ body.semics-page{margin:0;min-block-size:100vh;background:var(--events-page-bg, #f5f4f0);color:var(--events-fg, #1a1a1a);font-family:var(--events-font, system-ui, sans-serif);font-size:1.0625rem;line-height:1.55;overflow-wrap:anywhere;
81
+ --esign-fg:var(--events-fg, #1a1a1a);--esign-muted:var(--events-muted, #4a4a4a);--esign-bg:var(--events-bg, #ffffff);--esign-border:var(--events-border, #6b6b6b);--esign-accent:var(--events-accent, #0b57d0);--esign-accent-fg:var(--events-accent-fg, #ffffff);--esign-error:var(--events-error, #b3261e);--esign-radius:var(--events-radius, 6px);--esign-font:var(--events-font, system-ui, sans-serif)}
82
+ .semics-page-brand{max-inline-size:40rem;margin-inline:auto;padding:1.25rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
83
+ .semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
84
+ .semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
85
+ .semics-page-main{max-inline-size:40rem;margin-inline:auto;padding:1.5rem 1rem 2rem}
86
+ :where(.semics-page) :is(h1,h2,h3){margin:0 0 .75rem;font-family:var(--events-heading-font, inherit);color:var(--events-heading-fg, inherit);line-height:1.2}
87
+ :where(.semics-page) h1{margin-block-end:1.25rem;font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
88
+ :where(.semics-page) h2{font-size:1.25rem}
89
+ :where(.semics-page) h3{font-size:1.0625rem}
90
+ :where(.semics-page) p{margin:0 0 .75rem}
91
+ :where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
92
+ :where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
93
+ .semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){margin-block:0 1.25rem;padding:clamp(1.25rem,.9rem + 1.8vw,1.75rem);background:var(--events-bg, #ffffff);border:1px solid color-mix(in srgb,var(--events-border, #6b6b6b) 30%,transparent);border-radius:calc(var(--events-radius, 6px) + 6px);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 6px 24px rgb(0 0 0 / .05);max-inline-size:none}
94
+ :where(.semics-page-main > section,.semics-page-main > form,.semics-page-main > .semics-ceremony) > :last-child{margin-block-end:0}
95
+ :where(.semics-page) [role="alert"]{padding:.75rem 1rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
96
+ :where(.semics-page) :is(input:not([type="checkbox"],[type="radio"],[type="hidden"]),select,textarea){font:inherit;inline-size:100%;min-block-size:2.75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
97
+ :where(.semics-page) label{display:block}
98
+ :where(.semics-page) fieldset{min-inline-size:0;margin:0 0 1rem;padding:0;border:0}
99
+ :where(.semics-page) legend{padding:0;margin-block-end:.5rem;font-weight:600}
100
+ :where(.semics-page) button{font:inherit;font-weight:600;min-block-size:2.75rem;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
101
+ :where(.semics-page) a.semics-page-button{display:inline-block;font-weight:600;padding:.625rem 1.25rem;border:1px solid var(--events-accent, #0b57d0);border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);text-decoration:none}
102
+ .semics-page-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem 1.25rem;margin-block:0 1.25rem}
103
+ .semics-page-actions .semics-print{background:transparent;color:var(--events-accent, #0b57d0)}
104
+ .semics-page-organiser{max-inline-size:40rem;margin-inline:auto;padding:0 1rem 3rem;color:var(--events-muted, #4a4a4a);font-size:.9375rem}
105
+ .semics-page-organiser p{margin:0}
106
+ .semics-page-organiser address{font-style:normal}
107
+ @media print{
108
+ @page{margin:15mm}
109
+ body.semics-page{min-block-size:0;background:#ffffff;color:#000000;font-size:11pt}
110
+ .semics-page-brand,.semics-page-actions,.semics-page-main form,.semics-page-main button,.semics-page-main details,.semics-add-to-calendar,[data-semics-payment-live]{display:none !important}
111
+ .semics-page-main{max-inline-size:none;padding:0}
112
+ .semics-page-main > :is(section,form:not([hidden]),.semics-ceremony){box-shadow:none;border-color:#999999;break-inside:avoid}
113
+ .semics-ticket-pass{break-inside:avoid}
114
+ .semics-page-organiser{max-inline-size:none;padding:1rem 0 0;color:#000000}
115
+ }
116
+ `;
117
+ /** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
118
+ export function pageCss(page = {}) {
119
+ const set = Object.entries(page.theme ?? {});
120
+ if (set.length === 0)
121
+ return PAGE_CSS;
122
+ return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
123
+ }
@@ -1,3 +1,6 @@
1
+ import { type PageOptions } from "../astro/lib/page.ts";
2
+ export { PAGE_CSS, pageCss } from "../astro/lib/page.ts";
3
+ export type { PageOptions };
1
4
  export interface EventsIntegrationOptions {
2
5
  /**
3
6
  * The sandboxed core's plugin id. Defaults to the slug (`semics-events`, npm installs).
@@ -15,6 +18,16 @@ export interface EventsIntegrationOptions {
15
18
  * for a booking waiting for signatures (the suite passes its own, T066). Without it nothing is reconciled.
16
19
  */
17
20
  reconcile?: string;
21
+ /** How the plugin's own pages look on this site: theme, stylesheet, brand, event page path (`PageOptions`). */
22
+ page?: PageOptions;
23
+ /**
24
+ * Gift vouchers (T166): the Vouchers core's plugin id and a module exporting `holdVoucher(ctx, input, ids)`
25
+ * (the suite passes its own). The checkout then holds a typed "Gift voucher code" between reserve and continue.
26
+ */
27
+ vouchers?: {
28
+ pluginId: string;
29
+ module: string;
30
+ };
18
31
  }
19
32
  /** The slice of Astro's integration API this needs (so the package takes no `astro` dependency). */
20
33
  interface SetupArgs {
@@ -1,4 +1,7 @@
1
1
  import { EVENTS_PLUGIN_ID } from "../astro/lib/call.js";
2
+ import { checkPageOptions } from "../astro/lib/page.js";
3
+ // The page sheet itself, so the suite can hand e-sign's pages the same look (T169).
4
+ export { PAGE_CSS, pageCss } from "../astro/lib/page.js";
2
5
  const VIRTUAL = "virtual:semics-events/config";
3
6
  const RESOLVED = `\0${VIRTUAL}`;
4
7
  /**
@@ -14,10 +17,20 @@ export function eventsIntegration(options = {}) {
14
17
  const pluginId = options.pluginId ?? EVENTS_PLUGIN_ID;
15
18
  const config = [
16
19
  `export const pluginId = ${JSON.stringify(pluginId)};`,
20
+ `export const page = ${JSON.stringify(checkPageOptions(options.page))};`,
17
21
  `export const esignPluginId = ${JSON.stringify(options.esignPluginId ?? null)};`,
18
22
  options.reconcile
19
23
  ? `export { reconcileBooking as reconcile } from ${JSON.stringify(options.reconcile)};`
20
24
  : "export const reconcile = null;",
25
+ // Only with vouchers: a site without them gets exactly the config it had (pages read these by namespace).
26
+ ...(options.vouchers
27
+ ? [
28
+ `export const vouchersPluginId = ${JSON.stringify(options.vouchers.pluginId)};`,
29
+ `export { holdVoucher } from ${JSON.stringify(options.vouchers.module)};`,
30
+ // T168: the module's dry run, run before reserving.
31
+ `export { checkVoucher } from ${JSON.stringify(options.vouchers.module)};`,
32
+ ]
33
+ : []),
21
34
  ].join("\n");
22
35
  return {
23
36
  name: "semics-events",
@@ -189,6 +189,11 @@
189
189
  "label": "Stripe webhook signing secret (Pro)",
190
190
  "description": "Used by Events Pro only, for paid tickets; the Free edition ignores it. Stored encrypted."
191
191
  },
192
+ "vouchersPairing": {
193
+ "type": "secret",
194
+ "label": "Vouchers pairing string (Pro)",
195
+ "description": "Used by Events Pro only, for gift vouchers; the Free edition ignores it. Stored encrypted."
196
+ },
192
197
  "retentionDays": {
193
198
  "type": "number",
194
199
  "label": "Keep booking data (days)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semics-tech/emdash-events",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.22",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
@@ -25,6 +25,9 @@
25
25
  "./i18n": "./src/i18n/index.ts",
26
26
  "./client/*": "./src/client/*.ts",
27
27
  "./astro/BookingPage.astro": "./src/astro/BookingPage.astro",
28
+ "./astro/PageBrand.astro": "./src/astro/PageBrand.astro",
29
+ "./astro/PageOrganiser.astro": "./src/astro/PageOrganiser.astro",
30
+ "./astro/CancelBooking.astro": "./src/astro/CancelBooking.astro",
28
31
  "./astro/DoorSignPage.astro": "./src/astro/DoorSignPage.astro",
29
32
  "./astro/CheckIn.astro": "./src/astro/CheckIn.astro",
30
33
  "./astro/OptOutPage.astro": "./src/astro/OptOutPage.astro",
@@ -34,6 +37,7 @@
34
37
  "./astro/EventCard.astro": "./src/astro/EventCard.astro",
35
38
  "./astro/BookingStatus.astro": "./src/astro/BookingStatus.astro",
36
39
  "./astro/PaymentReturn.astro": "./src/astro/PaymentReturn.astro",
40
+ "./astro/AttendeeList.astro": "./src/astro/AttendeeList.astro",
37
41
  "./astro/TicketPass.astro": "./src/astro/TicketPass.astro",
38
42
  "./astro/AddToCalendar.astro": "./src/astro/AddToCalendar.astro"
39
43
  },
@@ -55,7 +59,7 @@
55
59
  "typescript": "^5.9.0",
56
60
  "vitest": "^4.1.12",
57
61
  "zod": "4.6.5",
58
- "@semics-tech/shared": "0.1.0-rc.1"
62
+ "@semics-tech/shared": "0.1.0-rc.2"
59
63
  },
60
64
  "description": "Events bookings and ticketing for EmDash",
61
65
  "license": "MIT",
@@ -3,9 +3,11 @@
3
3
  // by the `/booking` page only when Events Pro's `public/booking` carries a signing list. Every button
4
4
  // is a plain form POST back to the page (no JavaScript): Sign now opens that attendee's signing on
5
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`.
6
+ // and emails of attendees who have not signed, until the cutoff. Rows come from `signingRows`. A booking request
7
+ // (T174e, `minors`) was booked without names: unnamed rows ask for one, and each seat can be marked under 18.
7
8
  import { around, pickLocale, translator } from "../i18n/index";
8
9
  import type { SigningRow } from "./lib/attendees";
10
+ import { zonedAt } from "./lib/list";
9
11
 
10
12
  interface Props {
11
13
  rows: SigningRow[];
@@ -13,25 +15,22 @@ interface Props {
13
15
  action: string;
14
16
  /** While names may be changed: the deadline (ISO). */
15
17
  editUntil?: string;
18
+ /** The event's time zone, for that deadline. */
19
+ zone?: string | null;
16
20
  locale?: string;
21
+ /** A waiver after payment (T160): a seat not signed reads "Waiver pending" (else "Waiting"). */
22
+ pending?: boolean;
23
+ /** A booking request (T174e): the edit form also asks whether each person is under 18. */
24
+ minors?: boolean;
17
25
  }
18
26
 
19
- const { rows, action, editUntil } = Astro.props;
27
+ const { rows, action, editUntil, zone, pending, minors } = Astro.props;
20
28
  const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
21
29
  const { t, lang, dir } = translator(locale);
22
30
  const editable = rows.filter((r) => r.canEdit);
23
31
  const [untilBefore, untilAfter] = around(t("booking.attendees.editUntil"), "time");
24
32
  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
- };
33
+ const at = (iso: string) => zonedAt(iso, zone, locale);
35
34
  ---
36
35
  <section class="semics-events semics-attendee-list" data-testid="attendee-list" lang={lang} dir={dir} aria-labelledby="semics-attendees-title">
37
36
  <h2 id="semics-attendees-title">{t("booking.attendees.title")}</h2>
@@ -40,8 +39,9 @@ const at = (iso: string) => {
40
39
  rows.map((row) => (
41
40
  <li data-testid="attendee-row" data-seat={row.seat} data-signing={row.signed ? "signed" : "waiting"}>
42
41
  <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>
42
+ <span class="semics-status-badge">{row.signed ? t("booking.attendees.signed") : t(pending ? "booking.attendees.pending" : "booking.attendees.waiting")}</span>
44
43
  {row.minor && <p class="semics-attendee-note">{t("booking.attendees.minor")}</p>}
44
+ {row.unnamed && <p class="semics-attendee-note" data-testid="attendee-unnamed">{t("booking.attendees.unnamed")}</p>}
45
45
  {row.canResend && row.email && (
46
46
  <p class="semics-attendee-note">
47
47
  {emailedBefore}<span>{row.email}</span>{emailedAfter}
@@ -73,6 +73,7 @@ const at = (iso: string) => {
73
73
  ))
74
74
  }
75
75
  </ul>
76
+ {rows.some((r) => r.canResend) && <p class="semics-attendee-note" data-testid="attendee-not-arrived">{t("booking.attendees.notArrived")}</p>}
76
77
  {
77
78
  editable.length > 0 && (
78
79
  <form method="post" action={action} class="semics-attendee-edit" data-testid="attendee-edit">
@@ -88,11 +89,22 @@ const at = (iso: string) => {
88
89
  <legend>{row.name}</legend>
89
90
  <label for={`semics-attendee-name-${row.seat}`}>{t("booking.attendees.name")}</label>
90
91
  <input id={`semics-attendee-name-${row.seat}`} name={`name:${row.seat}`} value={row.name} required maxlength={200} autocomplete="off" />
91
- {!row.minor && (
92
+ {minors ? (
92
93
  <>
93
94
  <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
+ <input id={`semics-attendee-email-${row.seat}`} name={`email:${row.seat}`} type="email" value={row.email} maxlength={254} autocomplete="off" />
96
+ <span class="semics-attendee-minor">
97
+ <input id={`semics-attendee-minor-${row.seat}`} name={`minor:${row.seat}`} type="checkbox" checked={row.minor} />
98
+ <label for={`semics-attendee-minor-${row.seat}`}>{t("booking.attendees.under18")}</label>
99
+ </span>
95
100
  </>
101
+ ) : (
102
+ !row.minor && (
103
+ <>
104
+ <label for={`semics-attendee-email-${row.seat}`}>{t("booking.attendees.email")}</label>
105
+ <input id={`semics-attendee-email-${row.seat}`} name={`email:${row.seat}`} type="email" value={row.email} required maxlength={254} autocomplete="off" />
106
+ </>
107
+ )
96
108
  )}
97
109
  </fieldset>
98
110
  ))}
@@ -154,4 +166,13 @@ const at = (iso: string) => {
154
166
  inline-size: 100%;
155
167
  padding: 0.25rem 0.5rem;
156
168
  }
169
+ .semics-attendee-minor {
170
+ display: flex;
171
+ align-items: center;
172
+ gap: 0.5rem;
173
+ }
174
+ .semics-attendee-edit .semics-attendee-minor input {
175
+ inline-size: 1.5rem;
176
+ min-block-size: 1.5rem;
177
+ }
157
178
  </style>
@@ -8,11 +8,14 @@
8
8
  // `src/client/receipt.ts` clears the fragment and posts the receipt here, which forwards it to the
9
9
  // core's `signatures/receipt` (no access token needed: the receipt is HMAC-signed) and redirects to
10
10
  // `?ref=&waiver=<outcome>`.
11
- import { esignPluginId, pluginId, reconcile } from "virtual:semics-events/config";
11
+ import * as config from "virtual:semics-events/config";
12
12
 
13
13
  import { type MessageKey, pickLocale, translator } from "../i18n/index";
14
14
  import AddToCalendar from "./AddToCalendar.astro";
15
15
  import BookingStatus from "./BookingStatus.astro";
16
+ import CancelBooking from "./CancelBooking.astro";
17
+ import PageBrand from "./PageBrand.astro";
18
+ import PageOrganiser from "./PageOrganiser.astro";
16
19
  import PaymentReturn from "./PaymentReturn.astro";
17
20
  import { callPublicRoute } from "./lib/call";
18
21
  import {
@@ -27,14 +30,20 @@ import {
27
30
  resumePayment,
28
31
  } from "./lib/checkout-form";
29
32
  import AttendeeList from "./AttendeeList.astro";
30
- import { handleAttendeeAction, signingRows } from "./lib/attendees";
33
+ import { handleAttendeeAction, signingRows, waiverStep } from "./lib/attendees";
34
+ import { VOUCHER_COOKIE } from "./lib/book-link";
35
+ import { eventPageHref, pageCss } from "./lib/page";
31
36
  import { paymentView } from "./lib/payment";
32
37
  import { forwardReceipt } from "./lib/receipt";
33
- import { type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
38
+ import { asOfNow, type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
34
39
  import TicketPass from "./TicketPass.astro";
35
40
 
36
41
  export const prerender = false;
37
42
 
43
+ const { esignPluginId, page, pluginId, reconcile } = config;
44
+ // Gift vouchers (T166): exported only when the site wires Vouchers, so read through the namespace.
45
+ const vouchersPluginId = (config as Partial<typeof config>).vouchersPluginId;
46
+
38
47
  Astro.response.headers.set("Referrer-Policy", "no-referrer");
39
48
  Astro.response.headers.set("Cache-Control", "private, no-store");
40
49
 
@@ -62,7 +71,7 @@ const CODES = [
62
71
  "ESIGN_NOT_CONFIGURED",
63
72
  ];
64
73
  const WAIVER_OUTCOMES = ["signed", "declined", "voided", "expired", "failed"];
65
- const ATTENDEE_OUTCOMES = ["saved", "resent"];
74
+ const ATTENDEE_OUTCOMES = ["saved", "resent", "invited"];
66
75
  const errorText = (code: string, fallback: MessageKey) =>
67
76
  CODES.includes(code) ? t(`booking.error.${code}` as MessageKey) : t(fallback);
68
77
 
@@ -113,6 +122,20 @@ const token = ref && !opening ? (Astro.cookies.get(bookingCookieName(ref))?.valu
113
122
 
114
123
  let cancelled = false;
115
124
  if (ref && token && form) {
125
+ // Another time the organiser proposed (Events Pro, T174c): accepted, or "That doesn't work" (cancelled and refunded).
126
+ const answer = form.get("intent");
127
+ if (answer === "accept-time" || answer === "refuse-time") {
128
+ const accept = answer === "accept-time";
129
+ const result = await callPublicRoute(ctx, {
130
+ method: "POST",
131
+ path: `public/booking/request/${accept ? "accept" : "refuse"}`,
132
+ pluginId,
133
+ body: { bookingRef: ref, accessToken: token },
134
+ });
135
+ notice = result.ok
136
+ ? t(accept ? "booking.proposal.accepted" : "booking.proposal.refused")
137
+ : errorText(result.error.code, "booking.proposal.failed");
138
+ }
116
139
  if (form.get("intent") === "cancel") {
117
140
  const result = await callPublicRoute(ctx, {
118
141
  method: "POST",
@@ -140,7 +163,12 @@ if (ref && token) {
140
163
  // closed the tab or signed by email has a receipt this page forwards, then it shows the booking afresh.
141
164
  // An ended booking's open envelopes are voided the same way (Pro's void intents, T152).
142
165
  if (reconcileWanted(booking) && reconcile && esignPluginId) {
143
- const done = await reconcile(ctx, { booking, pluginId, esignPluginId });
166
+ const done = await reconcile(ctx, {
167
+ booking,
168
+ pluginId,
169
+ esignPluginId,
170
+ ...(vouchersPluginId ? { vouchersPluginId } : {}),
171
+ });
144
172
  if (done.forwarded > 0) {
145
173
  const fresh = await callPublicRoute<BookingView>(ctx, {
146
174
  method: "POST",
@@ -154,6 +182,9 @@ if (ref && token) {
154
182
  } else if (ref && !opening) {
155
183
  missing = true;
156
184
  }
185
+ if (booking) booking = asOfNow(booking, Date.now());
186
+ // T171: a booking that used a gift voucher forgets the code "Book with this voucher" left for the form.
187
+ if ((booking?.totals?.voucherMinor ?? 0) > 0) Astro.cookies.delete(VOUCHER_COOKIE, { path: "/" });
157
188
  // The attendee signing list's forms (T133): Sign now, Resend and Save, against the fresh answer.
158
189
  if (booking && form && ref && token) {
159
190
  const done = await handleAttendeeAction(ctx, form, { ref, token }, { pluginId, esignPluginId }, booking);
@@ -166,8 +197,11 @@ if (booking?.eventId) {
166
197
  if (event.ok) names = ticketNames(event.data);
167
198
  }
168
199
  const signingList = booking && !cancelled ? signingRows(booking) : null;
200
+ // A waiver that comes after payment (Events Pro, T160): the signing step leads the page while seats wait.
201
+ const waiverNext = booking && !cancelled ? waiverStep(booking) : null;
169
202
  const payment = booking && !cancelled ? paymentView(booking, locale) : null;
170
- const passes = booking && !cancelled && booking.status === "confirmed" ? booking.attendees.filter((a) => a.code) : [];
203
+ const confirmed = Boolean(booking && !cancelled && booking.status === "confirmed");
204
+ const passes = booking && confirmed ? booking.attendees.filter((a) => a.code) : [];
171
205
  ---
172
206
  <!doctype html>
173
207
  <html lang={lang} dir={dir}>
@@ -177,9 +211,12 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
177
211
  <meta name="robots" content="noindex" />
178
212
  <meta name="referrer" content="no-referrer" />
179
213
  <title>{t("booking.title")}</title>
214
+ <style is:inline set:html={pageCss(page)}></style>
215
+ {page.stylesheet && <link rel="stylesheet" href={page.stylesheet} />}
180
216
  </head>
181
- <body>
182
- <main class="semics-booking" data-testid="booking-page">
217
+ <body class="semics-page">
218
+ <PageBrand brand={page.brand} />
219
+ <main class="semics-booking semics-page-main" data-testid="booking-page">
183
220
  <h1>{t("booking.title")}</h1>
184
221
  <form method="post" action={ref ? `/booking?ref=${ref}` : "/booking"} data-semics-fragment="receipt" hidden>
185
222
  <input type="hidden" name="intent" value="receipt" />
@@ -196,14 +233,28 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
196
233
  </form>
197
234
  ) : booking ? (
198
235
  <>
199
- <BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} locale={locale} />
236
+ <BookingStatus booking={booking} cancelled={cancelled} proposalAction={`/booking?ref=${ref}`} ticketNames={names} bookAgain={eventPageHref(booking.event?.slug, page.eventPath)} showAttendees={!signingList} locale={locale} />
200
237
  {payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
238
+ {waiverNext && (
239
+ <section class="semics-events semics-waiver-step" data-testid="waiver-step" aria-labelledby="semics-waiver-step-title">
240
+ <h2 id="semics-waiver-step-title">{t("booking.waiverStep.title")}</h2>
241
+ <p>{t("booking.waiverStep.lead")}</p>
242
+ {waiverNext.invite && <p>{t("booking.waiverStep.emailed")}</p>}
243
+ <form method="post" action={`/booking?ref=${ref}`}>
244
+ <input type="hidden" name="intent" value="sign-waiver" />
245
+ <button type="submit" data-testid="waiver-step-sign">{waiverNext.sign ? t("booking.waiverStep.sign") : t("booking.waiverStep.invite")}</button>
246
+ </form>
247
+ </section>
248
+ )}
201
249
  {signingList && (
202
250
  <AttendeeList
203
251
  rows={signingList}
204
252
  action={`/booking?ref=${ref}`}
205
253
  editUntil={booking.signingList?.editable ? booking.signingList.editUntil : undefined}
254
+ zone={booking.event?.timezone}
206
255
  locale={locale}
256
+ pending={booking.waiverAfter === true}
257
+ minors={booking.signingList?.minors === true}
207
258
  />
208
259
  )}
209
260
  {passes.length > 0 && (
@@ -214,7 +265,15 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
214
265
  ))}
215
266
  </section>
216
267
  )}
217
- {!cancelled && booking.status === "confirmed" && <AddToCalendar signedQuery={booking.calendar?.query} locale={locale} />}
268
+ {confirmed && (
269
+ <div class="semics-page-actions" data-testid="booking-actions">
270
+ <AddToCalendar signedQuery={booking.calendar?.query} locale={locale} />
271
+ <button type="button" class="semics-print" data-print data-testid="booking-print" hidden>{t("booking.print")}</button>
272
+ </div>
273
+ )}
274
+ {booking.canCancel && !cancelled && (
275
+ <CancelBooking action={`/booking?ref=${ref}`} cancelBy={booking.cancelBy} zone={booking.event?.timezone} locale={locale} />
276
+ )}
218
277
  </>
219
278
  ) : missing ? (
220
279
  <p data-testid="booking-missing">{t("booking.missing")}</p>
@@ -223,9 +282,12 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
223
282
  ) : null
224
283
  }
225
284
  </main>
285
+ <PageOrganiser brand={page.brand} locale={locale} />
226
286
  <script>
227
287
  import "../client/receipt.ts";
228
288
  import "../client/payment.ts";
289
+ import "../client/forget-form.ts";
290
+ import "../client/print.ts";
229
291
  </script>
230
292
  </body>
231
293
  </html>