diff --git a/components/u/Badges.tsx b/components/u/Badges.tsx index 55dcb4639..bce149f47 100644 --- a/components/u/Badges.tsx +++ b/components/u/Badges.tsx @@ -1,15 +1,17 @@ import { Button } from "@chakra-ui/button"; import { Image } from "@chakra-ui/image"; import { Divider, Flex, Text } from "@chakra-ui/layout"; -import { useState } from "react"; -import { wonITZCount } from "utils/constants"; +import { Fragment, useState } from "react"; +import { wonITZCount, wonTournamentCount } from "utils/constants"; const Badges = ({ userId, + userDiscordId, patreonTier, peakXP = -1, }: { userId: number; + userDiscordId: string; patreonTier: number | null; peakXP?: number; }) => { @@ -97,6 +99,21 @@ const Badges = ({ }); } + // Triton-Cup + + if ( + wonTournamentCount({ tournament: "TRITON", discordId: userDiscordId }) > 0 + ) { + badges.push({ + src: "triton.gif", + description: "Awarded for winning Triton-Cup", + count: wonTournamentCount({ + tournament: "TRITON", + discordId: userDiscordId, + }), + }); + } + if (badges.length === 0) return null; return ( @@ -116,12 +133,12 @@ const Badges = ({ {badges.flatMap((badge) => { if (showInfo) return ( - <> - + + {" "} {badge.description} - + ); return new Array(badge.count).fill(null).map((_, i) => { return ( diff --git a/pages/u/[identifier].tsx b/pages/u/[identifier].tsx index c0abfb6c6..7ffce9368 100644 --- a/pages/u/[identifier].tsx +++ b/pages/u/[identifier].tsx @@ -110,6 +110,7 @@ const ProfilePage = (props: Props) => { /> { + let winnersString = ""; + switch (tournament) { + case "TRITON": + winnersString = TRITON_CUP_WINNERS; + break; + default: + console.error(`Invalid tournament: ${tournament}`); + } + + return winnersString + .split(",") + .reduce( + (count, winnersId) => (winnersId === discordId ? count + 1 : count), + 0 + ); +};