From d88005d9fe73e72c7ec7adff57bb1f951e6d49c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Fri, 5 Jun 2026 16:52:26 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20manueller=20Backup-Button=20f=C3=BCr=20?= =?UTF-8?q?Admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /api/backup (nur Admin) löst triggerBackup() aus. Button im Header zeigt ⏳/✓/✗ Feedback, verschwindet nach 4s. Co-Authored-By: Claude Sonnet 4.6 --- app/MainClient.tsx | 37 +++++++++++++++++++++++++++++++------ app/api/backup/route.ts | 12 ++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 app/api/backup/route.ts diff --git a/app/MainClient.tsx b/app/MainClient.tsx index d3069f1..84cf116 100644 --- a/app/MainClient.tsx +++ b/app/MainClient.tsx @@ -21,6 +21,7 @@ export default function MainClient({ kuerzel, beoId, beoName, role }: Props) { const [activeTab, setActiveTab] = useState<'eingabe' | 'liste' | 'statistik' | 'fahrkosten'>('eingabe'); const [refreshKey, setRefreshKey] = useState(0); const [editEntry, setEditEntry] = useState(null); + const [backupState, setBackupState] = useState<'idle' | 'running' | 'ok' | 'error'>('idle'); const grafikSrc = '/api/statistik/grafik'; @@ -47,6 +48,17 @@ export default function MainClient({ kuerzel, beoId, beoName, role }: Props) { window.location.href = '/login'; } + async function handleBackup() { + setBackupState('running'); + try { + const r = await fetch('/api/backup', { method: 'POST' }); + setBackupState(r.ok ? 'ok' : 'error'); + } catch { + setBackupState('error'); + } + setTimeout(() => setBackupState('idle'), 4000); + } + return (
@@ -59,12 +71,25 @@ export default function MainClient({ kuerzel, beoId, beoName, role }: Props) {
{role?.includes('admin') && ( - - Admin - + <> + + + Admin + + )}