mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-08 18:59:05 -06:00
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>
51 lines
1.2 KiB
TypeScript
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>
|
|
);
|
|
};
|