2025-10-14 12:20:36 -07:00
|
|
|
import { useEffect, useState } from "react";
|
2025-10-11 01:03:31 -07:00
|
|
|
import { Link, useSearchParams } from "react-router";
|
2025-10-11 00:07:39 -07:00
|
|
|
import { getAuth } from "@clerk/react-router/server";
|
2025-10-11 01:03:31 -07:00
|
|
|
import { toast } from "sonner";
|
2025-10-15 22:02:21 -07:00
|
|
|
import { format } from "date-fns";
|
2025-10-11 01:03:31 -07:00
|
|
|
import {
|
|
|
|
|
findLeagueById,
|
|
|
|
|
findCurrentSeason,
|
|
|
|
|
findTeamsBySeasonId,
|
|
|
|
|
findCommissionersByLeagueId,
|
2025-10-14 12:20:36 -07:00
|
|
|
isUserLeagueMember,
|
|
|
|
|
isCommissioner,
|
2025-10-14 21:20:58 -07:00
|
|
|
findUserByClerkId,
|
2025-10-15 08:58:35 -07:00
|
|
|
findDraftSlotsBySeasonId,
|
2025-10-11 01:03:31 -07:00
|
|
|
} from "~/models";
|
2025-10-15 21:50:02 -07:00
|
|
|
import { findSeasonWithSportsSeasons } from "~/models/season";
|
2025-10-11 00:07:39 -07:00
|
|
|
import type { Route } from "./+types/$leagueId";
|
2025-10-11 01:03:31 -07:00
|
|
|
import { Button } from "~/components/ui/button";
|
2025-10-11 00:07:39 -07:00
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
|
|
|
|
} from "~/components/ui/card";
|
|
|
|
|
|
|
|
|
|
export async function loader(args: Route.LoaderArgs) {
|
|
|
|
|
const { userId } = await getAuth(args);
|
|
|
|
|
const { params } = args;
|
|
|
|
|
const { leagueId } = params;
|
|
|
|
|
|
|
|
|
|
// Fetch league
|
|
|
|
|
const league = await findLeagueById(leagueId);
|
|
|
|
|
|
|
|
|
|
if (!league) {
|
|
|
|
|
throw new Response("League not found", { status: 404 });
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-15 21:50:02 -07:00
|
|
|
// Fetch current season with sports
|
2025-10-11 00:07:39 -07:00
|
|
|
const season = await findCurrentSeason(leagueId);
|
2025-10-20 15:53:38 -07:00
|
|
|
const seasonWithSports = season
|
|
|
|
|
? await findSeasonWithSportsSeasons(season.id)
|
|
|
|
|
: null;
|
2025-10-11 00:07:39 -07:00
|
|
|
|
2025-10-11 00:29:04 -07:00
|
|
|
// Fetch commissioners
|
|
|
|
|
const commissioners = await findCommissionersByLeagueId(leagueId);
|
|
|
|
|
|
|
|
|
|
// Check if current user is a commissioner
|
2025-10-14 21:24:58 -07:00
|
|
|
const isUserCommissioner = userId
|
|
|
|
|
? await isCommissioner(leagueId, userId)
|
|
|
|
|
: false;
|
2025-10-14 12:20:36 -07:00
|
|
|
|
|
|
|
|
// Check if user is a member (has a team in current season)
|
2025-10-14 21:24:58 -07:00
|
|
|
const isUserMember = userId
|
|
|
|
|
? await isUserLeagueMember(leagueId, userId)
|
|
|
|
|
: false;
|
2025-10-14 12:20:36 -07:00
|
|
|
|
|
|
|
|
// Check access: user must be a commissioner, a member, or an admin
|
|
|
|
|
// If not logged in or not authorized, throw 403
|
|
|
|
|
if (!userId) {
|
2025-10-14 21:24:58 -07:00
|
|
|
throw new Response("You must be logged in to view this league", {
|
|
|
|
|
status: 401,
|
|
|
|
|
});
|
2025-10-14 12:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isUserCommissioner && !isUserMember) {
|
2025-10-14 21:24:58 -07:00
|
|
|
throw new Response("You do not have access to this league", {
|
|
|
|
|
status: 403,
|
|
|
|
|
});
|
2025-10-14 12:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fetch teams for current season
|
|
|
|
|
const teams = season ? await findTeamsBySeasonId(season.id) : [];
|
2025-10-11 00:29:04 -07:00
|
|
|
|
2025-10-15 08:58:35 -07:00
|
|
|
// Fetch draft slots if season is in pre_draft or draft status
|
2025-10-20 15:53:38 -07:00
|
|
|
const draftSlots =
|
|
|
|
|
season && (season.status === "pre_draft" || season.status === "draft")
|
|
|
|
|
? await findDraftSlotsBySeasonId(season.id)
|
|
|
|
|
: [];
|
2025-10-15 08:58:35 -07:00
|
|
|
|
2025-10-14 21:20:58 -07:00
|
|
|
// Fetch user data for team owners
|
2025-10-14 21:24:58 -07:00
|
|
|
const ownerIds = teams
|
|
|
|
|
.map((t) => t.ownerId)
|
|
|
|
|
.filter((id): id is string => id !== null);
|
2025-10-14 21:20:58 -07:00
|
|
|
const uniqueOwnerIds = [...new Set(ownerIds)];
|
|
|
|
|
const owners = await Promise.all(
|
|
|
|
|
uniqueOwnerIds.map(async (ownerId) => {
|
|
|
|
|
const user = await findUserByClerkId(ownerId);
|
2025-10-14 21:24:58 -07:00
|
|
|
return user
|
|
|
|
|
? { clerkId: ownerId, name: user.username || user.displayName }
|
|
|
|
|
: null;
|
2025-10-14 21:20:58 -07:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
const ownerMap = new Map(
|
2025-10-14 21:24:58 -07:00
|
|
|
owners
|
|
|
|
|
.filter((o): o is NonNullable<typeof o> => o !== null)
|
|
|
|
|
.map((o) => [o.clerkId, o.name])
|
2025-10-14 21:20:58 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Fetch user data for commissioners
|
2025-10-14 21:24:58 -07:00
|
|
|
const commissionerIds = commissioners.map((c) => c.userId);
|
2025-10-14 21:20:58 -07:00
|
|
|
const commissionerUsers = await Promise.all(
|
|
|
|
|
commissionerIds.map(async (commissionerId) => {
|
|
|
|
|
const user = await findUserByClerkId(commissionerId);
|
2025-10-14 21:24:58 -07:00
|
|
|
return user
|
|
|
|
|
? { clerkId: commissionerId, name: user.username || user.displayName }
|
|
|
|
|
: null;
|
2025-10-14 21:20:58 -07:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
const commissionerMap = new Map(
|
2025-10-14 21:24:58 -07:00
|
|
|
commissionerUsers
|
|
|
|
|
.filter((c): c is NonNullable<typeof c> => c !== null)
|
|
|
|
|
.map((c) => [c.clerkId, c.name])
|
2025-10-14 21:20:58 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Count available teams
|
2025-10-14 21:24:58 -07:00
|
|
|
const availableTeamCount = teams.filter((t) => !t.ownerId).length;
|
2025-10-14 21:20:58 -07:00
|
|
|
|
2025-10-15 21:50:02 -07:00
|
|
|
// Count sports in season
|
|
|
|
|
const sportsCount = seasonWithSports?.seasonSports?.length || 0;
|
|
|
|
|
|
2025-10-11 00:07:39 -07:00
|
|
|
return {
|
|
|
|
|
league,
|
|
|
|
|
season,
|
|
|
|
|
teams,
|
2025-10-11 00:29:04 -07:00
|
|
|
commissioners,
|
2025-10-11 00:07:39 -07:00
|
|
|
currentUserId: userId,
|
2025-10-11 00:29:04 -07:00
|
|
|
isUserCommissioner,
|
2025-10-14 21:20:58 -07:00
|
|
|
ownerMap: Object.fromEntries(ownerMap),
|
|
|
|
|
commissionerMap: Object.fromEntries(commissionerMap),
|
|
|
|
|
availableTeamCount,
|
2025-10-15 08:58:35 -07:00
|
|
|
draftSlots,
|
2025-10-15 21:50:02 -07:00
|
|
|
sportsCount,
|
2025-10-11 00:07:39 -07:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function LeagueHome({ loaderData }: Route.ComponentProps) {
|
2025-10-14 21:24:58 -07:00
|
|
|
const {
|
|
|
|
|
league,
|
|
|
|
|
season,
|
|
|
|
|
teams,
|
|
|
|
|
commissioners,
|
|
|
|
|
currentUserId,
|
2025-10-14 21:20:58 -07:00
|
|
|
isUserCommissioner,
|
|
|
|
|
ownerMap,
|
|
|
|
|
commissionerMap,
|
|
|
|
|
availableTeamCount,
|
2025-10-15 08:58:35 -07:00
|
|
|
draftSlots,
|
2025-10-15 21:50:02 -07:00
|
|
|
sportsCount,
|
2025-10-14 21:20:58 -07:00
|
|
|
} = loaderData;
|
2025-10-11 01:03:31 -07:00
|
|
|
const [searchParams, setSearchParams] = useSearchParams();
|
2025-10-14 12:20:36 -07:00
|
|
|
const [copied, setCopied] = useState(false);
|
2025-10-11 01:03:31 -07:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (searchParams.get("updated") === "true") {
|
2025-10-14 22:04:37 -07:00
|
|
|
toast.success("Team updated successfully");
|
2025-10-14 12:20:36 -07:00
|
|
|
setSearchParams({});
|
|
|
|
|
}
|
|
|
|
|
if (searchParams.get("joined") === "true") {
|
|
|
|
|
toast.success("Welcome to the league! You've been assigned a team.");
|
2025-10-11 01:03:31 -07:00
|
|
|
setSearchParams({});
|
|
|
|
|
}
|
2025-10-14 22:04:37 -07:00
|
|
|
if (searchParams.get("left") === "true") {
|
|
|
|
|
toast.success("You have left the league. Your team is now available.");
|
|
|
|
|
setSearchParams({});
|
|
|
|
|
}
|
2025-10-11 01:03:31 -07:00
|
|
|
}, [searchParams, setSearchParams]);
|
2025-10-11 00:07:39 -07:00
|
|
|
|
2025-10-14 12:20:36 -07:00
|
|
|
const handleCopyInviteLink = async () => {
|
|
|
|
|
if (!season?.inviteCode) return;
|
2025-10-14 21:24:58 -07:00
|
|
|
|
2025-10-14 12:20:36 -07:00
|
|
|
const inviteUrl = `${window.location.origin}/i/${season.inviteCode}`;
|
|
|
|
|
try {
|
|
|
|
|
await navigator.clipboard.writeText(inviteUrl);
|
|
|
|
|
setCopied(true);
|
|
|
|
|
toast.success("Invite link copied to clipboard!");
|
|
|
|
|
setTimeout(() => setCopied(false), 2000);
|
2025-10-14 21:24:58 -07:00
|
|
|
} catch {
|
2025-10-14 12:20:36 -07:00
|
|
|
toast.error("Failed to copy invite link");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-11 00:07:39 -07:00
|
|
|
return (
|
|
|
|
|
<div className="container mx-auto py-8 px-4">
|
|
|
|
|
<div className="mb-8">
|
|
|
|
|
<div className="flex items-center justify-between mb-2">
|
|
|
|
|
<h1 className="text-4xl font-bold">{league.name}</h1>
|
2025-10-11 00:29:04 -07:00
|
|
|
<div className="flex gap-2">
|
2025-10-14 22:04:37 -07:00
|
|
|
{teams.find((t) => t.ownerId === currentUserId) && (
|
|
|
|
|
<Button variant="outline" asChild>
|
|
|
|
|
<Link
|
|
|
|
|
to={`/teams/${teams.find((t) => t.ownerId === currentUserId)?.id}/settings`}
|
|
|
|
|
>
|
|
|
|
|
Team Settings
|
|
|
|
|
</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2025-10-11 00:29:04 -07:00
|
|
|
{isUserCommissioner && (
|
|
|
|
|
<Button variant="outline" asChild>
|
2025-10-14 22:04:37 -07:00
|
|
|
<Link to={`/leagues/${league.id}/settings`}>
|
|
|
|
|
League Settings
|
|
|
|
|
</Link>
|
2025-10-11 00:29:04 -07:00
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-10-11 00:07:39 -07:00
|
|
|
</div>
|
|
|
|
|
{season && (
|
|
|
|
|
<p className="text-muted-foreground">
|
|
|
|
|
{season.year} Season • Status:{" "}
|
|
|
|
|
<span className="capitalize">
|
|
|
|
|
{season.status.replace("_", " ")}
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-10-14 21:54:46 -07:00
|
|
|
<div className="grid gap-6 md:grid-cols-3">
|
|
|
|
|
{/* Left Column - 2/3 width on desktop */}
|
|
|
|
|
<div className="md:col-span-2 space-y-6">
|
|
|
|
|
{isUserCommissioner && season && availableTeamCount > 0 && (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Invite Link</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
Share this link to invite people to join your league (
|
|
|
|
|
{availableTeamCount} spot{availableTeamCount !== 1 ? "s" : ""}{" "}
|
|
|
|
|
available)
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent className="space-y-3">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
readOnly
|
|
|
|
|
value={`${typeof window !== "undefined" ? window.location.origin : ""}/i/${season.inviteCode}`}
|
|
|
|
|
className="flex-1 px-3 py-2 text-sm border rounded-md bg-muted"
|
|
|
|
|
onClick={(e) => e.currentTarget.select()}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleCopyInviteLink}
|
|
|
|
|
variant={copied ? "default" : "outline"}
|
|
|
|
|
size="sm"
|
|
|
|
|
>
|
|
|
|
|
{copied ? "Copied!" : "Copy"}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
|
Anyone with this link can join your league
|
|
|
|
|
</p>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Card>
|
2025-10-14 21:20:58 -07:00
|
|
|
<CardHeader>
|
2025-10-14 21:54:46 -07:00
|
|
|
<CardTitle>Teams</CardTitle>
|
2025-10-14 21:20:58 -07:00
|
|
|
<CardDescription>
|
2025-10-14 22:04:37 -07:00
|
|
|
{teams.length} team{teams.length !== 1 ? "s" : ""} in this
|
|
|
|
|
league
|
2025-10-14 21:20:58 -07:00
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
2025-10-14 21:54:46 -07:00
|
|
|
<CardContent>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
{teams.map((team) => {
|
|
|
|
|
const isOwned = team.ownerId === currentUserId;
|
2025-10-14 22:04:37 -07:00
|
|
|
const ownerName = team.ownerId
|
|
|
|
|
? ownerMap[team.ownerId]
|
|
|
|
|
: null;
|
2025-10-14 21:54:46 -07:00
|
|
|
return (
|
|
|
|
|
<Card
|
|
|
|
|
key={team.id}
|
|
|
|
|
className={isOwned ? "border-primary" : ""}
|
|
|
|
|
>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle className="text-lg">{team.name}</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
{team.ownerId ? (
|
|
|
|
|
isOwned ? (
|
|
|
|
|
<span className="text-primary font-medium">
|
|
|
|
|
Your Team
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
<span>{ownerName || "Unknown Owner"}</span>
|
|
|
|
|
)
|
|
|
|
|
) : (
|
|
|
|
|
<span className="text-muted-foreground">
|
|
|
|
|
Available
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2025-10-14 21:20:58 -07:00
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2025-10-14 21:54:46 -07:00
|
|
|
</div>
|
2025-10-11 00:07:39 -07:00
|
|
|
|
2025-10-14 21:54:46 -07:00
|
|
|
{/* Right Column - 1/3 width on desktop */}
|
|
|
|
|
<div className="space-y-6">
|
2025-10-15 08:58:35 -07:00
|
|
|
{/* Draft Order Display - Only show during pre_draft and draft */}
|
2025-10-20 15:53:38 -07:00
|
|
|
{season &&
|
|
|
|
|
(season.status === "pre_draft" || season.status === "draft") &&
|
|
|
|
|
draftSlots.length > 0 && (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div>
|
|
|
|
|
<CardTitle>Draft Order</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
{season.status === "pre_draft"
|
|
|
|
|
? "Upcoming draft order"
|
|
|
|
|
: "Current draft order"}
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
<Button asChild size="sm">
|
|
|
|
|
<Link to={`/leagues/${league.id}/draft/${season.id}`}>
|
|
|
|
|
Enter Draft Room
|
|
|
|
|
</Link>
|
|
|
|
|
</Button>
|
2025-10-17 12:30:58 -07:00
|
|
|
</div>
|
2025-10-20 15:53:38 -07:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{draftSlots.map((slot: any, index: number) => {
|
|
|
|
|
const ownerName = slot.team.ownerId
|
|
|
|
|
? ownerMap[slot.team.ownerId]
|
|
|
|
|
: null;
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={slot.id}
|
|
|
|
|
className="flex items-center gap-3 py-2 border-b last:border-0"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center justify-center w-7 h-7 rounded-full bg-primary text-primary-foreground font-bold text-xs">
|
|
|
|
|
{index + 1}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
<p className="font-medium text-sm truncate">
|
|
|
|
|
{slot.team.name}
|
|
|
|
|
</p>
|
|
|
|
|
{ownerName && (
|
|
|
|
|
<p className="text-xs text-muted-foreground truncate">
|
|
|
|
|
{ownerName}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-10-15 08:58:35 -07:00
|
|
|
</div>
|
2025-10-20 15:53:38 -07:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)}
|
2025-10-15 08:58:35 -07:00
|
|
|
|
2025-10-14 21:54:46 -07:00
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>League Info</CardTitle>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent className="space-y-2">
|
2025-10-11 00:07:39 -07:00
|
|
|
<div>
|
2025-10-14 21:54:46 -07:00
|
|
|
<p className="text-sm text-muted-foreground">Created</p>
|
|
|
|
|
<p className="font-medium">
|
|
|
|
|
{new Date(league.createdAt).toLocaleDateString()}
|
2025-10-11 00:07:39 -07:00
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-10-14 21:54:46 -07:00
|
|
|
{season && (
|
2025-10-15 21:50:02 -07:00
|
|
|
<>
|
|
|
|
|
<div>
|
2025-10-20 15:53:38 -07:00
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
Season Status
|
|
|
|
|
</p>
|
2025-10-15 21:50:02 -07:00
|
|
|
<p className="font-medium capitalize">
|
|
|
|
|
{season.status.replace("_", " ")}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2025-10-20 15:53:38 -07:00
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
Draft Rounds
|
|
|
|
|
</p>
|
2025-10-15 21:50:02 -07:00
|
|
|
<p className="font-medium">{season.draftRounds}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2025-10-20 15:53:38 -07:00
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
Sports Selected
|
|
|
|
|
</p>
|
2025-10-15 21:50:02 -07:00
|
|
|
<p className="font-medium">{sportsCount}</p>
|
|
|
|
|
</div>
|
2025-10-20 15:53:38 -07:00
|
|
|
<div>
|
|
|
|
|
<p className="text-sm text-muted-foreground">Draft Board</p>
|
|
|
|
|
<Link
|
|
|
|
|
to={`/leagues/${league.id}/draft-board/${season.id}`}
|
|
|
|
|
className="text-blue-600 hover:underline font-medium"
|
|
|
|
|
>
|
|
|
|
|
View Draft Board
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
2025-10-15 21:50:02 -07:00
|
|
|
<div>
|
|
|
|
|
<p className="text-sm text-muted-foreground">Flex Spots</p>
|
|
|
|
|
<p className="font-medium text-primary">
|
|
|
|
|
{Math.max(0, season.draftRounds - sportsCount)}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-10-15 22:02:21 -07:00
|
|
|
{season.draftDateTime && (
|
|
|
|
|
<div>
|
2025-10-20 15:53:38 -07:00
|
|
|
<p className="text-sm text-muted-foreground">
|
|
|
|
|
Draft Date
|
|
|
|
|
</p>
|
2025-10-15 22:02:21 -07:00
|
|
|
<p className="font-medium">
|
|
|
|
|
{format(new Date(season.draftDateTime), "PPP 'at' p")}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-10-15 21:50:02 -07:00
|
|
|
</>
|
2025-10-14 21:54:46 -07:00
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2025-10-11 00:29:04 -07:00
|
|
|
|
2025-10-14 21:54:46 -07:00
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Commissioners</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
{commissioners.length} commissioner
|
|
|
|
|
{commissioners.length !== 1 ? "s" : ""}
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{commissioners.map((commissioner) => {
|
|
|
|
|
const commissionerName = commissionerMap[commissioner.userId];
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={commissioner.id}
|
|
|
|
|
className="py-2 border-b last:border-0"
|
|
|
|
|
>
|
|
|
|
|
<p className="font-medium">
|
|
|
|
|
{commissionerName || "Unknown User"}
|
|
|
|
|
{commissioner.userId === currentUserId && (
|
2025-10-14 22:04:37 -07:00
|
|
|
<span className="ml-2 text-xs text-primary">
|
|
|
|
|
(You)
|
|
|
|
|
</span>
|
2025-10-14 21:54:46 -07:00
|
|
|
)}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
2025-10-11 00:07:39 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|