Initial commit from gitea_uploader script

This commit is contained in:
bizzle
2025-08-11 15:52:32 -04:00
commit c913946c08
32 changed files with 8813 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
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(
<TimesheetPDF weekDays={weekDays} timeEntries={timeEntries} userName={userName} />
).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 (
<button
onClick={handleDownload}
disabled={!hasEntries}
className={`flex items-center gap-2 px-6 py-3 rounded-lg font-medium transition-colors ${
hasEntries
? 'bg-green-600 hover:bg-green-700 text-white'
: 'bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed'
}`}
>
<Download className="h-5 w-5" />
Download PDF
</button>
);
};
export default PDFExport;