2022-08-31 19:42:37 +00:00
|
|
|
/**
|
|
|
|
* @deprecated file
|
|
|
|
* All new changes should be made to the V2 file in
|
|
|
|
* `/packages/ui/v2/core/ConfirmationDialogContent.tsx`
|
|
|
|
*/
|
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-05-14 18:47:23 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-03-16 23:36:43 +00:00
|
|
|
import { Button } from "@calcom/ui/Button";
|
|
|
|
import { DialogClose, DialogContent } from "@calcom/ui/Dialog";
|
2022-07-27 02:24:00 +00:00
|
|
|
import { Icon } from "@calcom/ui/Icon";
|
2021-10-08 11:43:48 +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;
|
2022-05-14 18:47:23 +00:00
|
|
|
isLoading?: boolean;
|
2022-05-23 11:17:00 +00:00
|
|
|
loadingText?: 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
|
|
|
};
|
|
|
|
|
2022-08-31 19:42:37 +00:00
|
|
|
/**
|
|
|
|
* @deprecated file
|
|
|
|
* All new changes should be made to the V2 file in
|
|
|
|
* `/packages/ui/v2/core/ConfirmationDialogContent.tsx`
|
|
|
|
*/
|
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"),
|
2022-05-23 11:17:00 +00:00
|
|
|
loadingText = t("loading"),
|
2022-05-14 18:47:23 +00:00
|
|
|
isLoading = false,
|
2021-10-08 11:43:48 +00:00
|
|
|
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">
|
2022-08-03 16:01:29 +00:00
|
|
|
<Icon.FiAlertCircle 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">
|
2022-08-03 16:01:29 +00:00
|
|
|
<Icon.FiAlertCircle 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">
|
2022-08-03 16:01:29 +00:00
|
|
|
<Icon.FiCheck 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">
|
2022-05-14 18:47:23 +00:00
|
|
|
<DialogClose disabled={isLoading} onClick={onConfirm} asChild>
|
|
|
|
{confirmBtn || (
|
2022-08-26 18:44:02 +00:00
|
|
|
<Button data-testid="confirm-button" color="primary" loading={isLoading}>
|
2022-05-23 11:17:00 +00:00
|
|
|
{isLoading ? loadingText : confirmBtnText}
|
2022-05-14 18:47:23 +00:00
|
|
|
</Button>
|
|
|
|
)}
|
2021-08-10 22:25:26 +00:00
|
|
|
</DialogClose>
|
2022-05-14 18:47:23 +00:00
|
|
|
<DialogClose disabled={isLoading} asChild>
|
2021-09-13 11:28:17 +00:00
|
|
|
<Button color="secondary">{cancelBtnText}</Button>
|
2021-08-27 14:22:49 +00:00
|
|
|
</DialogClose>
|
2021-08-10 22:25:26 +00:00
|
|
|
</div>
|
|
|
|
</DialogContent>
|
|
|
|
);
|
|
|
|
}
|