dokpl0y / data /apps /dokploy /components /shared /dialog-action.tsx
llama1's picture
Migrated from GitHub
b80fc11 verified
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
interface Props {
title?: string | React.ReactNode;
description?: string | React.ReactNode;
onClick: () => void;
children?: React.ReactNode;
disabled?: boolean;
type?: "default" | "destructive";
}
export const DialogAction = ({
onClick,
children,
description,
title,
disabled,
type,
}: Props) => {
return (
<AlertDialog>
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{title ?? "Are you absolutely sure?"}
</AlertDialogTitle>
<AlertDialogDescription>
{description ?? "This action cannot be undone."}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
disabled={disabled}
onClick={onClick}
variant={type ?? "destructive"}
>
Confirm
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};