@profitstudio/booking-engine 2.0.0-beta.1 → 2.0.0-beta.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog — @profitstudio/booking-engine
2
2
 
3
+ ## 2.0.0-beta.3 — 2026-11-06
4
+
5
+ Honest email health in public demos. **No migration** (schema 2.0.0-alpha.10),
6
+ no client, CLI or Edge Function change, and no change for real sites.
7
+
8
+ **Fixed:**
9
+
10
+ - With `<BookingAdmin emailDelivery="none">` the dashboard no longer reports
11
+ deliveries that never happened. The Today health line says "Demo: no emails
12
+ are sent"; the Email page's status card says email is simulated, with no
13
+ "last delivered" time and no sent / code / waiting / failed counters; the
14
+ list of emails is titled "What would have been emailed" and marks every row
15
+ "Not sent (demo)"; the test-email card says no test email is sent; the
16
+ "emails not getting out" banner never shows. The demo still counts as ready,
17
+ so online booking can be switched on and off.
18
+ - Without the prop (or with `'live'`), every rule and text is exactly as in
19
+ 2.0.0-beta.2: one helper (`admin/email-health.ts`) now feeds the Today line,
20
+ the Email page, the banner and the setup checklist with those same rules.
21
+
22
+ ## 2.0.0-beta.2 — 2026-11-04
23
+
24
+ A dashboard option for public demos. **No migration** (schema 2.0.0-alpha.10),
25
+ no client or Edge Function change, and no change for existing sites.
26
+
27
+ **Added:**
28
+
29
+ - `<BookingAdmin emailDelivery="none">` (optional; default `'live'`) for an
30
+ installation that never emails anyone — a public demo or a showcase. The
31
+ dashboard then never says a customer gets an email: the answer footnote under a
32
+ request, the toast after Confirm / Decline / Cancel and the Decline / Cancel
33
+ dialogs say that no email is sent from the demo, and the Email page's subtitle
34
+ starts with "This demo sends no email". Without the prop (or with `'live'`)
35
+ every text is exactly as in 2.0.0-beta.1. Type: `EmailDelivery` from
36
+ `@profitstudio/booking-engine/admin`.
37
+
3
38
  ## 2.0.0-beta.1 — 2026-11-03
4
39
 
