import { Alert, AlertDescription } from '@/components/ui/alert'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { router } from '@inertiajs/react'; import { format } from 'date-fns'; import { CheckCircle2, Download, FileText, Info, XCircle } from 'lucide-react'; import { FormEvent, useState } from 'react'; import { Renderer } from 'richtor'; import 'richtor/styles'; interface Props { payment: PaymentHistory; isOpen: boolean; onClose: () => void; } const VerifyPaymentModal = ({ payment, isOpen, onClose }: Props) => { const paymentMeta = payment.meta ?? {}; const status = (paymentMeta.status as string) || 'pending'; const paymentInfo = paymentMeta.payment_info as string | undefined; const [adminNotes, setAdminNotes] = useState(''); const handleVerify = (e: FormEvent) => { router.post( route('payment-reports.offline.verify', payment.id), { admin_notes: adminNotes, }, { onSuccess: () => { onClose(); }, }, ); }; const handleReject = (e: FormEvent) => { router.post( route('payment-reports.offline.reject', payment.id), { admin_notes: adminNotes, }, { onSuccess: () => { onClose(); }, }, ); }; return ( Offline Payment Details Review and verify the offline payment submission
{/* Status Badge */}
Payment Status: {status === 'verified' ? ( ) : status === 'rejected' ? ( ) : ( )} {status as string}
{/* Payment Information */}

Payment Information

Transaction ID:

{payment.transaction_id}

Amount:

${Number(payment.amount).toFixed(2)}

Payment Date:

{paymentMeta.payment_date ? format(new Date(paymentMeta.payment_date as string), 'MMM dd, yyyy') : 'N/A'}

Submitted At:

{format(new Date(payment.created_at as string), 'MMM dd, yyyy HH:mm')}

{/* Payment Info (Rich Text) */} {!!paymentInfo && (

Submitted Payment Details

)} {/* Attachment */} {payment.media && payment.media.length > 0 && (

Attachment

{payment.media[0].file_name}

Transaction proof

)} {/* Verification Form (Only for Pending) */} {(status === 'pending' || status === 'rejected') && ( <> Verifying this payment will automatically enroll the user in the purchased course/exam.