From 332352278221bebe32e10b0d07a1d535faab3aa2 Mon Sep 17 00:00:00 2001 From: Chris Parsons <438676+chrisparsons83@users.noreply.github.com> Date: Fri, 20 Feb 2026 11:35:35 -0800 Subject: [PATCH] Fix sports season page 404 when sports season is linked to multiple leagues (#10) The loader was grabbing seasonSports[0] blindly instead of filtering by the current league, causing a 404 when the first linked fantasy season belonged to a different league. https://claude.ai/code/session_01Mq6BqFhiYFuJyDcc8ueVJc Co-authored-by: Claude --- ...agueId.sports-seasons.$sportsSeasonId.server.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts b/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts index 31eaaaf..27bf6ee 100644 --- a/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts +++ b/app/routes/leagues/$leagueId.sports-seasons.$sportsSeasonId.server.ts @@ -8,10 +8,8 @@ import { findUserByClerkId, } from "~/models"; import { getDraftPicks } from "~/models/draft-pick"; -import { findSportsSeasonById } from "~/models/sports-season"; import { getSeasonResults } from "~/models/participant-season-result"; import { getQPStandings } from "~/models/qualifying-points"; -import { findSeasonById } from "~/models/season"; import { database } from "~/database/context"; import * as schema from "~/database/schema"; import { eq } from "drizzle-orm"; @@ -64,19 +62,17 @@ export async function loader(args: Route.LoaderArgs) { // Get the fantasy season for this league (to get teams and draft picks) // We need to find which season in this league includes this sports season - const seasonSport = sportsSeason.seasonSports?.[0]; + // Filter by leagueId since a sports season can be linked to multiple leagues + const seasonSport = sportsSeason.seasonSports?.find( + (ss) => ss.season.leagueId === leagueId + ); if (!seasonSport) { throw new Response("This sports season is not linked to this league", { status: 404, }); } - const season = await findSeasonById(seasonSport.seasonId); - if (!season || season.leagueId !== leagueId) { - throw new Response("This sports season is not linked to this league", { - status: 404, - }); - } + const season = seasonSport.season; // Fetch teams and draft picks to determine ownership const teams = await findTeamsBySeasonId(season.id);