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