This commit is contained in:
Matthias Hochmeister
2026-03-16 15:01:09 +01:00
parent 3c72fe627f
commit f3ad989a9e
28 changed files with 794 additions and 52 deletions

View File

@@ -2,6 +2,7 @@ import React, { useEffect, useState, useCallback } from 'react';
import {
Alert,
Box,
Button,
Card,
CardActionArea,
CardContent,
@@ -20,6 +21,7 @@ import {
CheckCircle,
DirectionsCar,
Error as ErrorIcon,
FileDownload,
PauseCircle,
School,
Search,
@@ -328,6 +330,24 @@ function Fahrzeuge() {
fetchWarnings();
}, []);
const handleExportAlerts = useCallback(async () => {
try {
const blob = await vehiclesApi.exportAlerts();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
const today = new Date();
const dateStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
a.download = `pruefungen_${dateStr}.csv`;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
} catch {
setError('CSV-Export fehlgeschlagen.');
}
}, []);
const filtered = vehicles.filter((v) => {
if (!search.trim()) return true;
const q = search.toLowerCase();
@@ -366,6 +386,14 @@ function Fahrzeuge() {
</Typography>
)}
</Box>
<Button
variant="outlined"
size="small"
startIcon={<FileDownload />}
onClick={handleExportAlerts}
>
Prüfungen CSV
</Button>
</Box>
{hasOverdue && (