feat: add reusable confirmation dialogs for destructive actions
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
export function confirmAction(message: string): boolean {
|
||||
return window.confirm(message);
|
||||
}
|
||||
import { useConfirm } from "./confirm";
|
||||
|
||||
export function promptForValue(message: string, defaultValue = ""): string | null {
|
||||
return window.prompt(message, defaultValue);
|
||||
export function useDialogActions() {
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
return {
|
||||
confirmAction: (message: string, options?: { title?: string; confirmLabel?: string; cancelLabel?: string; destructive?: boolean }) =>
|
||||
confirm({
|
||||
message,
|
||||
title: options?.title,
|
||||
confirmLabel: options?.confirmLabel,
|
||||
cancelLabel: options?.cancelLabel,
|
||||
destructive: options?.destructive,
|
||||
}),
|
||||
promptForValue: async (_message: string, defaultValue = "") => window.prompt(_message, defaultValue),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user