import { format } from "date-fns"; import { Activity, ChevronRight, Crown } from "lucide-react"; import { Link } from "react-router"; import { GradientIcon } from "~/components/ui/GradientIcon"; import { formatAuditDetail } from "~/lib/audit-log-display"; import type { AuditLogEntry } from "~/models/audit-log"; // ─── Types ──────────────────────────────────────────────────────────────────── export interface CommissionerEntry { id: string; userId: string; } export interface CommissionersPanelProps { commissioners: CommissionerEntry[]; /** Maps userId → display name */ commissionerMap: Record; currentUserId: string | null; /** Used to determine whether a commissioner also has a team in the league. */ teams: Array<{ id: string; ownerId: string | null }>; activityEntries: AuditLogEntry[]; /** URL for the full audit log — shown only when there are activity entries. */ auditLogUrl: string; } // ─── Sub-components ─────────────────────────────────────────────────────────── function CommissionerRow({ name, isSelf, hasTeam, }: { name: string; isSelf: boolean; hasTeam: boolean; }) { return (

{name} {isSelf && ( (You) )}

{!hasTeam && (

No team

)}
); } // ─── Public API ─────────────────────────────────────────────────────────────── export function CommissionersPanel({ commissioners, commissionerMap, currentUserId, teams, activityEntries, auditLogUrl, }: CommissionersPanelProps) { return (
{/* Commissioners */}
Commissioners
{commissioners.map((commissioner) => ( t.ownerId === commissioner.userId)} /> ))}
{/* Commish Activity */} {activityEntries.length > 0 && (
Commish Activity
View All
    {activityEntries.map((entry) => (
  • {format(new Date(entry.createdAt), "MMM d, HH:mm")} {entry.actorDisplayName ?? entry.actorUserId} {" — "} {formatAuditDetail(entry)}
  • ))}
)}
); }