Skip to content

Commit

Permalink
releasef profile update for blitz
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Nov 17, 2024
1 parent 691ff8d commit 33686d3
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 175 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/AltsTable/SortableHeaderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const HeaderCell = ({ column, onSort, sort, sortable }: IProps) => {
sort.field === field && sort.sort === "desc" ? "asc" : "desc"
)
}
className="group gap-2 flex items-center justify-center cursor-pointer text-base"
className="group gap-2 flex items-center cursor-pointer text-base"
>
{label}
{sortable && renderOrderArrow(field)}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/containers/MClassLeaderboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function MClassLeaderboard() {
React.useEffect(() => {
getLeaderboard(region as REGION, role, page);
}, [region, role, page]);
console.log("rowsToShow", rowsToShow);
let pagination = (
<Pagination
boundaryCount={2}
Expand Down
54 changes: 34 additions & 20 deletions frontend/src/containers/Profile/Alts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { CLASS_AND_SPECS } from "@/constants/filterSchema";
import type { Alt, Bracket, TableColumn } from "@/types";
import { MINIMUM_NICKNAME_LENGTH, nickNameLenOnMobile } from "@/utils/common";

interface IParams {
interface Params {
record: Alt;
soloBracket: string;
}

const renderName = ({ record: alt }: IParams, isMobile: boolean) => {
const renderName = ({ record: alt }: Params, isMobile: boolean) => {
const realm = alt.realm;
const url = getAltProfileUrl(alt);
let name = alt.name;
Expand Down Expand Up @@ -54,7 +55,7 @@ const bracketTypeTitleMap = {
};

const renderBracket = (
{ record: alt }: IParams,
{ record: alt }: Params,
bracketName: keyof typeof bracketTypeTitleMap
) => {
const bracket = alt?.brackets?.find(
Expand Down Expand Up @@ -85,27 +86,34 @@ const renderBracket = (
);
};

const renderShuffle = ({ record: alt }: IParams, isMobile: boolean) => {
const renderSoloBracket = (
soloBracket: string,
{ record: alt }: Params,
isMobile: boolean
) => {
// @ts-ignore
const classAndSpec = CLASS_AND_SPECS[alt.class] as string[];

const sortedSpec = [...classAndSpec]
.sort((a, b) => {
const ratingA =
alt?.brackets?.find((bracket) => bracket.bracket_type.includes(a))
?.rating || 0;
alt?.brackets?.find(
(bracket) =>
bracket.bracket_type.includes(a) &&
bracket.bracket_type.includes(soloBracket)
)?.rating || 0;
const ratingB =
alt?.brackets?.find((bracket) => bracket.bracket_type.includes(b))
?.rating || 0;
alt?.brackets?.find(
(bracket) =>
bracket.bracket_type.includes(b) &&
bracket.bracket_type.includes(soloBracket)
)?.rating || 0;
return ratingA > ratingB ? -1 : 1;
})
.slice(0, 3);

.slice(0, 2);
if (isMobile) {
let max = 0;
let spec = sortedSpec[0];
let bracket: Bracket | null = null;

sortedSpec.forEach((spec) => {
const altBracket = alt?.brackets?.find((b) =>
b.bracket_type.includes(spec)
Expand All @@ -116,7 +124,6 @@ const renderShuffle = ({ record: alt }: IParams, isMobile: boolean) => {
}
});
if (!bracket) return <></>;

const specIcon = getSpecIcon(`${spec} ${alt.class}` || "");
const ratingColor = bracketToColor(bracket);
return (
Expand All @@ -131,8 +138,10 @@ const renderShuffle = ({ record: alt }: IParams, isMobile: boolean) => {
return (
<div className="flex md:gap-2">
{sortedSpec.map((spec) => {
const altBracket = alt?.brackets?.find((b) =>
b.bracket_type.includes(spec)
const altBracket = alt?.brackets?.find(
(b) =>
b.bracket_type.includes(spec) &&
b.bracket_type.includes(soloBracket)
);
if (!altBracket?.rating) return <></>;

Expand All @@ -155,26 +164,31 @@ export const tableColumns = (isMobile: boolean): TableColumn[] => [
{
field: "name",
label: "Name",
render: (params: IParams) => renderName(params, isMobile),
render: (params: Params) => renderName(params, isMobile),
},
{
field: "SHUFFLE",
label: "Shuffle",
render: (params: IParams) => renderShuffle(params, isMobile),
render: (params: Params) => renderSoloBracket("SHUFFLE", params, isMobile),
},
{
field: "BLITZ",
label: "Blitz",
render: (params: Params) => renderSoloBracket("BLITZ", params, isMobile),
},
{
field: "ARENA_2v2",
label: "2v2",
render: (params: IParams) => renderBracket(params, "2v2"),
render: (params: Params) => renderBracket(params, "2v2"),
},
{
field: "ARENA_3v3",
label: "3v3",
render: (params: IParams) => renderBracket(params, "3v3"),
render: (params: Params) => renderBracket(params, "3v3"),
},
{
field: "BATTLEGROUNDS",
label: "RBG",
render: (params: IParams) => renderBracket(params, "rbg"),
render: (params: Params) => renderBracket(params, "rbg"),
},
];
15 changes: 12 additions & 3 deletions frontend/src/containers/Profile/Alts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import { tableColumns } from "./columns";
import type { Player } from "@/types";
import { FormControlLabel, Switch } from "@mui/material";

type TPvpBracket = "SHUFFLE" | "ARENA_2v2" | "ARENA_3v3" | "BATTLEGROUNDS";
type TPvpBracket =
| "BLITZ"
| "SHUFFLE"
| "ARENA_2v2"
| "ARENA_3v3"
| "BATTLEGROUNDS";
const bracketsList: TPvpBracket[] = [
"SHUFFLE",
"BLITZ",
"ARENA_2v2",
"ARENA_3v3",
"BATTLEGROUNDS",
Expand All @@ -30,12 +36,15 @@ const Alts = ({ player }: { player: Player }) => {
const altCopy = structuredClone(alt);
altCopy.brackets?.forEach((bracket) => {
const isShuffle = bracket.bracket_type.startsWith("SHUFFLE");
if (isShuffle)
const isBlitz = bracket.bracket_type.startsWith("BLITZ");
if (isShuffle) {
altCopy["SHUFFLE"] = Math.max(
altCopy["SHUFFLE"] || 0,
bracket.rating
);
else altCopy[bracket.bracket_type as TPvpBracket] = bracket.rating;
} else if (isBlitz) {
altCopy["BLITZ"] = Math.max(altCopy["BLITZ"] || 0, bracket.rating);
} else altCopy[bracket.bracket_type as TPvpBracket] = bracket.rating;
});
bracketsList.forEach((bracket) => {
if (!altCopy[bracket]) altCopy[bracket] = 0;
Expand Down
Loading

0 comments on commit 33686d3

Please sign in to comment.