Files
formbricks/packages/ui/AlertDialog/index.tsx
Naitik Kapadia 04e43725d1 feat: New Question Type Address (#2162)
Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com>
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2024-04-11 13:30:11 +00:00

51 lines
1.2 KiB
TypeScript

"use client";
import { Button } from "../Button";
import { Modal } from "../Modal";
interface AlertDialogProps {
open: boolean;
setOpen: (open: boolean) => void;
headerText: string;
mainText: string;
confirmBtnLabel: string;
declineBtnLabel?: string;
declineBtnVariant?: "warn" | "minimal";
onDecline: () => void;
onConfirm?: () => void;
}
export const AlertDialog = ({
open,
setOpen,
headerText,
mainText = "Are you sure? This action cannot be undone.",
declineBtnLabel,
onDecline,
confirmBtnLabel,
declineBtnVariant = "minimal",
onConfirm,
}: AlertDialogProps) => {
return (
<Modal open={open} setOpen={setOpen} title={headerText}>
<p className="mb-6 text-slate-900">{mainText}</p>
<div className="space-x-2 text-right">
<Button variant={declineBtnVariant} onClick={onDecline}>
{declineBtnLabel || "Discard"}
</Button>
<Button
variant="darkCTA"
onClick={() => {
if (onConfirm) {
onConfirm();
} else {
setOpen(false);
}
}}>
{confirmBtnLabel}
</Button>
</div>
</Modal>
);
};