From 7cef969bb825f2b2d79c9df073baedf6c07e8d38 Mon Sep 17 00:00:00 2001 From: Markus Thielker Date: Wed, 1 Jan 2025 23:10:38 +0100 Subject: [PATCH] NORY-47: create confirmation dialog wrapper component --- .../confirmation-dialog-wrapper.tsx | 81 +++++++++++++++++++ dashboard/src/components/ui/alert-dialog.tsx | 2 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 dashboard/src/components/confirmation-dialog-wrapper.tsx diff --git a/dashboard/src/components/confirmation-dialog-wrapper.tsx b/dashboard/src/components/confirmation-dialog-wrapper.tsx new file mode 100644 index 0000000..dbd8c83 --- /dev/null +++ b/dashboard/src/components/confirmation-dialog-wrapper.tsx @@ -0,0 +1,81 @@ +'use client'; + +import { Button, ButtonProps } from '@/components/ui/button'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from '@/components/ui/alert-dialog'; +import { ReactNode } from 'react'; +import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; + +interface ButtonWithConfirmDialogProps { + buttonProps?: ButtonProps, + onCancel?: () => any + onSubmit: () => any + tooltipContent?: string + dialogTitle: string + dialogDescription: string + dialogButtonCancel?: string + dialogButtonCancelProps?: ButtonProps + dialogButtonSubmit?: string + dialogButtonSubmitProps?: ButtonProps + children: ReactNode +} + +export function ConfirmationDialogWrapper( + { + onCancel, + onSubmit, + tooltipContent, + dialogTitle, + dialogDescription, + dialogButtonCancel, + dialogButtonCancelProps, + dialogButtonSubmit, + dialogButtonSubmitProps, + children, + }: ButtonWithConfirmDialogProps) { + return ( + + + {tooltipContent} + + + + + {children} + + + + + {dialogTitle} + {dialogDescription} + + + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/dashboard/src/components/ui/alert-dialog.tsx b/dashboard/src/components/ui/alert-dialog.tsx index d65d9d1..0fce158 100644 --- a/dashboard/src/components/ui/alert-dialog.tsx +++ b/dashboard/src/components/ui/alert-dialog.tsx @@ -104,7 +104,7 @@ const AlertDialogAction = React.forwardRef< >(({ className, ...props }, ref) => ( ));