import { useState } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; import { Label } from '@/components/ui/label'; import { AlertTriangle } from 'lucide-react'; import { Alert, AlertDescription } from '@/components/ui/alert'; interface RollbackDialogProps { open: boolean; onOpenChange: (open: boolean) => void; versionId: string; entityType: string; entityId: string; entityName: string; onRollback: (reason: string) => Promise; } export function RollbackDialog({ open, onOpenChange, versionId, entityName, onRollback, }: RollbackDialogProps) { const [reason, setReason] = useState(''); const [loading, setLoading] = useState(false); const handleRollback = async () => { if (!reason.trim()) return; setLoading(true); try { await onRollback(reason); setReason(''); onOpenChange(false); } finally { setLoading(false); } }; return ( Restore Previous Version (Moderator Action) You are about to restore "{entityName}" to a previous version. This will create a new version with the restored data. This action will be logged in the audit trail. This action will restore the entity to its previous state. The current version will be preserved in history.