diff --git a/app/components/AddPlayers.tsx b/app/components/AddPlayers.tsx new file mode 100644 index 000000000..4e4abb059 --- /dev/null +++ b/app/components/AddPlayers.tsx @@ -0,0 +1,98 @@ +import { Form, useLocation } from "remix"; +import { useBaseURL, useTimeoutState } from "~/hooks/common"; +import { FindManyByTrustReceiverId } from "~/models/TrustRelationship.server"; +import { FormErrorMessage } from "./FormErrorMessage"; +import { Label } from "./Label"; +import { SubmitButton } from "./SubmitButton"; + +export function AddPlayers({ + inviteCode, + addUserError, + trustingUsers, + hiddenInputs, +}: { + inviteCode: string; + addUserError?: string; + trustingUsers: FindManyByTrustReceiverId; + hiddenInputs: { name: string; value: string }[]; +}) { + const baseURL = useBaseURL(); + const location = useLocation(); + const urlWithInviteCode = `${baseURL}${location.pathname.replace( + "manage-team", + "join-team" + )}?code=${inviteCode}`; + + return ( +
+ Add players to your team +
+ + + +
+ {trustingUsers.length > 0 && ( +
+
+ {hiddenInputs.map((input) => ( + + ))} + + + + + Add to roster + + +
+ )} +
+ ); +} + +function CopyToClipboardButton({ + urlWithInviteCode, +}: { + urlWithInviteCode: string; +}) { + const [showCopied, setShowCopied] = useTimeoutState(false); + + return ( + + ); +} diff --git a/app/routes/play/index.tsx b/app/routes/play/index.tsx index c9a72c108..68bb97222 100644 --- a/app/routes/play/index.tsx +++ b/app/routes/play/index.tsx @@ -16,6 +16,7 @@ export const links: LinksFunction = () => { return [{ rel: "stylesheet", href: styles }]; }; +// TODO: Switch to layout component export const meta: MetaFunction = () => { return { title: makeTitle("Play!"), diff --git a/app/routes/to/$organization.$tournament/manage-team.tsx b/app/routes/to/$organization.$tournament/manage-team.tsx index 2ea386bbb..19f3e5985 100644 --- a/app/routes/to/$organization.$tournament/manage-team.tsx +++ b/app/routes/to/$organization.$tournament/manage-team.tsx @@ -8,12 +8,11 @@ import { redirect, useActionData, useLoaderData, - useLocation, } from "remix"; import { z } from "zod"; +import { AddPlayers } from "~/components/AddPlayers"; import { Alert } from "~/components/Alert"; import { Catcher } from "~/components/Catcher"; -import { FormErrorMessage } from "~/components/FormErrorMessage"; import { FormInfoText } from "~/components/FormInfoText"; import { Label } from "~/components/Label"; import { SubmitButton } from "~/components/SubmitButton"; @@ -26,19 +25,18 @@ import { roompassRegExpString, tournamentURL, } from "~/core/tournament/utils"; -import { useBaseURL, useTimeoutState } from "~/hooks/common"; -import * as Tournament from "~/models/Tournament.server"; -import * as TournamentTeam from "~/models/TournamentTeam.server"; -import * as TournamentTeamMember from "~/models/TournamentTeamMember.server"; -import * as User from "~/models/User.server"; -import type { FindManyByTrustReceiverId } from "~/models/TrustRelationship.server"; -import styles from "~/styles/tournament-manage-team.css"; -import { parseRequestFormData, requireUser, validate } from "~/utils"; import { isCaptainOfTheTeam, teamHasNotCheckedIn, tournamentTeamIsNotFull, } from "~/core/tournament/validators"; +import * as Tournament from "~/models/Tournament.server"; +import * as TournamentTeam from "~/models/TournamentTeam.server"; +import * as TournamentTeamMember from "~/models/TournamentTeamMember.server"; +import type { FindManyByTrustReceiverId } from "~/models/TrustRelationship.server"; +import * as User from "~/models/User.server"; +import styles from "~/styles/tournament-manage-team.css"; +import { parseRequestFormData, requireUser, validate } from "~/utils"; export const links: LinksFunction = () => { return [{ rel: "stylesheet", href: styles }]; @@ -205,13 +203,6 @@ export const loader: LoaderFunction = async ({ params, context }) => { export default function ManageTeamPage() { const actionData = useActionData(); const { ownTeam, trustingUsers } = useLoaderData(); - const baseURL = useBaseURL(); - const location = useLocation(); - - const urlWithInviteCode = `${baseURL}${location.pathname.replace( - "manage-team", - "join-team" - )}?code=${ownTeam.inviteCode}`; return (
@@ -301,78 +292,19 @@ export default function ManageTeamPage() { {ownTeam.members.length < TOURNAMENT_TEAM_ROSTER_MAX_SIZE && ( -
- Add players to your team -
- - - -
- {trustingUsers.length > 0 && ( -
-
- - - - - - - Add to roster - - -
- )} -
+ )}
); } -function CopyToClipboardButton({ - urlWithInviteCode, -}: { - urlWithInviteCode: string; -}) { - const [showCopied, setShowCopied] = useTimeoutState(false); - - return ( - - ); -} - // TODO: handle 404 (logged in but not registered) export const CatchBoundary = Catcher; diff --git a/app/styles/global.css b/app/styles/global.css index 45a0a14f1..adba29539 100644 --- a/app/styles/global.css +++ b/app/styles/global.css @@ -397,6 +397,34 @@ select::selection { padding-inline: var(--s-2); } +.add-players__actions { + display: flex; + width: 100%; + flex-wrap: wrap; + justify-content: center; + column-gap: var(--s-14); + row-gap: var(--s-8); +} + +.add-players__actions__section { + display: flex; + width: 18rem; + flex-direction: column; + align-items: flex-start; +} + +.add-players__input { + width: min(100%, 20rem); +} + +.add-players__input__button { + margin-block-start: var(--s-4); +} + +.add-players__select { + width: min(100%, 10rem); +} + /* Utility classes */ .mt-2 { diff --git a/app/styles/tournament-manage-team.css b/app/styles/tournament-manage-team.css index 72332caf8..7d1064492 100644 --- a/app/styles/tournament-manage-team.css +++ b/app/styles/tournament-manage-team.css @@ -9,30 +9,6 @@ margin: 0 auto; } -.tournament__manage-team__actions { - display: flex; - width: 100%; - flex-wrap: wrap; - justify-content: center; - column-gap: var(--s-14); - row-gap: var(--s-8); -} - -.tournament__manage-team__actions__section { - display: flex; - width: 18rem; - flex-direction: column; - align-items: flex-start; -} - -.tournament__manage-team__input { - width: min(100%, 20rem); -} - -.tournament__manage-team__select { - width: min(100%, 10rem); -} - .tournament__manage-team__radio-with-label { display: flex; align-items: center; @@ -43,7 +19,3 @@ margin-block-end: 0; margin-inline-start: var(--s-2); } - -.tournament__manage-team__input__button { - margin-block-start: var(--s-4); -}