import React, { useState } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '../ui/dialog'; import { Button } from '../ui/button'; import { Textarea } from '../ui/textarea'; import { Label } from '../ui/label'; import { CheckCircle, XCircle, AlertTriangle } from 'lucide-react'; import { Badge } from '../ui/badge'; interface ApprovalActionModalProps { isOpen: boolean; onClose: () => void; action: 'approve' | 'reject'; requestId: string; requestTitle: string; onSubmit: (action: 'approve' | 'reject', comment: string) => void; } export function ApprovalActionModal({ isOpen, onClose, action, requestId, requestTitle, onSubmit }: ApprovalActionModalProps) { const [comment, setComment] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async () => { if (!comment.trim() || comment.length > 500) { return; } setIsSubmitting(true); try { await onSubmit(action, comment.trim()); setComment(''); onClose(); } catch (error) { console.error('Error submitting approval action:', error); } finally { setIsSubmitting(false); } }; const handleClose = () => { setComment(''); onClose(); }; const getActionConfig = () => { if (action === 'approve') { return { title: 'Approve Request', description: 'Please provide your approval comments and remarks', icon: CheckCircle, iconColor: 'text-green-600', buttonColor: 'bg-green-600 hover:bg-green-700', badgeColor: 'bg-green-100 text-green-800 border-green-200', placeholder: 'Enter your approval comments and any conditions or notes...' }; } else { return { title: 'Reject Request', description: 'Please provide detailed reasons for rejection', icon: XCircle, iconColor: 'text-red-600', buttonColor: 'bg-red-600 hover:bg-red-700', badgeColor: 'bg-red-100 text-red-800 border-red-200', placeholder: 'Enter detailed reasons for rejection and any suggestions for improvement...' }; } }; const config = getActionConfig(); const IconComponent = config.icon; return (
{config.title} {config.description}
Request ID: {requestId}
Title:

{requestTitle}

Action: {action === 'approve' ? 'APPROVE' : 'REJECT'}