From a24afa2af8105537540888f6185a4812ada768bc Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Mon, 6 Dec 2021 14:48:50 +0200 Subject: [PATCH] ActionSection initial --- README.md | 2 + app/components/tournament/ActionSection.tsx | 71 +++++++++++++++++++ app/components/tournament/InfoBanner.tsx | 13 +--- app/routes/to/$organization.$tournament.tsx | 16 ++++- .../manage-roster.tsx | 12 +--- app/styles/tournament-manage-roster.css | 1 - app/styles/tournament.css | 43 +++++++++-- 7 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 app/components/tournament/ActionSection.tsx diff --git a/README.md b/README.md index 3da3e89af..8fc945399 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Prerequisites: [Node.js 16.13](https://nodejs.org/en/) - [x] Captain can remove players from roster - [ ] Add info about architecture to README +- [ ] Make description mandatory + overview tab - [ ] Captain can check in - [ ] Admin can check teams in (and out) - [ ] Admin can drop people out (show on bracket somehow that they dropped) @@ -49,6 +50,7 @@ Prerequisites: [Node.js 16.13](https://nodejs.org/en/) - [ ] Detailed match reports from Lanista - [ ] Stats - [ ] Routine to calculate Trueskill +- [ ] Markdown support for tournament description - [ ] Can make a new tournament as org admin - [ ] Rules tab with a good default, highlight overrides - [ ] Friend code to add that is easily editable even before tournament starts diff --git a/app/components/tournament/ActionSection.tsx b/app/components/tournament/ActionSection.tsx new file mode 100644 index 000000000..35afa4726 --- /dev/null +++ b/app/components/tournament/ActionSection.tsx @@ -0,0 +1,71 @@ +import type { FindTournamentByNameForUrlI } from "~/services/tournament"; +import { useUser } from "~/utils/hooks"; +import { AlertIcon } from "../icons/Alert"; + +export function ActionSection({ + tournament, +}: { + tournament: FindTournamentByNameForUrlI; +}) { + const user = useUser(); + + const ownTeam = tournament.teams.find((team) => + team.members.some( + ({ member, captain }) => captain && member.id === user?.id + ) + ); + + // TODO: or tournament is over + if (!ownTeam) { + return null; + } + + const checkInHasStarted = new Date(tournament.checkInTime) < new Date(); + const teamHasEnoughMembers = true; + // const teamHasEnoughMembers = + // ownTeam.members.length >= TOURNAMENT_TEAM_ROSTER_MIN_SIZE; + + if (!checkInHasStarted && !teamHasEnoughMembers) { + return ( + + You need at least 4 players in your roster to play + + ); + } + + const differenceInMinutesBetweenCheckInAndStart = Math.floor( + (new Date(tournament.startTime).getTime() - + new Date(tournament.checkInTime).getTime()) / + (1000 * 60) + ); + + if (!checkInHasStarted && teamHasEnoughMembers) { + return ( + + Check-in starts{" "} + {differenceInMinutesBetweenCheckInAndStart} minutes before the + tournament starts + + ); + } + + console.error("Unexpected combination in ActionSection component"); + return null; +} + +function Wrapper({ + children, + icon, +}: { + children: React.ReactNode; + icon: "warning" | "info"; +}) { + return ( +
+
{children}
+
+ ); +} diff --git a/app/components/tournament/InfoBanner.tsx b/app/components/tournament/InfoBanner.tsx index f7aaf789e..66d576d64 100644 --- a/app/components/tournament/InfoBanner.tsx +++ b/app/components/tournament/InfoBanner.tsx @@ -15,18 +15,7 @@ export function InfoBanner() { return ( <> -
- } - > +