feat(admin): live active-work view (5s refresh)

This commit is contained in:
Bas van Rossem
2026-06-17 19:07:36 +02:00
parent 286e2d29db
commit 67dd0d398f
6 changed files with 238 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
import { useQuery } from '@tanstack/react-query';
import type { WorkSession } from '@solelog/shared';
import { apiFetch } from '../lib/api';
// Active work sessions across all workers (admin cross-user view).
// Polls every 5s so the Live view reflects who is working without a manual refresh.
export function useActiveSessions() {
return useQuery({
queryKey: ['admin', 'sessions', 'active'],
queryFn: () => apiFetch<WorkSession[]>('/api/admin/sessions/active'),
refetchInterval: 5000,
});
}