import { useMemo, useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; // No separate reason field per UI; comments & remarks only import { Badge } from '@/components/ui/badge'; import { XCircle, AlertCircle } from 'lucide-react'; type RejectionModalProps = { open: boolean; onClose: () => void; onConfirm: (description: string) => Promise | void; defaultDescription?: string; title?: string; requestIdDisplay?: string; requestTitle?: string; }; export function RejectionModal({ open, onClose, onConfirm, defaultDescription = '', title = 'Reject Request', requestIdDisplay, requestTitle, }: RejectionModalProps) { const [description, setDescription] = useState(defaultDescription); const [submitting, setSubmitting] = useState(false); const charsUsed = (description?.length || 0); const limitedDescription = useMemo(() => description.slice(0, 500), [description]); const handleSubmit = async () => { if (!limitedDescription.trim()) { alert('Comments & remarks are required'); return; } try { setSubmitting(true); await onConfirm(limitedDescription); onClose(); } finally { setSubmitting(false); } }; return ( !v && onClose()}>
{title}

Please provide detailed reasons for rejection

{/* Request Info Card */}
Request ID {requestIdDisplay || '—'}
{/* Title - keep original stacked style without spacing between */}
Title

{requestTitle || '—'}

{/* Action - label and badge inline without justify-between */}
Action REJECT
{/* Comments */}