julong-lib/components/ui/alert.tsx

59 lines
1.5 KiB
TypeScript

import { FC } from "react";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "./alert-dialog";
import { X } from "lucide-react";
export const Alert: FC<any> = ({
type,
onClick,
children,
className,
content,
msg,
}) => {
const message: any = {
save: "Your data will be saved securely. You can update it at any time if needed.",
delete:
"This action cannot be undone. This will permanently remove your data from our servers.",
};
return (
<>
<AlertDialog>
<AlertDialogTrigger>{children}</AlertDialogTrigger>
<AlertDialogContent className={className}>
{content ? (
content
) : (
<>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
{msg || message?.[type]}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>No</AlertDialogCancel>
<AlertDialogAction
className={"bg-primary text-white"}
onClick={onClick}
>
Yes
</AlertDialogAction>
</AlertDialogFooter>
</>
)}
</AlertDialogContent>
</AlertDialog>
</>
);
};