Skip to content

Commit

Permalink
Fixed names on player stat cards
Browse files Browse the repository at this point in the history
  • Loading branch information
MethSarcus committed Dec 2, 2024
1 parent f239917 commit 2ea51cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 4 additions & 3 deletions components/cards/statcards/TeamPlayerStatCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ const TeamStatCard = (props: MyProps) => {
{props.title}
</Box>

<Box fontWeight="bold" fontSize={"1em"} color={"textTheme.mediumEmphasis"}>
{props.playerDetails?.first_name} {props.playerDetails?.last_name}
</Box>

<Avatar
my={2}
size={"md"}
borderWidth={"1px"}
borderColor={"grey"}
src={isNaN(+props.player?.id!) ? `https://sleepercdn.com/images/team_logos/nfl/${props.player?.id.toLowerCase()}.png` : `https://sleepercdn.com/content/nfl/players/${props.player?.id}.jpg`}
/>
<Text color={"textTheme.highEmphasis"}>
{props.playerDetails?.first_name} {props.playerDetails?.last_name}
</Text>

<Text
fontSize={".9em"}
Expand Down
21 changes: 13 additions & 8 deletions components/groups/stats/TeamPlayerStatGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Box, Flex, HStack, SimpleGrid, Spacer } from "@chakra-ui/react";
import { useContext } from "react";
import League from "../../../classes/custom/League";
import { OrdinalStatInfo } from "../../../classes/custom/OrdinalStatInfo";
import { PlayerScores, SleeperPlayerDetails } from "../../../classes/custom/Player";
import { DatabasePlayer, PlayerScores, SleeperPlayerDetails } from "../../../classes/custom/Player";
import { PlayerDetailsContext } from "../../../contexts/PlayerDetailsContext";
import { PlayerScoresContext } from "../../../contexts/PlayerScoresContext";
import { POSITION } from "../../../utility/rosterFunctions";
Expand All @@ -19,7 +19,7 @@ interface MyProps {

const TeamPlayerStatGroup = (props: MyProps) => {
const [playerScoresContext, setPlayerInfoContext] = useContext(PlayerScoresContext) as [Map<string, PlayerScores>, any];
const [playerDetailsContext, setPlayerDetailsContext] = useContext(PlayerDetailsContext) as [Map<string, SleeperPlayerDetails>, any];
const [playerDetailsContext, setPlayerDetailsContext] = useContext(PlayerDetailsContext) as [Map<string, DatabasePlayer>, any];
if (props.league?.settings == undefined || playerScoresContext == null) return <div>Loading...</div>;
const member = props.league?.members.get(props.memberId);
let bestPlayer;
Expand All @@ -43,7 +43,7 @@ const TeamPlayerStatGroup = (props: MyProps) => {
<TeamPlayerStatCard
title={"MVP"}
player={bestPlayer}
playerDetails={playerDetailsContext?.get(bestPlayer?.id!)}
playerDetails={playerDetailsContext?.get(bestPlayer?.id!)?.details}
mainStat={`${bestPlayer?.points_scored.toFixed(2)} PF`}
subStat={`${bestPlayer?.avgPointsPerStart.toFixed(2)} Avg`}
isLoaded={true}
Expand All @@ -52,32 +52,36 @@ const TeamPlayerStatGroup = (props: MyProps) => {
<TeamPlayerStatCard
title={"LVP"}
player={lowestAvgScorer}
playerDetails={playerDetailsContext?.get(lowestAvgScorer?.id!)}
playerDetails={playerDetailsContext?.get(lowestAvgScorer?.id!)?.details}
mainStat={`${lowestAvgScorer?.avgPointsPerStart.toFixed(2)} Avg PF`}
subStat={`${lowestAvgScorer?.points_scored.toFixed(2)} PF`}
isLoaded={true}
isGoodThing={false}
/>
<TeamPlayerStatCard
title={"Least Consistent"}
player={leastConsistent}
playerDetails={playerDetailsContext?.get(leastConsistent?.id!)}
playerDetails={playerDetailsContext?.get(leastConsistent?.id!)?.details}
mainStat={`${leastConsistent?.stdDev.toFixed(2)} Std Dev`}
subStat={`${leastConsistent?.avgPointsPerStart.toFixed(2)} Avg PPG`}
isLoaded={true}
isGoodThing={true}
/>

<TeamPlayerStatCard
title={"Most Consistent"}
player={mostConsistent}
playerDetails={playerDetailsContext?.get(mostConsistent?.id!)}
playerDetails={playerDetailsContext?.get(mostConsistent?.id!)?.details}
mainStat={`${mostConsistent?.stdDev.toFixed(2)} Std Dev`}
subStat={`${mostConsistent?.avgPointsPerStart.toFixed(2)} Avg PPG`}
isLoaded={true}
isGoodThing={true}
/>
<TeamPlayerStatCard
title={"Most Predictable"}
player={leastPredictionError}
playerDetails={playerDetailsContext?.get(leastPredictionError?.id!)}
playerDetails={playerDetailsContext?.get(leastPredictionError?.id!)?.details}
subStat={`${leastPredictionError?.avgPointsPerStart.toFixed(2)} Avg`}
mainStat={`${leastPredictionError?.rootMeanSquareError.toFixed(
2
)} RSME`}
Expand All @@ -87,7 +91,8 @@ const TeamPlayerStatGroup = (props: MyProps) => {
<TeamPlayerStatCard
title={"Least Predictable"}
player={mostPredictionError}
playerDetails={playerDetailsContext?.get(mostPredictionError?.id!)}
playerDetails={playerDetailsContext?.get(mostPredictionError?.id!)?.details}
subStat={`${mostPredictionError?.avgPointsPerStart.toFixed(2)} Avg`}
mainStat={`${mostPredictionError?.rootMeanSquareError.toFixed(
2
)} RSME`}
Expand Down

0 comments on commit 2ea51cb

Please sign in to comment.