mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 13:41:51 +02:00
Confirm deletions
This commit is contained in:
@@ -1,14 +1,34 @@
|
||||
import type { ButtonProps } from '../components/core/Button';
|
||||
import { useDialog } from '../components/DialogContext';
|
||||
import { Confirm } from './Confirm';
|
||||
|
||||
export function useConfirm() {
|
||||
const dialog = useDialog();
|
||||
return ({ title, description }: { title: string; description?: string }) => {
|
||||
dialog.show({
|
||||
title,
|
||||
description,
|
||||
hideX: true,
|
||||
render: Confirm,
|
||||
return ({
|
||||
title,
|
||||
description,
|
||||
confirmButtonColor,
|
||||
confirmButtonText,
|
||||
}: {
|
||||
title: string;
|
||||
description?: string;
|
||||
confirmButtonColor?: ButtonProps['color'];
|
||||
confirmButtonText?: string;
|
||||
}) => {
|
||||
return new Promise((resolve: (r: boolean) => void) => {
|
||||
dialog.show({
|
||||
title,
|
||||
description,
|
||||
hideX: true,
|
||||
render: ({ hide }) => (
|
||||
<Confirm
|
||||
hide={hide}
|
||||
onResult={resolve}
|
||||
confirmButtonColor={confirmButtonColor}
|
||||
confirmButtonText={confirmButtonText}
|
||||
/>
|
||||
),
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user