61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
'use client';
|
|
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
} from '@kit/ui/alert-dialog';
|
|
|
|
interface ConfirmDialogProps {
|
|
trigger: React.ReactNode;
|
|
title: string;
|
|
description: string;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
variant?: 'default' | 'destructive';
|
|
onConfirm: () => void;
|
|
}
|
|
|
|
export function ConfirmDialog({
|
|
trigger,
|
|
title,
|
|
description,
|
|
confirmLabel = 'Bestätigen',
|
|
cancelLabel = 'Abbrechen',
|
|
variant = 'default',
|
|
onConfirm,
|
|
}: ConfirmDialogProps) {
|
|
return (
|
|
<AlertDialog>
|
|
<AlertDialogTrigger
|
|
render={trigger as React.ReactElement}
|
|
></AlertDialogTrigger>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>{cancelLabel}</AlertDialogCancel>
|
|
<AlertDialogAction
|
|
onClick={onConfirm}
|
|
className={
|
|
variant === 'destructive'
|
|
? 'bg-destructive text-destructive-foreground hover:bg-destructive/90'
|
|
: ''
|
|
}
|
|
>
|
|
{confirmLabel}
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
);
|
|
}
|