feat(worker): Geschiedenis screen with session list and CSV export

This commit is contained in:
Bas van Rossem
2026-06-17 16:30:34 +02:00
parent 5af5a9c2bb
commit 134e01a2e8
5 changed files with 302 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
import { API_URL } from './api';
import { getToken } from './auth-storage';
/**
* Authenticated CSV download. A plain `<a href>` cannot carry the bearer token,
* so we fetch the blob ourselves and trigger a download via an object URL.
*/
export async function downloadExport(): Promise<void> {
const token = getToken();
const res = await fetch(`${API_URL}/api/export`, {
headers: token ? { Authorization: `Bearer ${token}` } : {},
});
if (!res.ok) throw new Error('Kan de export niet openen');
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'insole-production-report.csv';
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
}