fix
Some checks failed
CD Preprod / Backend — Lint (push) Successful in 10m21s
CD Preprod / Frontend — Lint & Type-check (push) Successful in 10m54s
CD Preprod / Backend — Unit Tests (push) Successful in 10m12s
CD Preprod / Frontend — Unit Tests (push) Successful in 10m32s
CD Preprod / Backend — Integration Tests (push) Successful in 9m57s
CD Preprod / Build Backend (push) Successful in 50s
CD Preprod / Build Log Exporter (push) Successful in 26s
CD Preprod / Build Frontend (push) Successful in 19m3s
CD Preprod / Deploy to Preprod (push) Successful in 23s
CD Preprod / Notify Success (push) Has been cancelled
CD Preprod / Smoke Tests (push) Has been cancelled
CD Preprod / Notify Failure (push) Has been cancelled

This commit is contained in:
David 2026-04-06 15:21:01 +02:00
parent bbf059cce9
commit a5b21436c7

View File

@ -11,9 +11,9 @@ import {
Bug,
Server,
} from 'lucide-react';
import { get, download } from '@/lib/api/client';
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000';
const LOGS_API_URL = `${API_URL}/api/v1/logs`;
const LOGS_PREFIX = '/api/v1/logs';
// ─── Types ────────────────────────────────────────────────────────────────────
@ -125,8 +125,7 @@ export default function AdminLogsPage() {
// Load available services
useEffect(() => {
fetch(`${LOGS_API_URL}/services`)
.then(r => r.json())
get<{ services: string[] }>(`${LOGS_PREFIX}/services`)
.then(d => setServices(d.services || []))
.catch(() => {});
}, []);
@ -150,14 +149,9 @@ export default function AdminLogsPage() {
setLoading(true);
setError(null);
try {
const res = await fetch(
`${LOGS_API_URL}/export?${buildQueryString('json')}`,
const data = await get<LogsResponse>(
`${LOGS_PREFIX}/export?${buildQueryString('json')}`,
);
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(body.error || `HTTP ${res.status}`);
}
const data: LogsResponse = await res.json();
setLogs(data.logs || []);
setTotal(data.total || 0);
} catch (err: any) {
@ -174,19 +168,11 @@ export default function AdminLogsPage() {
const handleExport = async (format: 'json' | 'csv') => {
setExportLoading(true);
try {
const res = await fetch(
`${LOGS_API_URL}/export?${buildQueryString(format)}`,
const filename = `xpeditis-logs-${new Date().toISOString().slice(0, 10)}.${format}`;
await download(
`${LOGS_PREFIX}/export?${buildQueryString(format)}`,
filename,
);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `xpeditis-logs-${new Date().toISOString().slice(0, 10)}.${format}`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
} catch (err: any) {
setError(err.message);
} finally {