2021-08-10 22:25:26 +00:00
|
|
|
import { ExclamationIcon } from "@heroicons/react/outline";
|
2021-09-22 19:52:38 +00:00
|
|
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
2021-08-27 14:22:49 +00:00
|
|
|
import React, { PropsWithChildren } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
|
|
|
import { DialogClose, DialogContent } from "@components/Dialog";
|
2021-08-27 14:22:49 +00:00
|
|
|
import { Button } from "@components/ui/Button";
|
2021-08-10 22:25:26 +00:00
|
|
|
|
2021-08-27 14:22:49 +00:00
|
|
|
export type ConfirmationDialogContentProps = {
|
|
|
|
confirmBtnText?: string;
|
|
|
|
cancelBtnText?: string;
|
|
|
|
onConfirm: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
|
|
title: string;
|
|
|
|
variety?: "danger" /* no others yet */;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function ConfirmationDialogContent(props: PropsWithChildren<ConfirmationDialogContentProps>) {
|
|
|
|
const { title, variety, confirmBtnText = "Confirm", cancelBtnText = "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 && (
|
2021-08-10 22:25:26 +00:00
|
|
|
<div className="mr-3 mt-0.5">
|
2021-08-27 14:22:49 +00:00
|
|
|
{variety === "danger" && (
|
2021-08-10 22:25:26 +00:00
|
|
|
<div className="text-center p-2 rounded-full mx-auto bg-red-100">
|
|
|
|
<ExclamationIcon className="w-5 h-5 text-red-600" />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<div>
|
2021-09-24 11:28:57 +00:00
|
|
|
<DialogPrimitive.Title className="font-cal text-xl font-bold text-gray-900">
|
|
|
|
{title}
|
|
|
|
</DialogPrimitive.Title>
|
2021-08-10 22:25:26 +00:00
|
|
|
<DialogPrimitive.Description className="text-neutral-500">{children}</DialogPrimitive.Description>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-27 14:22:49 +00:00
|
|
|
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse gap-x-2">
|
2021-09-13 11:28:17 +00:00
|
|
|
<DialogClose onClick={onConfirm} asChild>
|
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|