mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-25 07:32:19 -05:00
.server. models to keep them out of browser bundle
This commit is contained in:
parent
fcce761c12
commit
6162528eea
|
|
@ -8,10 +8,7 @@ import {
|
|||
import { z } from "zod";
|
||||
import Modal from "~/components/Modal";
|
||||
import { TeamRosterInputs } from "~/components/tournament/TeamRosterInputs";
|
||||
import {
|
||||
FindMatchModalInfoByNumber,
|
||||
findMatchModalInfoByNumber,
|
||||
} from "~/db/tournament/queries/findMatchModalInfoByNumber";
|
||||
import * as TournamentMatch from "~/models/TournamentMatch.server";
|
||||
import { Unpacked } from "~/utils";
|
||||
import styles from "~/styles/tournament-match.css";
|
||||
import { FancyStageBanner } from "~/components/tournament/FancyStageBanner";
|
||||
|
|
@ -20,21 +17,25 @@ export const links: LinksFunction = () => {
|
|||
return [{ rel: "stylesheet", href: styles }];
|
||||
};
|
||||
|
||||
const typedJson = (args: NonNullable<FindMatchModalInfoByNumber>) => json(args);
|
||||
const typedJson = (args: NonNullable<TournamentMatch.FindInfoForModal>) =>
|
||||
json(args);
|
||||
|
||||
export const loader: LoaderFunction = async ({ params }) => {
|
||||
const { bid: bracketId, num: matchNumber } = z
|
||||
.object({ bid: z.string(), num: z.preprocess(Number, z.number()) })
|
||||
.parse(params);
|
||||
|
||||
const match = await findMatchModalInfoByNumber({ bracketId, matchNumber });
|
||||
const match = await TournamentMatch.findInfoForModal({
|
||||
bracketId,
|
||||
matchNumber,
|
||||
});
|
||||
if (!match) throw new Response("No match found", { status: 404 });
|
||||
|
||||
return typedJson(match);
|
||||
};
|
||||
|
||||
export default function MatchModal() {
|
||||
const data = useLoaderData<NonNullable<FindMatchModalInfoByNumber>>();
|
||||
const data = useLoaderData<NonNullable<TournamentMatch.FindInfoForModal>>();
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
|
|
@ -78,7 +79,9 @@ export default function MatchModal() {
|
|||
}
|
||||
|
||||
function matchInfoToCheckedPlayers(
|
||||
matchInfo: Unpacked<NonNullable<FindMatchModalInfoByNumber>["matchInfos"]>
|
||||
matchInfo: Unpacked<
|
||||
NonNullable<TournamentMatch.FindInfoForModal>["matchInfos"]
|
||||
>
|
||||
): [string[], string[]] {
|
||||
return [
|
||||
matchInfo.teamUpper.members
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ import {
|
|||
roompassRegExpString,
|
||||
} from "~/core/tournament/utils";
|
||||
import { useBaseURL, useTimeoutState } from "~/hooks/common";
|
||||
import * as TournamentTeam from "~/models/TournamentTeam";
|
||||
import * as TournamentTeamMember from "~/models/TournamentTeamMember";
|
||||
import type { FindManyByTrustReceiverId } from "~/models/TrustRelationship";
|
||||
import * as TournamentTeam from "~/models/TournamentTeam.server";
|
||||
import * as TournamentTeamMember from "~/models/TournamentTeamMember.server";
|
||||
import type { FindManyByTrustReceiverId } from "~/models/TrustRelationship.server";
|
||||
import {
|
||||
editTeam,
|
||||
ownTeamWithInviteCode,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import {
|
|||
validate,
|
||||
} from "~/utils";
|
||||
import { useTimeoutState } from "~/hooks/common";
|
||||
import * as Tournament from "~/models/Tournament";
|
||||
import * as Tournament from "~/models/Tournament.server";
|
||||
import {
|
||||
isTournamentAdmin,
|
||||
tournamentHasNotStarted,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import {
|
|||
} from "~/core/tournament/bracket";
|
||||
import { canReportMatchScore } from "~/core/tournament/permissions";
|
||||
import { matchIsOver } from "~/core/tournament/utils";
|
||||
import * as TournamentBracket from "~/models/TournamentBracket";
|
||||
import * as TournamentMatch from "~/models/TournamentMatch";
|
||||
import * as TournamentBracket from "~/models/TournamentBracket.server";
|
||||
import * as TournamentMatch from "~/models/TournamentMatch.server";
|
||||
import { Unpacked } from "~/utils";
|
||||
import { db } from "~/utils/db.server";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import {
|
|||
} from "~/constants";
|
||||
import { MapListIds, tournamentRoundsForDB } from "~/core/tournament/bracket";
|
||||
import { captainOfTeam, sortTeamsBySeed } from "~/core/tournament/utils";
|
||||
import * as Tournament from "~/models/Tournament";
|
||||
import * as TournamentTeam from "~/models/TournamentTeam";
|
||||
import * as TournamentTeamMember from "~/models/TournamentTeamMember";
|
||||
import * as TrustRelationship from "~/models/TrustRelationship";
|
||||
import * as Tournament from "~/models/Tournament.server";
|
||||
import * as TournamentTeam from "~/models/TournamentTeam.server";
|
||||
import * as TournamentTeamMember from "~/models/TournamentTeamMember.server";
|
||||
import * as TrustRelationship from "~/models/TrustRelationship.server";
|
||||
import { Serialized, Unpacked } from "~/utils";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { isTournamentAdmin } from "~/validators/tournament";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import * as TrustRelationship from "~/models/TrustRelationship";
|
||||
import * as TrustRelationship from "~/models/TrustRelationship.server";
|
||||
|
||||
export const getTrustingUsers = TrustRelationship.findManyByTrustReceiverId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user