Fix standings page team icons to use selected team avatar
The full standings page was not passing avatar data (logoUrl, flagConfig, avatarType, ownerAvatarData) to StandingsPreview entries, so all teams showed the default initials fallback instead of their chosen avatar. Fetches the avatar columns from the teams table in the loader, resolves owner avatar data for teams using the owner avatar type, and threads all avatar fields through formattedStandings into previewEntries. https://claude.ai/code/session_01CVt5Vo2PDGY4G3wSWbsmRG
This commit is contained in:
parent
46a81a6435
commit
4593917e7a
1 changed files with 22 additions and 6 deletions
|
|
@ -10,6 +10,7 @@ import { isSeasonComplete, getSeasonCompletionPercentage } from "~/lib/season-he
|
|||
import { getRecentTeamScoreEvents } from "~/models/team-score-events";
|
||||
import { PointProgressionChart } from "~/components/standings/PointProgressionChart";
|
||||
import { findUsersByIds, getUserDisplayName } from "~/models/user";
|
||||
import { resolveUserAvatarData } from "~/lib/avatar-data";
|
||||
import { StandingsPreview } from "~/components/league/StandingsPreview";
|
||||
import { buildTiedRankChecker, getDisplayRank } from "~/lib/standings-display";
|
||||
import { RecentScoresCard } from "~/components/standings/RecentScoresCard";
|
||||
|
|
@ -59,7 +60,7 @@ export async function loader(args: Route.LoaderArgs) {
|
|||
getSevenDayStandingsChange(seasonId, db),
|
||||
db.query.teams.findMany({
|
||||
where: eq(schema.teams.seasonId, seasonId),
|
||||
columns: { id: true, ownerId: true },
|
||||
columns: { id: true, ownerId: true, logoUrl: true, flagConfig: true, avatarType: true },
|
||||
}),
|
||||
getSeasonPointProgression(seasonId, db),
|
||||
isSeasonComplete(seasonId, db),
|
||||
|
|
@ -80,12 +81,23 @@ export async function loader(args: Route.LoaderArgs) {
|
|||
})
|
||||
);
|
||||
|
||||
const ownerAvatarDataByUserId = new Map(userRows.map((u) => [u.id, resolveUserAvatarData(u)]));
|
||||
const teamById = new Map(teams.map((t) => [t.id, t]));
|
||||
|
||||
// Map to format expected by component (use sevenDayRankChange instead of previousRank)
|
||||
const formattedStandings = standingsWithComparison.map((standing) => ({
|
||||
...standing,
|
||||
rankChange: standing.sevenDayRankChange,
|
||||
ownerName: ownerNameByTeamId.get(standing.teamId) ?? null,
|
||||
}));
|
||||
const formattedStandings = standingsWithComparison.map((standing) => {
|
||||
const team = teamById.get(standing.teamId);
|
||||
const ownerAvatarData = team?.ownerId ? (ownerAvatarDataByUserId.get(team.ownerId) ?? null) : null;
|
||||
return {
|
||||
...standing,
|
||||
rankChange: standing.sevenDayRankChange,
|
||||
ownerName: ownerNameByTeamId.get(standing.teamId) ?? null,
|
||||
logoUrl: team?.logoUrl ?? null,
|
||||
flagConfig: team?.flagConfig ?? null,
|
||||
avatarType: team?.avatarType ?? null,
|
||||
ownerAvatarData,
|
||||
};
|
||||
});
|
||||
|
||||
// Enrich recentScoreEvents with owner names
|
||||
const enrichedScoreEvents = recentScoreEvents.map((event) => ({
|
||||
|
|
@ -119,6 +131,10 @@ export default function LeagueStandings() {
|
|||
teamId: s.teamId,
|
||||
teamName: s.teamName,
|
||||
ownerName: s.ownerName,
|
||||
logoUrl: s.logoUrl,
|
||||
flagConfig: s.flagConfig,
|
||||
avatarType: s.avatarType,
|
||||
ownerAvatarData: s.ownerAvatarData,
|
||||
displayRank: getDisplayRank(s, standings.length, isTied(s.currentRank)),
|
||||
currentRank: s.currentRank,
|
||||
points: s.totalPoints,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue