diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 9c1437a..bbb52df 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -222,21 +222,31 @@ function App() { const [creating, setCreating] = useState(false); const [editKey, setEditKey] = useState(null); const [editForm, setEditForm] = useState({}); - - useEffect(() => { - if (!password) { setLoading(false); return; } - fetchApiKeys().finally(() => setLoading(false)); - }, [password]); + const [refreshKey, setRefreshKey] = useState(0); + const [lastUpdated, setLastUpdated] = useState(null); const fetchApiKeys = async () => { try { const res = await axios.get('/api/api-keys', { headers: authHeaders(password) }); setApiKeys(res.data); + setLastUpdated(new Date()); } catch { setError('API-Keys konnten nicht geladen werden.'); } }; + useEffect(() => { + if (!password) { setLoading(false); return; } + fetchApiKeys().finally(() => setLoading(false)); + + const timer = setInterval(() => { + fetchApiKeys(); + setRefreshKey(k => k + 1); + }, 5 * 60 * 1000); + + return () => clearInterval(timer); + }, [password]); + const handleCreate = async (e) => { e.preventDefault(); setCreating(true); @@ -328,10 +338,17 @@ function App() {