From 1438a49fa6fb33341e9f4cdaf328ed47ee4c6d49 Mon Sep 17 00:00:00 2001 From: Sendou Date: Sun, 20 Oct 2019 01:45:03 +0300 Subject: [PATCH] tournament cards --- react-ui/src/assets/imageImports.js | 6 +- react-ui/src/components/root/Routes.js | 6 ++ .../components/tournament/TournamentCard.js | 51 +++++++++++++++++ .../tournament/TournamentDetailsPage.js | 55 +++++++++++++++++++ .../queries/searchForTournamentById.js | 35 ++++++++++++ schemas/tournament.js | 1 + 6 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 react-ui/src/components/tournament/TournamentCard.js create mode 100644 react-ui/src/components/tournament/TournamentDetailsPage.js create mode 100644 react-ui/src/graphql/queries/searchForTournamentById.js diff --git a/react-ui/src/assets/imageImports.js b/react-ui/src/assets/imageImports.js index 4fc972c88..975444db1 100644 --- a/react-ui/src/assets/imageImports.js +++ b/react-ui/src/assets/imageImports.js @@ -123,5 +123,9 @@ export const modeIcons = { "Splat Zones": szIcon, "Tower Control": tcIcon, Rainmaker: rmIcon, - "Clam Blitz": cbIcon + "Clam Blitz": cbIcon, + SZ: szIcon, + TC: tcIcon, + RM: rmIcon, + CB: cbIcon } diff --git a/react-ui/src/components/root/Routes.js b/react-ui/src/components/root/Routes.js index d6603237d..42f809703 100644 --- a/react-ui/src/components/root/Routes.js +++ b/react-ui/src/components/root/Routes.js @@ -10,6 +10,9 @@ const XLeaderboard = lazy(() => import("../xleaderboard/XLeaderboard")) const PlayerXRankStats = lazy(() => import("../xsearch/PlayerXRankStats")) const XTrends = lazy(() => import("../xtrends/XTrends")) const Links = lazy(() => import("../links/Links")) +const TournamentDetailsPage = lazy(() => + import("../tournament/TournamentDetailsPage") +) const Routes = () => { return ( @@ -39,6 +42,9 @@ const Routes = () => { + + + ) diff --git a/react-ui/src/components/tournament/TournamentCard.js b/react-ui/src/components/tournament/TournamentCard.js new file mode 100644 index 000000000..9de17d9fa --- /dev/null +++ b/react-ui/src/components/tournament/TournamentCard.js @@ -0,0 +1,51 @@ +import React from "react" +import { Card, Flag, Header } from "semantic-ui-react" +import { wpnSmall } from "../../assets/imageImports" +import weaponDict from "../../utils/english_internal.json" +import { months } from "../../utils/lists" + +const TournamentCard = ({ tournament, centered = false }) => { + const a = new Date(parseInt(tournament["date"])) + const dateStr = `${a.getDate()} ${months[a.getMonth()]} ${a.getFullYear()}` + return ( + + + + {tournament["name"]} + {tournament["jpn"] && } + + {dateStr} + {tournament.hasOwnProperty("bracket") && ( + + Bracket + + )} + + + 🏆 + {" "} + {tournament["winning_team_name"]} + + + {" "} + {/*TODO: add link to profile if unique id*/} + {tournament["winning_team_players"].map(player => { + return {player} + })} + + + + +
+ Popular weapons +
+
+ {tournament["popular_weapons"].map(weapon => ( + {weapon} + ))} +
+
+ ) +} + +export default TournamentCard diff --git a/react-ui/src/components/tournament/TournamentDetailsPage.js b/react-ui/src/components/tournament/TournamentDetailsPage.js new file mode 100644 index 000000000..22ae4ce09 --- /dev/null +++ b/react-ui/src/components/tournament/TournamentDetailsPage.js @@ -0,0 +1,55 @@ +import React from "react" +import Loading from "../common/Loading" +import Error from "../common/Error" +import { useQuery } from "@apollo/react-hooks" +import { Redirect, useParams } from "react-router-dom" +import { searchForTournamentById } from "../../graphql/queries/searchForTournamentById" +import TournamentCard from "./TournamentCard" +import { Divider, Header, Card, Image } from "semantic-ui-react" + +import { modeIcons, mapIcons } from "../../assets/imageImports" + +const TournamentDetailsPage = () => { + const { id } = useParams() + const { data, error, loading } = useQuery(searchForTournamentById, { + variables: { id } + }) + + if (loading) return + if (error) return + console.log("data", data) + return ( + <> + + {data["searchForTournamentById"]["rounds"].map(round => { + return ( + + {round["game_number"] === 1 && ( + +
{round.round_name}
+
+ )} + + + + + + {round.game_number} + + {modeIcons[round.mode]} + {round.stage} + + + +
+ ) + })} + + ) +} + +export default TournamentDetailsPage diff --git a/react-ui/src/graphql/queries/searchForTournamentById.js b/react-ui/src/graphql/queries/searchForTournamentById.js new file mode 100644 index 000000000..8a411e3ba --- /dev/null +++ b/react-ui/src/graphql/queries/searchForTournamentById.js @@ -0,0 +1,35 @@ +import { gql } from "apollo-boost" + +export const searchForTournamentById = gql` + query searchForTournamentById($id: String!) { + searchForTournamentById(id: $id) { + name + jpn + google_sheet_url + date + popular_weapons + winning_team_name + winning_team_players + winning_team_unique_ids + rounds { + stage + mode + round_name + round_number + game_number + winning_team_name + winning_team_players + winning_team_unique_ids + winning_team_weapons + winning_team_main_abilities + winning_team_sub_abilities + losing_team_name + losing_team_players + losing_team_unique_ids + losing_team_weapons + losing_team_main_abilities + losing_team_sub_abilities + } + } + } +` diff --git a/schemas/tournament.js b/schemas/tournament.js index ad6268d09..198b12de4 100644 --- a/schemas/tournament.js +++ b/schemas/tournament.js @@ -8,6 +8,7 @@ const typeDef = gql` } type Tournament { name: String! + bracket_url: String "True if the tournament was a Japanese one" jpn: Boolean! "Link to the Google Sheet containing ganbawoomy's data"