2025-11-13 13:24:03 -08:00
|
|
|
|
import { useLoaderData, Link } from "react-router";
|
|
|
|
|
|
import { getAuth } from "@clerk/react-router/server";
|
|
|
|
|
|
import { database } from "~/database/context";
|
|
|
|
|
|
import { eq, and } from "drizzle-orm";
|
|
|
|
|
|
import * as schema from "~/database/schema";
|
|
|
|
|
|
import { Button } from "~/components/ui/button";
|
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card";
|
|
|
|
|
|
import { StandingsTable } from "~/components/standings/StandingsTable";
|
2025-11-14 21:18:34 -08:00
|
|
|
|
import { getSevenDayStandingsChange, getSeasonPointProgression } from "~/models/standings";
|
|
|
|
|
|
import { isSeasonComplete, getSeasonCompletionPercentage } from "~/lib/season-helpers.server";
|
|
|
|
|
|
import { PointProgressionChart } from "~/components/standings/PointProgressionChart";
|
Display team owner names in standings views (#184)
* Show team name + username in standings, extract TeamNameDisplay component
- Add TeamNameDisplay component that renders team name (as link) with owner username below, matching the league homepage style
- Update StandingsTable to use TeamNameDisplay with owner username shown below team name
- Update league homepage standings section to use TeamNameDisplay
- Add ownerName/teamOwnerId fields to TeamStanding type
- Extend getSeasonStandings to include teamOwnerId from team relation
- Fetch and attach owner display names in the full standings page loader
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
* Address code review: type hygiene, explicit types, parallel fetching, style fix
- Remove teamOwnerId from TeamStanding type (was an internal server concern, not display data)
- Remove teamOwnerId from getSeasonStandings return value
- Add TeamStandingWithChange interface extending TeamStanding with sevenDayRankChange/sevenDayOldRank fields
- Annotate getSevenDayStandingsChange with explicit Promise<TeamStandingWithChange[]> return type
- Re-export TeamStandingWithChange from models/standings.ts
- Standings loader: query teams table directly for ownerIds instead of relying on teamOwnerId in standings data
- Standings loader: parallelize all independent queries (standings, teams, progressionData, seasonComplete, completionPercentage) with Promise.all
- Restore font-medium on StandingsTable team TableCell
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 20:19:28 -07:00
|
|
|
|
import { findUsersByClerkIds, getUserDisplayName } from "~/models/user";
|
Claude/fix pick timer ghll n (#29)
* Fix force-manual-pick resetting next team's timer to initial time
When a commissioner forced a manual pick, the next team's timer was
being reset to the initial time (2 minutes) instead of carrying
forward their existing time bank balance.
This aligns force-manual-pick with the behavior of regular user picks
and force-autopick: the picking team gets their increment added, and
the next team's timer is left untouched so their bank carries forward.
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add regression tests for draft.force-manual-pick timer behavior
18 tests across 5 describe blocks covering:
- Authorization (401/403)
- Input validation (missing fields, bad participant, ineligible sport)
- Successful pick (response shape, draft-complete detection, socket events)
- Timer behavior (increment added to picking team, new timer creation, additive not reset)
- Two regression tests confirming the next team's timer is never touched:
draftTimers.findFirst called exactly once, no timer-update emitted for
next team, db.update called exactly twice (not three times)
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add TypeScript types and improve draft validation (#28)
* Code review fixes: type safety, security hardening, and dead code removal
- Fix Socket.IO event types: draft-paused and draft-resumed were typed as
() => void but are emitted with { seasonId, paused } data payloads
- Fix draft.force-manual-pick: add missing season.status === "draft" guard
so commissioners cannot force picks outside an active draft; add duplicate
pick-number check so a slot cannot be assigned two picks (the previous
code only checked participant uniqueness, not slot uniqueness)
- Replace args: any with ActionFunctionArgs / Route.LoaderArgs across all
API routes and league loaders; replace (auth as any).userId casts with
proper const { userId } = await getAuth(args) destructuring
- Remove unused isSnakeDraft = true dead variable from draft.make-pick
- Replace autodraftSettings: any and draftSlots: any[] in draft-utils with
properly typed InferSelectModel / DraftSlot types
- Update force-manual-pick tests: sequence draftPicks.findFirst mock for
the two-call flow; add new tests for status-check and slot-uniqueness
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
* Fix RouterContextProvider type errors in action test files
Cast context argument to RouterContextProvider in test helpers so
ActionFunctionArgs strict typing is satisfied without weakening the
production action signatures back to any.
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-22 19:29:29 -08:00
|
|
|
|
import type { Route } from "./+types/$leagueId.standings.$seasonId";
|
2025-11-13 13:24:03 -08:00
|
|
|
|
|
2026-03-10 12:10:52 -07:00
|
|
|
|
export function meta({ data }: Route.MetaArgs): Route.MetaDescriptors {
|
|
|
|
|
|
return [{ title: `Standings — ${data?.league?.name ?? "League"} - Brackt` }];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Claude/fix pick timer ghll n (#29)
* Fix force-manual-pick resetting next team's timer to initial time
When a commissioner forced a manual pick, the next team's timer was
being reset to the initial time (2 minutes) instead of carrying
forward their existing time bank balance.
This aligns force-manual-pick with the behavior of regular user picks
and force-autopick: the picking team gets their increment added, and
the next team's timer is left untouched so their bank carries forward.
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add regression tests for draft.force-manual-pick timer behavior
18 tests across 5 describe blocks covering:
- Authorization (401/403)
- Input validation (missing fields, bad participant, ineligible sport)
- Successful pick (response shape, draft-complete detection, socket events)
- Timer behavior (increment added to picking team, new timer creation, additive not reset)
- Two regression tests confirming the next team's timer is never touched:
draftTimers.findFirst called exactly once, no timer-update emitted for
next team, db.update called exactly twice (not three times)
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add TypeScript types and improve draft validation (#28)
* Code review fixes: type safety, security hardening, and dead code removal
- Fix Socket.IO event types: draft-paused and draft-resumed were typed as
() => void but are emitted with { seasonId, paused } data payloads
- Fix draft.force-manual-pick: add missing season.status === "draft" guard
so commissioners cannot force picks outside an active draft; add duplicate
pick-number check so a slot cannot be assigned two picks (the previous
code only checked participant uniqueness, not slot uniqueness)
- Replace args: any with ActionFunctionArgs / Route.LoaderArgs across all
API routes and league loaders; replace (auth as any).userId casts with
proper const { userId } = await getAuth(args) destructuring
- Remove unused isSnakeDraft = true dead variable from draft.make-pick
- Replace autodraftSettings: any and draftSlots: any[] in draft-utils with
properly typed InferSelectModel / DraftSlot types
- Update force-manual-pick tests: sequence draftPicks.findFirst mock for
the two-call flow; add new tests for status-check and slot-uniqueness
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
* Fix RouterContextProvider type errors in action test files
Cast context argument to RouterContextProvider in test helpers so
ActionFunctionArgs strict typing is satisfied without weakening the
production action signatures back to any.
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-22 19:29:29 -08:00
|
|
|
|
export async function loader(args: Route.LoaderArgs) {
|
2025-11-13 13:24:03 -08:00
|
|
|
|
try {
|
Claude/fix pick timer ghll n (#29)
* Fix force-manual-pick resetting next team's timer to initial time
When a commissioner forced a manual pick, the next team's timer was
being reset to the initial time (2 minutes) instead of carrying
forward their existing time bank balance.
This aligns force-manual-pick with the behavior of regular user picks
and force-autopick: the picking team gets their increment added, and
the next team's timer is left untouched so their bank carries forward.
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add regression tests for draft.force-manual-pick timer behavior
18 tests across 5 describe blocks covering:
- Authorization (401/403)
- Input validation (missing fields, bad participant, ineligible sport)
- Successful pick (response shape, draft-complete detection, socket events)
- Timer behavior (increment added to picking team, new timer creation, additive not reset)
- Two regression tests confirming the next team's timer is never touched:
draftTimers.findFirst called exactly once, no timer-update emitted for
next team, db.update called exactly twice (not three times)
https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p
* Add TypeScript types and improve draft validation (#28)
* Code review fixes: type safety, security hardening, and dead code removal
- Fix Socket.IO event types: draft-paused and draft-resumed were typed as
() => void but are emitted with { seasonId, paused } data payloads
- Fix draft.force-manual-pick: add missing season.status === "draft" guard
so commissioners cannot force picks outside an active draft; add duplicate
pick-number check so a slot cannot be assigned two picks (the previous
code only checked participant uniqueness, not slot uniqueness)
- Replace args: any with ActionFunctionArgs / Route.LoaderArgs across all
API routes and league loaders; replace (auth as any).userId casts with
proper const { userId } = await getAuth(args) destructuring
- Remove unused isSnakeDraft = true dead variable from draft.make-pick
- Replace autodraftSettings: any and draftSlots: any[] in draft-utils with
properly typed InferSelectModel / DraftSlot types
- Update force-manual-pick tests: sequence draftPicks.findFirst mock for
the two-call flow; add new tests for status-check and slot-uniqueness
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
* Fix RouterContextProvider type errors in action test files
Cast context argument to RouterContextProvider in test helpers so
ActionFunctionArgs strict typing is satisfied without weakening the
production action signatures back to any.
https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-02-22 19:29:29 -08:00
|
|
|
|
const { userId } = await getAuth(args);
|
2025-11-13 13:24:03 -08:00
|
|
|
|
const { params } = args;
|
|
|
|
|
|
const { leagueId, seasonId } = params;
|
|
|
|
|
|
|
|
|
|
|
|
const db = database();
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch league
|
|
|
|
|
|
const league = await db.query.leagues.findFirst({
|
|
|
|
|
|
where: eq(schema.leagues.id, leagueId),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!league) {
|
|
|
|
|
|
throw new Response("League not found", { status: 404 });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Fetch season
|
|
|
|
|
|
const season = await db.query.seasons.findFirst({
|
|
|
|
|
|
where: eq(schema.seasons.id, seasonId),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!season || season.leagueId !== leagueId) {
|
|
|
|
|
|
throw new Response("Season not found", { status: 404 });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check access
|
|
|
|
|
|
if (!userId) {
|
|
|
|
|
|
throw new Response("You must be logged in to view standings", {
|
|
|
|
|
|
status: 401,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check if user is a commissioner
|
|
|
|
|
|
const isUserCommissioner = await db.query.commissioners.findFirst({
|
|
|
|
|
|
where: and(
|
|
|
|
|
|
eq(schema.commissioners.leagueId, leagueId),
|
|
|
|
|
|
eq(schema.commissioners.userId, userId)
|
|
|
|
|
|
),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Check if user has a team in this season
|
|
|
|
|
|
const hasTeam = await db.query.teams.findFirst({
|
|
|
|
|
|
where: and(
|
|
|
|
|
|
eq(schema.teams.seasonId, seasonId),
|
|
|
|
|
|
eq(schema.teams.ownerId, userId)
|
|
|
|
|
|
),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!isUserCommissioner && !hasTeam) {
|
|
|
|
|
|
throw new Response("You do not have access to this league", {
|
|
|
|
|
|
status: 403,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Display team owner names in standings views (#184)
* Show team name + username in standings, extract TeamNameDisplay component
- Add TeamNameDisplay component that renders team name (as link) with owner username below, matching the league homepage style
- Update StandingsTable to use TeamNameDisplay with owner username shown below team name
- Update league homepage standings section to use TeamNameDisplay
- Add ownerName/teamOwnerId fields to TeamStanding type
- Extend getSeasonStandings to include teamOwnerId from team relation
- Fetch and attach owner display names in the full standings page loader
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
* Address code review: type hygiene, explicit types, parallel fetching, style fix
- Remove teamOwnerId from TeamStanding type (was an internal server concern, not display data)
- Remove teamOwnerId from getSeasonStandings return value
- Add TeamStandingWithChange interface extending TeamStanding with sevenDayRankChange/sevenDayOldRank fields
- Annotate getSevenDayStandingsChange with explicit Promise<TeamStandingWithChange[]> return type
- Re-export TeamStandingWithChange from models/standings.ts
- Standings loader: query teams table directly for ownerIds instead of relying on teamOwnerId in standings data
- Standings loader: parallelize all independent queries (standings, teams, progressionData, seasonComplete, completionPercentage) with Promise.all
- Restore font-medium on StandingsTable team TableCell
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 20:19:28 -07:00
|
|
|
|
// Fetch standings, teams (for owner lookup), and independent data in parallel
|
|
|
|
|
|
const [standingsWithComparison, teams, progressionData, seasonComplete, completionPercentage] =
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
getSevenDayStandingsChange(seasonId, db),
|
|
|
|
|
|
db.query.teams.findMany({
|
|
|
|
|
|
where: eq(schema.teams.seasonId, seasonId),
|
|
|
|
|
|
columns: { id: true, ownerId: true },
|
|
|
|
|
|
}),
|
|
|
|
|
|
getSeasonPointProgression(seasonId, db),
|
|
|
|
|
|
isSeasonComplete(seasonId, db),
|
|
|
|
|
|
getSeasonCompletionPercentage(seasonId, db),
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
// Build teamId -> ownerName map
|
2026-03-21 09:44:05 -07:00
|
|
|
|
const ownerIds = [...new Set(teams.map((t) => t.ownerId).filter((id): id is string => id !== null))];
|
Display team owner names in standings views (#184)
* Show team name + username in standings, extract TeamNameDisplay component
- Add TeamNameDisplay component that renders team name (as link) with owner username below, matching the league homepage style
- Update StandingsTable to use TeamNameDisplay with owner username shown below team name
- Update league homepage standings section to use TeamNameDisplay
- Add ownerName/teamOwnerId fields to TeamStanding type
- Extend getSeasonStandings to include teamOwnerId from team relation
- Fetch and attach owner display names in the full standings page loader
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
* Address code review: type hygiene, explicit types, parallel fetching, style fix
- Remove teamOwnerId from TeamStanding type (was an internal server concern, not display data)
- Remove teamOwnerId from getSeasonStandings return value
- Add TeamStandingWithChange interface extending TeamStanding with sevenDayRankChange/sevenDayOldRank fields
- Annotate getSevenDayStandingsChange with explicit Promise<TeamStandingWithChange[]> return type
- Re-export TeamStandingWithChange from models/standings.ts
- Standings loader: query teams table directly for ownerIds instead of relying on teamOwnerId in standings data
- Standings loader: parallelize all independent queries (standings, teams, progressionData, seasonComplete, completionPercentage) with Promise.all
- Restore font-medium on StandingsTable team TableCell
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 20:19:28 -07:00
|
|
|
|
const userRows = await findUsersByClerkIds(ownerIds);
|
|
|
|
|
|
const userByClerkId = new Map(userRows.map((u) => [u.clerkId, u]));
|
|
|
|
|
|
const ownerNameByTeamId = new Map(
|
|
|
|
|
|
teams
|
2026-03-21 09:44:05 -07:00
|
|
|
|
.filter((t): t is typeof t & { ownerId: string } => t.ownerId !== null)
|
Display team owner names in standings views (#184)
* Show team name + username in standings, extract TeamNameDisplay component
- Add TeamNameDisplay component that renders team name (as link) with owner username below, matching the league homepage style
- Update StandingsTable to use TeamNameDisplay with owner username shown below team name
- Update league homepage standings section to use TeamNameDisplay
- Add ownerName/teamOwnerId fields to TeamStanding type
- Extend getSeasonStandings to include teamOwnerId from team relation
- Fetch and attach owner display names in the full standings page loader
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
* Address code review: type hygiene, explicit types, parallel fetching, style fix
- Remove teamOwnerId from TeamStanding type (was an internal server concern, not display data)
- Remove teamOwnerId from getSeasonStandings return value
- Add TeamStandingWithChange interface extending TeamStanding with sevenDayRankChange/sevenDayOldRank fields
- Annotate getSevenDayStandingsChange with explicit Promise<TeamStandingWithChange[]> return type
- Re-export TeamStandingWithChange from models/standings.ts
- Standings loader: query teams table directly for ownerIds instead of relying on teamOwnerId in standings data
- Standings loader: parallelize all independent queries (standings, teams, progressionData, seasonComplete, completionPercentage) with Promise.all
- Restore font-medium on StandingsTable team TableCell
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 20:19:28 -07:00
|
|
|
|
.map((t) => {
|
|
|
|
|
|
const user = userByClerkId.get(t.ownerId);
|
|
|
|
|
|
return [t.id, user ? getUserDisplayName(user) : null] as const;
|
|
|
|
|
|
})
|
|
|
|
|
|
);
|
2025-11-13 13:24:03 -08:00
|
|
|
|
|
2025-11-14 09:15:58 -08:00
|
|
|
|
// Map to format expected by component (use sevenDayRankChange instead of previousRank)
|
|
|
|
|
|
const formattedStandings = standingsWithComparison.map((standing) => ({
|
|
|
|
|
|
...standing,
|
|
|
|
|
|
rankChange: standing.sevenDayRankChange,
|
Display team owner names in standings views (#184)
* Show team name + username in standings, extract TeamNameDisplay component
- Add TeamNameDisplay component that renders team name (as link) with owner username below, matching the league homepage style
- Update StandingsTable to use TeamNameDisplay with owner username shown below team name
- Update league homepage standings section to use TeamNameDisplay
- Add ownerName/teamOwnerId fields to TeamStanding type
- Extend getSeasonStandings to include teamOwnerId from team relation
- Fetch and attach owner display names in the full standings page loader
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
* Address code review: type hygiene, explicit types, parallel fetching, style fix
- Remove teamOwnerId from TeamStanding type (was an internal server concern, not display data)
- Remove teamOwnerId from getSeasonStandings return value
- Add TeamStandingWithChange interface extending TeamStanding with sevenDayRankChange/sevenDayOldRank fields
- Annotate getSevenDayStandingsChange with explicit Promise<TeamStandingWithChange[]> return type
- Re-export TeamStandingWithChange from models/standings.ts
- Standings loader: query teams table directly for ownerIds instead of relying on teamOwnerId in standings data
- Standings loader: parallelize all independent queries (standings, teams, progressionData, seasonComplete, completionPercentage) with Promise.all
- Restore font-medium on StandingsTable team TableCell
https://claude.ai/code/session_01EYgGnuTBaRVdBDapJRTxDZ
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-19 20:19:28 -07:00
|
|
|
|
ownerName: ownerNameByTeamId.get(standing.teamId) ?? null,
|
2025-11-14 09:15:58 -08:00
|
|
|
|
}));
|
2025-11-13 13:24:03 -08:00
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
league,
|
|
|
|
|
|
season,
|
|
|
|
|
|
standings: formattedStandings,
|
2025-11-14 21:18:34 -08:00
|
|
|
|
progressionData,
|
|
|
|
|
|
seasonComplete,
|
|
|
|
|
|
completionPercentage,
|
2025-11-13 13:24:03 -08:00
|
|
|
|
};
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error("Error loading standings:", error);
|
|
|
|
|
|
console.error("Error details:", {
|
|
|
|
|
|
message: error instanceof Error ? error.message : String(error),
|
|
|
|
|
|
stack: error instanceof Error ? error.stack : undefined,
|
|
|
|
|
|
});
|
|
|
|
|
|
throw error;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function LeagueStandings() {
|
2025-11-14 21:18:34 -08:00
|
|
|
|
const { league, season, standings, progressionData, seasonComplete, completionPercentage } = useLoaderData<typeof loader>();
|
2025-11-13 13:24:03 -08:00
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="container mx-auto py-8 px-4">
|
|
|
|
|
|
{/* Header */}
|
|
|
|
|
|
<div className="mb-8">
|
|
|
|
|
|
<Button variant="ghost" className="mb-4" asChild>
|
|
|
|
|
|
<Link to={`/leagues/${league.id}`}>
|
|
|
|
|
|
← Back to League
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<h1 className="text-4xl font-bold mb-2">{league.name}</h1>
|
|
|
|
|
|
<p className="text-muted-foreground text-lg">
|
|
|
|
|
|
{season.year} Season Standings
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
2025-11-14 21:18:34 -08:00
|
|
|
|
<div className="text-right">
|
|
|
|
|
|
{seasonComplete ? (
|
|
|
|
|
|
<div className="inline-flex items-center px-3 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100 text-sm font-medium">
|
|
|
|
|
|
✓ Season Complete
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div className="text-sm text-muted-foreground">
|
|
|
|
|
|
{completionPercentage}% Complete
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2025-11-13 13:24:03 -08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-14 21:18:34 -08:00
|
|
|
|
{/* Point Progression Chart */}
|
|
|
|
|
|
{progressionData.chartData.length > 0 && (
|
|
|
|
|
|
<div className="mb-6">
|
|
|
|
|
|
<PointProgressionChart
|
|
|
|
|
|
chartData={progressionData.chartData}
|
|
|
|
|
|
teams={progressionData.teams}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
2025-11-13 13:24:03 -08:00
|
|
|
|
{/* Standings Card */}
|
|
|
|
|
|
<Card>
|
|
|
|
|
|
<CardHeader>
|
2025-11-14 21:18:34 -08:00
|
|
|
|
<CardTitle>
|
|
|
|
|
|
{seasonComplete ? "Final Standings" : "Current Standings"}
|
|
|
|
|
|
</CardTitle>
|
2025-11-13 13:24:03 -08:00
|
|
|
|
</CardHeader>
|
|
|
|
|
|
<CardContent>
|
|
|
|
|
|
{standings.length === 0 ? (
|
|
|
|
|
|
<div className="text-center py-12 text-muted-foreground">
|
|
|
|
|
|
<p className="text-lg">No standings data yet.</p>
|
|
|
|
|
|
<p className="text-sm mt-2">
|
|
|
|
|
|
Standings will appear once participants have results.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
2025-11-14 20:01:21 -08:00
|
|
|
|
<StandingsTable
|
|
|
|
|
|
standings={standings}
|
|
|
|
|
|
leagueId={league.id}
|
|
|
|
|
|
seasonId={season.id}
|
|
|
|
|
|
showPlacementBreakdown={true}
|
|
|
|
|
|
/>
|
2025-11-13 13:24:03 -08:00
|
|
|
|
)}
|
|
|
|
|
|
</CardContent>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Info Card */}
|
|
|
|
|
|
<Card className="mt-6">
|
|
|
|
|
|
<CardContent className="pt-6">
|
|
|
|
|
|
<div className="text-sm text-muted-foreground space-y-2">
|
2026-02-14 22:30:12 -08:00
|
|
|
|
<p>
|
|
|
|
|
|
<strong>Projected Points:</strong> Shows actual points from finished
|
|
|
|
|
|
participants plus expected value (EV) from remaining participants based
|
|
|
|
|
|
on their probability distributions. The "+X.X EV" indicates how many
|
|
|
|
|
|
additional points are expected from unfinished participants.
|
|
|
|
|
|
</p>
|
2025-11-13 13:24:03 -08:00
|
|
|
|
<p>
|
|
|
|
|
|
<strong>Tiebreaker Rules:</strong> Teams are ranked by total
|
|
|
|
|
|
points. If tied, the team with more 1st place finishes ranks
|
|
|
|
|
|
higher. If still tied, 2nd place finishes are compared, then 3rd,
|
|
|
|
|
|
and so on through 8th place.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
<strong>Movement Indicators:</strong> Arrows show rank changes
|
2025-11-14 09:15:58 -08:00
|
|
|
|
compared to 7 days ago. Green arrows (↑) indicate improvement in rank,
|
|
|
|
|
|
red arrows (↓) indicate decline.
|
2025-11-13 13:24:03 -08:00
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
<strong>Placement Breakdown:</strong> Shows how many times each
|
|
|
|
|
|
team's participants finished in each position (1st×2 means 2 first-place finishes).
|
|
|
|
|
|
</p>
|
2025-11-14 21:18:34 -08:00
|
|
|
|
{progressionData.chartData.length > 0 && (
|
|
|
|
|
|
<p>
|
|
|
|
|
|
<strong>Point Progression Chart:</strong> Visualizes how each team's
|
|
|
|
|
|
total points evolved over time based on {progressionData.chartData.length} day{progressionData.chartData.length !== 1 ? 's' : ''} of snapshot data.
|
|
|
|
|
|
{seasonComplete && " Use this to see how the final standings developed throughout the season."}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
2025-11-13 13:24:03 -08:00
|
|
|
|
</div>
|
|
|
|
|
|
</CardContent>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|