refactor: dialog auto swap platform primitives (#14186)
* refactor: dialog auto swap platform primities * fixup! refactor: dialog auto swap platform primities * fixup! fixup! refactor: dialog auto swap platform primities
This commit is contained in:
1 parent
d08c3fdc71
commit
896ba104fd
3 files changed
+68
-100
No files matched your search
@@ -13,15 +13,15 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { TimeRange, WorkingHours } from "@calcom/types/schedule";
|
||||
import {
|
||||
Button,
|
||||
ConfirmationDialogContent as WebConfirmationDialogContent,
|
||||
Dialog as WebDialog,
|
||||
DialogTrigger as WebDialogTrigger,
|
||||
ConfirmationDialogContent,
|
||||
EditableHeading,
|
||||
Form,
|
||||
SkeletonText,
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
Label,
|
||||
SelectSkeletonLoader,
|
||||
Skeleton,
|
||||
SkeletonText,
|
||||
Switch,
|
||||
TimezoneSelect as WebTimezoneSelect,
|
||||
Tooltip,
|
||||
@@ -29,11 +29,6 @@ import {
|
||||
} from "@calcom/ui";
|
||||
import { ArrowLeft, Info, MoreVertical, Plus, Trash } from "@calcom/ui/components/icon";
|
||||
|
||||
import { ConfirmationDialogContent as PlatformConfirmationDialogContent } from "../src/components/ui/confirmation-dialog-content";
|
||||
import {
|
||||
Dialog as PlatformDialog,
|
||||
DialogTrigger as PlatformDialogTrigger,
|
||||
} from "../src/components/ui/dialog";
|
||||
import { Shell as PlatformShell } from "../src/components/ui/shell";
|
||||
import { cn } from "../src/lib/utils";
|
||||
import { Timezone as PlatformTimzoneSelect } from "../timezone/index";
|
||||
@@ -96,22 +91,14 @@ const DeleteDialogButton = ({
|
||||
buttonClassName,
|
||||
isPending,
|
||||
onDeleteConfirmed,
|
||||
isPlatform,
|
||||
handleDelete,
|
||||
}: {
|
||||
disabled?: boolean;
|
||||
onDeleteConfirmed?: () => void;
|
||||
buttonClassName: string;
|
||||
isPlatform: boolean;
|
||||
handleDelete: () => void;
|
||||
isPending: boolean;
|
||||
}) => {
|
||||
const [Dialog, DialogTrigger, ConfirmationDialogContent] = useMemo(() => {
|
||||
return isPlatform
|
||||
? [PlatformDialog, PlatformDialogTrigger, PlatformConfirmationDialogContent]
|
||||
: [WebDialog, WebDialogTrigger, WebConfirmationDialogContent];
|
||||
}, [isPlatform]);
|
||||
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
@@ -318,7 +305,6 @@ export function AvailabilitySettings({
|
||||
disabled={schedule.isLastSchedule}
|
||||
isPending={isDeleting}
|
||||
handleDelete={handleDelete}
|
||||
isPlatform={isPlatform}
|
||||
/>
|
||||
<VerticalDivider className="hidden sm:inline" />
|
||||
<SmallScreenSideBar open={openSidebar}>
|
||||
@@ -342,7 +328,6 @@ export function AvailabilitySettings({
|
||||
disabled={schedule.isLastSchedule}
|
||||
isPending={isDeleting}
|
||||
handleDelete={handleDelete}
|
||||
isPlatform={isPlatform}
|
||||
onDeleteConfirmed={() => {
|
||||
setOpenSidebar(false);
|
||||
}}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import type { PropsWithChildren } from "react";
|
||||
|
||||
import type { ConfirmationDialogContentProps } from "@calcom/ui";
|
||||
import { Button } from "@calcom/ui";
|
||||
import { AlertCircle, Check } from "@calcom/ui/components/icon";
|
||||
|
||||
import { DialogContent, DialogClose, DialogTitle, DialogDescription, DialogHeader } from "./dialog";
|
||||
|
||||
export function ConfirmationDialogContent(props: PropsWithChildren<ConfirmationDialogContentProps>) {
|
||||
const {
|
||||
title,
|
||||
variety,
|
||||
confirmBtn = null,
|
||||
confirmBtnText = "Confirm",
|
||||
cancelBtnText = "Cancel",
|
||||
loadingText = "Loading",
|
||||
isPending = false,
|
||||
onConfirm,
|
||||
children,
|
||||
} = props;
|
||||
return (
|
||||
<DialogContent>
|
||||
<>
|
||||
<div className="flex items-center">
|
||||
{variety && (
|
||||
<div className="mt-0.5 ltr:mr-3">
|
||||
{variety === "danger" && (
|
||||
<div className="bg-error mx-auto rounded-full p-2 text-center">
|
||||
<AlertCircle className="h-5 w-5 text-red-600 dark:text-red-100" />
|
||||
</div>
|
||||
)}
|
||||
{variety === "warning" && (
|
||||
<div className="bg-attention mx-auto rounded-full p-2 text-center">
|
||||
<AlertCircle className="h-5 w-5 text-orange-600" />
|
||||
</div>
|
||||
)}
|
||||
{variety === "success" && (
|
||||
<div className="bg-success mx-auto rounded-full p-2 text-center">
|
||||
<Check className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<DialogHeader>
|
||||
<DialogTitle className="font-cal text-emphasis mt-2 text-xl">{title}</DialogTitle>
|
||||
<DialogDescription className="text-subtle text-sm">{children}</DialogDescription>
|
||||
</DialogHeader>
|
||||
</div>
|
||||
<div className="my-5 flex flex-row-reverse gap-x-2 sm:my-8">
|
||||
{confirmBtn ? (
|
||||
confirmBtn
|
||||
) : (
|
||||
<DialogClose asChild>
|
||||
<Button
|
||||
color="primary"
|
||||
onClick={(e) => onConfirm && onConfirm(e)}
|
||||
data-testid="dialog-confirmation">
|
||||
{isPending ? loadingText : confirmBtnText}
|
||||
</Button>
|
||||
</DialogClose>
|
||||
)}
|
||||
<DialogClose asChild>
|
||||
<Button disabled={isPending}>{cancelBtnText}</Button>
|
||||
</DialogClose>
|
||||
</div>
|
||||
</>
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user