mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 05:56:47 +01:00
32 lines
815 B
TypeScript
32 lines
815 B
TypeScript
import type { DialogProps } from '../components/core/Dialog';
|
|
import { useDialog } from '../components/DialogContext';
|
|
import type { ConfirmProps } from './Confirm';
|
|
import { Confirm } from './Confirm';
|
|
|
|
export function useConfirm() {
|
|
const dialog = useDialog();
|
|
return ({
|
|
id,
|
|
title,
|
|
description,
|
|
variant,
|
|
confirmText,
|
|
}: {
|
|
id: string;
|
|
title: DialogProps['title'];
|
|
description?: DialogProps['description'];
|
|
variant?: ConfirmProps['variant'];
|
|
confirmText?: ConfirmProps['confirmText'];
|
|
}) =>
|
|
new Promise((onResult: ConfirmProps['onResult']) => {
|
|
dialog.show({
|
|
id,
|
|
title,
|
|
description,
|
|
hideX: true,
|
|
size: 'sm',
|
|
render: ({ hide }) => Confirm({ onHide: hide, variant, onResult, confirmText }),
|
|
});
|
|
});
|
|
}
|