import { pdf } from '@react-pdf/renderer';
import { Download } from 'lucide-react';
import { formatWeekRange } from '../utils/dateUtils';
import TimesheetPDF from './TimesheetPDF';
const PDFExport = ({ weekDays, timeEntries, userName }) => {
const handleDownload = async () => {
try {
const blob = await pdf(
).toBlob();
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `Coastal_Timesheet_${formatWeekRange(weekDays).replace(/[^\w\s-]/g, '').replace(/\s+/g, '_')}.pdf`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
} catch (error) {
console.error('Error generating PDF:', error);
alert('Error generating PDF. Please try again.');
}
};
const hasEntries = Object.values(timeEntries).some(dayEntries =>
dayEntries.some(entry => entry.workDescription || entry.hoursWorked || entry.homeowner)
);
return (
);
};
export default PDFExport;