import { Link } from "@remix-run/react"; import { useSettings } from "~/contexts/SettingsContext"; import type { MaintenanceVisitWithRelations } from "~/types/database"; interface MaintenanceVisitDetailsViewProps { visit: MaintenanceVisitWithRelations; } export function MaintenanceVisitDetailsView({ visit }: MaintenanceVisitDetailsViewProps) { const { formatCurrency, formatDate, formatNumber } = useSettings(); const getPaymentStatusColor = (status: string) => { switch (status) { case 'paid': return 'bg-green-100 text-green-800 border-green-200'; case 'pending': return 'bg-yellow-100 text-yellow-800 border-yellow-200'; case 'partial': return 'bg-blue-100 text-blue-800 border-blue-200'; case 'cancelled': return 'bg-red-100 text-red-800 border-red-200'; default: return 'bg-gray-100 text-gray-800 border-gray-200'; } }; const getPaymentStatusLabel = (status: string) => { switch (status) { case 'paid': return 'مدفوع'; case 'pending': return 'معلق'; case 'partial': return 'مدفوع جزئياً'; case 'cancelled': return 'ملغي'; default: return status; } }; const getDelayLabel = (months: number) => { const delayOptions = [ { value: 1, label: 'شهر واحد' }, { value: 2, label: 'شهرين' }, { value: 3, label: '3 أشهر' }, { value: 4, label: '4 أشهر' }, { value: 6, label: '6 أشهر' }, { value: 12, label: 'سنة واحدة' }, ]; const option = delayOptions.find(opt => opt.value === months); return option ? option.label : `${months} أشهر`; }; return (
{/* Header Section */}
🔧

زيارة صيانة #{visit.id}

{formatDate(visit.visitDate)}

{formatCurrency(visit.cost)}
{getPaymentStatusLabel(visit.paymentStatus)}
{/* Main Details Grid */}
{/* Visit Information */}

📋 تفاصيل الزيارة

{(() => { try { const jobs = JSON.parse(visit.maintenanceJobs); return jobs.map((job: any, index: number) => (

{job.job}

{job.notes && (

{job.notes}

)}
#{index + 1}
)); } catch { return (

لا توجد تفاصيل أعمال الصيانة

); } })()}

{formatNumber(visit.kilometers)} كم

{getDelayLabel(visit.nextVisitDelay)}

{visit.description}

{/* Vehicle & Customer Information */}
{/* Vehicle Info */}

🚗 معلومات المركبة

{visit.vehicle.plateNumber}

{visit.vehicle.year}

{visit.vehicle.manufacturer}

{visit.vehicle.model}

{/* Customer Info */}

👤 معلومات العميل

{visit.customer.name}

{(visit.customer.phone || visit.customer.email) && (
{visit.customer.phone && (
📞 {visit.customer.phone}
)} {visit.customer.email && (
✉️ {visit.customer.email}
)}
)} {visit.customer.address && (

{visit.customer.address}

)}
{/* Income Information */} {visit.income && visit.income.length > 0 && (

💰 سجل الدخل

{visit.income.map((income) => (

تاريخ الدخل

{formatDate(income.incomeDate)}

المبلغ

{formatCurrency(income.amount)}

))}
)} {/* Action Buttons */}
🚗 عرض تفاصيل المركبة 👤 عرض تفاصيل العميل 📋 جميع زيارات هذه المركبة
); }