diff --git a/apps/fabrikanabytok/components/shared/action-confirmation-dialog.tsx b/apps/fabrikanabytok/components/shared/action-confirmation-dialog.tsx new file mode 100644 index 0000000..2ca3883 --- /dev/null +++ b/apps/fabrikanabytok/components/shared/action-confirmation-dialog.tsx @@ -0,0 +1,225 @@ +"use client" + +import { useState } from "react" +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from "@/components/ui/dialog" +import { Button } from "@/components/ui/button" +import { Textarea } from "@/components/ui/textarea" +import { Label } from "@/components/ui/label" +import { Badge } from "@/components/ui/badge" +import { AlertTriangle, Info, CheckCircle, Loader2 } from "lucide-react" +import { cn } from "@/lib/utils" + +interface ActionConfirmationDialogProps { + open: boolean + onOpenChange: (open: boolean) => void + title: string + description: string + actionType: "info" | "warning" | "danger" + requireReason?: boolean + currentState?: any + newState?: any + onConfirm: (reason?: string) => Promise +} + +export function ActionConfirmationDialog({ + open, + onOpenChange, + title, + description, + actionType = "warning", + requireReason = false, + currentState, + newState, + onConfirm, +}: ActionConfirmationDialogProps) { + const [reason, setReason] = useState("") + const [loading, setLoading] = useState(false) + + const handleConfirm = async () => { + if (requireReason && !reason.trim()) { + return + } + + setLoading(true) + try { + await onConfirm(reason.trim() || undefined) + onOpenChange(false) + setReason("") + } catch (error) { + // Error will be handled by parent + } finally { + setLoading(false) + } + } + + const getIcon = () => { + if (actionType === "danger") return + if (actionType === "warning") return + return + } + + const getButtonVariant = () => { + if (actionType === "danger") return "destructive" + if (actionType === "warning") return "default" + return "default" + } + + return ( + + + +
+ {getIcon()} +
+ {title} + {description} +
+
+
+ +
+ {/* Current vs New State Comparison */} + {(currentState || newState) && ( +
+ {currentState && ( +
+ +
+
+                      {JSON.stringify(currentState, null, 2)}
+                    
+
+
+ )} + + {newState && ( +
+ +
+
+                      {JSON.stringify(newState, null, 2)}
+                    
+
+
+ )} +
+ )} + + {/* Reason Input */} + {requireReason && ( +
+ +