import {
Badge,
Button,
Table,
TableBody,
TableCell,
TableCellLayout,
TableHeader,
TableHeaderCell,
TableRow,
Text,
Tooltip,
tokens,
} from "@fluentui/react-components";
import { ChevronLeftRegular, ChevronRightRegular } from "@fluentui/react-icons";
import type { MapBanItem } from "../../types/map";
interface MapBansTableProps {
pageBans: MapBanItem[];
visibleCount: number;
page: number;
pageSize: number;
totalPages: number;
hasPrev: boolean;
hasNext: boolean;
onPageChange: (nextPage: number) => void;
onPageSizeChange: (pageSize: number) => void;
}
export function MapBansTable({
pageBans,
visibleCount,
page,
pageSize,
totalPages,
hasPrev,
hasNext,
onPageChange,
onPageSizeChange,
}: MapBansTableProps): React.JSX.Element {
return (
<>
IP Address
Jail
Banned At
Country
Origin
Times Banned
{visibleCount === 0 ? (
No bans found.
) : (
pageBans.map((ban) => (
{ban.ip}
{ban.jail}
{new Date(ban.banned_at).toLocaleString()}
{ban.country_name ?? ban.country_code ? (
ban.country_name ?? ban.country_code
) : (
—
)}
{ban.origin === "blocklist" ? "Blocklist" : "Selfblock"}
{String(ban.ban_count)}
))
)}
{visibleCount > 0 && (
Showing {pageBans.length} of {visibleCount} filtered ban{visibleCount !== 1 ? "s" : ""}
{" · "}Page {page} of {totalPages}
Page size
}
appearance="subtle"
disabled={!hasPrev}
onClick={(): void => onPageChange(page - 1)}
aria-label="Previous page"
/>
}
appearance="subtle"
disabled={!hasNext}
onClick={(): void => onPageChange(page + 1)}
aria-label="Next page"
/>
)}
>
);
}