5
40
  First public beta, after the hosted rehearsal (a real Supabase project, Resend,
package/README.md CHANGED
@@ -12,7 +12,7 @@ an AI builder.
12
12
  - Changes and upgrade notes: [CHANGELOG.md](CHANGELOG.md)
13
13
  - Versions: see `engine.manifest.json`
14
14
 
15
- **Status:** 2.0.0-beta.1 — first public beta (owner-editable website content, the Studio dashboard, calendar helpers for booking UIs, optional service photos, opening times with closures; builds check the Supabase connection; the dashboard asks where new-request alerts go; `connect` sets up Supabase and email, `photos` prepares a site's photos). Install the exact version.
15
+ **Status:** 2.0.0-beta.3 — public beta (owner-editable website content, the Studio dashboard, calendar helpers for booking UIs, optional service photos, opening times with closures; builds check the Supabase connection; the dashboard asks where new-request alerts go; `connect` sets up Supabase and email, `photos` prepares a site's photos). Install the exact version.
16
16
 
17
17
  ## Licence
18
18
 
@@ -1,6 +1,7 @@
1
1
  import type { BookingEngine } from '../client.js';
2
2
  import type { SiteContentSchema } from '../content/schema.js';
3
3
  import type { Preset } from '../types.js';
4
+ import { type EmailDelivery } from './context.js';
4
5
  export interface BookingAdminProps {
5
6
  /** The same engine instance the website uses. */
6
7
  engine: BookingEngine;
@@ -13,10 +14,16 @@ export interface BookingAdminProps {
13
14
  * it the Website section explains how to add some.
14
15
  */
15
16
  content?: SiteContentSchema;
17
+ /**
18
+ * How booking emails reach customers. 'live' (the default): the engine's mailer
19
+ * sends them. 'none': an installation that never emails anyone — a public demo
20
+ * or a showcase. The dashboard then never says that a customer gets an email.
21
+ */
22
+ emailDelivery?: EmailDelivery;
16
23
  }
17
24
  export type Appearance = 'system' | 'light' | 'dark';
18
25
  /**
19
26
  * The packaged admin dashboard. Mount it on its own page (e.g. /admin/).
20
27
  * It handles sign-in, admin checks and every management screen.
21
28
  */
22
- export declare function BookingAdmin({ engine, presets, siteUrl, content }: BookingAdminProps): import("react").JSX.Element;
29
+ export declare function BookingAdmin({ engine, presets, siteUrl, content, emailDelivery }: BookingAdminProps): import("react").JSX.Element;
@@ -4,6 +4,7 @@ import { presets as builtInPresets } from '../presets/index.js';
4
4
  import { formatTime, timeZoneLabel } from '../time.js';
5
5
  import { ALERTS_VIEW, alertsAddress } from './alerts.js';
6
6
  import { AdminContext, useAdmin } from './context.js';
7
+ import { emailHealth } from './email-health.js';
7
8
  import { ToastRegion, useConfirm, useToasts } from './feedback.js';
8
9
  import { Icon } from './icons.js';
9
10
  import { ADMIN_SECTIONS, NAV_GROUPS } from './sections.js';
@@ -58,7 +59,7 @@ function routeFromHash() {
58
59
  * The packaged admin dashboard. Mount it on its own page (e.g. /admin/).
59
60
  * It handles sign-in, admin checks and every management screen.
60
61
  */
61
- export function BookingAdmin({ engine, presets, siteUrl = '/', content }) {
62
+ export function BookingAdmin({ engine, presets, siteUrl = '/', content, emailDelivery = 'live' }) {
62
63
  const [phase, setPhase] = useState({ kind: 'checking' });
63
64
  const { appearance, setAppearance, mode } = useAppearance();
64
65
  const rootProps = { 'data-appearance': appearance, 'data-mode': mode };
@@ -215,6 +216,7 @@ export function BookingAdmin({ engine, presets, siteUrl = '/', content }) {
215
216
  refreshCounts,
216
217
  contentSchema: content ?? null,
217
218
  siteUrl,
219
+ emailDelivery,
218
220
  website,
219
221
  refreshWebsite,
220
222
  toast,
@@ -251,7 +253,7 @@ function BusinessClock({ timezone, locale }) {
251
253
  }
252
254
  /** On every page: say so when booking emails are not getting out (customers then cannot receive codes). */
253
255
  function EmailHealthBanner() {
254
- const { engine, settings, go } = useAdmin();
256
+ const { engine, settings, go, emailDelivery } = useAdmin();
255
257
  const [status, setStatus] = useState(null);
256
258
  useEffect(() => {
257
259
  let alive = true;
@@ -263,10 +265,11 @@ function EmailHealthBanner() {
263
265
  alive = false;
264
266
  };
265
267
  }, [engine]);
266
- if (!status)
268
+ // A demo sends nothing, so there is nothing to warn about.
269
+ if (!status || emailDelivery === 'none')
267
270
  return null;
268
- const { lastSuccessAt, lastFailureAt, lastError } = status.mailer;
269
- const failing = Boolean(lastFailureAt && (!lastSuccessAt || Date.parse(lastFailureAt) > Date.parse(lastSuccessAt)));
271
+ const { lastError } = status.mailer;
272
+ const { failing } = emailHealth(status, emailDelivery);
270
273
  const stuck = Boolean(status.counts.oldestQueuedAt && Date.now() - Date.parse(status.counts.oldestQueuedAt) > 5 * 60_000);
271
274
  // The same count and 24-hour window the database uses to refuse new codes (RATE_LIMITED).
272
275
  const capReached = settings.onlineBookingEnabled && status.counts.codesLast24h >= settings.maxVerificationEmailsPerDay;
@@ -1,4 +1,5 @@
1
1
  import type { AdminBooking, AdminService, BookingStatus } from '../types.js';
2
+ import { type EmailDelivery } from './context.js';
2
3
  import type { ConfirmInput } from './feedback.js';
3
4
  export interface BookingAction {
4
5
  status: Exclude<BookingStatus, 'pending'>;
@@ -7,8 +8,17 @@ export interface BookingAction {
7
8
  /** Asked first, for answers that email the customer and cannot be taken back. */
8
9
  confirm?: ConfirmInput;
9
10
  }
11
+ /** What an answer means for the customer's inbox — in the confirm dialogs. */
12
+ export declare const notifies: (b: AdminBooking, delivery?: EmailDelivery) => string;
13
+ /** The line under a request's answers. */
14
+ export declare const answerNote: (b: AdminBooking, delivery?: EmailDelivery) => string;
10
15
  /** The answers that make sense for a booking right now. */
11
- export declare function actionsFor(b: AdminBooking, now?: number): BookingAction[];
16
+ export declare function actionsFor(b: AdminBooking, now?: number, delivery?: EmailDelivery): BookingAction[];
17
+ /** The toast after an answer. */
18
+ export declare function doneMessage(b: AdminBooking, a: BookingAction, delivery?: EmailDelivery): {
19
+ title: string;
20
+ detail?: string;
21
+ };
12
22
  /**
13
23
  * Run an answer: ask first when needed, save it, tell the owner, recount the
14
24
  * badge. Resolves to the updated booking, or an error message to show in place.
@@ -10,11 +10,20 @@ import { Drawer } from './drawer.js';
10
10
  import { Icon } from './icons.js';
11
11
  import { holdState } from './today.js';
12
12
  import { Button, IconButton, Notice, StatusBadge, firstName, formatMinutes, formatSpan, useNow } from './ui.js';
13
- const notifies = (b) => b.emailVerified
14
- ? `${firstName(b.customer.name)} gets an email.`
15
- : `${firstName(b.customer.name)}’s email address was never verified, so they are not emailed — contact them directly.`;
13
+ /** What an answer means for the customer's inbox — in the confirm dialogs. */
14
+ export const notifies = (b, delivery = 'live') => delivery === 'none'
15
+ ? 'No email is sent from this demo.'
16
+ : b.emailVerified
17
+ ? `${firstName(b.customer.name)} gets an email.`
18
+ : `${firstName(b.customer.name)}’s email address was never verified, so they are not emailed — contact them directly.`;
19
+ /** The line under a request's answers. */
20
+ export const answerNote = (b, delivery = 'live') => delivery === 'none'
21
+ ? 'No email is sent from this demo — answer here and see the result on the website.'
22
+ : b.emailVerified
23
+ ? `${b.customer.name} gets an email with your answer.`
24
+ : `${b.customer.name} is not emailed (unverified address).`;
16
25
  /** The answers that make sense for a booking right now. */
17
- export function actionsFor(b, now = Date.now()) {
26
+ export function actionsFor(b, now = Date.now(), delivery = 'live') {
18
27
  const started = Date.parse(b.startsAt) <= now;
19
28
  if (b.status === 'pending' || b.status === 'expired') {
20
29
  return [
@@ -24,7 +33,7 @@ export function actionsFor(b, now = Date.now()) {
24
33
  tone: 'danger',
25
34
  confirm: {
26
35
  title: `Decline ${b.customer.name}’s request?`,
27
- body: `The time opens again for other customers. ${notifies(b)}`,
36
+ body: `The time opens again for other customers. ${notifies(b, delivery)}`,
28
37
  confirmLabel: 'Decline request',
29
38
  cancelLabel: 'Keep the request',
30
39
  },
@@ -39,7 +48,7 @@ export function actionsFor(b, now = Date.now()) {
39
48
  tone: 'danger',
40
49
  confirm: {
41
50
  title: `Cancel ${b.customer.name}’s appointment?`,
42
- body: `The time opens again for other customers. ${notifies(b)}`,
51
+ body: `The time opens again for other customers. ${notifies(b, delivery)}`,
43
52
  confirmLabel: 'Cancel appointment',
44
53
  cancelLabel: 'Keep it',
45
54
  },
@@ -50,9 +59,10 @@ export function actionsFor(b, now = Date.now()) {
50
59
  }
51
60
  return [];
52
61
  }
53
- function doneMessage(b, a) {
62
+ /** The toast after an answer. */
63
+ export function doneMessage(b, a, delivery = 'live') {
54
64
  const name = b.customer.name;
55
- const emailed = b.emailVerified ? `${firstName(name)} gets an email` : undefined;
65
+ const emailed = delivery === 'live' && b.emailVerified ? `${firstName(name)} gets an email` : undefined;
56
66
  if (a.status === 'confirmed')
57
67
  return { title: `${name} confirmed`, detail: emailed };
58
68
  if (a.status === 'cancelled')
@@ -66,7 +76,7 @@ function doneMessage(b, a) {
66
76
  * badge. Resolves to the updated booking, or an error message to show in place.
67
77
  */
68
78
  export function useBookingActions() {
69
- const { engine, toast, confirm, refreshCounts } = useAdmin();
79
+ const { engine, toast, confirm, refreshCounts, emailDelivery } = useAdmin();
70
80
  return async (b, a, onStart) => {
71
81
  if (a.confirm && !(await confirm(a.confirm)))
72
82
  return { skipped: true };
@@ -74,7 +84,7 @@ export function useBookingActions() {
74
84
  const r = await engine.admin.setBookingStatus(b.id, a.status);
75
85
  if (!r.ok)
76
86
  return { error: r.error.message };
77
- toast({ kind: 'success', ...doneMessage(b, a) });
87
+ toast({ kind: 'success', ...doneMessage(b, a, emailDelivery) });
78
88
  refreshCounts();
79
89
  return { booking: r.data };
80
90
  };
@@ -97,7 +107,7 @@ export function priceText(b, services, locale) {
97
107
  }
98
108
  /** The detail panel for one booking. */
99
109
  export function BookingDrawer({ booking, services, docked, onClose, onChanged, onPrevious, onNext, }) {
100
- const { settings } = useAdmin();
110
+ const { settings, emailDelivery } = useAdmin();
101
111
  const run = useBookingActions();
102
112
  const now = useNow(15_000);
103
113
  const [busy, setBusy] = useState(null);
@@ -109,7 +119,7 @@ export function BookingDrawer({ booking, services, docked, onClose, onChanged, o
109
119
  const time = (hhmm) => formatClockTime(hhmm, locale);
110
120
  const at = (iso) => formatDateTime(iso, tz, locale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });
111
121
  const hold = b.status === 'pending' || b.status === 'expired' ? holdState(b, settings.pendingHoldMinutes, now) : null;
112
- const actions = actionsFor(b, now);
122
+ const actions = actionsFor(b, now, emailDelivery);
113
123
  const minutes = Math.round((Date.parse(b.endsAt) - Date.parse(b.startsAt)) / 60_000);
114
124
  const name = firstName(b.customer.name);
115
125
  const phoneHref = b.customer.phone ? `tel:${b.customer.phone.replace(/[^\d+]/g, '')}` : null;
@@ -136,7 +146,7 @@ export function BookingDrawer({ booking, services, docked, onClose, onChanged, o
136
146
  ? 'Cancelled'
137
147
  : b.status === 'completed'
138
148
  ? 'Marked as done'
139
- : 'Marked as a no-show' }) }), _jsx("time", { dateTime: b.statusChangedAt, children: at(b.statusChangedAt) })] }))] })] })] }), actions.length ? (_jsxs("div", { className: "pbe-drawer-foot", children: [b.status === 'pending' || b.status === 'expired' ? (_jsx("p", { className: "pbe-drawer-foot-note", children: b.emailVerified ? `${name} gets an email with your answer.` : `${name} is not emailed (unverified address).` })) : null, _jsx("div", { className: `pbe-drawer-actions${primaryRow.length === 2 ? ' pbe-drawer-actions--weighted' : ''}`, children: primaryRow.map((a) => (_jsx(Button, { variant: a.tone === 'primary' ? 'primary' : a.tone === 'danger' ? 'danger-quiet' : 'secondary', icon: a.status === 'confirmed' || a.status === 'completed' ? 'check' : undefined, loading: busy === a.status, disabled: busy !== null && busy !== a.status, onClick: () => void act(a), children: a.status === 'confirmed' ? 'Confirm request' : a.label }, a.status))) }), trailing ? (_jsx(Button, { variant: "quiet", size: "sm", className: "pbe-button--danger-text", loading: busy === 'cancelled', disabled: busy !== null && busy !== 'cancelled', onClick: () => void act(trailing), children: trailing.label })) : null] })) : null] }));
149
+ : 'Marked as a no-show' }) }), _jsx("time", { dateTime: b.statusChangedAt, children: at(b.statusChangedAt) })] }))] })] })] }), actions.length ? (_jsxs("div", { className: "pbe-drawer-foot", children: [b.status === 'pending' || b.status === 'expired' ? (_jsx("p", { className: "pbe-drawer-foot-note", children: answerNote(b, emailDelivery) })) : null, _jsx("div", { className: `pbe-drawer-actions${primaryRow.length === 2 ? ' pbe-drawer-actions--weighted' : ''}`, children: primaryRow.map((a) => (_jsx(Button, { variant: a.tone === 'primary' ? 'primary' : a.tone === 'danger' ? 'danger-quiet' : 'secondary', icon: a.status === 'confirmed' || a.status === 'completed' ? 'check' : undefined, loading: busy === a.status, disabled: busy !== null && busy !== a.status, onClick: () => void act(a), children: a.status === 'confirmed' ? 'Confirm request' : a.label }, a.status))) }), trailing ? (_jsx(Button, { variant: "quiet", size: "sm", className: "pbe-button--danger-text", loading: busy === 'cancelled', disabled: busy !== null && busy !== 'cancelled', onClick: () => void act(trailing), children: trailing.label })) : null] })) : null] }));
140
150
  }
