@semics-tech/emdash-events 1.0.0-rc.4 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/manifest.json +1 -1
- package/dist/plugin.mjs +6 -6
- package/dist/ts/astro/lib/page.d.ts +38 -0
- package/dist/ts/astro/lib/page.js +89 -0
- package/dist/ts/integration/index.d.ts +4 -0
- package/dist/ts/integration/index.js +2 -0
- package/package.json +2 -1
- package/src/astro/AttendeeList.astro +6 -11
- package/src/astro/BookingPage.astro +13 -5
- package/src/astro/BookingStatus.astro +9 -12
- package/src/astro/PageBrand.astro +18 -0
- package/src/astro/lib/attendees.ts +2 -2
- package/src/astro/lib/list.ts +27 -0
- package/src/astro/lib/page.ts +109 -0
- package/src/astro/lib/payment.ts +6 -10
- package/src/astro/lib/widget.ts +43 -0
- package/src/astro/virtual.d.ts +2 -0
- package/src/client/forget-form.ts +16 -0
- package/src/i18n/ar.ts +10 -1
- package/src/i18n/en.ts +10 -1
|
@@ -0,0 +1,38 @@
|
|
|
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. */
|
|
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
|
+
}
|
|
21
|
+
export interface PageOptions {
|
|
22
|
+
/** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
|
|
23
|
+
theme?: Partial<Record<ThemeProperty, string>>;
|
|
24
|
+
/** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
|
|
25
|
+
stylesheet?: string;
|
|
26
|
+
/** The site's name or logo at the top of each page. */
|
|
27
|
+
brand?: PageBrand;
|
|
28
|
+
/** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
|
|
29
|
+
eventPath?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
|
|
32
|
+
export declare function checkPageOptions(page?: PageOptions): PageOptions;
|
|
33
|
+
/** The event's page for "Book again"; undefined when the booking does not know its slug. */
|
|
34
|
+
export declare function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined;
|
|
35
|
+
/** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
|
|
36
|
+
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:38rem;margin-inline:auto;padding:1rem 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:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}\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{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:where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}\n:where(.semics-page) [role=\"alert\"]{padding:.5rem .75rem;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:.375rem .5rem;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 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}\n:where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}\n";
|
|
37
|
+
/** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
|
|
38
|
+
export declare function pageCss(page?: PageOptions): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 CSS, nothing that could end the declaration, the rule or the `<style>` element. */
|
|
28
|
+
const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
|
|
29
|
+
/** A path on this site; `;` and `,` would end a source in the signing page's CSP header. */
|
|
30
|
+
const SITE_PATH = /^\/(?!\/)[^\s"'<>\\;,]*$/;
|
|
31
|
+
/** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
|
|
32
|
+
export function checkPageOptions(page = {}) {
|
|
33
|
+
const refuse = (what) => {
|
|
34
|
+
throw new Error(`page.${what} is not valid`); // i18n-ignore
|
|
35
|
+
};
|
|
36
|
+
for (const [name, value] of Object.entries(page.theme ?? {})) {
|
|
37
|
+
const known = THEME_PROPERTIES.includes(name);
|
|
38
|
+
if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
|
|
39
|
+
refuse(`theme.${name}`);
|
|
40
|
+
}
|
|
41
|
+
const { brand, stylesheet, eventPath } = page;
|
|
42
|
+
if (stylesheet !== undefined && !SITE_PATH.test(stylesheet))
|
|
43
|
+
refuse("stylesheet");
|
|
44
|
+
if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}")))
|
|
45
|
+
refuse("eventPath");
|
|
46
|
+
if (brand) {
|
|
47
|
+
if (typeof brand.name !== "string" || !brand.name.trim())
|
|
48
|
+
refuse("brand.name");
|
|
49
|
+
if (brand.href !== undefined && !SITE_PATH.test(brand.href))
|
|
50
|
+
refuse("brand.href");
|
|
51
|
+
if (brand.logo !== undefined && !SITE_PATH.test(brand.logo))
|
|
52
|
+
refuse("brand.logo");
|
|
53
|
+
}
|
|
54
|
+
return page;
|
|
55
|
+
}
|
|
56
|
+
/** The event's page for "Book again"; undefined when the booking does not know its slug. */
|
|
57
|
+
export function eventPageHref(slug, eventPath) {
|
|
58
|
+
return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
|
|
61
|
+
export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
|
|
62
|
+
html{color-scheme:light;-webkit-text-size-adjust:100%}
|
|
63
|
+
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;
|
|
64
|
+
--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)}
|
|
65
|
+
.semics-page-brand{max-inline-size:38rem;margin-inline:auto;padding:1rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
|
|
66
|
+
.semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
|
|
67
|
+
.semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
|
|
68
|
+
.semics-page-main{max-inline-size:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}
|
|
69
|
+
: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}
|
|
70
|
+
:where(.semics-page) h1{font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
|
|
71
|
+
:where(.semics-page) h2{font-size:1.25rem}
|
|
72
|
+
:where(.semics-page) h3{font-size:1.0625rem}
|
|
73
|
+
:where(.semics-page) p{margin:0 0 .75rem}
|
|
74
|
+
:where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
|
|
75
|
+
:where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
|
|
76
|
+
:where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}
|
|
77
|
+
:where(.semics-page) [role="alert"]{padding:.5rem .75rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
|
|
78
|
+
: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:.375rem .5rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
|
|
79
|
+
:where(.semics-page) label{display:block}
|
|
80
|
+
:where(.semics-page) fieldset{min-inline-size:0;margin:0 0 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}
|
|
81
|
+
:where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
|
|
82
|
+
`;
|
|
83
|
+
/** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
|
|
84
|
+
export function pageCss(page = {}) {
|
|
85
|
+
const set = Object.entries(page.theme ?? {});
|
|
86
|
+
if (set.length === 0)
|
|
87
|
+
return PAGE_CSS;
|
|
88
|
+
return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
|
|
89
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type PageOptions } from "../astro/lib/page.ts";
|
|
2
|
+
export type { PageOptions };
|
|
1
3
|
export interface EventsIntegrationOptions {
|
|
2
4
|
/**
|
|
3
5
|
* The sandboxed core's plugin id. Defaults to the slug (`semics-events`, npm installs).
|
|
@@ -15,6 +17,8 @@ export interface EventsIntegrationOptions {
|
|
|
15
17
|
* for a booking waiting for signatures (the suite passes its own, T066). Without it nothing is reconciled.
|
|
16
18
|
*/
|
|
17
19
|
reconcile?: string;
|
|
20
|
+
/** How the plugin's own pages look on this site: theme, stylesheet, brand, event page path (`PageOptions`). */
|
|
21
|
+
page?: PageOptions;
|
|
18
22
|
}
|
|
19
23
|
/** The slice of Astro's integration API this needs (so the package takes no `astro` dependency). */
|
|
20
24
|
interface SetupArgs {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EVENTS_PLUGIN_ID } from "../astro/lib/call.js";
|
|
2
|
+
import { checkPageOptions } from "../astro/lib/page.js";
|
|
2
3
|
const VIRTUAL = "virtual:semics-events/config";
|
|
3
4
|
const RESOLVED = `\0${VIRTUAL}`;
|
|
4
5
|
/**
|
|
@@ -14,6 +15,7 @@ export function eventsIntegration(options = {}) {
|
|
|
14
15
|
const pluginId = options.pluginId ?? EVENTS_PLUGIN_ID;
|
|
15
16
|
const config = [
|
|
16
17
|
`export const pluginId = ${JSON.stringify(pluginId)};`,
|
|
18
|
+
`export const page = ${JSON.stringify(checkPageOptions(options.page))};`,
|
|
17
19
|
`export const esignPluginId = ${JSON.stringify(options.esignPluginId ?? null)};`,
|
|
18
20
|
options.reconcile
|
|
19
21
|
? `export { reconcileBooking as reconcile } from ${JSON.stringify(options.reconcile)};`
|
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.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -25,6 +25,7 @@
|
|
|
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",
|
|
28
29
|
"./astro/DoorSignPage.astro": "./src/astro/DoorSignPage.astro",
|
|
29
30
|
"./astro/CheckIn.astro": "./src/astro/CheckIn.astro",
|
|
30
31
|
"./astro/OptOutPage.astro": "./src/astro/OptOutPage.astro",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// and emails of attendees who have not signed, until the cutoff. Rows come from `signingRows`.
|
|
7
7
|
import { around, pickLocale, translator } from "../i18n/index";
|
|
8
8
|
import type { SigningRow } from "./lib/attendees";
|
|
9
|
+
import { zonedAt } from "./lib/list";
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
11
12
|
rows: SigningRow[];
|
|
@@ -13,25 +14,18 @@ interface Props {
|
|
|
13
14
|
action: string;
|
|
14
15
|
/** While names may be changed: the deadline (ISO). */
|
|
15
16
|
editUntil?: string;
|
|
17
|
+
/** The event's time zone, for that deadline. */
|
|
18
|
+
zone?: string | null;
|
|
16
19
|
locale?: string;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
const { rows, action, editUntil } = Astro.props;
|
|
22
|
+
const { rows, action, editUntil, zone } = Astro.props;
|
|
20
23
|
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
21
24
|
const { t, lang, dir } = translator(locale);
|
|
22
25
|
const editable = rows.filter((r) => r.canEdit);
|
|
23
26
|
const [untilBefore, untilAfter] = around(t("booking.attendees.editUntil"), "time");
|
|
24
27
|
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
|
-
};
|
|
28
|
+
const at = (iso: string) => zonedAt(iso, zone, locale);
|
|
35
29
|
---
|
|
36
30
|
<section class="semics-events semics-attendee-list" data-testid="attendee-list" lang={lang} dir={dir} aria-labelledby="semics-attendees-title">
|
|
37
31
|
<h2 id="semics-attendees-title">{t("booking.attendees.title")}</h2>
|
|
@@ -73,6 +67,7 @@ const at = (iso: string) => {
|
|
|
73
67
|
))
|
|
74
68
|
}
|
|
75
69
|
</ul>
|
|
70
|
+
{rows.some((r) => r.canResend) && <p class="semics-attendee-note" data-testid="attendee-not-arrived">{t("booking.attendees.notArrived")}</p>}
|
|
76
71
|
{
|
|
77
72
|
editable.length > 0 && (
|
|
78
73
|
<form method="post" action={action} class="semics-attendee-edit" data-testid="attendee-edit">
|
|
@@ -8,11 +8,12 @@
|
|
|
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 { esignPluginId, page, pluginId, reconcile } 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 PageBrand from "./PageBrand.astro";
|
|
16
17
|
import PaymentReturn from "./PaymentReturn.astro";
|
|
17
18
|
import { callPublicRoute } from "./lib/call";
|
|
18
19
|
import {
|
|
@@ -28,9 +29,10 @@ import {
|
|
|
28
29
|
} from "./lib/checkout-form";
|
|
29
30
|
import AttendeeList from "./AttendeeList.astro";
|
|
30
31
|
import { handleAttendeeAction, signingRows } from "./lib/attendees";
|
|
32
|
+
import { eventPageHref, pageCss } from "./lib/page";
|
|
31
33
|
import { paymentView } from "./lib/payment";
|
|
32
34
|
import { forwardReceipt } from "./lib/receipt";
|
|
33
|
-
import { type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
|
|
35
|
+
import { asOfNow, type BookingView, type PublicEvent, reconcileWanted, ticketNames } from "./lib/widget";
|
|
34
36
|
import TicketPass from "./TicketPass.astro";
|
|
35
37
|
|
|
36
38
|
export const prerender = false;
|
|
@@ -154,6 +156,7 @@ if (ref && token) {
|
|
|
154
156
|
} else if (ref && !opening) {
|
|
155
157
|
missing = true;
|
|
156
158
|
}
|
|
159
|
+
if (booking) booking = asOfNow(booking, Date.now());
|
|
157
160
|
// The attendee signing list's forms (T133): Sign now, Resend and Save, against the fresh answer.
|
|
158
161
|
if (booking && form && ref && token) {
|
|
159
162
|
const done = await handleAttendeeAction(ctx, form, { ref, token }, { pluginId, esignPluginId }, booking);
|
|
@@ -177,9 +180,12 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
|
|
|
177
180
|
<meta name="robots" content="noindex" />
|
|
178
181
|
<meta name="referrer" content="no-referrer" />
|
|
179
182
|
<title>{t("booking.title")}</title>
|
|
183
|
+
<style is:inline set:html={pageCss(page)}></style>
|
|
184
|
+
{page.stylesheet && <link rel="stylesheet" href={page.stylesheet} />}
|
|
180
185
|
</head>
|
|
181
|
-
<body>
|
|
182
|
-
<
|
|
186
|
+
<body class="semics-page">
|
|
187
|
+
<PageBrand brand={page.brand} />
|
|
188
|
+
<main class="semics-booking semics-page-main" data-testid="booking-page">
|
|
183
189
|
<h1>{t("booking.title")}</h1>
|
|
184
190
|
<form method="post" action={ref ? `/booking?ref=${ref}` : "/booking"} data-semics-fragment="receipt" hidden>
|
|
185
191
|
<input type="hidden" name="intent" value="receipt" />
|
|
@@ -196,13 +202,14 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
|
|
|
196
202
|
</form>
|
|
197
203
|
) : booking ? (
|
|
198
204
|
<>
|
|
199
|
-
<BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} locale={locale} />
|
|
205
|
+
<BookingStatus booking={booking} cancelled={cancelled} cancelAction={`/booking?ref=${ref}`} ticketNames={names} bookAgain={eventPageHref(booking.event?.slug, page.eventPath)} locale={locale} />
|
|
200
206
|
{payment && <PaymentReturn view={payment} bookingRef={ref} action={`/booking?ref=${ref}`} locale={locale} />}
|
|
201
207
|
{signingList && (
|
|
202
208
|
<AttendeeList
|
|
203
209
|
rows={signingList}
|
|
204
210
|
action={`/booking?ref=${ref}`}
|
|
205
211
|
editUntil={booking.signingList?.editable ? booking.signingList.editUntil : undefined}
|
|
212
|
+
zone={booking.event?.timezone}
|
|
206
213
|
locale={locale}
|
|
207
214
|
/>
|
|
208
215
|
)}
|
|
@@ -226,6 +233,7 @@ const passes = booking && !cancelled && booking.status === "confirmed" ? booking
|
|
|
226
233
|
<script>
|
|
227
234
|
import "../client/receipt.ts";
|
|
228
235
|
import "../client/payment.ts";
|
|
236
|
+
import "../client/forget-form.ts";
|
|
229
237
|
</script>
|
|
230
238
|
</body>
|
|
231
239
|
</html>
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// <BookingStatus>: a booking's state, order and cancel button (EU-FR-06). Rendered by the
|
|
3
3
|
// `/booking` page from the `public/booking` answer; the cancel form is a plain POST back to it.
|
|
4
4
|
import { around, pickLocale, translator } from "../i18n/index";
|
|
5
|
-
import {
|
|
5
|
+
import { zonedAt } from "./lib/list";
|
|
6
|
+
import { type BookingView, endedNotes, formatMoney, statusLabel } from "./lib/widget";
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
booking: BookingView;
|
|
@@ -12,10 +13,12 @@ interface Props {
|
|
|
12
13
|
cancelAction?: string;
|
|
13
14
|
/** Ticket type names by id, when the page knows them. */
|
|
14
15
|
ticketNames?: Record<string, string>;
|
|
16
|
+
/** A lapsed booking's way back: the event's page, when known. */
|
|
17
|
+
bookAgain?: string;
|
|
15
18
|
locale?: string;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
const { booking, cancelled = false, cancelAction, ticketNames = {} } = Astro.props;
|
|
21
|
+
const { booking, cancelled = false, cancelAction, ticketNames = {}, bookAgain } = Astro.props;
|
|
19
22
|
const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
|
|
20
23
|
const { t, plural, lang, dir } = translator(locale);
|
|
21
24
|
// A request awaiting approval (T131) holds its places until the organiser's deadline.
|
|
@@ -26,16 +29,8 @@ const [heldBefore, heldAfter] = around(
|
|
|
26
29
|
const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
|
|
27
30
|
const tickets = booking.lines.reduce((n, line) => n + line.qty, 0);
|
|
28
31
|
const status = cancelled ? "cancelled" : booking.status;
|
|
29
|
-
const at = (iso: string) =>
|
|
30
|
-
|
|
31
|
-
const time = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" }).format(
|
|
32
|
-
new Date(iso),
|
|
33
|
-
);
|
|
34
|
-
return t("time.utc", { time });
|
|
35
|
-
} catch {
|
|
36
|
-
return iso;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
32
|
+
const at = (iso: string) => zonedAt(iso, booking.event?.timezone, locale);
|
|
33
|
+
const notes = endedNotes({ ...booking, status }, locale);
|
|
39
34
|
---
|
|
40
35
|
<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
36
|
<h2 id="semics-booking-status-title" class="semics-visually-hidden">{t("booking.status")}</h2>
|
|
@@ -52,6 +47,8 @@ const at = (iso: string) => {
|
|
|
52
47
|
</p>
|
|
53
48
|
)
|
|
54
49
|
}
|
|
50
|
+
{notes.map((note) => <p data-testid="booking-note">{note}</p>)}
|
|
51
|
+
{status === "expired" && bookAgain && <p><a href={bookAgain} data-testid="booking-book-again">{t("booking.bookAgain")}</a></p>}
|
|
55
52
|
<ul class="semics-lines" aria-label={plural("booking.lines", tickets)}>
|
|
56
53
|
{
|
|
57
54
|
booking.lines.map((line) => (
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
// The site's name or logo at the top of the plugins' own pages (`/booking`, `/_events/waiver`), linking
|
|
3
|
+
// home: those pages run outside the site's layout (`eventsIntegration({ page: { brand } })`).
|
|
4
|
+
import type { PageBrand } from "./lib/page";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
brand?: PageBrand | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { brand } = Astro.props;
|
|
11
|
+
---
|
|
12
|
+
{
|
|
13
|
+
brand && (
|
|
14
|
+
<header class="semics-page-brand">
|
|
15
|
+
<a href={brand.href ?? "/"}>{brand.logo ? <img src={brand.logo} alt={brand.name} /> : brand.name}</a>
|
|
16
|
+
</header>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -52,8 +52,8 @@ export interface AttendeeEdit {
|
|
|
52
52
|
email?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Statuses in which a waiver can still be signed: the
|
|
56
|
-
const OPEN = ["awaiting_signature", "awaiting_payment", "confirmed"];
|
|
55
|
+
/** Statuses in which a waiver can still be signed: the holds', and a confirmed booking's pending seats. */
|
|
56
|
+
const OPEN = ["awaiting_signature", "awaiting_payment", "awaiting_approval", "confirmed"];
|
|
57
57
|
const SEAT = /^[0-9]{1,3}$/;
|
|
58
58
|
const CODE = /^[A-Z_]{1,40}$/;
|
|
59
59
|
const MAX_TEXT = 254;
|
package/src/astro/lib/list.ts
CHANGED
|
@@ -62,6 +62,33 @@ const WHEN: Intl.DateTimeFormatOptions = {
|
|
|
62
62
|
timeZoneName: "short",
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
const AT: Intl.DateTimeFormatOptions = {
|
|
66
|
+
day: "numeric",
|
|
67
|
+
month: "short",
|
|
68
|
+
year: "numeric",
|
|
69
|
+
hour: "2-digit",
|
|
70
|
+
minute: "2-digit",
|
|
71
|
+
hourCycle: "h23",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A deadline on a customer page: local time in the event's own zone, named as the emails name it
|
|
76
|
+
* ("9 Nov 2026, 15:09 (Europe/London)", not workerd's "GMT+0"). UTC for a missing or unknown zone; the raw value
|
|
77
|
+
* for one that is not a date.
|
|
78
|
+
*/
|
|
79
|
+
export function zonedAt(iso: string, timezone: string | null | undefined, locale: string): string {
|
|
80
|
+
const ms = Date.parse(iso);
|
|
81
|
+
if (!Number.isFinite(ms)) return iso;
|
|
82
|
+
const zone = timezone && isValidTimeZone(timezone) ? timezone : "UTC";
|
|
83
|
+
let time: string;
|
|
84
|
+
try {
|
|
85
|
+
time = formatInZone(ms, zone, locale, AT);
|
|
86
|
+
} catch {
|
|
87
|
+
time = formatInZone(ms, zone, "en-GB", AT); // A locale `Intl` refuses, such as `en_GB`.
|
|
88
|
+
}
|
|
89
|
+
return `${time} (${zone})`;
|
|
90
|
+
}
|
|
91
|
+
|
|
65
92
|
const BADGES = { cancelled: "list.badge.cancelled", closed: "list.badge.closed", paused: "list.badge.paused" } as const;
|
|
66
93
|
|
|
67
94
|
/** The start in the event's own zone; a missing or unknown zone shows UTC rather than failing. */
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
|
|
12
|
+
/** A theme value by property: `accent` sets `--events-accent` (the signing form follows, see `PAGE_CSS`). */
|
|
13
|
+
export const THEME_PROPERTIES = [
|
|
14
|
+
"fg",
|
|
15
|
+
"muted",
|
|
16
|
+
"bg",
|
|
17
|
+
"border",
|
|
18
|
+
"accent",
|
|
19
|
+
"accent-fg",
|
|
20
|
+
"error",
|
|
21
|
+
"success",
|
|
22
|
+
"radius",
|
|
23
|
+
"font",
|
|
24
|
+
"page-bg",
|
|
25
|
+
"heading-font",
|
|
26
|
+
"heading-fg",
|
|
27
|
+
] as const;
|
|
28
|
+
export type ThemeProperty = (typeof THEME_PROPERTIES)[number];
|
|
29
|
+
export interface PageBrand {
|
|
30
|
+
/** The site's name: the link's text, or the logo's alternative text. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Where it links, a path on this site (default `/`). */
|
|
33
|
+
href?: string;
|
|
34
|
+
/** A logo, a path on this site. */
|
|
35
|
+
logo?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PageOptions {
|
|
39
|
+
/** Values for the pages' custom properties, for example `{ accent: "#1f3a2e", "page-bg": "#f6f1ea" }`. */
|
|
40
|
+
theme?: Partial<Record<ThemeProperty, string>>;
|
|
41
|
+
/** A stylesheet on this site, loaded after the defaults: for `@font-face`, or any further rules. */
|
|
42
|
+
stylesheet?: string;
|
|
43
|
+
/** The site's name or logo at the top of each page. */
|
|
44
|
+
brand?: PageBrand;
|
|
45
|
+
/** The event's page, where "Book again" goes: a path with `{slug}` (default `/events/{slug}`). */
|
|
46
|
+
eventPath?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** One line of CSS, nothing that could end the declaration, the rule or the `<style>` element. */
|
|
50
|
+
const THEME_VALUE = /^[^;{}<>\\@]{1,200}$/;
|
|
51
|
+
/** A path on this site; `;` and `,` would end a source in the signing page's CSP header. */
|
|
52
|
+
const SITE_PATH = /^\/(?!\/)[^\s"'<>\\;,]*$/;
|
|
53
|
+
|
|
54
|
+
/** Checks a site's page options when the site's config loads; a bad value stops the build with its name. */
|
|
55
|
+
export function checkPageOptions(page: PageOptions = {}): PageOptions {
|
|
56
|
+
const refuse = (what: string) => {
|
|
57
|
+
throw new Error(`page.${what} is not valid`); // i18n-ignore
|
|
58
|
+
};
|
|
59
|
+
for (const [name, value] of Object.entries(page.theme ?? {})) {
|
|
60
|
+
const known = (THEME_PROPERTIES as readonly string[]).includes(name);
|
|
61
|
+
if (!known || typeof value !== "string" || !THEME_VALUE.test(value) || /url\(/i.test(value))
|
|
62
|
+
refuse(`theme.${name}`);
|
|
63
|
+
}
|
|
64
|
+
const { brand, stylesheet, eventPath } = page;
|
|
65
|
+
if (stylesheet !== undefined && !SITE_PATH.test(stylesheet)) refuse("stylesheet");
|
|
66
|
+
if (eventPath !== undefined && !(SITE_PATH.test(eventPath) && eventPath.includes("{slug}"))) refuse("eventPath");
|
|
67
|
+
if (brand) {
|
|
68
|
+
if (typeof brand.name !== "string" || !brand.name.trim()) refuse("brand.name");
|
|
69
|
+
if (brand.href !== undefined && !SITE_PATH.test(brand.href)) refuse("brand.href");
|
|
70
|
+
if (brand.logo !== undefined && !SITE_PATH.test(brand.logo)) refuse("brand.logo");
|
|
71
|
+
}
|
|
72
|
+
return page;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The event's page for "Book again"; undefined when the booking does not know its slug. */
|
|
76
|
+
export function eventPageHref(slug: string | null | undefined, eventPath?: string): string | undefined {
|
|
77
|
+
return slug ? (eventPath ?? "/events/{slug}").replace("{slug}", encodeURIComponent(slug)) : undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Works with no site theme at all. Zero specificity on elements, so the components' own rules win. */
|
|
81
|
+
export const PAGE_CSS = `*,*::before,*::after{box-sizing:border-box}
|
|
82
|
+
html{color-scheme:light;-webkit-text-size-adjust:100%}
|
|
83
|
+
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;
|
|
84
|
+
--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)}
|
|
85
|
+
.semics-page-brand{max-inline-size:38rem;margin-inline:auto;padding:1rem 1rem 0;font-family:var(--events-heading-font, inherit);font-weight:600}
|
|
86
|
+
.semics-page-brand a{color:var(--events-heading-fg, inherit);text-decoration:none}
|
|
87
|
+
.semics-page-brand img{display:block;block-size:2.5rem;inline-size:auto;max-inline-size:100%}
|
|
88
|
+
.semics-page-main{max-inline-size:38rem;margin-inline:auto;padding:1.5rem 1rem 3rem}
|
|
89
|
+
: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}
|
|
90
|
+
:where(.semics-page) h1{font-size:clamp(1.75rem,1.5rem + 1.5vw,2.25rem)}
|
|
91
|
+
:where(.semics-page) h2{font-size:1.25rem}
|
|
92
|
+
:where(.semics-page) h3{font-size:1.0625rem}
|
|
93
|
+
:where(.semics-page) p{margin:0 0 .75rem}
|
|
94
|
+
:where(.semics-page) a{color:var(--events-accent, #0b57d0);text-underline-offset:.2em}
|
|
95
|
+
:where(.semics-page) :focus-visible{outline:3px solid var(--events-accent, #0b57d0);outline-offset:2px}
|
|
96
|
+
:where(.semics-page-main) > section,:where(.semics-page-main) > form:not([hidden]){margin-block:0 1rem;padding:1rem 1.25rem;background:var(--events-bg, #ffffff);border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);max-inline-size:none}
|
|
97
|
+
:where(.semics-page) [role="alert"]{padding:.5rem .75rem;border:1px solid var(--events-error, #b3261e);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-error, #b3261e)}
|
|
98
|
+
: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:.375rem .5rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px);background:var(--events-bg, #ffffff);color:var(--events-fg, #1a1a1a)}
|
|
99
|
+
:where(.semics-page) label{display:block}
|
|
100
|
+
:where(.semics-page) fieldset{min-inline-size:0;margin:0 0 .75rem;padding:.5rem .75rem;border:1px solid var(--events-border, #6b6b6b);border-radius:var(--events-radius, 6px)}
|
|
101
|
+
:where(.semics-page) button{font:inherit;min-block-size:2.75rem;padding:.5rem 1rem;border:0;border-radius:var(--events-radius, 6px);background:var(--events-accent, #0b57d0);color:var(--events-accent-fg, #ffffff);cursor:pointer}
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
/** The stylesheet for a page: the defaults, then the site's theme. Exact: the signing page hashes this text. */
|
|
105
|
+
export function pageCss(page: PageOptions = {}): string {
|
|
106
|
+
const set = Object.entries(page.theme ?? {}) as Array<[ThemeProperty, string]>;
|
|
107
|
+
if (set.length === 0) return PAGE_CSS;
|
|
108
|
+
return `${PAGE_CSS}:root{${set.map(([name, value]) => `--events-${name}:${value}`).join(";")}}\n`;
|
|
109
|
+
}
|
package/src/astro/lib/payment.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* way" are told apart by asking the core, never by a query parameter.
|
|
6
6
|
*/
|
|
7
7
|
import { type MessageKey, t } from "../../i18n/index";
|
|
8
|
+
import { zonedAt } from "./list";
|
|
8
9
|
import type { BookingView } from "./widget";
|
|
9
10
|
|
|
10
11
|
export type PaymentState = "confirmed" | "pending" | "expired" | "cancelled" | "refunded" | "refunded_unavailable";
|
|
@@ -19,15 +20,6 @@ export interface PaymentView {
|
|
|
19
20
|
resume: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const utc = (iso: string, locale: string) => {
|
|
23
|
-
try {
|
|
24
|
-
const at = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" });
|
|
25
|
-
return t(locale, "time.utc", { time: at.format(new Date(iso)) });
|
|
26
|
-
} catch {
|
|
27
|
-
return iso;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
23
|
/** The provider's payment page is followed only when it is an `https:` URL (never `javascript:` or `//host`). */
|
|
32
24
|
export function isPayUrl(value: unknown): value is string {
|
|
33
25
|
if (typeof value !== "string" || !value.startsWith("https://")) return false;
|
|
@@ -49,13 +41,17 @@ const final = (state: PaymentState, locale: string): PaymentView => ({
|
|
|
49
41
|
/** The payment section for a booking, or `null` when there is nothing to say about money. */
|
|
50
42
|
export function paymentView(booking: BookingView, locale = "en-GB"): PaymentView | null {
|
|
51
43
|
const paid = booking.totals.totalMinor > 0;
|
|
44
|
+
// Ran out waiting for the organiser: not about a payment (`endedNotes` says what happened).
|
|
45
|
+
if (booking.status === "expired" && booking.undecided) return null;
|
|
52
46
|
switch (booking.status) {
|
|
53
47
|
case "awaiting_payment":
|
|
54
48
|
return {
|
|
55
49
|
state: "pending",
|
|
56
50
|
heading: t(locale, "payment.pending.heading"),
|
|
57
51
|
body: booking.holdExpiresAt
|
|
58
|
-
? t(locale, "payment.pending.bodyUntil", {
|
|
52
|
+
? t(locale, "payment.pending.bodyUntil", {
|
|
53
|
+
time: zonedAt(booking.holdExpiresAt, booking.event?.timezone, locale),
|
|
54
|
+
})
|
|
59
55
|
: t(locale, "payment.pending.body"),
|
|
60
56
|
poll: true,
|
|
61
57
|
resume: true,
|
package/src/astro/lib/widget.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface PublicEvent {
|
|
|
36
36
|
turnstileSiteKey?: string;
|
|
37
37
|
/** True when the event requires a signed waiver (T066): the booking form then asks for attendees. */
|
|
38
38
|
waiver?: boolean;
|
|
39
|
+
/** Events Pro: that waiver is signed per attendee, so its seat rules can be checked before reserving. */
|
|
40
|
+
waiverEach?: boolean;
|
|
39
41
|
/** True when the core takes promo codes (Events Pro, T078): the widget then shows a code field. */
|
|
40
42
|
promoCodes?: boolean;
|
|
41
43
|
/** True when a sold-out event takes a waitlist (T081): the widget then shows a "Join the waitlist" form. */
|
|
@@ -74,6 +76,14 @@ export interface BookingView {
|
|
|
74
76
|
lines: Array<{ ticketTypeId: string; qty: number }>;
|
|
75
77
|
totals: { totalMinor: number; currency: string };
|
|
76
78
|
holdExpiresAt?: string;
|
|
79
|
+
/** The event's public info (`timezone` for times on the page, `slug` for "Book again"). */
|
|
80
|
+
event?: { title?: string; startsAt?: string; timezone?: string | null; slug?: string | null };
|
|
81
|
+
/** Why the organiser declined (`status: "declined"`), when they said. */
|
|
82
|
+
declineReason?: string | null;
|
|
83
|
+
/** Declined, a price was due and no money was taken (`closeBooking`). */
|
|
84
|
+
notCharged?: boolean;
|
|
85
|
+
/** Expired, this means it ran out waiting for the organiser's decision (Pro: not one approved but left unpaid). */
|
|
86
|
+
undecided?: boolean;
|
|
77
87
|
/** `qr`: Events Pro's QR matrix of `code` (T082), drawn by `<TicketPass>`; Free sends none. */
|
|
78
88
|
attendees: Array<{ name: string; ticketTypeId?: string; status: string; code?: string; qr?: unknown }>;
|
|
79
89
|
canCancel: boolean;
|
|
@@ -302,3 +312,36 @@ export const statusLabel = (status: string, locale?: string) =>
|
|
|
302
312
|
|
|
303
313
|
/** English status labels (the 1.0 API; components use `statusLabel`). */
|
|
304
314
|
export const STATUS_LABELS: Record<string, string> = Object.fromEntries(STATUSES.map((s) => [s, statusLabel(s, "en")]));
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The booking as it stands at `now`: a hold past its deadline has lapsed even before the sweeper moves it (the core
|
|
318
|
+
* refuses anything on it, and the waiver page already says so), so the page shows it as expired.
|
|
319
|
+
*/
|
|
320
|
+
export function asOfNow<T extends Pick<BookingView, "status" | "holdExpiresAt" | "canCancel">>(
|
|
321
|
+
booking: T,
|
|
322
|
+
now: number,
|
|
323
|
+
): T {
|
|
324
|
+
const until = booking.holdExpiresAt ? Date.parse(booking.holdExpiresAt) : Number.NaN;
|
|
325
|
+
if (!(until <= now)) return booking;
|
|
326
|
+
const { holdExpiresAt: _gone, ...rest } = booking;
|
|
327
|
+
return { ...rest, status: "expired", canCancel: false } as T;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** What a booking that ended without going ahead should say beyond its status (declined, or lapsed). */
|
|
331
|
+
export function endedNotes(
|
|
332
|
+
booking: Pick<BookingView, "status" | "declineReason" | "notCharged" | "undecided"> & {
|
|
333
|
+
totals?: BookingView["totals"];
|
|
334
|
+
},
|
|
335
|
+
locale?: string,
|
|
336
|
+
) {
|
|
337
|
+
if (booking.status === "expired") {
|
|
338
|
+
if (booking.undecided) return [t(locale, "booking.undecided")];
|
|
339
|
+
// A paid one has the payment section's "This booking expired": only what that does not say.
|
|
340
|
+
return [t(locale, booking.totals?.totalMinor ? "booking.signAgain" : "booking.lapsed")];
|
|
341
|
+
}
|
|
342
|
+
if (booking.status !== "declined") return [];
|
|
343
|
+
return [
|
|
344
|
+
...(booking.declineReason ? [t(locale, "booking.declinedReason", { reason: booking.declineReason })] : []),
|
|
345
|
+
...(booking.notCharged ? [t(locale, "booking.notCharged")] : []),
|
|
346
|
+
];
|
|
347
|
+
}
|
package/src/astro/virtual.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Provided by the integration's Vite plugin (`eventsIntegration({ pluginId })`).
|
|
2
2
|
declare module "virtual:semics-events/config" {
|
|
3
3
|
export const pluginId: string;
|
|
4
|
+
/** How the site dresses the plugin's own pages (`eventsIntegration({ page })`). */
|
|
5
|
+
export const page: import("./lib/page").PageOptions;
|
|
4
6
|
/** The e-sign core's plugin id, or `null` when e-sign is not configured (`eventsIntegration({ esignPluginId })`). */
|
|
5
7
|
export const esignPluginId: string | null;
|
|
6
8
|
/**
|