Files
upstream-yaak/apps/yaak-client/lib/confirm.ts
upstream-mirror 906fb231cc
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped
snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 17:39:41 +05:00

35 lines
977 B
TypeScript

import type { ConfirmProps } from "../components/core/Confirm";
import { Confirm } from "../components/core/Confirm";
import type { DialogProps } from "../components/core/Dialog";
import { showDialog } from "./dialog";
type ConfirmArgs = {
id: string;
} & Pick<DialogProps, "title" | "description" | "size"> &
Pick<ConfirmProps, "color" | "confirmText" | "requireTyping">;
export async function showConfirm({
color,
confirmText,
requireTyping,
size = "sm",
...extraProps
}: ConfirmArgs) {
return new Promise((onResult: ConfirmProps["onResult"]) => {
showDialog({
...extraProps,
size,
disableClose: true,
render: ({ hide }) => Confirm({ onHide: hide, color, onResult, confirmText, requireTyping }),
});
});
}
export async function showConfirmDelete({ confirmText, color, ...extraProps }: ConfirmArgs) {
return showConfirm({
color: color ?? "danger",
confirmText: confirmText ?? "Delete",
...extraProps,
});
}