@profitstudio/booking-engine 2.0.0-beta.2 → 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,24 @@
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
+
3
22
  ## 2.0.0-beta.2 — 2026-11-04
4
23
 
5
24
  A dashboard option for public demos. **No migration** (schema 2.0.0-alpha.10),
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.2 — 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
 
@@ -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';
@@ -252,7 +253,7 @@ function BusinessClock({ timezone, locale }) {
252
253
  }
253
254
  /** On every page: say so when booking emails are not getting out (customers then cannot receive codes). */
254
255
  function EmailHealthBanner() {
255
- const { engine, settings, go } = useAdmin();
256
+ const { engine, settings, go, emailDelivery } = useAdmin();
256
257
  const [status, setStatus] = useState(null);
257
258
  useEffect(() => {
258
259
  let alive = true;
@@ -264,10 +265,11 @@ function EmailHealthBanner() {
264
265
  alive = false;
265
266
  };
266
267
  }, [engine]);
267
- if (!status)
268
+ // A demo sends nothing, so there is nothing to warn about.
269
+ if (!status || emailDelivery === 'none')
268
270
  return null;
269
- const { lastSuccessAt, lastFailureAt, lastError } = status.mailer;
270
- const failing = Boolean(lastFailureAt && (!lastSuccessAt || Date.parse(lastFailureAt) > Date.parse(lastSuccessAt)));
271
+ const { lastError } = status.mailer;
272
+ const { failing } = emailHealth(status, emailDelivery);
271
273
  const stuck = Boolean(status.counts.oldestQueuedAt && Date.now() - Date.parse(status.counts.oldestQueuedAt) > 5 * 60_000);
272
274
  // The same count and 24-hour window the database uses to refuse new codes (RATE_LIMITED).
273
275
  const capReached = settings.onlineBookingEnabled && status.counts.codesLast24h >= settings.maxVerificationEmailsPerDay;
@@ -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
+ };
@@ -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';
@@ -166,8 +167,8 @@ 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.
@@ -178,7 +179,13 @@ export function EmailSection() {
178
179
  ? 'Customers can request appointments on your website.'
179
180
  : !working
180
181
  ? 'Send a test email first: customers must be able to receive their code before they can book.'
181
- : !alerts
182
- ? 'Email works. Choose where new-request alerts go, then switch online booking on.'
183
- : '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 })] }));
184
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';
@@ -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.2";
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.2";
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.2 · 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.2 # 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
 
@@ -627,7 +627,9 @@ owner has no services; default the engine's own — pass the site's preset from
627
627
  §5 for any other kind of business) and `emailDelivery` (optional, since
628
628
  2.0.0-beta.2: `'live'` by default; `'none'` only for a public demo or showcase
629
629
  that never emails anyone — the dashboard then never says a customer gets an
630
- email. A real site never sets it).
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).
631
633
 
632
634
  The dashboard handles sign-in, the admin check, a **Today** overview (the
633
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.2",
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.2",
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",