import React from 'react'; import { exportReportToExcel } from '~/utils/excelExport'; interface ReportSheet { id: string; date: string; area: string; dredgerLocation: string; reclamationLocation: string; dayReport?: any; nightReport?: any; } interface ReportSheetViewModalProps { isOpen: boolean; onClose: () => void; sheet: ReportSheet | null; } export default function ReportSheetViewModal({ isOpen, onClose, sheet }: ReportSheetViewModalProps) { if (!isOpen || !sheet) return null; const handleExportExcel = async () => { if (sheet.dayReport) { await exportReportToExcel(sheet.dayReport); } if (sheet.nightReport) { await exportReportToExcel(sheet.nightReport); } }; return (

Report Sheet - {new Date(sheet.date).toLocaleDateString('en-GB')}

{/* Combined Report Sheet Layout */}
{/* Day Shift Section */} {sheet.dayReport && ( <> )} {/* Night Shift Section */} {sheet.nightReport && ( <> )}
); } // Header Section Component function ReportSheetHeader({ sheet }: { sheet: ReportSheet }) { return (
Reclamation Work Diary - Daily Sheet
QF-3.6.1-08
Rev. 1.0
Arab Potash Logo { e.currentTarget.style.display = 'none'; }} />
); } // Report Info Component function ReportSheetInfo({ sheet }: { sheet: ReportSheet }) { return (
Date: {new Date(sheet.date).toLocaleDateString('en-GB')} Report No. {sheet.id}
); } // Dredger Section Component function ReportSheetDredgerSection({ sheet }: { sheet: ReportSheet }) { return (
{sheet.area} Dredger
); } // Location Data Component (using data from either available report) function ReportSheetLocationData({ sheet }: { sheet: ReportSheet }) { const report = sheet.dayReport || sheet.nightReport; if (!report) return null; return (
Dredger Location {report.dredgerLocation.name} Dredger Line Length {report.dredgerLineLength}
Reclamation Location {report.reclamationLocation.name} Shore Connection {report.shoreConnection}
Reclamation Height {report.reclamationHeight?.base || 0}m - {(report.reclamationHeight?.extra + report.reclamationHeight?.base || 0 || 0)}m
); } // Pipeline Length Component (using data from either available report) function ReportSheetPipelineLength({ sheet }: { sheet: ReportSheet }) { const report = sheet.dayReport || sheet.nightReport; if (!report) return null; return (
Pipeline Length "from Shore Connection" Main extension total Reserve extension total
{report.pipelineLength?.main || 0} {report.pipelineLength?.ext1 || 0} {(report.pipelineLength?.main || 0) + (report.pipelineLength?.ext1 || 0)} {report.pipelineLength?.reserve || 0} {report.pipelineLength?.ext2 || 0} {(report.pipelineLength?.reserve || 0) + (report.pipelineLength?.ext2 || 0)}
); } // Shift Header Component function ReportSheetShiftHeader({ shift }: { shift: string }) { return (
{shift.charAt(0).toUpperCase() + shift.slice(1)} Shift
); } // Equipment Statistics Component function ReportSheetEquipmentStats({ report }: { report: any }) { return (
Dozers Exc. Loader Foreman Laborer
{report.stats?.Dozers || 0} {report.stats?.Exc || 0} {report.stats?.Loaders || 0} {report.stats?.Foreman || ''} {report.stats?.Laborer || 0}
); } // Time Sheet Component function ReportSheetTimeSheet({ report }: { report: any }) { return (
{Array.isArray(report.timeSheet) && report.timeSheet.length > 0 ? ( report.timeSheet.map((entry: any, index: number) => ( )) ) : ( )}
Time Sheet From To From To Total Reason
{entry.machine} {entry.from1} {entry.to1} {entry.from2} {entry.to2} {entry.total} {entry.reason}
No time sheet entries
); } // Stoppages Component function ReportSheetStoppages({ report }: { report: any }) { return ( <>
Dredger Stoppages
{Array.isArray(report.stoppages) && report.stoppages.length > 0 ? ( report.stoppages.map((entry: any, index: number) => ( )) ) : ( )}
From To Total Reason Responsible Notes
{entry.from} {entry.to} {entry.total} {entry.reason} {entry.responsible} {entry.note}
No stoppages recorded
); } // Notes Component function ReportSheetNotes({ report }: { report: any }) { return ( <>
Notes & Comments
{report.notes || 'No additional notes'}
); } // Footer Component function ReportSheetFooter() { return (
{/* موقعة لأعمال الصيانة */}
); }