certimate/ui/src/components/workflow/CustomAlertDialog.tsx
2024-11-15 08:06:39 +08:00

47 lines
1.3 KiB
TypeScript

import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { useTranslation } from "react-i18next";
type CustomAlertDialogProps = {
open: boolean;
onOpenChange?: (open: boolean) => void;
title?: string;
description?: string;
confirm?: () => void;
};
const CustomAlertDialog = ({ open, title, description, confirm, onOpenChange }: CustomAlertDialogProps) => {
const { t } = useTranslation();
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent>
<AlertDialogHeader className="dark:text-stone-200">
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel className="dark:text-stone-200">{t("common.cancel")}</AlertDialogCancel>
<AlertDialogAction
onClick={() => {
confirm && confirm();
}}
>
{t("common.confirm")}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};
export default CustomAlertDialog;