From 85becef31248208263a855486103ce60f81c5ef7 Mon Sep 17 00:00:00 2001 From: Sendou Date: Fri, 3 Apr 2020 01:04:02 +0300 Subject: [PATCH] draft cup to sidebar --- .../src/components/plusdraftcup/DraftCupPage.tsx | 10 +++++++++- .../components/plusdraftcup/DraftLeaderboard.tsx | 5 ++++- .../src/components/root/SideNavContent.tsx | 2 ++ graphql-schemas/detailedtournament.js | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/frontend-react/src/components/plusdraftcup/DraftCupPage.tsx b/frontend-react/src/components/plusdraftcup/DraftCupPage.tsx index c3697e2da..1c63a2758 100644 --- a/frontend-react/src/components/plusdraftcup/DraftCupPage.tsx +++ b/frontend-react/src/components/plusdraftcup/DraftCupPage.tsx @@ -1,4 +1,4 @@ -import React from "react" +import React, { useContext } from "react" import { RouteComponentProps } from "@reach/router" import PageHeader from "../common/PageHeader" import { useQuery } from "@apollo/react-hooks" @@ -11,8 +11,11 @@ import Loading from "../common/Loading" import DraftLeaderboard from "./DraftLeaderboard" import { Helmet } from "react-helmet-async" import DraftTournamentCards from "./DraftTournamentCards" +import { Box } from "@chakra-ui/core" +import MyThemeContext from "../../themeContext" const DraftCupPage: React.FC = () => { + const { grayWithShade } = useContext(MyThemeContext) const { data, error, loading } = useQuery(PLUS_DRAFT_CUPS) if (error) return @@ -24,6 +27,11 @@ const DraftCupPage: React.FC = () => { Draft Cup Home | sendou.ink + + Draft Cup is a tournament series open for +1 and +2 members. On this + page you can browse the leaderboards and detailed match reports. + + diff --git a/frontend-react/src/components/plusdraftcup/DraftLeaderboard.tsx b/frontend-react/src/components/plusdraftcup/DraftLeaderboard.tsx index 1fe48df7e..c96fdbbc3 100644 --- a/frontend-react/src/components/plusdraftcup/DraftLeaderboard.tsx +++ b/frontend-react/src/components/plusdraftcup/DraftLeaderboard.tsx @@ -67,7 +67,10 @@ const DraftLeaderboard: React.FC = ({ > {players.map((player, i, array) => { print = false - if (i > 0 && player.score !== array[i - 1].score) { + if (i === 0) { + placement = 1 + print = true + } else if (i > 0 && player.score !== array[i - 1].score) { placement = i + 1 print = true } diff --git a/frontend-react/src/components/root/SideNavContent.tsx b/frontend-react/src/components/root/SideNavContent.tsx index ad3f22af9..c29e3ac7e 100644 --- a/frontend-react/src/components/root/SideNavContent.tsx +++ b/frontend-react/src/components/root/SideNavContent.tsx @@ -25,6 +25,7 @@ import { FaUserAlt, FaDoorOpen, FaListOl, + FaPeopleCarry, } from "react-icons/fa" import Logo from "./Logo" import NavItem from "./NavItem" @@ -148,6 +149,7 @@ export const SideNavContent: React.FC = ({ showLogo = true }) => { icon={FaTrophy} title="Tournament Results" /> + {/**/} {data?.user?.plus?.membership_status && ( diff --git a/graphql-schemas/detailedtournament.js b/graphql-schemas/detailedtournament.js index 6b11c1bb0..6b9f5bf57 100644 --- a/graphql-schemas/detailedtournament.js +++ b/graphql-schemas/detailedtournament.js @@ -6,6 +6,7 @@ const { const DetailedTournament = require("../mongoose-models/detailedtournament") const DetailedMatch = require("../mongoose-models/detailedmatch") const Leaderboard = require("../mongoose-models/leaderboard") +const User = require("../mongoose-models/user") const PlayerStat = require("../mongoose-models/playerstat") const { validateDetailedTournamentInput, @@ -364,8 +365,20 @@ const resolvers = { (a.first * 4 + a.second * 2 + a.third) ) + const users = await User.find({}) + + const filteredPlayers = players.filter(player => { + const found = users.find(user => user.discord_id === player.discord_id) + + return !!found + }) + const type = `DRAFT${args.plus_server}` - await Leaderboard.updateOne({ type }, { type, players }, { upsert: true }) + await Leaderboard.updateOne( + { type }, + { type, players: filteredPlayers }, + { upsert: true } + ) return true },