refactor(ui): update components to use new player field names

This commit is contained in:
2026-04-03 21:03:57 -07:00
parent 1f7d589698
commit e0c986f594
9 changed files with 193 additions and 212 deletions
+25 -23
View File
@@ -64,17 +64,17 @@ export default async function PlayerProfilePage({ params }: PageProps) {
const recentMatches = await prisma.match.findMany({
where: {
OR: [
{ team1P1Id: playerId },
{ team1P2Id: playerId },
{ team2P1Id: playerId },
{ team2P2Id: playerId },
{ player1P1Id: playerId },
{ player1P2Id: playerId },
{ player2P1Id: playerId },
{ player2P2Id: playerId },
],
},
include: {
team1P1: true,
team1P2: true,
team2P1: true,
team2P2: true,
player1P1: true,
player1P2: true,
player2P1: true,
player2P2: true,
event: true,
},
orderBy: { playedAt: "desc" },
@@ -247,18 +247,18 @@ export default async function PlayerProfilePage({ params }: PageProps) {
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{recentMatches.map((match) => {
const isTeam1 = match.team1P1Id === playerId || match.team1P2Id === playerId;
const isTeam1 = match.player1P1Id === playerId || match.player1P2Id === playerId;
const teamWon = isTeam1 ? match.team1Score > match.team2Score : match.team2Score > match.team1Score;
const teamScore = isTeam1 ? match.team1Score : match.team2Score;
const opponentScore = isTeam1 ? match.team2Score : match.team1Score;
const teammate = isTeam1
? (match.team1P1Id === playerId ? match.team1P2 : match.team1P1)
: (match.team2P1Id === playerId ? match.team2P2 : match.team2P1);
? (match.player1P1Id === playerId ? match.player1P2 : match.player1P1)
: (match.player2P1Id === playerId ? match.player2P2 : match.player2P1);
const opponents = isTeam1
? [match.team2P1, match.team2P2]
: [match.team1P1, match.team1P2];
? [match.player2P1, match.player2P2]
: [match.player1P1, match.player1P2];
return (
<tr key={match.id} className="hover:bg-gray-50">
@@ -276,21 +276,23 @@ export default async function PlayerProfilePage({ params }: PageProps) {
{match.event?.name || "N/A"}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
<Link
href={`/players/${teammate.id}/profile`}
className="text-green-600 hover:text-green-900"
>
{teammate.name}
</Link>
{teammate && (
<Link
href={`/players/${teammate.id}/profile`}
className="text-green-600 hover:text-green-900"
>
{teammate.name}
</Link>
)}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{opponents.map((opponent, index) => (
<span key={opponent.id}>
{opponents.filter(o => o !== null).map((opponent, index) => (
<span key={opponent?.id}>
<Link
href={`/players/${opponent.id}/profile`}
href={`/players/${opponent?.id}/profile`}
className="text-green-600 hover:text-green-900"
>
{opponent.name}
{opponent?.name}
</Link>
{index < opponents.length - 1 ? ", " : ""}
</span>