141
151
  function CopyButton({ text }) {
142
152
  const [copied, setCopied] = useState(false);
@@ -2,6 +2,8 @@ import type { BookingEngine } from '../client.js';
2
2
  import type { SiteContentSchema } from '../content/schema.js';
3
3
  import type { AdminSettings, Preset } from '../types.js';
4
4
  import type { ConfirmInput, ToastInput } from './feedback.js';
5
+ /** Whether this installation emails customers ('none': a demo — see BookingAdminProps.emailDelivery). */
6
+ export type EmailDelivery = 'live' | 'none';
5
7
  /** What the navigation shows about the website (null until known, or without editable content). */
6
8
  export interface WebsiteStatus {
7
9
  version: number;
@@ -25,6 +27,8 @@ export interface AdminContextValue {
25
27
  contentSchema: SiteContentSchema | null;
26
28
  /** The public website (for "View website" and previews). */
27
29
  siteUrl: string;
30
+ /** 'none' in a demo that never emails anyone: no copy may say a customer gets an email. */
31
+ emailDelivery: EmailDelivery;
28
32
  /** Published version and draft state, for the navigation and Today. */
29
33
  website: WebsiteStatus | null;
30
34
  refreshWebsite: () => void;
@@ -0,0 +1,20 @@
1
+ import type { EmailStatus } from '../types.js';
2
+ import type { EmailDelivery } from './context.js';
3
+ export interface EmailHealth {
4
+ /** A demo: email is simulated, nothing is delivered. */
5
+ demo: boolean;
6
+ /** Ready for online booking: an email was delivered (live), or a demo. */
7
+ working: boolean;
8
+ /** The last delivery attempt failed (live only). */
9
+ failing: boolean;
10
+ }
11
+ export declare function emailHealth(status: EmailStatus | null, delivery?: EmailDelivery): EmailHealth;
12
+ /** What the demo says wherever a live dashboard reports deliveries. */
13
+ export declare const DEMO_EMAIL: {
14
+ readonly health: "Demo: no emails are sent";
15
+ readonly title: "Email is simulated in this demo";
16
+ readonly sub: "Nothing is delivered from this demo. On your own website, this card shows when booking emails were last delivered and how many went out.";
17
+ readonly testSub: "In this demo no test email is sent. On your own website, a delivered test email is what unlocks online booking.";
18
+ readonly recentTitle: "What would have been emailed";
19
+ readonly notSent: "Not sent (demo)";
20
+ };
@@ -0,0 +1,20 @@
1
+ export function emailHealth(status, delivery = 'live') {
2
+ if (delivery === 'none')
3
+ return { demo: true, working: true, failing: false };
4
+ const lastSuccessAt = status?.mailer.lastSuccessAt ?? null;
5
+ const lastFailureAt = status?.mailer.lastFailureAt ?? null;
6
+ return {
7
+ demo: false,
8
+ working: Boolean(lastSuccessAt),
9
+ failing: Boolean(lastFailureAt && (!lastSuccessAt || Date.parse(lastFailureAt) > Date.parse(lastSuccessAt))),
10
+ };
11
+ }
12
+ /** What the demo says wherever a live dashboard reports deliveries. */
13
+ export const DEMO_EMAIL = {
14
+ health: 'Demo: no emails are sent',
15
+ title: 'Email is simulated in this demo',
16
+ sub: 'Nothing is delivered from this demo. On your own website, this card shows when booking emails were last delivered and how many went out.',
17
+ testSub: 'In this demo no test email is sent. On your own website, a delivered test email is what unlocks online booking.',
18
+ recentTitle: 'What would have been emailed',
19
+ notSent: 'Not sent (demo)',
20
+ };
@@ -1,5 +1,6 @@
1
1
  export { BookingAdmin } from './BookingAdmin.js';
2
2
  export type { Appearance, BookingAdminProps } from './BookingAdmin.js';
3
+ export type { EmailDelivery } from './context.js';
3
4
  export { ADMIN_SECTIONS } from './sections.js';
4
5
  export type { AdminSection } from './sections.js';
5
6
  export { BUSINESS_GROUP, POLICY_GROUP } from './fields.js';
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react';
3
3
  import { formatDateTime } from '../../time.js';
4
4
  import { ALERTS_VIEW, TEST_EMAIL_VIEW, alertsAddress } from '../alerts.js';
5
5
  import { useAdmin } from '../context.js';
6
+ import { DEMO_EMAIL, emailHealth } from '../email-health.js';
6
7
  import { EMAIL_GROUP } from '../fields.js';
7
8
  import { Icon } from '../icons.js';
8
9
  import { Badge, Button, ErrorNotice, Field, Notice, PageHeader, SkeletonBlock, formatAgo, useResult } from '../ui.js';
@@ -58,7 +59,7 @@ function reveal(id) {
58
59
  }
59
60
  /** Email health, test email, the online-booking switch and email settings. */
60
61
  export function EmailSection() {
61
- const { engine, settings, refreshSettings, toast, view } = useAdmin();
62
+ const { engine, settings, refreshSettings, toast, view, emailDelivery } = useAdmin();
62
63
  const [load, reload] = useResult(() => engine.admin.emailStatus(), []);
63
64
  // Where new-request alerts go (the alerts address, else the public email); the test email goes there by default.
64
65
  const alerts = alertsAddress(settings);
@@ -166,17 +167,25 @@ export function EmailSection() {
166
167
  }
167
168
  const status = load.state === 'ready' ? load.data : null;
168
169
  const lastStart = status ? describeLastStart(status.wiring.lastStart) : null;
169
- const working = Boolean(status?.mailer.lastSuccessAt);
170
- const failing = Boolean(status?.mailer.lastFailureAt && (!status.mailer.lastSuccessAt || Date.parse(status.mailer.lastFailureAt) > Date.parse(status.mailer.lastSuccessAt)));
170
+ // In a demo ('none') nothing is delivered: no time, count or "Sent" is shown, and online booking can still be switched.
171
+ const { demo, working, failing } = emailHealth(status, emailDelivery);
171
172
  const wired = status ? WIRING.every((w) => status.wiring[w.key]) : true;
172
173
  const online = settings.onlineBookingEnabled;
173
174
  // Going live needs both: customers receive their codes, and the owner hears about every request.
174
175
  const canGoLive = working && Boolean(alerts);
175
- return (_jsxs("section", { "aria-labelledby": "pbe-email-title", className: "pbe-page", children: [_jsx(PageHeader, { id: "pbe-email-title", title: "Email & online booking", sub: `Customers confirm their email address with a code before a request reaches you, and get an email when you confirm, decline or cancel.${alerts ? ` You are emailed about every new request at ${alerts}.` : ''}` }), problem ? _jsx(Notice, { kind: "error", children: problem }) : null, !alerts ? (_jsxs(Notice, { kind: "warning", children: [_jsx("strong", { children: "New-request alerts have no address." }), " Nobody is emailed when a customer asks for an appointment, so a request could wait unanswered until its hold ends. Choose an address under \u201CSend new-request alerts to\u201D, or add a public email in Business.", ' ', _jsx("button", { type: "button", className: "pbe-link-button", onClick: () => reveal(ALERTS_FIELD), children: "Choose an address" })] })) : null, _jsxs("div", { className: "pbe-grid-2", children: [_jsxs("div", { className: "pbe-card pbe-card--pad pbe-stack", "aria-labelledby": "pbe-online-title", role: "region", children: [_jsxs("div", { className: "pbe-status-head", children: [_jsx("span", { className: `pbe-status-icon${online ? ' pbe-status-icon--ok' : ''}`, "aria-hidden": "true", children: _jsx(Icon, { name: "online", size: 20 }) }), _jsxs("div", { children: [_jsxs("h2", { id: "pbe-online-title", className: "pbe-card-title", children: ["Online booking is ", online ? 'on' : 'off'] }), _jsx("p", { className: "pbe-card-sub", children: online
176
+ return (_jsxs("section", { "aria-labelledby": "pbe-email-title", className: "pbe-page", children: [_jsx(PageHeader, { id: "pbe-email-title", title: "Email & online booking", sub: emailDelivery === 'none'
177
+ ? 'This demo sends no email. On your own website, customers confirm their email address with a code before a request reaches you, get an email when you confirm, decline or cancel, and you are emailed about every new request.'
178
+ : `Customers confirm their email address with a code before a request reaches you, and get an email when you confirm, decline or cancel.${alerts ? ` You are emailed about every new request at ${alerts}.` : ''}` }), problem ? _jsx(Notice, { kind: "error", children: problem }) : null, !alerts ? (_jsxs(Notice, { kind: "warning", children: [_jsx("strong", { children: "New-request alerts have no address." }), " Nobody is emailed when a customer asks for an appointment, so a request could wait unanswered until its hold ends. Choose an address under \u201CSend new-request alerts to\u201D, or add a public email in Business.", ' ', _jsx("button", { type: "button", className: "pbe-link-button", onClick: () => reveal(ALERTS_FIELD), children: "Choose an address" })] })) : null, _jsxs("div", { className: "pbe-grid-2", children: [_jsxs("div", { className: "pbe-card pbe-card--pad pbe-stack", "aria-labelledby": "pbe-online-title", role: "region", children: [_jsxs("div", { className: "pbe-status-head", children: [_jsx("span", { className: `pbe-status-icon${online ? ' pbe-status-icon--ok' : ''}`, "aria-hidden": "true", children: _jsx(Icon, { name: "online", size: 20 }) }), _jsxs("div", { children: [_jsxs("h2", { id: "pbe-online-title", className: "pbe-card-title", children: ["Online booking is ", online ? 'on' : 'off'] }), _jsx("p", { className: "pbe-card-sub", children: online
176
179
  ? 'Customers can request appointments on your website.'
177
180
  : !working
178
181
  ? 'Send a test email first: customers must be able to receive their code before they can book.'
179
- : !alerts
180
- ? 'Email works. Choose where new-request alerts go, then switch online booking on.'
181
- : 'Email works. Switch online booking on when you are ready for requests.' })] })] }), _jsx("div", { className: "pbe-form-actions", children: online ? (_jsx(Button, { loading: busy === 'online', onClick: () => void setOnline(false), children: "Turn online booking off" })) : (_jsx(Button, { variant: "primary", loading: busy === 'online', disabled: !canGoLive, onClick: () => void setOnline(true), children: "Turn online booking on" })) })] }), _jsxs("div", { className: "pbe-card pbe-card--pad pbe-stack", "aria-labelledby": "pbe-sending-title", role: "region", children: [load.state === 'loading' ? _jsx(SkeletonBlock, { lines: 2, label: "Checking booking emails\u2026" }) : null, load.state === 'error' ? _jsx(ErrorNotice, { error: load.error, onRetry: reload }) : null, status ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "pbe-status-head", children: [_jsx("span", { className: `pbe-status-icon${failing ? ' pbe-status-icon--bad' : working ? ' pbe-status-icon--ok' : ' pbe-status-icon--warn'}`, "aria-hidden": "true", children: _jsx(Icon, { name: failing ? 'mail-problem' : 'mail-ok', size: 20 }) }), _jsxs("div", { children: [_jsx("h2", { id: "pbe-sending-title", className: "pbe-card-title", children: failing ? 'Booking emails are failing' : working ? 'Booking emails are working' : 'No email delivered yet' }), _jsx("p", { className: "pbe-card-sub", children: working ? `Last delivered ${formatAgo(status.mailer.lastSuccessAt)} (${when(status.mailer.lastSuccessAt)}).` : 'Send a test email to check the set-up.' })] })] }), failing ? (_jsxs(Notice, { kind: "warning", children: ["Last problem (", when(status.mailer.lastFailureAt), "): ", status.mailer.lastError ?? 'unknown error'] })) : null, _jsxs("p", { className: "pbe-stats-line", children: [_jsxs("span", { children: [_jsx("b", { children: status.counts.sentLast24h }), "sent in 24 h"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.codesLast24h }), "of ", settings.maxVerificationEmailsPerDay, " code emails"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.queued }), "waiting"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.failedLast7Days }), "failed in 7 days"] })] }), status.counts.retryable > 0 ? (_jsxs("div", { className: "pbe-form-actions", children: [_jsxs(Button, { icon: "retry", loading: busy === 'retry', onClick: () => void retryFailed(), children: ["Retry ", status.counts.retryable, " failed email", status.counts.retryable === 1 ? '' : 's'] }), _jsx("span", { className: "pbe-help", children: "Emails from the last 23 hours; nobody gets one twice." })] })) : null] })) : null] })] }), _jsxs("div", { className: "pbe-card", role: "region", "aria-labelledby": "pbe-test-title", children: [_jsx("div", { className: "pbe-card-head pbe-card-head--rule", children: _jsxs("div", { children: [_jsx("h2", { id: "pbe-test-title", className: "pbe-card-title", children: "Send a test email" }), _jsx("p", { className: "pbe-card-sub", children: "A delivered test email is what unlocks online booking." })] }) }), _jsxs("form", { className: "pbe-form pbe-card-form", onSubmit: sendTest, children: [_jsxs("div", { className: "pbe-test-row", children: [_jsx("div", { className: "pbe-test-field", children: _jsx(Field, { id: "pbe-test-recipient", label: "Send a test email to", help: "Use an inbox you can check now.", children: _jsx("input", { id: "pbe-test-recipient", type: "email", required: true, autoComplete: "email", value: recipient, onChange: (e) => setRecipient(e.target.value) }) }) }), _jsx("div", { className: "pbe-test-action", children: _jsx(Button, { type: "submit", variant: "primary", icon: "send", loading: busy === 'test', children: "Send test email" }) })] }), test ? _jsx(Notice, { kind: test.kind, children: test.text }) : null] }), status ? (_jsxs("details", { className: "pbe-details pbe-card-details", open: !wired || (lastStart ? !lastStart.ok : false), children: [_jsxs("summary", { children: ["Technical details", _jsx("span", { className: "pbe-push" }), wired && (!lastStart || lastStart.ok) ? _jsx(Badge, { tone: "ok", children: "Set up" }) : _jsx(Badge, { tone: "warn", children: "Needs attention" }), _jsx(Icon, { name: "down" })] }), _jsxs("div", { className: "pbe-details-body", children: [_jsxs("ul", { className: "pbe-checklist", "aria-label": "Automatic sending", children: [WIRING.map((w) => (_jsxs("li", { className: status.wiring[w.key] ? 'pbe-done' : undefined, children: [_jsx("span", { className: "pbe-checklist-mark", "aria-hidden": "true", children: status.wiring[w.key] ? _jsx(Icon, { name: "check" }) : null }), _jsxs("span", { children: [w.label, _jsx("span", { className: "pbe-sr-only", children: status.wiring[w.key] ? ' (done)' : ' (missing)' })] })] }, w.key))), lastStart ? (_jsxs("li", { className: lastStart.ok ? 'pbe-done' : 'pbe-bad', children: [_jsx("span", { className: "pbe-checklist-mark", "aria-hidden": "true", children: _jsx(Icon, { name: lastStart.ok ? 'check' : 'close' }) }), _jsxs("span", { children: ["Last start of the mailer (", when(status.wiring.lastStart?.at ?? null), "): ", lastStart.text] })] })) : null] }), !wired ? (_jsxs("p", { className: "pbe-help", children: ["Set up once from your project folder: run ", _jsx("code", { className: "pbe-inline-code", children: "npx booking-engine mailer-sql" }), ", paste its output into the Supabase SQL Editor, then add the token it returns as the Edge Function secret ", _jsx("code", { className: "pbe-inline-code", children: "BOOKING_MAILER_TOKEN" }), "."] })) : null] })] })) : null] }), status && status.recent.length ? (_jsxs("div", { className: "pbe-stack", role: "region", "aria-labelledby": "pbe-recent-title", children: [_jsx("h2", { id: "pbe-recent-title", className: "pbe-section-title", children: "Recent emails" }), _jsxs("table", { className: "pbe-table pbe-table--card", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Email" }), _jsx("th", { scope: "col", children: "To" }), _jsx("th", { scope: "col", children: "Status" }), _jsx("th", { scope: "col", children: "Queued" })] }) }), _jsx("tbody", { children: (showAll ? status.recent : status.recent.slice(0, 8)).map((m) => (_jsxs("tr", { children: [_jsx("td", { children: KIND_LABELS[m.kind] ?? m.kind }), _jsx("td", { className: "pbe-tnum", children: m.recipient }), _jsxs("td", { children: [_jsx(Badge, { tone: DELIVERY[m.status].tone, children: DELIVERY[m.status].label }), m.status === 'failed' && m.lastError ? _jsx("div", { className: "pbe-help", children: m.lastError }) : null] }), _jsx("td", { className: "pbe-nowrap pbe-tnum", children: when(m.createdAt) })] }, m.id))) })] }), status.recent.length > 8 && !showAll ? (_jsxs(Button, { size: "sm", className: "pbe-table-more", onClick: () => setShowAll(true), children: ["Show all ", status.recent.length] })) : null] })) : null, _jsx(SettingsSection, { group: EMAIL_GROUP, embedded: true })] }));
182
+ : demo
183
+ ? 'Switch online booking on to take requests on the demo website.'
184
+ : !alerts
185
+ ? 'Email works. Choose where new-request alerts go, then switch online booking on.'
186
+ : 'Email works. Switch online booking on when you are ready for requests.' })] })] }), _jsx("div", { className: "pbe-form-actions", children: online ? (_jsx(Button, { loading: busy === 'online', onClick: () => void setOnline(false), children: "Turn online booking off" })) : (_jsx(Button, { variant: "primary", loading: busy === 'online', disabled: !canGoLive, onClick: () => void setOnline(true), children: "Turn online booking on" })) })] }), _jsxs("div", { className: "pbe-card pbe-card--pad pbe-stack", "aria-labelledby": "pbe-sending-title", role: "region", children: [load.state === 'loading' ? _jsx(SkeletonBlock, { lines: 2, label: "Checking booking emails\u2026" }) : null, load.state === 'error' ? _jsx(ErrorNotice, { error: load.error, onRetry: reload }) : null, status ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "pbe-status-head", children: [_jsx("span", { className: `pbe-status-icon${demo ? '' : failing ? ' pbe-status-icon--bad' : working ? ' pbe-status-icon--ok' : ' pbe-status-icon--warn'}`, "aria-hidden": "true", children: _jsx(Icon, { name: failing ? 'mail-problem' : 'mail-ok', size: 20 }) }), _jsxs("div", { children: [_jsx("h2", { id: "pbe-sending-title", className: "pbe-card-title", children: demo ? DEMO_EMAIL.title : failing ? 'Booking emails are failing' : working ? 'Booking emails are working' : 'No email delivered yet' }), _jsx("p", { className: "pbe-card-sub", children: demo
187
+ ? DEMO_EMAIL.sub
188
+ : working
189
+ ? `Last delivered ${formatAgo(status.mailer.lastSuccessAt)} (${when(status.mailer.lastSuccessAt)}).`
190
+ : 'Send a test email to check the set-up.' })] })] }), failing ? (_jsxs(Notice, { kind: "warning", children: ["Last problem (", when(status.mailer.lastFailureAt), "): ", status.mailer.lastError ?? 'unknown error'] })) : null, demo ? null : (_jsxs("p", { className: "pbe-stats-line", children: [_jsxs("span", { children: [_jsx("b", { children: status.counts.sentLast24h }), "sent in 24 h"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.codesLast24h }), "of ", settings.maxVerificationEmailsPerDay, " code emails"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.queued }), "waiting"] }), _jsxs("span", { children: [_jsx("b", { children: status.counts.failedLast7Days }), "failed in 7 days"] })] })), !demo && status.counts.retryable > 0 ? (_jsxs("div", { className: "pbe-form-actions", children: [_jsxs(Button, { icon: "retry", loading: busy === 'retry', onClick: () => void retryFailed(), children: ["Retry ", status.counts.retryable, " failed email", status.counts.retryable === 1 ? '' : 's'] }), _jsx("span", { className: "pbe-help", children: "Emails from the last 23 hours; nobody gets one twice." })] })) : null] })) : null] })] }), _jsxs("div", { className: "pbe-card", role: "region", "aria-labelledby": "pbe-test-title", children: [_jsx("div", { className: "pbe-card-head pbe-card-head--rule", children: _jsxs("div", { children: [_jsx("h2", { id: "pbe-test-title", className: "pbe-card-title", children: "Send a test email" }), _jsx("p", { className: "pbe-card-sub", children: demo ? DEMO_EMAIL.testSub : 'A delivered test email is what unlocks online booking.' })] }) }), _jsxs("form", { className: "pbe-form pbe-card-form", onSubmit: sendTest, children: [_jsxs("div", { className: "pbe-test-row", children: [_jsx("div", { className: "pbe-test-field", children: _jsx(Field, { id: "pbe-test-recipient", label: "Send a test email to", help: "Use an inbox you can check now.", children: _jsx("input", { id: "pbe-test-recipient", type: "email", required: true, autoComplete: "email", value: recipient, onChange: (e) => setRecipient(e.target.value) }) }) }), _jsx("div", { className: "pbe-test-action", children: _jsx(Button, { type: "submit", variant: "primary", icon: "send", loading: busy === 'test', children: "Send test email" }) })] }), test ? _jsx(Notice, { kind: test.kind, children: test.text }) : null] }), status ? (_jsxs("details", { className: "pbe-details pbe-card-details", open: !wired || (lastStart ? !lastStart.ok : false), children: [_jsxs("summary", { children: ["Technical details", _jsx("span", { className: "pbe-push" }), wired && (!lastStart || lastStart.ok) ? _jsx(Badge, { tone: "ok", children: "Set up" }) : _jsx(Badge, { tone: "warn", children: "Needs attention" }), _jsx(Icon, { name: "down" })] }), _jsxs("div", { className: "pbe-details-body", children: [_jsxs("ul", { className: "pbe-checklist", "aria-label": "Automatic sending", children: [WIRING.map((w) => (_jsxs("li", { className: status.wiring[w.key] ? 'pbe-done' : undefined, children: [_jsx("span", { className: "pbe-checklist-mark", "aria-hidden": "true", children: status.wiring[w.key] ? _jsx(Icon, { name: "check" }) : null }), _jsxs("span", { children: [w.label, _jsx("span", { className: "pbe-sr-only", children: status.wiring[w.key] ? ' (done)' : ' (missing)' })] })] }, w.key))), lastStart ? (_jsxs("li", { className: lastStart.ok ? 'pbe-done' : 'pbe-bad', children: [_jsx("span", { className: "pbe-checklist-mark", "aria-hidden": "true", children: _jsx(Icon, { name: lastStart.ok ? 'check' : 'close' }) }), _jsxs("span", { children: ["Last start of the mailer (", when(status.wiring.lastStart?.at ?? null), "): ", lastStart.text] })] })) : null] }), !wired ? (_jsxs("p", { className: "pbe-help", children: ["Set up once from your project folder: run ", _jsx("code", { className: "pbe-inline-code", children: "npx booking-engine mailer-sql" }), ", paste its output into the Supabase SQL Editor, then add the token it returns as the Edge Function secret ", _jsx("code", { className: "pbe-inline-code", children: "BOOKING_MAILER_TOKEN" }), "."] })) : null] })] })) : null] }), status && status.recent.length ? (_jsxs("div", { className: "pbe-stack", role: "region", "aria-labelledby": "pbe-recent-title", children: [_jsx("h2", { id: "pbe-recent-title", className: "pbe-section-title", children: demo ? DEMO_EMAIL.recentTitle : 'Recent emails' }), _jsxs("table", { className: "pbe-table pbe-table--card", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Email" }), _jsx("th", { scope: "col", children: "To" }), _jsx("th", { scope: "col", children: "Status" }), _jsx("th", { scope: "col", children: "Queued" })] }) }), _jsx("tbody", { children: (showAll ? status.recent : status.recent.slice(0, 8)).map((m) => (_jsxs("tr", { children: [_jsx("td", { children: KIND_LABELS[m.kind] ?? m.kind }), _jsx("td", { className: "pbe-tnum", children: m.recipient }), _jsxs("td", { children: [demo ? (_jsx(Badge, { tone: "neutral", children: DEMO_EMAIL.notSent })) : (_jsx(Badge, { tone: DELIVERY[m.status].tone, children: DELIVERY[m.status].label })), !demo && m.status === 'failed' && m.lastError ? _jsx("div", { className: "pbe-help", children: m.lastError }) : null] }), _jsx("td", { className: "pbe-nowrap pbe-tnum", children: when(m.createdAt) })] }, m.id))) })] }), status.recent.length > 8 && !showAll ? (_jsxs(Button, { size: "sm", className: "pbe-table-more", onClick: () => setShowAll(true), children: ["Show all ", status.recent.length] })) : null] })) : null, _jsx(SettingsSection, { group: EMAIL_GROUP, embedded: true })] }));
182
191
  }
@@ -8,6 +8,7 @@ import { addDays, formatClockTime, formatDate, formatDateTime, formatMoney, form
8
8
  import { ALERTS_VIEW, alertsAddress } from '../alerts.js';
9
9
  import { BookingDrawer, actionsFor, dayWord, priceText, useBookingActions } from '../booking-detail.js';
10
10
  import { useAdmin } from '../context.js';
11
+ import { DEMO_EMAIL, emailHealth } from '../email-health.js';
11
12
  import { Icon } from '../icons.js';
12
13
  import { SetupChecklist } from '../setup.js';
13
14
  import { OCCUPYING, bookingSpan, byUrgency, closuresOn, freeSpans, holdRunning, holdState, openSpans, overlapMinutes, toMinutes, total, weekStart, } from '../today.js';
@@ -51,7 +52,7 @@ const FIRST_REQUESTS = { wide: 3, phone: 2 };
51
52
  * booking drawer). When nothing waits, the same place says so, calmly.
52
53
  */
53
54
  function Requests({ requests, services, now, onOpen, onAnswered, }) {
54
- const { settings, go } = useAdmin();
55
+ const { settings, go, emailDelivery } = useAdmin();
55
56
  const run = useBookingActions();
56
57
  const phone = useMediaQuery('(max-width: 899px)');
57
58
  const [expanded, setExpanded] = useState(false);
@@ -103,7 +104,7 @@ function Requests({ requests, services, now, onOpen, onAnswered, }) {
103
104
  return (_jsxs("section", { ref: panel, className: "pbe-urgent", "aria-labelledby": "pbe-urgent-title", children: [_jsxs("div", { className: "pbe-urgent-head", children: [_jsx("span", { className: "pbe-urgent-number", "aria-hidden": "true", children: n }), _jsxs("div", { className: "pbe-urgent-text", children: [_jsxs("h2", { id: "pbe-urgent-title", className: "pbe-urgent-title", tabIndex: -1, children: [_jsxs("span", { className: "pbe-sr-only", children: [n, " "] }), n === 1 ? 'request needs your answer' : 'requests need your answer'] }), _jsx("p", { className: "pbe-urgent-sub", children: soonest ? (_jsxs(_Fragment, { children: ["Times stay held until you answer or the hold ends. Next to expire: ", _jsx("b", { children: firstName(soonest.customer.name) }), ", at", ' ', _jsx("b", { children: until(soonest.holdExpiresAt) }), ".", ended ? (_jsxs(_Fragment, { children: [' ', _jsxs("span", { className: "pbe-urgent-ended", children: [ended === 1 ? '1 hold has ended' : `${ended} holds have ended`, ": confirm ", ended === 1 ? 'it' : 'them', " if the time is still free."] })] })) : null] })) : n === 1 ? ('Its hold has ended, so the time is open to others again. Confirm it if the time is still free.') : ('Their holds have ended, so the times are open to others again. Confirm the ones that are still free.') })] }), _jsx(Button, { size: "sm", className: "pbe-urgent-link", iconAfter: "arrow", onClick: () => go('bookings', 'pending'), children: "Open in Bookings" })] }), _jsxs("div", { className: "pbe-requests", children: [_jsx("ul", { className: "pbe-requests-list", id: "pbe-requests-list", "aria-labelledby": "pbe-urgent-title", children: shown.map((b, index) => {
104
105
  const hold = holdState(b, settings.pendingHoldMinutes, now);
105
106
  const isEnded = !holdRunning(b, now);
106
- const actions = actionsFor(b, now);
107
+ const actions = actionsFor(b, now, emailDelivery);
107
108
  const decline = actions.find((a) => a.status === 'cancelled');
108
109
  const confirm = actions.find((a) => a.status === 'confirmed');
109
110
  const error = errors[b.id];
@@ -375,11 +376,15 @@ function ClosuresAhead({ closures, today }) {
375
376
  return (_jsxs("section", { className: "pbe-card", "aria-labelledby": "pbe-closures-ahead-title", children: [_jsxs("div", { className: "pbe-card-head", children: [_jsx("h2", { id: "pbe-closures-ahead-title", className: "pbe-card-title", children: "Closures ahead" }), _jsx("div", { className: "pbe-card-actions", children: _jsxs("button", { type: "button", className: "pbe-link-button pbe-link-button--quiet", onClick: () => go('hours'), children: ["Hours & closures ", _jsx(Icon, { name: "arrow" })] }) })] }), closures === null ? (_jsx("div", { className: "pbe-card-body", children: _jsxs("div", { className: "pbe-skeleton", "aria-hidden": "true", children: [_jsx("span", { className: "pbe-sk" }), _jsx("span", { className: "pbe-sk" })] }) })) : upcoming.length ? (_jsx("ul", { className: "pbe-list-rows", children: upcoming.map((c) => (_jsxs("li", { className: "pbe-list-row", children: [_jsx("span", { className: "pbe-list-row-date", children: date(c.startsOn) }), _jsxs("span", { className: "pbe-list-row-main", children: [_jsx("span", { children: c.endsOn !== c.startsOn ? `Until ${date(c.endsOn)}` : c.startTime ? `${formatClockTime(c.startTime, locale)} – ${formatClockTime(c.endTime ?? '24:00', locale)}` : 'All day' }), _jsx("span", { children: c.reason ?? 'No note' })] })] }, c.id))) })) : (_jsx("div", { className: "pbe-card-body", children: _jsx("p", { className: "pbe-help", children: "No closures planned. Add holidays and time off so nobody can book them." }) }))] }));
376
377
  }
377
378
  function useHealth(email) {
378
- const { settings, contentSchema, website } = useAdmin();
379
+ const { settings, contentSchema, website, emailDelivery } = useAdmin();
379
380
  const items = [];
380
- if (email) {
381
- const { lastSuccessAt, lastFailureAt } = email.mailer;
382
- const failing = Boolean(lastFailureAt && (!lastSuccessAt || Date.parse(lastFailureAt) > Date.parse(lastSuccessAt)));
381
+ if (email && emailDelivery === 'none') {
382
+ // A demo delivers nothing: say so, with no "last sent" time.
383
+ items.push({ key: 'email', tone: 'ok', text: DEMO_EMAIL.health, section: 'email' });
384
+ }
385
+ else if (email) {
386
+ const { lastSuccessAt } = email.mailer;
387
+ const { failing } = emailHealth(email, emailDelivery);
383
388
  items.push(failing
384
389
  ? { key: 'email', tone: 'bad', text: 'Booking emails failing', section: 'email' }
385
390
  : lastSuccessAt
@@ -4,22 +4,23 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import { useEffect, useState } from 'react';
5
5
  import { ALERTS_VIEW, TEST_EMAIL_VIEW, alertsAddress } from './alerts.js';
6
6
  import { useAdmin } from './context.js';
7
+ import { emailHealth } from './email-health.js';
7
8
  import { Icon } from './icons.js';
8
9
  import { Meter } from './ui.js';
9
10
  export function SetupChecklist() {
10
- const { engine, settings, go } = useAdmin();
11
+ const { engine, settings, go, emailDelivery } = useAdmin();
11
12
  const [counts, setCounts] = useState(null);
12
13
  useEffect(() => {
13
14
  let alive = true;
14
15
  Promise.all([engine.admin.listServices(), engine.admin.getWorkingHours(), engine.admin.emailStatus()]).then(([s, h, e]) => {
15
16
  if (alive && s.ok && h.ok) {
16
- setCounts({ services: s.data.length, hours: h.data.length, emailWorks: e.ok && Boolean(e.data.mailer.lastSuccessAt) });
17
+ setCounts({ services: s.data.length, hours: h.data.length, emailWorks: emailHealth(e.ok ? e.data : null, emailDelivery).working });
17
18
  }
18
19
  });
19
20
  return () => {
20
21
  alive = false;
21
22
  };
22
- }, [engine, settings.onlineBookingEnabled]);
23
+ }, [engine, settings.onlineBookingEnabled, emailDelivery]);
23
24
  if (!counts)
24
25
  return null;
25
26
  // Every new request is emailed to this address: without one, nobody hears about it.
@@ -1,5 +1,5 @@
1
1
  export declare const ENGINE_PACKAGE = "@profitstudio/booking-engine";
2
- export declare const ENGINE_VERSION = "2.0.0-beta.1";
2
+ export declare const ENGINE_VERSION = "2.0.0-beta.3";
3
3
  /** Schema version this package's migrations produce. */
4
4
  export declare const SCHEMA_VERSION = "2.0.0-alpha.10";
5
5
  /** Oldest database schema this package can talk to (same major). */
@@ -1,6 +1,6 @@
1
1
  // GENERATED by scripts/build.mjs from package.json — do not edit.
2
2
  export const ENGINE_PACKAGE = "@profitstudio/booking-engine";
3
- export const ENGINE_VERSION = "2.0.0-beta.1";
3
+ export const ENGINE_VERSION = "2.0.0-beta.3";
4
4
  /** Schema version this package's migrations produce. */
5
5
  export const SCHEMA_VERSION = "2.0.0-alpha.10";
6
6
  /** Oldest database schema this package can talk to (same major). */
@@ -1,6 +1,6 @@
1
1
  # Booking Engine — Integration Contract
2
2
 
3
- `@profitstudio/booking-engine` · engine 2.0.0-beta.1 · database schema 2.0.0-alpha.10
3
+ `@profitstudio/booking-engine` · engine 2.0.0-beta.3 · database schema 2.0.0-alpha.10
4
4
  (booking works from schema alpha.5; website content (§15) needs alpha.7;
5
5
  service photos and opening times need alpha.10)
6
6
 
@@ -56,7 +56,7 @@ prompt and this document disagree on a technical point, this document wins.
56
56
  ## 3. Install
57
57
 
58
58
  ```bash
59
- npm install --save-exact @profitstudio/booking-engine@2.0.0-beta.1 # exact version from the guide
59
+ npm install --save-exact @profitstudio/booking-engine@2.0.0-beta.3 # exact version from the guide
60
60
  npx booking-engine init # a hair salon may add: --preset hair-salon
61
61
  ```
62
62
 
@@ -622,9 +622,14 @@ createRoot(document.getElementById('admin')!).render(
622
622
  ```
623
623
 
624
624
  Props: `engine` (the site's one instance), `siteUrl` (default `/`), `content`
625
- (optional, §15) and `presets` (optional: the starter sets offered while the
625
+ (optional, §15), `presets` (optional: the starter sets offered while the
626
626
  owner has no services; default the engine's own — pass the site's preset from
627
- §5 for any other kind of business).
627
+ §5 for any other kind of business) and `emailDelivery` (optional, since
628
+ 2.0.0-beta.2: `'live'` by default; `'none'` only for a public demo or showcase
629
+ that never emails anyone — the dashboard then never says a customer gets an
630
+ email, and, since 2.0.0-beta.3, never reports a delivery: the Today health
631
+ line, the Email page's status card and its list of emails say that email is
632
+ simulated, with no delivery time, count or "Sent". A real site never sets it).
628
633
 
629
634
  The dashboard handles sign-in, the admin check, a **Today** overview (the
630
635
  requests waiting for an answer, with their hold countdown and Confirm /
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@profitstudio/booking-engine",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "schemaVersion": "2.0.0-alpha.10",
5
5
  "requiredSchemaVersion": "2.0.0-alpha.5",
6
6
  "migrations": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profitstudio/booking-engine",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Secure, versioned booking engine for independently owned small-business websites: Supabase migrations, a typed client, an admin dashboard and a CLI.",
5
5
  "license": "MIT",
6
6
  "author": "Youssef Es-salhi",