import * as DialogPrimitive from "@radix-ui/react-dialog"; import type { PropsWithChildren, ReactElement } from "react"; import React from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { AlertCircle, Check } from "../icon"; import { DialogClose, DialogContent } from "./Dialog"; type ConfirmBtnType = | { confirmBtn?: never; confirmBtnText?: string } | { confirmBtnText?: never; confirmBtn?: ReactElement }; export type ConfirmationDialogContentProps = { cancelBtnText?: string; isLoading?: boolean; loadingText?: string; onConfirm?: (event: React.MouseEvent) => void; title: string; variety?: "danger" | "warning" | "success"; } & ConfirmBtnType; export function ConfirmationDialogContent(props: PropsWithChildren) { const { t } = useLocale(); const { title, variety, confirmBtn = null, confirmBtnText = t("confirm"), cancelBtnText = t("cancel"), loadingText = t("loading"), isLoading = false, onConfirm, children, } = props; return (
{variety && (
{variety === "danger" && (
)} {variety === "warning" && (
)} {variety === "success" && (
)}
)}
{title} {children}
{confirmBtn ? ( confirmBtn ) : ( onConfirm && onConfirm(e)}> {isLoading ? loadingText : confirmBtnText} )} {cancelBtnText}
); }