mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 23:58:36 -05:00
Don't show Register button after tournament start
This commit is contained in:
@@ -2,6 +2,7 @@ import { Link, useLoaderData, useLocation } from "remix";
|
||||
import { DiscordIcon } from "~/components/icons/Discord";
|
||||
import { TwitterIcon } from "~/components/icons/Twitter";
|
||||
import { resolveTournamentFormatString } from "~/core/tournament/bracket";
|
||||
import { tournamentHasStarted } from "~/core/tournament/utils";
|
||||
import { FindTournamentByNameForUrlI } from "~/services/tournament";
|
||||
import { getLogInUrl } from "~/utils";
|
||||
import { useUser } from "~/utils/hooks";
|
||||
@@ -109,6 +110,31 @@ function InfoBannerActionButton() {
|
||||
const user = useUser();
|
||||
const location = useLocation();
|
||||
|
||||
const isAlreadyInATeamButNotCaptain = data.teams
|
||||
.flatMap((team) => team.members)
|
||||
.filter(({ captain }) => !captain)
|
||||
.some(({ member }) => member.id === user?.id);
|
||||
if (isAlreadyInATeamButNotCaptain) return null;
|
||||
|
||||
const alreadyRegistered = data.teams
|
||||
.flatMap((team) => team.members)
|
||||
.some(({ member }) => member.id === user?.id);
|
||||
if (alreadyRegistered) {
|
||||
return (
|
||||
<Link
|
||||
to="manage-roster"
|
||||
className="info-banner__action-button"
|
||||
prefetch="intent"
|
||||
>
|
||||
Manage roster
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
if (tournamentHasStarted(data.brackets)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
return (
|
||||
<form action={getLogInUrl(location)} method="post">
|
||||
@@ -122,27 +148,6 @@ function InfoBannerActionButton() {
|
||||
);
|
||||
}
|
||||
|
||||
const isAlreadyInATeamButNotCaptain = data.teams
|
||||
.flatMap((team) => team.members)
|
||||
.filter(({ captain }) => !captain)
|
||||
.some(({ member }) => member.id === user.id);
|
||||
if (isAlreadyInATeamButNotCaptain) return null;
|
||||
|
||||
const alreadyRegistered = data.teams
|
||||
.flatMap((team) => team.members)
|
||||
.some(({ member }) => member.id === user.id);
|
||||
if (alreadyRegistered) {
|
||||
return (
|
||||
<Link
|
||||
to="manage-roster"
|
||||
className="info-banner__action-button"
|
||||
prefetch="intent"
|
||||
>
|
||||
Manage roster
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
to="register"
|
||||
|
||||
Reference in New Issue
Block a user