update
This commit is contained in:
@@ -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 && (
|
||||
|
||||
Reference in New Issue
Block a user