Add BanTrendChart component and useBanTrend hook

- Add BanTrendBucket / BanTrendResponse interfaces to types/ban.ts
- Add dashboardBansTrend endpoint constant to api/endpoints.ts
- Add fetchBanTrend() to api/dashboard.ts
- Create useBanTrend hook with abort-safe data fetching
- Create BanTrendChart: AreaChart with gradient fill, dynamic
  X-axis labels per range, custom tooltip, loading/error/empty states
- tsc --noEmit and ESLint pass with zero warnings
This commit is contained in:
2026-03-11 16:48:49 +01:00
parent 9242b4709a
commit 259ff17eba
6 changed files with 416 additions and 2 deletions

View File

@@ -82,3 +82,31 @@ export interface DashboardBanListResponse {
/** Maximum items per page. */
page_size: number;
}
// ---------------------------------------------------------------------------
// Ban trend
// ---------------------------------------------------------------------------
/**
* A single time bucket in the ban trend series.
*
* Mirrors `BanTrendBucket` from `backend/app/models/ban.py`.
*/
export interface BanTrendBucket {
/** ISO 8601 UTC start of the bucket. */
timestamp: string;
/** Number of bans that started in this bucket. */
count: number;
}
/**
* Response from `GET /api/dashboard/bans/trend`.
*
* Mirrors `BanTrendResponse` from `backend/app/models/ban.py`.
*/
export interface BanTrendResponse {
/** Time-ordered list of ban-count buckets covering the full window. */
buckets: BanTrendBucket[];
/** Human-readable bucket size label, e.g. `"1h"`, `"6h"`, `"1d"`, `"7d"`. */
bucket_size: string;
}