import { useSearchParams } from 'react-router'; // Shared horizontal tab strip — the same underlined-button style the // per-player modal and the old Bans page already used inline, pulled // out so the consolidated hub pages (Players / Activity / Content / // Settings) all render their sub-tabs identically. export function Tabs({ tabs, active, onChange, }: { tabs: ReadonlyArray<{ key: T; label: string }>; active: T; onChange: (key: T) => void; }) { return (
{tabs.map(t => ( ))}
); } // Binds the active hub tab to a `?tab=` query param so the back-compat // redirects (e.g. /bans → /players?tab=bans) land on the right sub-tab // and the choice survives a refresh / shared link. The default tab // drops the param entirely to keep URLs clean. export function useTabParam(def: T, valid: readonly T[]): [T, (t: T) => void] { const [params, setParams] = useSearchParams(); const raw = params.get('tab'); const active = (valid as readonly string[]).includes(raw ?? '') ? (raw as T) : def; const set = (t: T) => { const next = new URLSearchParams(params); if (t === def) next.delete('tab'); else next.set('tab', t); setParams(next, { replace: true }); }; return [active, set]; }