import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
import { ReactNode, FC, MouseEventHandler } from 'react';
type Props = {
children: ReactNode;
title: string;
description: string;
action: string;
isDeleting?: boolean;
onClick?: MouseEventHandler<HTMLButtonElement> | undefined;
};
const AlertDialogDemo: FC<Props> = ({
children,
title,
description,
action,
isDeleting = false,
onClick,
}) => {
return (
<AlertDialog>
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel className="rounded-md hover:text-primary/50">Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={onClick}
className="rounded-md bg-destructive hover:bg-destructive/85"
disabled={isDeleting}
>
{action}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};
export default AlertDialogDemo;