diff --git a/src/app/stream-card/[id]/_components/stream-card-client.tsx b/src/app/stream-card/[id]/_components/stream-card-client.tsx index 593d79a..206d924 100644 --- a/src/app/stream-card/[id]/_components/stream-card-client.tsx +++ b/src/app/stream-card/[id]/_components/stream-card-client.tsx @@ -93,12 +93,31 @@ export function StreamCardClient() { const isQueuing = playerState?.status === 'queuing' const opponentId = playerState?.currentMatch?.opponentId + + let winsVsOpponent = 0 + let lossesVsOpponent = 0 + if (opponentId) { + for (const game of games) { + if (game.opponentId === opponentId) { + if (game.result === 'win') { + winsVsOpponent++ + } else if (game.result === 'loss') { + lossesVsOpponent++ + } + } + } + } + console.log(winsVsOpponent, lossesVsOpponent) return (
- + {isQueuing && playerState.queueStartTime && ( )} @@ -108,7 +127,7 @@ export function StreamCardClient() { {' '} - + )}
@@ -149,7 +168,7 @@ function QueueTimer({ startTime }: { startTime: number }) { ) } -function Opponent({ id }: { id: string }) { +function Opponent({ id, wins }: { id: string; wins?: number }) { const { data: gamesQueryResult } = api.history.user_games.useQuery({ user_id: id, }) @@ -164,7 +183,7 @@ function Opponent({ id }: { id: string }) { } const playerData = getPlayerData(rankedUserRank, games) - return + return } function PlayerInfo({ @@ -173,11 +192,13 @@ function PlayerInfo({ children, isReverse = false, isInBattle = false, + wins, ...rest }: { playerData: ReturnType isReverse?: boolean isInBattle?: boolean + wins?: number } & ComponentPropsWithoutRef<'div'>) { return (
- {playerData.rank} + #{playerData.rank}
{/* Player Name */} @@ -229,7 +250,12 @@ function PlayerInfo({ )} {/* Win/Loss */} -
+
{playerData.wins}W @@ -242,6 +268,16 @@ function PlayerInfo({
+ {isInBattle && ( +
+ {wins} +
+ )} {/* Streak */} {!isInBattle && (