2021-08-10 22:25:26 +00:00
|
|
|
import { ExclamationIcon } from "@heroicons/react/outline";
|
2021-09-30 23:42:08 +00:00
|
|
|
import { CheckIcon } from "@heroicons/react/solid";
|
2021-09-22 19:52:38 +00:00
|
|
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
2022-01-14 13:49:15 +00:00
|
|
|
import React, { PropsWithChildren, ReactNode } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2022-03-16 23:36:43 +00:00
|
|
|
import { Button } from "@calcom/ui/Button";
|
|
|
|
import { DialogClose, DialogContent } from "@calcom/ui/Dialog";
|
2021-10-08 11:43:48 +00:00
|
|
|
|
2022-03-16 23:36:43 +00:00
|
|
|
import { useLocale } from "@lib/hooks/useLocale";
|
2021-08-10 22:25:26 +00:00
|
|
|
|
2021-08-27 14:22:49 +00:00
|
|
|
export type ConfirmationDialogContentProps = {
|
2022-01-14 13:49:15 +00:00
|
|
|
confirmBtn?: ReactNode;
|
2021-08-27 14:22:49 +00:00
|
|
|
confirmBtnText?: string;
|
|
|
|
cancelBtnText?: string;
|
2021-09-30 23:42:08 +00:00
|
|
|
onConfirm?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
2021-08-27 14:22:49 +00:00
|
|
|
title: string;
|
2021-09-30 23:42:08 +00:00
|
|
|
variety?: "danger" | "warning" | "success";
|
2021-08-27 14:22:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function ConfirmationDialogContent(props: PropsWithChildren<ConfirmationDialogContentProps>) {
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
2021-10-08 11:43:48 +00:00
|
|
|
const {
|
|
|
|
title,
|
|
|
|
variety,
|
2022-01-14 13:49:15 +00:00
|
|
|
confirmBtn = null,
|
2021-10-08 11:43:48 +00:00
|
|
|
confirmBtnText = t("confirm"),
|
|
|
|
cancelBtnText = t("cancel"),
|
|
|
|
onConfirm,
|
|
|
|
children,
|
|
|
|
} = props;
|
2021-08-10 22:25:26 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<DialogContent>
|
|
|
|
<div className="flex">
|
2021-08-27 14:22:49 +00:00
|
|
|
{variety && (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mt-0.5 ltr:mr-3">
|
2021-08-27 14:22:49 +00:00
|
|
|
{variety === "danger" && (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mx-auto rounded-full bg-red-100 p-2 text-center">
|
|
|
|
<ExclamationIcon className="h-5 w-5 text-red-600" />
|
2021-08-10 22:25:26 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2021-09-30 23:42:08 +00:00
|
|
|
{variety === "warning" && (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mx-auto rounded-full bg-orange-100 p-2 text-center">
|
|
|
|
<ExclamationIcon className="h-5 w-5 text-orange-600" />
|
2021-09-30 23:42:08 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{variety === "success" && (
|
2022-02-09 00:05:13 +00:00
|
|
|
<div className="mx-auto rounded-full bg-green-100 p-2 text-center">
|
|
|
|
<CheckIcon className="h-5 w-5 text-green-600" />
|
2021-09-30 23:42:08 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2021-08-10 22:25:26 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div>
|
2022-03-15 16:59:04 +00:00
|
|
|
<DialogPrimitive.Title className="font-cal text-xl text-gray-900">{title}</DialogPrimitive.Title>
|
2022-01-14 13:49:15 +00:00
|
|
|
<DialogPrimitive.Description className="text-sm text-neutral-500">
|
2021-10-15 10:01:49 +00:00
|
|
|
{children}
|
|
|
|
</DialogPrimitive.Description>
|
2021-08-10 22:25:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-27 21:03:56 +00:00
|
|
|
<div className="mt-5 flex flex-row-reverse gap-x-2 sm:mt-8">
|
2021-09-13 11:28:17 +00:00
|
|
|
<DialogClose onClick={onConfirm} asChild>
|
2022-01-14 13:49:15 +00:00
|
|
|
{confirmBtn || <Button color="primary">{confirmBtnText}</Button>}
|
2021-08-10 22:25:26 +00:00
|
|
|
</DialogClose>
|
2021-09-13 11:28:17 +00:00
|
|
|
<DialogClose asChild>
|
|
|
|
<Button color="secondary">{cancelBtnText}</Button>
|
2021-08-27 14:22:49 +00:00
|
|
|
</DialogClose>
|
2021-08-10 22:25:26 +00:00
|
|
|
</div>
|
|
|
|
</DialogContent>
|
|
|
|
);
|
|
|
|
}
|