diff --git a/components/providers/DeleteProvider.tsx b/components/providers/DeleteProvider.tsx index c5090ef274..ae79e216f8 100644 --- a/components/providers/DeleteProvider.tsx +++ b/components/providers/DeleteProvider.tsx @@ -4,7 +4,7 @@ import { useRef } from "react"; import { deleteProvider } from "@/actions"; -import { CustomButtonClientAction } from "../ui/custom"; +import { CustomAlertDialog, CustomButtonClientAction } from "../ui/custom"; import { useToast } from "../ui/toast"; export const DeleteProvider = ({ id }: { id: string }) => { @@ -35,7 +35,7 @@ export const DeleteProvider = ({ id }: { id: string }) => { return (
- + {/* */} ); }; diff --git a/components/ui/alert-dialog/AlertDialog.tsx b/components/ui/alert-dialog/AlertDialog.tsx new file mode 100644 index 0000000000..474aee7665 --- /dev/null +++ b/components/ui/alert-dialog/AlertDialog.tsx @@ -0,0 +1,131 @@ +"use client"; + +import { cn } from "@nextui-org/react"; +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; +import * as React from "react"; + +const AlertDialog = AlertDialogPrimitive.Root; + +const AlertDialogTrigger = AlertDialogPrimitive.Trigger; + +const AlertDialogPortal = AlertDialogPrimitive.Portal; + +const AlertDialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; + +const AlertDialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + +)); +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; + +const AlertDialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+); +AlertDialogHeader.displayName = "AlertDialogHeader"; + +const AlertDialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+); +AlertDialogFooter.displayName = "AlertDialogFooter"; + +const AlertDialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; + +const AlertDialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AlertDialogDescription.displayName = + AlertDialogPrimitive.Description.displayName; + +const AlertDialogAction = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; + +const AlertDialogCancel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; + +export { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogOverlay, + AlertDialogPortal, + AlertDialogTitle, + AlertDialogTrigger, +}; diff --git a/components/ui/custom/CustomAlertDialog.tsx b/components/ui/custom/CustomAlertDialog.tsx new file mode 100644 index 0000000000..8a5c014dee --- /dev/null +++ b/components/ui/custom/CustomAlertDialog.tsx @@ -0,0 +1,36 @@ +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/"; +import { useDialog } from "@/hooks"; + +export const CustomAlertDialog = () => { + const { isOpen, onClose } = useDialog(); + return ( + + + Show Dialog + + + + Are you absolutely sure? + + This action cannot be undone. This will permanently delete your + account and remove your data from our servers. + + + + Cancel + Continue + + + + ); +}; diff --git a/components/ui/custom/index.ts b/components/ui/custom/index.ts index 1599c7850f..04de3b6ca4 100644 --- a/components/ui/custom/index.ts +++ b/components/ui/custom/index.ts @@ -1,3 +1,4 @@ +export * from "./CustomAlertDialog"; export * from "./CustomBox"; export * from "./CustomButtonClientAction"; export * from "./CustomInput"; diff --git a/components/ui/index.ts b/components/ui/index.ts index 70705ba015..17f6f0e874 100644 --- a/components/ui/index.ts +++ b/components/ui/index.ts @@ -1,5 +1,6 @@ export * from "./action-card/ActionCard"; export * from "./alert/Alert"; +export * from "./alert-dialog/AlertDialog"; export * from "./chart/Chart"; export * from "./dialog/Dialog"; export * from "./dropdown/Dropdown";