diff --git a/frontend/src/containers/Profile/PvpBrackets.tsx b/frontend/src/containers/Profile/PvpBrackets.tsx index 06bfa602..db03e605 100644 --- a/frontend/src/containers/Profile/PvpBrackets.tsx +++ b/frontend/src/containers/Profile/PvpBrackets.tsx @@ -1,58 +1,55 @@ -import { useMemo } from 'react'; +import {useMemo} from 'react'; import dayjs from 'dayjs-ext'; -import { Chip, LinearProgress, Tooltip } from '@mui/material'; +import {Chip, LinearProgress, Tooltip} from '@mui/material'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; -import { getSpecIcon, getWonAndLossColors, bracketToColor, getSeasonRankImageFromRating } from '@/utils/table'; -import { CLASS_AND_SPECS } from '@/constants/filterSchema'; -import type { IPlayerBracket, IPlayer } from '@/types'; +import {getSpecIcon, getWonAndLossColors, bracketToColor, getSeasonRankImageFromRating} from '@/utils/table'; +import {CLASS_AND_SPECS} from '@/constants/filterSchema'; +import type {IPlayerBracket, IPlayer} from '@/types'; interface IProps { player: IPlayer; } const arenaAndRbg = [ - { name: 'ARENA_2v2', title: '2v2' }, - { name: 'ARENA_3v3', title: '3v3' }, - { name: 'BATTLEGROUNDS', title: 'RBG' }, + {name: 'ARENA_2v2', title: '2v2'}, + {name: 'ARENA_3v3', title: '3v3'}, + {name: 'BATTLEGROUNDS', title: 'RBG'}, ]; const PvpBracket = ({ - title, - bracket, - isShuffle, - playerClass, - hasFourSpecs, -}: { + title, + bracket, + isZolo, + zoloName, + playerClass, + hasFourSpecs, + }: { title?: string; bracket?: IPlayerBracket; - isShuffle?: boolean; + isZolo?: boolean; + zoloName?: string playerClass?: string; hasFourSpecs: boolean; }) => { const specIcon = useMemo(() => { - if (!isShuffle || !title) return; - + if (!isZolo || !title) return; return getSpecIcon(`${title} ${playerClass}` || ''); - }, [title, isShuffle, playerClass]); - + }, [title, isZolo, playerClass]); const ratingColor = useMemo(() => { if (!bracket) return '#ffffff'; return bracketToColor(bracket); }, [bracket]); - const stats = useMemo(() => { const won = bracket?.won || 0; const lost = bracket?.lost || 0; const rating = bracket?.rating || 0; const is_rank_one_range = bracket?.is_rank_one_range || false; - - const { wonColor, lossColor } = getWonAndLossColors(won, lost); + const {wonColor, lossColor} = getWonAndLossColors(won, lost); const showWinRate = won > 0 || lost > 0; const winRate = ((won * 100) / (won + lost)).toFixed(2); const winRateColor = parseInt(winRate, 10) >= 50 ? "green" : "#ff0531"; - - return { rating, is_rank_one_range, showWinRate, winRateColor, wonColor, lossColor, winRate }; + return {rating, is_rank_one_range, showWinRate, winRateColor, wonColor, lossColor, winRate}; }, [bracket]); const ratingImg = ( -
+
{specIcon ? ( - {title} +
+ {zoloName} + {title} +
) : ( {title} )} -
{bracket?.season_max_rating && bracket.season_max_rating !== -1 && @@ -92,7 +92,7 @@ const PvpBracket = ({ Season {bracket.season_max_rating} - +
@@ -108,7 +108,7 @@ const PvpBracket = ({ Record {bracket.max_rating} - +
@@ -120,14 +120,14 @@ const PvpBracket = ({ {/* {ratingImg} */} {ratingImg} {stats.rating} {bracket?.rank && bracket.rank !== -1 ? (
- +
) : null}
@@ -143,7 +143,7 @@ const PvpBracket = ({
{stats.showWinRate ? `${stats.winRate}%` : '-'} @@ -153,8 +153,8 @@ const PvpBracket = ({ variant="determinate" value={parseInt(stats.winRate, 10)} sx={{ - '& .MuiLinearProgress-bar': { backgroundColor: '#008000' }, - '&.MuiLinearProgress-root': { backgroundColor: '#ff0000' }, + '& .MuiLinearProgress-bar': {backgroundColor: '#008000'}, + '&.MuiLinearProgress-root': {backgroundColor: '#ff0000'}, }} />
@@ -162,45 +162,63 @@ const PvpBracket = ({ ); }; -const PvpBrackets = ({ player }: IProps) => { +const PvpBrackets = ({player}: IProps) => { // @ts-ignore const classAndSpec = CLASS_AND_SPECS[player.class] as string[]; const hasFourSpecs = classAndSpec.length === 4; - const shuffleBrackets = classAndSpec .map((spec) => { - const bracket = player?.brackets?.find(({ bracket_type }) => bracket_type.includes(spec)); + const bracket = player?.brackets?.find(({bracket_type}) => bracket_type.includes(spec) && bracket_type.includes("SHUFFLE")) const noRender = player.class === 'Druid' && spec === 'Guardian' && !bracket; - - return { bracket, spec, noRender }; + return {bracket, spec, noRender}; + }) + .sort((a, b) => (b.bracket?.rating ?? 0) - (a.bracket?.rating ?? 0)); + const blitzBrackets = classAndSpec + .map((spec) => { + const bracket = player?.brackets?.find(({bracket_type}) => bracket_type.includes(spec) && bracket_type.includes("BLITZ")) + const noRender = player.class === 'Druid' && spec === 'Guardian' && !bracket; + return {bracket, spec, noRender}; }) .sort((a, b) => (b.bracket?.rating ?? 0) - (a.bracket?.rating ?? 0)); - const hasDruidTank = player.class === 'Druid' && !!(player?.brackets || []).find((b) => b.bracket_type.includes('Guardian')); - return (
- {arenaAndRbg.map(({ title, name }) => { + {arenaAndRbg.map(({title, name}) => { const playerBracket = (player?.brackets || []).find((b) => b.bracket_type === name); return ( - + ); })}
-
- {shuffleBrackets.map(({ bracket, spec, noRender }) => { + {shuffleBrackets.map(({bracket, spec, noRender}) => { + if (noRender) return null; + return ( + + ); + })} +
+
+ {blitzBrackets.map(({bracket, spec, noRender}) => { if (noRender) return null; - return (