T-16: Centralize PAGE_SIZE frontend constants

- Add BAN_PAGE_SIZE (100) and HISTORY_PAGE_SIZE (50) to frontend/src/utils/constants.ts
- Replace local PAGE_SIZE definitions in useBans.ts and HistoryPage.tsx with imports
- Eliminates risk of pagination constants silently diverging from backend defaults
- Single source of truth for all pagination sizes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-25 19:27:24 +02:00
parent f84aeef249
commit 6490e9d3df
4 changed files with 11 additions and 33 deletions

View File

@@ -8,11 +8,9 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { fetchBans } from "../api/dashboard";
import { handleFetchError } from "../utils/fetchError";
import { BAN_PAGE_SIZE } from "../utils/constants";
import type { DashboardBanItem, TimeRange, BanOriginFilter } from "../types/ban";
/** Items per page for the ban table. */
const PAGE_SIZE = 100;
/** Return value shape for {@link useBans}. */
export interface UseBansResult {
/** Ban items for the current page. */
@@ -67,7 +65,7 @@ export function useBans(
setError(null);
try {
const data = await fetchBans(timeRange, page, PAGE_SIZE, origin, source, controller.signal);
const data = await fetchBans(timeRange, page, BAN_PAGE_SIZE, origin, source, controller.signal);
if (controller.signal.aborted) return;
setBanItems(data.items);
setTotal(data.total);