mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 14:06:49 +01:00
27 lines
693 B
TypeScript
27 lines
693 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 ({
|
|
title,
|
|
description,
|
|
variant,
|
|
}: {
|
|
title: DialogProps['title'];
|
|
description?: DialogProps['description'];
|
|
variant: ConfirmProps['variant'];
|
|
}) =>
|
|
new Promise((onResult: ConfirmProps['onResult']) => {
|
|
dialog.show({
|
|
title,
|
|
description,
|
|
hideX: true,
|
|
size: 'sm',
|
|
render: ({ hide }) => Confirm({ hide, variant, onResult }),
|
|
});
|
|
});
|
|
}
|