diff --git a/src/components/form/serverActionTrigger.tsx b/src/components/form/serverActionTrigger.tsx index ce5b431..252b70f 100644 --- a/src/components/form/serverActionTrigger.tsx +++ b/src/components/form/serverActionTrigger.tsx @@ -9,11 +9,29 @@ import { toast } from 'sonner'; import { sonnerContent } from '@/components/ui/sonner'; import type { VariantProps } from 'class-variance-authority'; import { ActionResponse } from '@/lib/types/actionResponse'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from '@/components/ui/alert-dialog'; + +export interface ConfirmationDialogProps { + title: string; + description?: string; + actionText?: string; +} export interface ButtonWithActionProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; + dialog?: ConfirmationDialogProps; action: () => Promise>; callback?: (data: T) => void; } @@ -36,14 +54,40 @@ const ServerActionTrigger = React.forwardRef + + + + + + {props.dialog.title} + {props.dialog?.description && ( + + {props.dialog.description} + + )} + + + + Cancel + + + {props.dialog.actionText || 'Confirm'} + + + + + ) : ( ); },