From 0611fb0bb6f61a5bb10f48c2d5037aeab4c24a6e Mon Sep 17 00:00:00 2001 From: mlogclub Date: Thu, 28 May 2026 10:08:24 +0800 Subject: [PATCH] feat: allow deleteConfirm to be set to false for conditional delete confirmation in DashboardCrudPage --- .../dashboard/crud/dashboard-crud-page.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/components/dashboard/crud/dashboard-crud-page.tsx b/web/components/dashboard/crud/dashboard-crud-page.tsx index 6e4ff49..3efaf07 100644 --- a/web/components/dashboard/crud/dashboard-crud-page.tsx +++ b/web/components/dashboard/crud/dashboard-crud-page.tsx @@ -144,7 +144,7 @@ export type DashboardCrudPageProps = { updateItem: (item: TItem, payload: TPayload) => Promise deleteItem?: (item: TItem) => Promise canDelete?: (item: TItem) => boolean - deleteConfirm?: ConfirmOptions | ((item: TItem) => ConfirmOptions) + deleteConfirm?: false | ConfirmOptions | ((item: TItem) => ConfirmOptions) rowActions?: DashboardCrudRowAction[] renderRowActions?: (context: DashboardCrudRowActionContext) => ReactNode sort?: { @@ -270,9 +270,15 @@ export function DashboardCrudPage({ async function handleDelete(item: TItem) { if (!deleteItem) return - if (deleteConfirm) { + if (deleteConfirm !== false) { const confirmed = await confirm( - typeof deleteConfirm === "function" ? deleteConfirm(item) : deleteConfirm + typeof deleteConfirm === "function" + ? deleteConfirm(item) + : { + confirmText: labels.delete, + variant: "destructive", + ...deleteConfirm, + } ) if (!confirmed) return }