From 5aa216664c5e90705317ed22d45785b29d7459b8 Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Sun, 22 Nov 2026 00:50:16 +0000
Subject: [PATCH 1/3] Restore sticky full-width demo banner; replace native
controls with shadcn components
Co-Authored-By: Max Farrell
---
.changeset/sticky-banner-shadcn.md | 5 +
src/lib/components/app/demo-banner.svelte | 2 +-
.../ui/confirm-dialog/confirm-dialog.svelte | 134 ++++++++++++++
src/lib/components/ui/confirm-dialog/index.ts | 3 +
src/routes/(app)/+layout.svelte | 4 +-
src/routes/(app)/billing/+page.svelte | 126 +++++++++----
src/routes/(app)/checkins/+page.svelte | 13 +-
src/routes/(app)/dashboard/+page.svelte | 52 ++++--
src/routes/(app)/members/+page.svelte | 93 ++++++----
src/routes/(app)/members/[id]/+page.svelte | 142 +++++++++------
src/routes/(app)/plans/+page.svelte | 17 +-
src/routes/(app)/schedule/+page.svelte | 142 +++++++++------
src/routes/(app)/settings/+page.svelte | 154 +++++++++-------
src/routes/kiosk/+page.svelte | 35 ++--
src/routes/portal/+layout.svelte | 8 +-
src/routes/portal/+page.svelte | 166 +++++++++++-------
16 files changed, 762 insertions(+), 334 deletions(-)
create mode 100644 .changeset/sticky-banner-shadcn.md
create mode 100644 src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
create mode 100644 src/lib/components/ui/confirm-dialog/index.ts
diff --git a/.changeset/sticky-banner-shadcn.md b/.changeset/sticky-banner-shadcn.md
new file mode 100644
index 00000000..48da07dd
--- /dev/null
+++ b/.changeset/sticky-banner-shadcn.md
@@ -0,0 +1,5 @@
+---
+freeweight: patch
+---
+
+Restore the full-width sticky demo banner and replace native browser controls (confirm/prompt dialogs, details/summary) with shadcn-svelte components, including a new confirm-dialog UI component.
diff --git a/src/lib/components/app/demo-banner.svelte b/src/lib/components/app/demo-banner.svelte
index da825282..5edbb9ea 100644
--- a/src/lib/components/app/demo-banner.svelte
+++ b/src/lib/components/app/demo-banner.svelte
@@ -28,7 +28,7 @@
Private demo · {remaining > 0 ? 'Session ends in' : 'Session ended'}
diff --git a/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte b/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
new file mode 100644
index 00000000..ef001f7f
--- /dev/null
+++ b/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/ui/confirm-dialog/index.ts b/src/lib/components/ui/confirm-dialog/index.ts
new file mode 100644
index 00000000..7175c175
--- /dev/null
+++ b/src/lib/components/ui/confirm-dialog/index.ts
@@ -0,0 +1,3 @@
+import ConfirmDialog, { confirmDialog, type ConfirmDialogOptions } from './confirm-dialog.svelte';
+
+export { ConfirmDialog, confirmDialog, type ConfirmDialogOptions };
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte
index 119f2986..fbb936bf 100644
--- a/src/routes/(app)/+layout.svelte
+++ b/src/routes/(app)/+layout.svelte
@@ -8,6 +8,7 @@
import { setContext } from 'svelte';
import { contrastText } from '#lib/format.ts';
import type { LayoutProps } from './$types';
+ import { ConfirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
let { children, data }: LayoutProps = $props();
// White-label brand for PageHeader's and any brand-aware component.
@@ -37,7 +38,7 @@
deployUrl="https://github.com/maxffarrell/freeweight#quick-start"
/>
{/if}
-
+
{@render children()}
@@ -45,3 +46,4 @@
+
diff --git a/src/routes/(app)/billing/+page.svelte b/src/routes/(app)/billing/+page.svelte
index d692d0f7..d4eddfae 100644
--- a/src/routes/(app)/billing/+page.svelte
+++ b/src/routes/(app)/billing/+page.svelte
@@ -58,6 +58,7 @@
import Gift from '@lucide/svelte/icons/gift';
import Trash2 from '@lucide/svelte/icons/trash-2';
import { toCsv } from '#lib/csv.ts';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const currency = await getCurrency();
const memberList = await getMembers();
@@ -223,8 +224,15 @@
}
let remindingAll = $state(false);
- async function emailAllDebtors() {
- if (!confirm(`Email a payment request to all ${aging.debtors} members owing?`)) return;
+ function emailAllDebtors() {
+ confirmDialog({
+ title: `Email a payment request to all ${aging.debtors} members owing?`,
+ confirm: { text: 'Send' },
+ onConfirm: () => emailAllDebtorsNow()
+ });
+ }
+
+ async function emailAllDebtorsNow() {
remindingAll = true;
try {
const r = await requestAllPayments();
@@ -235,8 +243,16 @@
remindingAll = false;
}
- async function refund(paymentId: string, amount: number) {
- if (!confirm(`Refund ${formatMoney(amount, currency)}? The charge it covered reopens.`)) return;
+ function refund(paymentId: string, amount: number) {
+ confirmDialog({
+ title: `Refund ${formatMoney(amount, currency)}?`,
+ description: 'The charge it covered reopens.',
+ confirm: { text: 'Refund' },
+ onConfirm: () => refundNow(paymentId)
+ });
+ }
+
+ async function refundNow(paymentId: string) {
try {
await refundPayment(paymentId);
payments = await getPayments();
@@ -310,10 +326,17 @@
toast.error(errMsg(err, 'Could not update'));
}
}
- async function deleteRecurring(r: { rec: { id: string; description: string } }) {
- if (!confirm(`Delete the recurring "${r.rec.description}"? Past charges stay.`)) return;
+ function deleteRecurring(r: { rec: { id: string; description: string } }) {
+ confirmDialog({
+ title: `Delete the recurring "${r.rec.description}"?`,
+ description: 'Past charges stay.',
+ onConfirm: () => deleteRecurringNow(r.rec.id)
+ });
+ }
+
+ async function deleteRecurringNow(id: string) {
try {
- await removeRecurring(r.rec.id);
+ await removeRecurring(id);
recurring = await getRecurring();
} catch (err) {
toast.error(errMsg(err, 'Could not delete'));
@@ -436,9 +459,16 @@
let selectedCharges = $state([]);
let voidingMany = $state(false);
- async function voidSelected() {
+ function voidSelected() {
if (!selectedCharges.length) return;
- if (!confirm(`Void ${selectedCharges.length} open charge(s)?`)) return;
+ confirmDialog({
+ title: `Void ${selectedCharges.length} open charge(s)?`,
+ confirm: { text: 'Void' },
+ onConfirm: () => voidSelectedNow()
+ });
+ }
+
+ async function voidSelectedNow() {
voidingMany = true;
try {
for (const id of selectedCharges) await updateCharge({ id, status: 'void' });
@@ -460,8 +490,16 @@
toast.error(errMsg(err, 'Could not void'));
}
}
- async function writeOffCharge(id: string) {
- if (!confirm("Write this charge off as bad debt? It leaves the member's open balance.")) return;
+ function writeOffCharge(id: string) {
+ confirmDialog({
+ title: 'Write this charge off as bad debt?',
+ description: "It leaves the member's open balance.",
+ confirm: { text: 'Write off' },
+ onConfirm: () => writeOffNow(id)
+ });
+ }
+
+ async function writeOffNow(id: string) {
try {
await updateCharge({ id, status: 'written_off' });
await refreshCharges();
@@ -526,29 +564,51 @@
lowStockAt: number | null;
cost: number | null;
}) {
- const raw = prompt(
- `${item.name} — units on hand (blank = unlimited)`,
- String(item.stock ?? '')
- );
- if (raw === null) return;
- const n = raw.trim() === '' ? null : Math.max(0, Math.floor(Number(raw)));
- if (n !== null && !Number.isFinite(n)) return toast.error('Not a number');
- const rawLow = prompt(
- `${item.name} — alert staff when stock drops to (blank = never)`,
- String(item.lowStockAt ?? '')
- );
- if (rawLow === null) return;
- const low = rawLow.trim() === '' ? null : Math.max(0, Math.floor(Number(rawLow)));
- if (low !== null && !Number.isFinite(low)) return toast.error('Not a number');
- const rawCost = prompt(
- `${item.name} — unit cost in cents (blank = untracked)`,
- String(item.cost ?? '')
- );
- if (rawCost === null) return;
- const cost = rawCost.trim() === '' ? null : Math.max(0, Math.floor(Number(rawCost)));
- if (cost !== null && !Number.isFinite(cost)) return toast.error('Not a number');
+ const num = (v: string) => (v.trim() === '' ? null : Math.max(0, Math.floor(Number(v))));
+ confirmDialog({
+ title: `${item.name} — units on hand`,
+ input: { label: 'Units (blank = unlimited)', defaultValue: String(item.stock ?? '') },
+ confirm: { text: 'Next' },
+ onConfirm: (raw) => {
+ const n = num(raw);
+ if (n !== null && !Number.isFinite(n)) return toast.error('Not a number');
+ confirmDialog({
+ title: `${item.name} — low-stock alert`,
+ input: {
+ label: 'Alert staff when stock drops to (blank = never)',
+ defaultValue: String(item.lowStockAt ?? '')
+ },
+ confirm: { text: 'Next' },
+ onConfirm: (rawLow) => {
+ const low = num(rawLow);
+ if (low !== null && !Number.isFinite(low)) return toast.error('Not a number');
+ confirmDialog({
+ title: `${item.name} — unit cost`,
+ input: {
+ label: 'Unit cost in cents (blank = untracked)',
+ defaultValue: String(item.cost ?? '')
+ },
+ confirm: { text: 'Save' },
+ onConfirm: (rawCost) => {
+ const cost = num(rawCost);
+ if (cost !== null && !Number.isFinite(cost)) return toast.error('Not a number');
+ return saveShopStock(item.id, n, low, cost);
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ async function saveShopStock(
+ id: string,
+ n: number | null,
+ low: number | null,
+ cost: number | null
+ ) {
try {
- await updateShopItem({ id: item.id, stock: n, lowStockAt: low, cost });
+ await updateShopItem({ id, stock: n, lowStockAt: low, cost });
shopItems = await getShopItems();
} catch (err) {
toast.error(errMsg(err, 'Could not update stock'));
diff --git a/src/routes/(app)/checkins/+page.svelte b/src/routes/(app)/checkins/+page.svelte
index 1c1ebe7b..e30a915d 100644
--- a/src/routes/(app)/checkins/+page.svelte
+++ b/src/routes/(app)/checkins/+page.svelte
@@ -18,6 +18,7 @@
import { errMsg, todayISO } from '#lib/format.ts';
import { toCsv } from '#lib/csv.ts';
import MonitorSmartphone from '@lucide/svelte/icons/monitor-smartphone';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const settings = await getSettings();
const locations = await getLocations();
@@ -47,8 +48,16 @@
clearTimeout(searchTimer);
searchTimer = setTimeout(() => void refilter(), 250);
}
- async function voidRow(id: string) {
- if (!confirm('Void this check-in? Same-day attendance marks revert too.')) return;
+ function voidRow(id: string) {
+ confirmDialog({
+ title: 'Void this check-in?',
+ description: 'Same-day attendance marks revert too.',
+ confirm: { text: 'Void' },
+ onConfirm: () => voidRowNow(id)
+ });
+ }
+
+ async function voidRowNow(id: string) {
try {
await voidCheckIn(id);
toast.success('Check-in voided');
diff --git a/src/routes/(app)/dashboard/+page.svelte b/src/routes/(app)/dashboard/+page.svelte
index ce1b23c9..dbac0f8b 100644
--- a/src/routes/(app)/dashboard/+page.svelte
+++ b/src/routes/(app)/dashboard/+page.svelte
@@ -53,6 +53,7 @@
import { Checkbox } from '#lib/components/ui/checkbox/index.js';
import Circle from '@lucide/svelte/icons/circle';
import { Progress } from '#lib/components/ui/progress/index.js';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const d = await getDashboard();
const ai = await getAiStatus();
@@ -91,16 +92,31 @@
clockedInAt: Date | string;
clockedOutAt: Date | string | null;
}) {
- const inAt = prompt('Clock-in (YYYY-MM-DDTHH:mm, gym time)', fmtLocal(s.clockedInAt));
- if (inAt === null) return;
- const outAt = prompt(
- 'Clock-out (YYYY-MM-DDTHH:mm, blank = still open)',
- s.clockedOutAt ? fmtLocal(s.clockedOutAt) : ''
- );
- if (outAt === null) return;
+ confirmDialog({
+ title: 'Edit shift times',
+ input: {
+ label: 'Clock-in (YYYY-MM-DDTHH:mm, gym time)',
+ defaultValue: fmtLocal(s.clockedInAt)
+ },
+ confirm: { text: 'Next' },
+ onConfirm: (inAt) =>
+ inAt !== null &&
+ confirmDialog({
+ title: 'Edit shift times',
+ input: {
+ label: 'Clock-out (YYYY-MM-DDTHH:mm, blank = still open)',
+ defaultValue: s.clockedOutAt ? fmtLocal(s.clockedOutAt) : ''
+ },
+ confirm: { text: 'Save' },
+ onConfirm: (outAt) => (outAt !== null ? saveShift(s.id, inAt, outAt) : undefined)
+ })
+ });
+ }
+
+ async function saveShift(id: string, inAt: string, outAt: string) {
try {
await updateShift({
- id: s.id,
+ id,
clockedInAt: inAt.trim(),
clockedOutAt: outAt.trim() || null
});
@@ -845,14 +861,18 @@
variant="ghost"
class="text-muted-foreground"
title="Delete shift"
- onclick={async () => {
- if (!confirm('Delete this shift record?')) return;
- try {
- await deleteShift(r.shift.id);
- toast.success('Deleted');
- } catch (e) {
- toast.error(errMsg(e, 'Could not delete'));
- }
+ onclick={() => {
+ confirmDialog({
+ title: 'Delete this shift record?',
+ onConfirm: async () => {
+ try {
+ await deleteShift(r.shift.id);
+ toast.success('Deleted');
+ } catch (e) {
+ toast.error(errMsg(e, 'Could not delete'));
+ }
+ }
+ });
}}>
diff --git a/src/routes/(app)/members/+page.svelte b/src/routes/(app)/members/+page.svelte
index 080e2136..85a4e83a 100644
--- a/src/routes/(app)/members/+page.svelte
+++ b/src/routes/(app)/members/+page.svelte
@@ -74,6 +74,7 @@
aiSubjectVariants,
getAiStatus
} from '#lib/remote/ai.remote.ts';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const currency = await getCurrency();
const ai = await getAiStatus();
@@ -415,12 +416,19 @@
}
}
});
- async function saveTemplate() {
- const name = window.prompt('Template name', emailSubject.slice(0, 40));
- if (!name?.trim()) return;
+ function saveTemplate() {
+ confirmDialog({
+ title: 'Save template',
+ input: { label: 'Template name', defaultValue: emailSubject.slice(0, 40) },
+ confirm: { text: 'Save' },
+ onConfirm: (name) => (name?.trim() ? saveTemplateNow(name.trim()) : undefined)
+ });
+ }
+
+ async function saveTemplateNow(name: string) {
try {
await saveAnnouncementTemplate({
- name: name.trim(),
+ name,
subject: emailSubject,
message: emailBody,
tag: emailAudience.startsWith('tag:') ? emailAudience.slice(4) : undefined
@@ -629,8 +637,15 @@
toast.error(errMsg(err, 'Could not remove'));
}
}
- async function resendAnnouncement(id: string, n: number) {
- if (!confirm(`Resend to the ${n} member${n === 1 ? '' : 's'} who haven't opened it?`)) return;
+ function resendAnnouncement(id: string, n: number) {
+ confirmDialog({
+ title: `Resend to the ${n} member${n === 1 ? '' : 's'} who haven't opened it?`,
+ confirm: { text: 'Resend' },
+ onConfirm: () => resendNow(id)
+ });
+ }
+
+ async function resendNow(id: string) {
try {
const r = await resendToNonOpeners(id);
toast.success(
@@ -950,44 +965,46 @@
{#if entitlements.dataRetention}
{/if}
diff --git a/src/routes/(app)/members/[id]/+page.svelte b/src/routes/(app)/members/[id]/+page.svelte
index afb0d053..9edb7aaa 100644
--- a/src/routes/(app)/members/[id]/+page.svelte
+++ b/src/routes/(app)/members/[id]/+page.svelte
@@ -130,6 +130,8 @@
import Sparkles from '@lucide/svelte/icons/sparkles';
import Printer from '@lucide/svelte/icons/printer';
import { paymentMethods } from '#lib/schemas.ts';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
+ import * as Collapsible from '#lib/components/ui/collapsible/index.js';
const id = page.params.id!;
const m = $derived(await getMember(id));
@@ -288,8 +290,16 @@
toast.error(errMsg(err, 'Could not resolve'));
}
}
- async function closeIncident(incidentId: string) {
- const followUp = prompt('Follow-up notes (what was done):') ?? '';
+ function closeIncident(incidentId: string) {
+ confirmDialog({
+ title: 'Close incident',
+ input: { label: 'Follow-up notes (what was done)' },
+ confirm: { text: 'Close' },
+ onConfirm: (followUp) => closeIncidentNow(incidentId, followUp ?? '')
+ });
+ }
+
+ async function closeIncidentNow(incidentId: string, followUp: string) {
try {
await updateIncidentEntry({ id: incidentId, memberId: id, status: 'closed', followUp });
} catch (err) {
@@ -314,11 +324,18 @@
}
}
});
- async function saveSrTemplate() {
- const name = window.prompt('Template name', srTitle.slice(0, 40));
- if (!name?.trim()) return;
+ function saveSrTemplate() {
+ confirmDialog({
+ title: 'Save template',
+ input: { label: 'Template name', defaultValue: srTitle.slice(0, 40) },
+ confirm: { text: 'Save' },
+ onConfirm: (name) => (name?.trim() ? saveSrTemplateNow(name.trim()) : undefined)
+ });
+ }
+
+ async function saveSrTemplateNow(name: string) {
try {
- await saveSignDocTemplate({ name: name.trim(), title: srTitle.trim(), body: srBody.trim() });
+ await saveSignDocTemplate({ name, title: srTitle.trim(), body: srBody.trim() });
toast.success('Template saved');
} catch (err) {
toast.error(errMsg(err, 'Could not save template'));
@@ -503,8 +520,14 @@
await getMemberDocuments(id).refresh();
if (fileInput) fileInput.value = '';
}
- async function removeDoc(docId: string, docName: string) {
- if (!confirm(`Delete ${docName}?`)) return;
+ function removeDoc(docId: string, docName: string) {
+ confirmDialog({
+ title: `Delete ${docName}?`,
+ onConfirm: () => removeDocNow(docId)
+ });
+ }
+
+ async function removeDocNow(docId: string) {
try {
await deleteDocument(docId);
await getMemberDocuments(id).refresh();
@@ -513,8 +536,16 @@
}
}
- async function refund(paymentId: string, amount: number) {
- if (!confirm(`Refund ${formatMoney(amount, currency)}? The charge it covered reopens.`)) return;
+ function refund(paymentId: string, amount: number) {
+ confirmDialog({
+ title: `Refund ${formatMoney(amount, currency)}?`,
+ description: 'The charge it covered reopens.',
+ confirm: { text: 'Refund' },
+ onConfirm: () => refundNow(paymentId)
+ });
+ }
+
+ async function refundNow(paymentId: string) {
try {
await refundPayment(paymentId);
toast.success('Payment refunded');
@@ -1037,13 +1068,17 @@
}
}
- async function doAnonymize() {
- if (
- !confirm(
- 'Anonymize this member? Name, email, phone, birthday, notes, photo and measurements are permanently scrubbed. Booking and payment history is kept for accounting. This cannot be undone.'
- )
- )
- return;
+ function doAnonymize() {
+ confirmDialog({
+ title: 'Anonymize this member?',
+ description:
+ 'Name, email, phone, birthday, notes, photo and measurements are permanently scrubbed. Booking and payment history is kept for accounting. This cannot be undone.',
+ confirm: { text: 'Anonymize' },
+ onConfirm: () => doAnonymizeNow()
+ });
+ }
+
+ async function doAnonymizeNow() {
try {
await anonymizeMember(id);
toast.success('Personal data anonymized');
@@ -1348,21 +1383,23 @@
{/each}
{#if m.member.parqHistory?.length}
-
-
+
+
{m.member.parqHistory.length} earlier signing{m.member.parqHistory.length === 1
? ''
: 's'}
-
- {#each m.member.parqHistory as h, i (i)}
-
- Signed {formatDate(h.signedAt)} — {Object.values(h.answers).filter(Boolean)
- .length} yes answer{Object.values(h.answers).filter(Boolean).length === 1
- ? ''
- : 's'}
-
- {/each}
-
+
+
+ {#each m.member.parqHistory as h, i (i)}
+
+ Signed {formatDate(h.signedAt)} — {Object.values(h.answers).filter(Boolean)
+ .length} yes answer{Object.values(h.answers).filter(Boolean).length === 1
+ ? ''
+ : 's'}
+
+ {/each}
+
+
{/if}
{/if}
@@ -1750,22 +1787,25 @@
size="sm"
class="h-7 px-2 text-xs"
title="Push this pack's expiry out — 'paid before it lapsed' fixes"
- onclick={async () => {
- const days = Number(
- window.prompt(
- `Extend the pack by how many days? (currently ${
- mm.membership.endsAt ? formatDate(mm.membership.endsAt) : 'no expiry'
- })`,
- '30'
- )
- );
- if (!days || days <= 0) return;
- try {
- const r = await extendPack({ membershipId: mm.membership.id, days });
- toast.success(`Pack extended to ${formatDate(r.endsAt)}`);
- } catch (err) {
- toast.error(errMsg(err, 'Could not extend'));
- }
+ onclick={() => {
+ confirmDialog({
+ title: `Extend the pack by how many days?`,
+ description: `Currently ${
+ mm.membership.endsAt ? formatDate(mm.membership.endsAt) : 'no expiry'
+ }`,
+ input: { label: 'Days', defaultValue: '30' },
+ confirm: { text: 'Extend' },
+ onConfirm: async (value) => {
+ const days = Number(value);
+ if (!days || days <= 0) return;
+ try {
+ const r = await extendPack({ membershipId: mm.membership.id, days });
+ toast.success(`Pack extended to ${formatDate(r.endsAt)}`);
+ } catch (err) {
+ toast.error(errMsg(err, 'Could not extend'));
+ }
+ }
+ });
}}>Extend
{:else}
@@ -3400,10 +3440,14 @@
variant="ghost"
size="sm"
class="h-7 px-2 text-xs text-destructive"
- onclick={async () => {
- if (!confirm(`Delete "${p.program.name}"?`)) return;
- await removeProgram(p.program.id);
- toast.success('Deleted');
+ onclick={() => {
+ confirmDialog({
+ title: `Delete "${p.program.name}"?`,
+ onConfirm: async () => {
+ await removeProgram(p.program.id);
+ toast.success('Deleted');
+ }
+ });
}}>Delete
diff --git a/src/routes/(app)/plans/+page.svelte b/src/routes/(app)/plans/+page.svelte
index 6f4b1112..cc13a5b1 100644
--- a/src/routes/(app)/plans/+page.svelte
+++ b/src/routes/(app)/plans/+page.svelte
@@ -32,6 +32,7 @@
import Link2 from '@lucide/svelte/icons/link-2';
import ArrowRightLeft from '@lucide/svelte/icons/arrow-right-left';
import { NativeSelect } from '#lib/components/ui/native-select/index.js';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const currency = await getCurrency();
const joinInfo = await getJoinInfo();
@@ -52,12 +53,16 @@
let migBusy = $state(false);
async function doMigrate() {
if (!migFrom || !migTarget) return;
- if (
- !confirm(
- `Move every active/paused membership from ${migFrom.name} to the selected plan? Pricing and billing dates are kept.`
- )
- )
- return;
+ confirmDialog({
+ title: `Move every active/paused membership from ${migFrom.name} to the selected plan?`,
+ description: 'Pricing and billing dates are kept.',
+ confirm: { text: 'Move' },
+ onConfirm: () => doMigrateNow()
+ });
+ }
+
+ async function doMigrateNow() {
+ if (!migFrom || !migTarget) return;
migBusy = true;
try {
const r = await migratePlanMembers({ fromPlanId: migFrom.id, toPlanId: migTarget });
diff --git a/src/routes/(app)/schedule/+page.svelte b/src/routes/(app)/schedule/+page.svelte
index fa4cbabf..4c3d59f9 100644
--- a/src/routes/(app)/schedule/+page.svelte
+++ b/src/routes/(app)/schedule/+page.svelte
@@ -103,6 +103,7 @@
import Ellipsis from '@lucide/svelte/icons/ellipsis';
import Sparkles from '@lucide/svelte/icons/sparkles';
import { errMsg, formatDate, formatMoney } from '#lib/format.ts';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const settings = await getSettings();
const ai = $derived(await getAiStatus());
@@ -163,14 +164,17 @@
if (bulkChecked.has(id)) bulkChecked.delete(id);
else bulkChecked.add(id);
}
- async function runBulkCancel() {
+ function runBulkCancel() {
if (!bulkChecked.size) return;
- if (
- !confirm(
- `Cancel ${bulkChecked.size} session${bulkChecked.size === 1 ? '' : 's'}? Booked members get the usual cancellation emails and credits back.`
- )
- )
- return;
+ confirmDialog({
+ title: `Cancel ${bulkChecked.size} session${bulkChecked.size === 1 ? '' : 's'}?`,
+ description: 'Booked members get the usual cancellation emails and credits back.',
+ confirm: { text: 'Cancel sessions' },
+ onConfirm: () => runBulkCancelNow()
+ });
+ }
+
+ async function runBulkCancelNow() {
bulkPending = true;
let done = 0;
for (const id of bulkChecked) {
@@ -647,9 +651,16 @@
}
}
- async function unenrollRow(enrollmentId: string, name: string) {
+ function unenrollRow(enrollmentId: string, name: string) {
if (!cRosterId) return;
- if (!confirm(`Remove ${name} from this course? Their seat frees up for the waitlist.`)) return;
+ confirmDialog({
+ title: `Remove ${name} from this course?`,
+ description: 'Their seat frees up for the waitlist.',
+ onConfirm: () => unenrollRowNow(enrollmentId, name)
+ });
+ }
+
+ async function unenrollRowNow(enrollmentId: string, name: string) {
try {
await unenrollCourseMember({ courseId: cRosterId, enrollmentId });
toast.success(`${name} removed`);
@@ -659,8 +670,15 @@
}
}
- async function removeCourseRow(id: string) {
- if (!confirm('Remove this course? (only possible with no enrollees)')) return;
+ function removeCourseRow(id: string) {
+ confirmDialog({
+ title: 'Remove this course?',
+ description: 'Only possible with no enrollees.',
+ onConfirm: () => removeCourseRowNow(id)
+ });
+ }
+
+ async function removeCourseRowNow(id: string) {
try {
await removeCourse(id);
toast.success('Course removed');
@@ -766,13 +784,16 @@
toast.error(errMsg(err, 'Could not update'));
}
}
- async function cancelWholeEvent(id: string) {
- if (
- !confirm(
- 'Cancel this event? Registered members are emailed and unpaid signup charges voided.'
- )
- )
- return;
+ function cancelWholeEvent(id: string) {
+ confirmDialog({
+ title: 'Cancel this event?',
+ description: 'Registered members are emailed and unpaid signup charges voided.',
+ confirm: { text: 'Cancel event' },
+ onConfirm: () => cancelWholeEventNow(id)
+ });
+ }
+
+ async function cancelWholeEventNow(id: string) {
try {
await cancelEvent(id);
toast.success('Event cancelled — registrants notified');
@@ -937,9 +958,21 @@
}
}
- async function setResourceStatus(id: string, status: 'open' | 'maintenance' | 'closed') {
- const statusNote =
- status === 'open' ? '' : String(prompt('Why? (shown to members, optional)') ?? '').trim();
+ function setResourceStatus(id: string, status: 'open' | 'maintenance' | 'closed') {
+ if (status === 'open') return setResourceStatusNow(id, status, '');
+ confirmDialog({
+ title: 'Why? (shown to members, optional)',
+ input: { label: 'Reason' },
+ confirm: { text: 'Update' },
+ onConfirm: (note) => setResourceStatusNow(id, status, String(note ?? '').trim())
+ });
+ }
+
+ async function setResourceStatusNow(
+ id: string,
+ status: 'open' | 'maintenance' | 'closed',
+ statusNote: string
+ ) {
try {
await updateResource({ id, status, statusNote });
await getResources().refresh();
@@ -1692,21 +1725,24 @@
variant="outline"
class="w-full"
title="Cancel this session and try booking its members into the next session of this class"
- onclick={async () => {
- if (
- !confirm(
- 'Cancel this session and try booking its members into the next session of this class?'
- )
- )
- return;
- try {
- await updateSession({ id: focusId, cancelled: true, rebookNext: true });
- toast.success('Session cancelled — members moved to the next class if one exists');
- await reload();
- rosterOpen = false;
- } catch (err) {
- toast.error(errMsg(err, 'Failed'));
- }
+ onclick={() => {
+ confirmDialog({
+ title:
+ 'Cancel this session and try booking its members into the next session of this class?',
+ confirm: { text: 'Cancel & rebook' },
+ onConfirm: async () => {
+ try {
+ await updateSession({ id: focusId, cancelled: true, rebookNext: true });
+ toast.success(
+ 'Session cancelled — members moved to the next class if one exists'
+ );
+ await reload();
+ rosterOpen = false;
+ } catch (err) {
+ toast.error(errMsg(err, 'Failed'));
+ }
+ }
+ });
}}
>
Cancel + rebook members
@@ -3325,11 +3361,15 @@
class="text-muted-foreground"
title="Set next service date"
onclick={() => {
- const d = prompt(
- 'Next service date (YYYY-MM-DD, blank to clear)',
- eq.nextServiceOn ?? ''
- );
- if (d !== null) setEquipment(eq.id, { nextServiceOn: d.trim() || null });
+ confirmDialog({
+ title: 'Next service date',
+ input: {
+ label: 'YYYY-MM-DD (blank to clear)',
+ defaultValue: eq.nextServiceOn ?? ''
+ },
+ confirm: { text: 'Save' },
+ onConfirm: (d) => setEquipment(eq.id, { nextServiceOn: d.trim() || null })
+ });
}}>
diff --git a/src/routes/(app)/settings/+page.svelte b/src/routes/(app)/settings/+page.svelte
index 83ff6e4b..196d900d 100644
--- a/src/routes/(app)/settings/+page.svelte
+++ b/src/routes/(app)/settings/+page.svelte
@@ -87,6 +87,7 @@
import Sparkles from '@lucide/svelte/icons/sparkles';
import Map from '@lucide/svelte/icons/map';
import { tour } from '#lib/tour.svelte.ts';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
let settings = $state(await getSettings());
let locations = $state(await getLocations());
@@ -281,12 +282,15 @@
let fzPending = $state(false);
async function submitFreezeAll(e: SubmitEvent) {
e.preventDefault();
- if (
- !confirm(
- `Pause every active plan until ${fzUntil}? They auto-resume that day and no fees are charged.`
- )
- )
- return;
+ confirmDialog({
+ title: `Pause every active plan until ${fzUntil}?`,
+ description: 'They auto-resume that day and no fees are charged.',
+ confirm: { text: 'Pause all' },
+ onConfirm: () => freezeAllNow()
+ });
+ }
+
+ async function freezeAllNow() {
fzPending = true;
try {
const r = await freezeAllMemberships({ until: fzUntil });
@@ -1110,19 +1114,24 @@
type="button"
variant="outline"
disabled={anonBusy}
- onclick={async () => {
- if (!confirm('Scrub personal details of long-inactive members?')) return;
- anonBusy = true;
- try {
- const r = await anonymizeInactiveMembers({});
- toast.success(`Anonymized ${r.anonymized} members`);
- anonPreview = null;
- anonNames = [];
- } catch (err) {
- toast.error(errMsg(err, 'Failed'));
- } finally {
- anonBusy = false;
- }
+ onclick={() => {
+ confirmDialog({
+ title: 'Scrub personal details of long-inactive members?',
+ confirm: { text: 'Scrub' },
+ onConfirm: async () => {
+ anonBusy = true;
+ try {
+ const r = await anonymizeInactiveMembers({});
+ toast.success(`Anonymized ${r.anonymized} members`);
+ anonPreview = null;
+ anonNames = [];
+ } catch (err) {
+ toast.error(errMsg(err, 'Failed'));
+ } finally {
+ anonBusy = false;
+ }
+ }
+ });
}}>Anonymize
@@ -1174,17 +1183,22 @@
variant="outline"
size="sm"
disabled={resignAllBusy}
- onclick={async () => {
- if (!confirm('Email every member a re-sign request?')) return;
- resignAllBusy = true;
- try {
- const r = await resignAllParq({});
- toast.success(`Sent ${r.sent} re-sign requests`);
- } catch (err) {
- toast.error(errMsg(err, 'Could not send'));
- } finally {
- resignAllBusy = false;
- }
+ onclick={() => {
+ confirmDialog({
+ title: 'Email every member a re-sign request?',
+ confirm: { text: 'Send' },
+ onConfirm: async () => {
+ resignAllBusy = true;
+ try {
+ const r = await resignAllParq({});
+ toast.success(`Sent ${r.sent} re-sign requests`);
+ } catch (err) {
+ toast.error(errMsg(err, 'Could not send'));
+ } finally {
+ resignAllBusy = false;
+ }
+ }
+ });
}}>Re-sign all
@@ -1377,24 +1391,25 @@
variant="outline"
size="sm"
disabled={digestBusy}
- onclick={async () => {
- if (
- !confirm(
- "Send last month's digest to all recipients now? They won't get it again on the 1st."
- )
- )
- return;
- digestBusy = true;
- try {
- const r = await sendDigestNow();
- toast.success(
- `Digest sent to ${r.sent} recipient${r.sent === 1 ? '' : 's'}`
- );
- } catch (err) {
- toast.error(errMsg(err, 'Could not send'));
- } finally {
- digestBusy = false;
- }
+ onclick={() => {
+ confirmDialog({
+ title: "Send last month's digest to all recipients now?",
+ description: "They won't get it again on the 1st.",
+ confirm: { text: 'Send' },
+ onConfirm: async () => {
+ digestBusy = true;
+ try {
+ const r = await sendDigestNow();
+ toast.success(
+ `Digest sent to ${r.sent} recipient${r.sent === 1 ? '' : 's'}`
+ );
+ } catch (err) {
+ toast.error(errMsg(err, 'Could not send'));
+ } finally {
+ digestBusy = false;
+ }
+ }
+ });
}}>Send now
@@ -1612,14 +1627,18 @@
size="sm"
variant="ghost"
class="text-destructive"
- onclick={async () => {
- if (!confirm(`Delete "${fld.name}" and its values?`)) return;
- try {
- await deleteMemberFieldCmd({ id: fld.id });
- toast.success('Field deleted');
- } catch (e) {
- toast.error(errMsg(e, 'Something went wrong'));
- }
+ onclick={() => {
+ confirmDialog({
+ title: `Delete "${fld.name}" and its values?`,
+ onConfirm: async () => {
+ try {
+ await deleteMemberFieldCmd({ id: fld.id });
+ toast.success('Field deleted');
+ } catch (e) {
+ toast.error(errMsg(e, 'Something went wrong'));
+ }
+ }
+ });
}}>Delete
@@ -1878,15 +1897,20 @@
variant="outline"
size="sm"
disabled={passkeyBusy}
- onclick={async () => {
- passkeyBusy = true;
- const name = window.prompt('Name this passkey', 'This device');
- if (name) {
- const res = await authClient.passkey.addPasskey({ name });
- if (res?.error) toast.error(res.error.message ?? 'Passkey not created');
- else passkeys = await listPasskeys();
- }
- passkeyBusy = false;
+ onclick={() => {
+ confirmDialog({
+ title: 'Name this passkey',
+ input: { label: 'Passkey name', defaultValue: 'This device' },
+ confirm: { text: 'Add passkey' },
+ onConfirm: async (name) => {
+ if (!name) return;
+ passkeyBusy = true;
+ const res = await authClient.passkey.addPasskey({ name });
+ if (res?.error) toast.error(res.error.message ?? 'Passkey not created');
+ else passkeys = await listPasskeys();
+ passkeyBusy = false;
+ }
+ });
}}>{passkeyBusy ? 'Working…' : 'Add passkey'}
diff --git a/src/routes/kiosk/+page.svelte b/src/routes/kiosk/+page.svelte
index 1eb08f9b..b46549db 100644
--- a/src/routes/kiosk/+page.svelte
+++ b/src/routes/kiosk/+page.svelte
@@ -29,6 +29,7 @@
import QrCode from '@lucide/svelte/icons/qr-code';
import CircleCheck from '@lucide/svelte/icons/circle-check';
import TriangleAlert from '@lucide/svelte/icons/triangle-alert';
+ import { ConfirmDialog, confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
const { data }: PageProps = $props();
@@ -359,8 +360,16 @@
}
}
- async function voidRow(id: string) {
- if (!confirm('Void this check-in? Same-day attendance marks revert too.')) return;
+ function voidRow(id: string) {
+ confirmDialog({
+ title: 'Void this check-in?',
+ description: 'Same-day attendance marks revert too.',
+ confirm: { text: 'Void' },
+ onConfirm: () => voidRowNow(id)
+ });
+ }
+
+ async function voidRowNow(id: string) {
try {
await voidCheckIn(id);
checkIns = await getTodayCheckIns();
@@ -429,14 +438,19 @@
variant="ghost"
size="sm"
class="ml-auto shrink-0"
- onclick={async () => {
- if (!confirm(`Check out all ${insideRows.length} member(s) still inside?`)) return;
- try {
- const n = await checkOutAll();
- toast.success(`Checked out ${n}`);
- } catch (err) {
- toast.error(errMsg(err, 'Could not check out'));
- }
+ onclick={() => {
+ confirmDialog({
+ title: `Check out all ${insideRows.length} member(s) still inside?`,
+ confirm: { text: 'Check out all' },
+ onConfirm: async () => {
+ try {
+ const n = await checkOutAll();
+ toast.success(`Checked out ${n}`);
+ } catch (err) {
+ toast.error(errMsg(err, 'Could not check out'));
+ }
+ }
+ });
}}>Out all
@@ -837,3 +851,4 @@
{/if}
+
diff --git a/src/routes/portal/+layout.svelte b/src/routes/portal/+layout.svelte
index 451ae8b1..b1dc8a5c 100644
--- a/src/routes/portal/+layout.svelte
+++ b/src/routes/portal/+layout.svelte
@@ -5,6 +5,7 @@
import Logo from '#lib/components/app/logo.svelte';
import { Button } from '#lib/components/ui/button/index.js';
import { Skeleton } from '#lib/components/ui/skeleton/index.js';
+ import { ConfirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
let { children, data } = $props();
@@ -43,14 +44,11 @@
>
-
+
{@render children()}
{#snippet pending()}{/snippet}
+
diff --git a/src/routes/portal/+page.svelte b/src/routes/portal/+page.svelte
index de332bcf..3d19cf61 100644
--- a/src/routes/portal/+page.svelte
+++ b/src/routes/portal/+page.svelte
@@ -130,6 +130,8 @@
import { Textarea } from '#lib/components/ui/textarea/index.js';
import { NativeSelect } from '#lib/components/ui/native-select/index.js';
import type { PageProps } from './$types';
+ import { confirmDialog } from '#lib/components/ui/confirm-dialog/index.js';
+ import * as Collapsible from '#lib/components/ui/collapsible/index.js';
let { data }: PageProps = $props();
const memberId = $derived(data.memberId);
@@ -137,13 +139,17 @@
// ------- data export -------
let exportPending = $state(false);
let delPending = $state(false);
- async function askDataDeletion() {
- if (
- !confirm(
- 'Request deletion of your personal data? The gym will scrub your name, contact details and profile. Your booking and payment history is kept anonymized for their records.'
- )
- )
- return;
+ function askDataDeletion() {
+ confirmDialog({
+ title: 'Request deletion of your personal data?',
+ description:
+ 'The gym will scrub your name, contact details and profile. Your booking and payment history is kept anonymized for their records.',
+ confirm: { text: 'Request deletion' },
+ onConfirm: () => askDataDeletionNow()
+ });
+ }
+
+ async function askDataDeletionNow() {
delPending = true;
try {
await requestDataDeletion(memberId);
@@ -364,9 +370,16 @@
// ------- gift cards -------
let gcCode = $state('');
let gcBusy = $state(false);
- async function askRemoveAddon(addOnId: string) {
- if (!confirm('Ask the front desk to stop this add-on? They will confirm before it ends.'))
- return;
+ function askRemoveAddon(addOnId: string) {
+ confirmDialog({
+ title: 'Ask the front desk to stop this add-on?',
+ description: 'They will confirm before it ends.',
+ confirm: { text: 'Request removal' },
+ onConfirm: () => askRemoveAddonNow(addOnId)
+ });
+ }
+
+ async function askRemoveAddonNow(addOnId: string) {
try {
await requestAddonRemoval({ memberId, addOnId });
toast.success('Removal requested');
@@ -387,17 +400,26 @@
}
gcBusy = false;
}
- async function editGoal() {
- const v = prompt(
- 'How many visits this month are you aiming for? (1–60, blank clears)',
- d.member.goalVisitsPerMonth ? String(d.member.goalVisitsPerMonth) : '12'
- );
- if (v === null) return;
- const goal = v.trim() === '' ? null : Number(v);
- if (goal !== null && (!Number.isInteger(goal) || goal < 1 || goal > 60)) {
- toast.error('Pick a number of visits between 1 and 60');
- return;
- }
+ function editGoal() {
+ confirmDialog({
+ title: 'Monthly visit goal',
+ input: {
+ label: 'How many visits this month are you aiming for? (1–60, blank clears)',
+ defaultValue: d.member.goalVisitsPerMonth ? String(d.member.goalVisitsPerMonth) : '12'
+ },
+ confirm: { text: 'Save' },
+ onConfirm: (v) => {
+ const goal = v.trim() === '' ? null : Number(v);
+ if (goal !== null && (!Number.isInteger(goal) || goal < 1 || goal > 60)) {
+ toast.error('Pick a number of visits between 1 and 60');
+ return;
+ }
+ return saveGoal(goal);
+ }
+ });
+ }
+
+ async function saveGoal(goal: number | null) {
try {
await setVisitGoal({ memberId, goal });
toast.success(goal ? `Goal set: ${goal} visits` : 'Goal cleared');
@@ -531,13 +553,16 @@
}
return [...byType.values()].filter((r) => r.n >= 2);
});
- async function cancelSeries(classTypeId: string, name: string, n: number) {
- if (
- !confirm(
- `Cancel all ${n} upcoming ${name} bookings? Sessions inside the cancel cutoff are kept.`
- )
- )
- return;
+ function cancelSeries(classTypeId: string, name: string, n: number) {
+ confirmDialog({
+ title: `Cancel all ${n} upcoming ${name} bookings?`,
+ description: 'Sessions inside the cancel cutoff are kept.',
+ confirm: { text: 'Cancel bookings' },
+ onConfirm: () => cancelSeriesNow(classTypeId)
+ });
+ }
+
+ async function cancelSeriesNow(classTypeId: string) {
busy = 'cancelSeries';
try {
const r = await memberCancelSeries({ memberId, classTypeId });
@@ -664,13 +689,20 @@
}
});
let chalBusy = $state('');
- async function joinChal(challengeId: string, teamMode = false) {
- let team: string | undefined;
+ function joinChal(challengeId: string, teamMode = false) {
if (teamMode) {
- const t = window.prompt('Team name? Leave empty to play solo');
- if (t === null) return;
- team = t.trim() || undefined;
+ confirmDialog({
+ title: 'Team name?',
+ input: { label: 'Leave empty to play solo' },
+ confirm: { text: 'Join' },
+ onConfirm: (t) => joinChalNow(challengeId, t.trim() || undefined)
+ });
+ return;
}
+ joinChalNow(challengeId, undefined);
+ }
+
+ async function joinChalNow(challengeId: string, team: string | undefined) {
chalBusy = challengeId;
try {
await joinChallenge({ memberId, challengeId, team });
@@ -1083,8 +1115,15 @@
}
const nextOfType = (classTypeId: string) =>
bookable.find((b) => b.session.classTypeId === classTypeId && !b.myStatus);
- async function bookSeriesAll(classTypeId: string, className: string) {
- if (!confirm(`Book into every upcoming ${className} session?`)) return;
+ function bookSeriesAll(classTypeId: string, className: string) {
+ confirmDialog({
+ title: `Book into every upcoming ${className} session?`,
+ confirm: { text: 'Book all' },
+ onConfirm: () => bookSeriesAllNow(classTypeId)
+ });
+ }
+
+ async function bookSeriesAllNow(classTypeId: string) {
busy = `series:${classTypeId}`;
try {
const r = await memberBookSeries({ memberId, classTypeId });
@@ -2124,14 +2163,14 @@
{/if}
{#if c.mine && c.mySessions.length}
-
-
+
My sessions ({c.mySessions.filter((s) => s.status !== 'cancelled').length}
upcoming)
-
-
+
+
{#each c.mySessions as s (s.bookingId)}
{/each}
-
-
+
+
{/if}
{#if c.mine}
@@ -2441,23 +2480,27 @@
class="text-xs text-muted-foreground underline-offset-4 hover:underline"
title="Give this spot to another member"
disabled={busy === `give:${u.booking.id}`}
- onclick={async () => {
- const email = window.prompt(
- `Give your ${u.className} spot to which member? (their email)`
- );
- if (!email?.trim()) return;
- busy = `give:${u.booking.id}`;
- try {
- const r = await memberGiveSpot({
- memberId,
- bookingId: u.booking.id,
- email: email.trim()
- });
- toast.success(`Spot given to ${r.recipient}`);
- } catch (err) {
- toast.error(errMsg(err, 'Could not give the spot'));
- }
- busy = null;
+ onclick={() => {
+ confirmDialog({
+ title: `Give your ${u.className} spot to which member?`,
+ input: { label: 'Their email', placeholder: 'member@example.com' },
+ confirm: { text: 'Give spot' },
+ onConfirm: async (email) => {
+ if (!email?.trim()) return;
+ busy = `give:${u.booking.id}`;
+ try {
+ const r = await memberGiveSpot({
+ memberId,
+ bookingId: u.booking.id,
+ email: email.trim()
+ });
+ toast.success(`Spot given to ${r.recipient}`);
+ } catch (err) {
+ toast.error(errMsg(err, 'Could not give the spot'));
+ }
+ busy = null;
+ }
+ });
}}>Give
{/if}
@@ -3517,7 +3560,12 @@
await navigator.clipboard.writeText(url);
toast.success('Link copied');
} catch {
- window.prompt('Copy this link:', url);
+ confirmDialog({
+ title: 'Copy this link',
+ input: { label: 'Link', defaultValue: url },
+ confirm: { text: 'Done' },
+ onConfirm: () => undefined
+ });
}
}}>Share
From 6650d94d00efce465464dd7426ff776bf893f6db Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Sun, 22 Nov 2026 00:55:52 +0000
Subject: [PATCH 2/3] Fix confirm-dialog: loading guard and in-place replace
for chained questions
Co-Authored-By: Max Farrell
---
.../ui/confirm-dialog/confirm-dialog.svelte | 21 ++++++++++++++++---
src/lib/components/ui/confirm-dialog/index.ts | 8 +++++--
src/routes/(app)/billing/+page.svelte | 6 +++---
src/routes/(app)/dashboard/+page.svelte | 4 ++--
4 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte b/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
index ef001f7f..cc0b1336 100644
--- a/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
+++ b/src/lib/components/ui/confirm-dialog/confirm-dialog.svelte
@@ -17,6 +17,13 @@
this.open = true;
}
+ replaceConfirmation(options: ConfirmDialogOptions) {
+ this.options = options;
+ this.inputText = options.input?.defaultValue ?? '';
+ this.loading = false;
+ this.open = true;
+ }
+
reset() {
this.open = false;
this.inputText = '';
@@ -24,16 +31,19 @@
}
confirm() {
+ if (this.loading) return;
if (this.options?.input?.confirmationText) {
if (this.inputText !== this.options.input.confirmationText) {
return;
}
}
+ const options = this.options;
this.loading = true;
- Promise.resolve(this.options?.onConfirm(this.inputText))
+ Promise.resolve(options?.onConfirm(this.inputText))
.then(() => {
- this.open = false;
+ // onConfirm may have opened a follow-up dialog; only close if still ours
+ if (this.options === options) this.open = false;
})
.finally(() => {
this.loading = false;
@@ -70,6 +80,11 @@
export function confirmDialog(options: ConfirmDialogOptions) {
dialogState.newConfirmation(options);
}
+
+ /** Swap the open dialog's contents in place — used for chained multi-step questions. */
+ export function replaceConfirmDialog(options: ConfirmDialogOptions) {
+ dialogState.replaceConfirmation(options);
+ }
diff --git a/src/lib/components/app/page-header.svelte b/src/lib/components/app/page-header.svelte
index 2d5e3d47..eb81a8bd 100644
--- a/src/lib/components/app/page-header.svelte
+++ b/src/lib/components/app/page-header.svelte
@@ -17,7 +17,7 @@
{title} · {appName}