refactor: cut web results over to competition projections
This commit is contained in:
1 parent
7db97c540b
commit
6bddb666fc
13 files changed
+2153
-3885
No files matched your search
@@ -390,23 +390,15 @@ function formatCompactDateTime(dateLike: string) {
|
||||
function HistoryMetaText({
|
||||
map,
|
||||
participants,
|
||||
result,
|
||||
}: {
|
||||
map: string;
|
||||
participants: number;
|
||||
result?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={HISTORY_MOBILE_META_CLASS}>
|
||||
<span>{map}</span>
|
||||
<span className="text-base-content/20">·</span>
|
||||
<span>{participants}명</span>
|
||||
{result && (
|
||||
<>
|
||||
<span className="text-base-content/20">·</span>
|
||||
<span>{result}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -691,11 +683,12 @@ export default function HomePage() {
|
||||
{match.participants.length}명
|
||||
</td>
|
||||
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
||||
<span className="block truncate">
|
||||
{match.result?.winner
|
||||
? `${match.result.winner} 승리`
|
||||
: '-'}
|
||||
</span>
|
||||
<Link
|
||||
to={`/match/${match.id}`}
|
||||
className="font-semibold text-base-content/45 hover:text-primary"
|
||||
>
|
||||
공식 결과
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
@@ -717,10 +710,6 @@ export default function HomePage() {
|
||||
<div className="md:hidden border border-base-content/10">
|
||||
{historyMatches.length > 0 ? (
|
||||
historyMatches.map((match) => {
|
||||
const resultLabel = match.result?.winner
|
||||
? `${match.result.winner} 승리`
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={match.id}
|
||||
@@ -747,7 +736,6 @@ export default function HomePage() {
|
||||
<HistoryMetaText
|
||||
map={match.map}
|
||||
participants={match.participants.length}
|
||||
result={resultLabel}
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
+634
-2794
File diff suppressed because it is too large.
Load diff
@@ -1,625 +1,65 @@
|
||||
import { useState } from "react";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { AlertTriangle, ChevronDown, ChevronUp } from "lucide-react";
|
||||
import { Link, useLocation, useParams } from "react-router";
|
||||
import {
|
||||
useDdragonManifest,
|
||||
useMatch,
|
||||
useReplaceTournamentCode,
|
||||
useUserHistoryProfile,
|
||||
} from "../api/hooks";
|
||||
import { formatKoreanDate } from "../api/mappers";
|
||||
import { RankBadge } from "../components/RankBadge";
|
||||
import type {
|
||||
ApiMatch,
|
||||
ApiMatchGameResult,
|
||||
ApiMatchParticipant,
|
||||
ApiTierInfo,
|
||||
MatchGameMode,
|
||||
Position,
|
||||
TeamSide,
|
||||
TournamentCodeSlotView,
|
||||
} from "../api/types";
|
||||
import { Link, useParams } from "react-router";
|
||||
import { useCompetition, useTeamCompetition } from "../api/hooks";
|
||||
import { SeriesScoreCard } from "../components/competition/SeriesScoreCard";
|
||||
import { DEFAULT_COMMUNITY_ID } from "../config";
|
||||
import { profileIconUrl } from "../lib/ddragon";
|
||||
import { positionLabel, sideShortLabel, teamIndexLabel } from "../lib/league";
|
||||
|
||||
const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
|
||||
pair: "페어 매치",
|
||||
bracket: "토너먼트",
|
||||
"round-robin": "리그전",
|
||||
"double-elimination": "더블 엘리미네이션",
|
||||
};
|
||||
|
||||
function resultBadgeClass(won: boolean) {
|
||||
return won
|
||||
? "border-info/20 bg-info/10 text-info"
|
||||
: "border-error/20 bg-error/10 text-error";
|
||||
}
|
||||
|
||||
function captainName(
|
||||
team: ApiMatch["teams"][number] | undefined,
|
||||
participantByUserId: Map<string, ApiMatchParticipant>,
|
||||
) {
|
||||
if (!team?.captainUserId) return undefined;
|
||||
return participantByUserId.get(team.captainUserId)?.gameName;
|
||||
}
|
||||
|
||||
function tierByQueue(tiers: ApiTierInfo[], queueType: string) {
|
||||
return tiers.find((tier) => tier.queueType === queueType);
|
||||
}
|
||||
|
||||
function SummonerStatsSummary({
|
||||
assignedPosition,
|
||||
fallbackTier,
|
||||
userId,
|
||||
}: {
|
||||
assignedPosition?: Position;
|
||||
fallbackTier?: ApiTierInfo;
|
||||
userId?: string;
|
||||
}) {
|
||||
const profileQuery = useUserHistoryProfile(userId, DEFAULT_COMMUNITY_ID);
|
||||
const tiers = profileQuery.data?.tiers ?? [];
|
||||
const soloTier =
|
||||
tierByQueue(tiers, "RANKED_SOLO_5x5") ??
|
||||
(fallbackTier?.queueType === "RANKED_SOLO_5x5" ? fallbackTier : undefined);
|
||||
const flexTier = tierByQueue(tiers, "RANKED_FLEX_SR");
|
||||
|
||||
return (
|
||||
<div className="ml-auto flex min-w-[148px] shrink-0 flex-col items-end text-right leading-tight">
|
||||
<div className="text-xs font-black text-primary">
|
||||
{assignedPosition ? positionLabel[assignedPosition] : "-"}
|
||||
</div>
|
||||
<div className="mt-1 flex items-center justify-end gap-2 text-xs font-black text-base-content/35">
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<span>SOLO</span>
|
||||
<RankBadge tier={soloTier} size="sm" tooltipPlacement="left" />
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<span>FLEX</span>
|
||||
<RankBadge tier={flexTier} size="sm" tooltipPlacement="left" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamMemberScoutLine({
|
||||
isCaptain,
|
||||
member,
|
||||
participant,
|
||||
}: {
|
||||
isCaptain?: boolean;
|
||||
member: ApiMatch["teams"][number]["members"][number];
|
||||
participant?: ApiMatchParticipant;
|
||||
}) {
|
||||
return (
|
||||
<ParticipantLine
|
||||
assignedPosition={member.assignedPosition}
|
||||
isCaptain={isCaptain}
|
||||
participant={participant}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ParticipantLine({
|
||||
participant,
|
||||
assignedPosition,
|
||||
isCaptain,
|
||||
}: {
|
||||
participant?: ApiMatchParticipant;
|
||||
assignedPosition?: Position;
|
||||
isCaptain?: boolean;
|
||||
}) {
|
||||
const { data: ddragon } = useDdragonManifest();
|
||||
const location = useLocation();
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const name = participant?.gameName ?? "알 수 없는 참가자";
|
||||
const tag = participant?.tagLine ?? "----";
|
||||
const content = (
|
||||
<>
|
||||
<div className="h-8 w-8 shrink-0 overflow-hidden bg-base-content/10">
|
||||
<img
|
||||
src={profileIconUrl(ddragon, participant?.profileIconId ?? 0)}
|
||||
alt=""
|
||||
className="h-full w-full object-cover"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="truncate text-sm font-bold text-base-content">
|
||||
{name}
|
||||
</span>
|
||||
{isCaptain && (
|
||||
<span className="shrink-0 border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-xs font-bold text-warning">
|
||||
팀장
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-xs text-base-content/30">#{tag}</div>
|
||||
</div>
|
||||
<SummonerStatsSummary
|
||||
assignedPosition={assignedPosition}
|
||||
fallbackTier={participant?.tier}
|
||||
userId={participant?.userId}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
const className =
|
||||
"flex items-center gap-3 border-b border-base-content/5 px-3 py-2 last:border-b-0";
|
||||
|
||||
if (participant?.userId) {
|
||||
return (
|
||||
<Link
|
||||
to={`/users/${participant.userId}/history`}
|
||||
state={{ backTo: historyBackTo }}
|
||||
className={`${className} hover:bg-base-content/[0.025]`}
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return <div className={className}>{content}</div>;
|
||||
}
|
||||
|
||||
function UpcomingGameCard({
|
||||
expanded,
|
||||
game,
|
||||
isNext,
|
||||
onToggle,
|
||||
onReplaceCode,
|
||||
participantByUserId,
|
||||
parsedTeamIndex,
|
||||
replacingCode,
|
||||
slot,
|
||||
teamByIndex,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
game?: ApiMatchGameResult;
|
||||
isNext?: boolean;
|
||||
onToggle: () => void;
|
||||
onReplaceCode?: (slot: TournamentCodeSlotView) => void;
|
||||
participantByUserId: Map<string, ApiMatchParticipant>;
|
||||
parsedTeamIndex: number;
|
||||
replacingCode?: boolean;
|
||||
slot: TournamentCodeSlotView;
|
||||
teamByIndex: Map<number, ApiMatch["teams"][number]>;
|
||||
}) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const opponentIndex =
|
||||
slot.teamAIndex === parsedTeamIndex ? slot.teamBIndex : slot.teamAIndex;
|
||||
const ourTeam = teamByIndex.get(parsedTeamIndex);
|
||||
const opponentTeam = opponentIndex ? teamByIndex.get(opponentIndex) : undefined;
|
||||
const ourTeamName = teamIndexLabel(parsedTeamIndex, ourTeam?.name);
|
||||
const opponentTeamName = opponentIndex
|
||||
? teamIndexLabel(opponentIndex, opponentTeam?.name)
|
||||
: "상대 미정";
|
||||
const ourCaptainName = captainName(ourTeam, participantByUserId);
|
||||
const opponentCaptainName = captainName(opponentTeam, participantByUserId);
|
||||
const opponentMembers = opponentTeam?.members ?? [];
|
||||
const finished = Boolean(game?.winnerTeamIndex);
|
||||
const won = finished && game?.winnerTeamIndex === parsedTeamIndex;
|
||||
const ourSide: TeamSide =
|
||||
slot.teamAIndex === parsedTeamIndex ? "blue" : "red";
|
||||
const replaceable = Boolean(slot.code && !finished && slot.state !== "used");
|
||||
|
||||
async function handleCopy() {
|
||||
if (!slot.code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(slot.code);
|
||||
setCopied(true);
|
||||
window.setTimeout(() => setCopied(false), 1500);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<li
|
||||
className={`w-full border bg-base-100 p-4 ${
|
||||
isNext
|
||||
? "border-primary/30 bg-primary/[0.03]"
|
||||
: "border-base-content/10"
|
||||
} ${finished ? "bg-base-content/[0.015]" : ""}`}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={`border px-2 py-1 text-xs font-black ${
|
||||
isNext
|
||||
? "border-primary/25 bg-primary/10 text-primary"
|
||||
: "border-base-content/10 bg-base-content/5 text-base-content/55"
|
||||
}`}
|
||||
>
|
||||
{isNext ? "다음 경기" : `${slot.gameNumber}경기`}
|
||||
</span>
|
||||
<span className="text-xs font-semibold text-base-content/35">
|
||||
{sideShortLabel(ourSide)}
|
||||
</span>
|
||||
</div>
|
||||
{finished ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={`border px-2 py-1 text-xs font-black ${resultBadgeClass(won)}`}
|
||||
>
|
||||
{won ? "승리" : "패배"}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-7 w-7 items-center justify-center text-base-content/45 hover:text-primary"
|
||||
onClick={onToggle}
|
||||
aria-expanded={expanded}
|
||||
aria-label={expanded ? "상대팀 정보 접기" : "상대팀 정보 펼치기"}
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-7 w-7 items-center justify-center text-base-content/45 hover:text-primary"
|
||||
onClick={onToggle}
|
||||
aria-expanded={expanded}
|
||||
aria-label={expanded ? "상대팀 정보 접기" : "상대팀 정보 펼치기"}
|
||||
>
|
||||
{expanded ? (
|
||||
<ChevronUp className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mt-4 grid grid-cols-[1fr_auto_1fr] items-start gap-2">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-black text-primary">
|
||||
{ourTeamName}
|
||||
</div>
|
||||
{ourCaptainName && (
|
||||
<div className="mt-1 truncate text-xs text-base-content/35">
|
||||
팀장 {ourCaptainName}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="pt-0.5 text-xs font-black uppercase tracking-wider text-base-content/25">
|
||||
vs
|
||||
</div>
|
||||
<div className="min-w-0 text-right">
|
||||
<div className="truncate text-sm font-bold text-base-content/70">
|
||||
{opponentTeamName}
|
||||
</div>
|
||||
{opponentCaptainName && (
|
||||
<div className="mt-1 truncate text-xs text-base-content/35">
|
||||
팀장 {opponentCaptainName}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 border border-base-content/8 bg-base-content/[0.02] px-3 py-2">
|
||||
<div className="text-xs font-black uppercase tracking-wider text-base-content/35">
|
||||
토너먼트 코드
|
||||
</div>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
{slot.code ? (
|
||||
<>
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-xs font-black text-primary">
|
||||
{slot.code}
|
||||
</code>
|
||||
<button
|
||||
type="button"
|
||||
className="whitespace-nowrap border border-base-content/10 px-2 py-1 text-xs font-bold text-base-content/45 hover:text-primary"
|
||||
onClick={handleCopy}
|
||||
>
|
||||
{copied ? "복사됨" : "복사"}
|
||||
</button>
|
||||
{replaceable && (
|
||||
<button
|
||||
type="button"
|
||||
className="whitespace-nowrap border border-base-content/10 px-2 py-1 text-xs font-bold text-base-content/45 hover:text-primary disabled:cursor-not-allowed disabled:opacity-45"
|
||||
disabled={replacingCode}
|
||||
onClick={() => onReplaceCode?.(slot)}
|
||||
>
|
||||
{replacingCode ? "교체 중" : "교체"}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className="text-xs font-semibold text-base-content/30">
|
||||
발급 대기
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expanded && (
|
||||
<div className="mt-3 border border-base-content/8 bg-base-content/[0.015]">
|
||||
<div className="flex items-center justify-between gap-2 border-b border-base-content/8 px-3 py-2">
|
||||
<div>
|
||||
<div className="text-xs font-black text-base-content/55">
|
||||
상대팀 멤버
|
||||
</div>
|
||||
<div className="mt-0.5 text-xs text-base-content/30">
|
||||
라인 · 티어
|
||||
</div>
|
||||
</div>
|
||||
<div className="truncate text-right text-xs font-bold text-base-content/45">
|
||||
{opponentTeamName}
|
||||
</div>
|
||||
</div>
|
||||
{opponentMembers.length > 0 ? (
|
||||
<div>
|
||||
{opponentMembers.map((member) => (
|
||||
<TeamMemberScoutLine
|
||||
key={member.userId}
|
||||
isCaptain={opponentTeam?.captainUserId === member.userId}
|
||||
member={member}
|
||||
participant={participantByUserId.get(member.userId)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="px-3 py-5 text-center text-xs text-base-content/30">
|
||||
상대팀 멤버 정보가 아직 없습니다.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{finished && game?.riotMatchId && (
|
||||
<div className="mt-2 truncate font-mono text-xs text-base-content/25">
|
||||
{game.riotMatchId}
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamGameCardsSection({
|
||||
defaultExpandedGameNumber,
|
||||
emptyMessage,
|
||||
gameByNumber,
|
||||
isPreTeamBuilt,
|
||||
match,
|
||||
participantByUserId,
|
||||
parsedTeamIndex,
|
||||
replaceError,
|
||||
replacingGameNumber,
|
||||
teamByIndex,
|
||||
slots,
|
||||
title,
|
||||
onReplaceCode,
|
||||
}: {
|
||||
defaultExpandedGameNumber?: number | null;
|
||||
emptyMessage: string;
|
||||
gameByNumber: Map<number, ApiMatchGameResult>;
|
||||
isPreTeamBuilt?: boolean;
|
||||
match: ApiMatch;
|
||||
participantByUserId: Map<string, ApiMatchParticipant>;
|
||||
parsedTeamIndex: number;
|
||||
replaceError?: string | null;
|
||||
replacingGameNumber?: number | null;
|
||||
teamByIndex: Map<number, ApiMatch["teams"][number]>;
|
||||
slots: TournamentCodeSlotView[];
|
||||
title: string;
|
||||
onReplaceCode?: (slot: TournamentCodeSlotView) => void;
|
||||
}) {
|
||||
const formatted = formatKoreanDate(match.scheduledAt);
|
||||
const [expandedGameNumber, setExpandedGameNumber] = useState<number | null>(
|
||||
defaultExpandedGameNumber ?? null,
|
||||
);
|
||||
const nextGameNumber = defaultExpandedGameNumber ?? null;
|
||||
|
||||
return (
|
||||
<section className="mb-4 border border-base-content/10 bg-base-100">
|
||||
<div className="flex flex-col gap-1 border-b border-base-content/10 bg-base-200/40 px-4 py-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<h2 className="text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
{title}
|
||||
</h2>
|
||||
<div className="sm:text-right">
|
||||
<div className="text-sm font-black text-base-content/70">
|
||||
{formatted.date} {formatted.time}
|
||||
</div>
|
||||
<div className="mt-0.5 text-xs font-semibold text-base-content/35">
|
||||
{GAME_MODE_LABEL[match.gameMode]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
{replaceError && (
|
||||
<div className="mb-3 border border-error/20 bg-error/8 px-3 py-2 text-xs text-error">
|
||||
{replaceError}
|
||||
</div>
|
||||
)}
|
||||
{isPreTeamBuilt ? (
|
||||
<div className="border border-dashed border-base-content/10 px-4 py-8 text-center text-xs text-base-content/35">
|
||||
팀 빌딩이 끝나면 일정이 표시됩니다.
|
||||
</div>
|
||||
) : slots.length === 0 ? (
|
||||
<div className="border border-dashed border-base-content/10 px-4 py-8 text-center text-xs text-base-content/35">
|
||||
{emptyMessage}
|
||||
</div>
|
||||
) : (
|
||||
<ul className="space-y-3">
|
||||
{slots.map((slot) => (
|
||||
<UpcomingGameCard
|
||||
key={slot.gameNumber}
|
||||
expanded={expandedGameNumber === slot.gameNumber}
|
||||
game={gameByNumber.get(slot.gameNumber)}
|
||||
isNext={slot.gameNumber === nextGameNumber}
|
||||
onToggle={() =>
|
||||
setExpandedGameNumber((current) =>
|
||||
current === slot.gameNumber ? null : slot.gameNumber,
|
||||
)
|
||||
}
|
||||
onReplaceCode={onReplaceCode}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
replacingCode={replacingGameNumber === slot.gameNumber}
|
||||
slot={slot}
|
||||
teamByIndex={teamByIndex}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function buildFinishedSlot(
|
||||
game: ApiMatchGameResult,
|
||||
slotByGameNumber: Map<number, TournamentCodeSlotView>,
|
||||
): TournamentCodeSlotView {
|
||||
const slot = slotByGameNumber.get(game.gameNumber);
|
||||
|
||||
return {
|
||||
gameNumber: game.gameNumber,
|
||||
teamAIndex: game.blueTeamIndex,
|
||||
teamBIndex: game.redTeamIndex,
|
||||
code: slot?.code ?? null,
|
||||
expiresAt: slot?.expiresAt ?? null,
|
||||
state: slot?.state ?? "used",
|
||||
riotMatchId: slot?.riotMatchId ?? game.riotMatchId,
|
||||
};
|
||||
}
|
||||
|
||||
export default function MatchTeamProgressPage() {
|
||||
const { id, teamIndex } = useParams();
|
||||
const parsedTeamIndex = Number(teamIndex);
|
||||
const queryClient = useQueryClient();
|
||||
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
||||
const replaceTournamentCodeMutation =
|
||||
useReplaceTournamentCode(DEFAULT_COMMUNITY_ID);
|
||||
const [replaceCodeSlot, setReplaceCodeSlot] =
|
||||
useState<TournamentCodeSlotView | null>(null);
|
||||
const [replaceCodeConfirmText, setReplaceCodeConfirmText] = useState("");
|
||||
const { id } = useParams();
|
||||
const competitionQuery = useCompetition(id, DEFAULT_COMMUNITY_ID);
|
||||
const teamQuery = useTeamCompetition(id, DEFAULT_COMMUNITY_ID);
|
||||
const [copiedSlotId, setCopiedSlotId] = useState<string | null>(null);
|
||||
|
||||
function handleReplaceTournamentCode(slot: TournamentCodeSlotView) {
|
||||
if (!slot.code) return;
|
||||
setReplaceCodeConfirmText("");
|
||||
setReplaceCodeSlot(slot);
|
||||
}
|
||||
|
||||
function closeReplaceTournamentCodeDialog() {
|
||||
setReplaceCodeSlot(null);
|
||||
setReplaceCodeConfirmText("");
|
||||
}
|
||||
|
||||
function handleConfirmReplaceTournamentCode() {
|
||||
if (!id || !replaceCodeSlot || replaceCodeConfirmText.trim() !== "예") {
|
||||
return;
|
||||
}
|
||||
replaceTournamentCodeMutation.mutate(
|
||||
{ matchId: id, gameNumber: replaceCodeSlot.gameNumber },
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null],
|
||||
});
|
||||
closeReplaceTournamentCodeDialog();
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (!DEFAULT_COMMUNITY_ID) {
|
||||
if (competitionQuery.isLoading || teamQuery.isLoading) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-warning">
|
||||
`VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
|
||||
<main
|
||||
className="mx-auto max-w-5xl space-y-3 px-4 py-12 sm:px-6"
|
||||
aria-busy="true"
|
||||
aria-label="팀 진행 정보를 불러오는 중"
|
||||
>
|
||||
<div className="h-7 w-48 animate-pulse bg-base-200" />
|
||||
<div className="h-32 animate-pulse bg-base-200/70" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
if (matchQuery.isLoading) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-base-content/40">
|
||||
팀 진행 정보를 불러오는 중...
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!Number.isInteger(parsedTeamIndex) ||
|
||||
parsedTeamIndex < 1 ||
|
||||
!matchQuery.data
|
||||
) {
|
||||
const competition = competitionQuery.data;
|
||||
const teamView = teamQuery.data;
|
||||
if (!competition || !teamView) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">팀 정보를 찾을 수 없습니다</h1>
|
||||
<Link
|
||||
to={`/match/${id}`}
|
||||
className="btn btn-primary btn-sm mt-4 px-5 text-xs"
|
||||
>
|
||||
내전 상세로
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const match = matchQuery.data;
|
||||
const team = match.teams.find((item) => item.teamIndex === parsedTeamIndex);
|
||||
const participantByUserId = new Map(
|
||||
match.participants.map((participant) => [participant.userId, participant]),
|
||||
);
|
||||
const slotByGameNumber = new Map(
|
||||
(match.tournamentCodes ?? []).map((slot) => [slot.gameNumber, slot]),
|
||||
);
|
||||
const codes = (match.tournamentCodes ?? []).filter(
|
||||
(slot) =>
|
||||
slot.teamAIndex === parsedTeamIndex ||
|
||||
slot.teamBIndex === parsedTeamIndex,
|
||||
);
|
||||
const upcomingSlots = [...codes].sort(
|
||||
(left, right) => left.gameNumber - right.gameNumber,
|
||||
);
|
||||
const teamByIndex = new Map(
|
||||
match.teams.map((team) => [team.teamIndex, team]),
|
||||
);
|
||||
const gameByNumber = new Map(
|
||||
(match.result?.games ?? []).map((game) => [game.gameNumber, game]),
|
||||
);
|
||||
const isPreTeamBuilt =
|
||||
match.status === "recruiting" || (match.teams ?? []).length === 0;
|
||||
const teamGames = (match.result?.games ?? []).filter(
|
||||
(game) =>
|
||||
game.blueTeamIndex === parsedTeamIndex ||
|
||||
game.redTeamIndex === parsedTeamIndex,
|
||||
);
|
||||
const finishedSlots = teamGames
|
||||
.filter((game) => Boolean(game.winnerTeamIndex))
|
||||
.map((game) => buildFinishedSlot(game, slotByGameNumber))
|
||||
.sort((left, right) => left.gameNumber - right.gameNumber);
|
||||
const activeSlots = upcomingSlots.filter(
|
||||
(slot) => !gameByNumber.get(slot.gameNumber)?.winnerTeamIndex,
|
||||
);
|
||||
|
||||
if (!team) {
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">아직 팀이 생성되지 않았습니다</h1>
|
||||
<p className="mt-2 text-sm text-base-content/40">
|
||||
경매가 완료되면 팀별 진행 페이지를 사용할 수 있습니다.
|
||||
<h1 className="text-lg font-bold">팀 진행 정보를 볼 수 없습니다</h1>
|
||||
<p className="mt-2 text-sm text-base-content/45">
|
||||
이 내전에 참여한 계정으로 로그인했는지 확인해주세요.
|
||||
</p>
|
||||
<Link
|
||||
to={`/match/${id}`}
|
||||
className="btn btn-primary btn-sm mt-4 px-5 text-xs"
|
||||
>
|
||||
<Link to={`/match/${id}`} className="btn btn-primary btn-sm mt-5">
|
||||
내전 상세로
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const team = teamById.get(teamView.teamId);
|
||||
const completedSeries = competition.projection.series.filter(
|
||||
(series) =>
|
||||
series.status === "completed" &&
|
||||
series.entries.some((entry) => entry.teamId === teamView.teamId),
|
||||
);
|
||||
|
||||
async function copyCode(gameSlotId: string, code: string | null) {
|
||||
if (!code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
setCopiedSlotId(gameSlotId);
|
||||
window.setTimeout(() => setCopiedSlotId(null), 1500);
|
||||
} catch {
|
||||
setCopiedSlotId(null);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl px-4 py-6 sm:px-6">
|
||||
<Link
|
||||
@@ -629,153 +69,152 @@ export default function MatchTeamProgressPage() {
|
||||
← 내전 상세로
|
||||
</Link>
|
||||
|
||||
<div className="mb-6 border-b border-base-content/8 pb-5">
|
||||
<h1 className="text-2xl font-black text-base-content">
|
||||
{teamIndexLabel(team.teamIndex, team.name)}
|
||||
</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
이 팀의 다가오는 경기 일정과 결과를 한곳에서 확인합니다.
|
||||
<header className="mb-6 border-b border-base-content/10 pb-5">
|
||||
<p className="text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
My Competition
|
||||
</p>
|
||||
</div>
|
||||
<h1 className="mt-1 text-2xl font-black">{team?.name ?? "내 팀"}</h1>
|
||||
<p className="mt-1 text-sm text-base-content/45">
|
||||
우리 팀의 공식 대진과 토너먼트 코드는 이 페이지에서만 표시됩니다.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<TeamGameCardsSection
|
||||
defaultExpandedGameNumber={activeSlots[0]?.gameNumber ?? null}
|
||||
emptyMessage="남은 경기가 없습니다."
|
||||
gameByNumber={gameByNumber}
|
||||
isPreTeamBuilt={isPreTeamBuilt}
|
||||
match={match}
|
||||
onReplaceCode={handleReplaceTournamentCode}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
replaceError={
|
||||
replaceTournamentCodeMutation.error instanceof Error
|
||||
? replaceTournamentCodeMutation.error.message
|
||||
: null
|
||||
}
|
||||
replacingGameNumber={
|
||||
replaceTournamentCodeMutation.isPending
|
||||
? replaceTournamentCodeMutation.variables?.gameNumber ?? null
|
||||
: null
|
||||
}
|
||||
teamByIndex={teamByIndex}
|
||||
slots={activeSlots}
|
||||
title="다가오는 경기"
|
||||
/>
|
||||
|
||||
<TeamGameCardsSection
|
||||
defaultExpandedGameNumber={null}
|
||||
emptyMessage="아직 종료된 경기가 없습니다."
|
||||
gameByNumber={gameByNumber}
|
||||
match={match}
|
||||
participantByUserId={participantByUserId}
|
||||
parsedTeamIndex={parsedTeamIndex}
|
||||
teamByIndex={teamByIndex}
|
||||
slots={finishedSlots}
|
||||
title="종료된 경기"
|
||||
/>
|
||||
|
||||
<section className="border border-base-content/10 bg-base-100">
|
||||
<div className="border-b border-base-content/10 bg-base-200/40 px-4 py-2">
|
||||
<h2 className="text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
팀 구성
|
||||
</h2>
|
||||
</div>
|
||||
<ParticipantLine
|
||||
participant={
|
||||
team.captainUserId
|
||||
? participantByUserId.get(team.captainUserId)
|
||||
: undefined
|
||||
}
|
||||
isCaptain
|
||||
/>
|
||||
{team.members.map((member) => (
|
||||
<ParticipantLine
|
||||
key={member.userId}
|
||||
participant={participantByUserId.get(member.userId)}
|
||||
assignedPosition={member.assignedPosition}
|
||||
/>
|
||||
))}
|
||||
<section className="mb-6" aria-labelledby="active-series-heading">
|
||||
<h2
|
||||
id="active-series-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
진행할 Series
|
||||
</h2>
|
||||
{teamView.activeSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{teamView.activeSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="현재 진행할 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
{replaceCodeSlot && (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/55 px-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="team-tournament-code-replace-title"
|
||||
<section className="mb-6" aria-labelledby="codes-heading">
|
||||
<h2
|
||||
id="codes-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
<div className="w-full max-w-md border border-warning/25 bg-base-100 p-5 shadow-2xl">
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="inline-flex h-9 w-9 shrink-0 items-center justify-center border border-warning/25 bg-warning/10 text-warning">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
</span>
|
||||
<div className="min-w-0">
|
||||
<h2
|
||||
id="team-tournament-code-replace-title"
|
||||
className="text-base font-bold text-base-content"
|
||||
>
|
||||
토너먼트 코드 교체
|
||||
</h2>
|
||||
<p className="mt-2 text-sm leading-6 text-base-content/60">
|
||||
정상적인 경기 진행이 불가한 경우 우리팀과 상대팀에
|
||||
상황을 알린 뒤 {replaceCodeSlot.gameNumber}경기 코드를
|
||||
교체하세요.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label
|
||||
htmlFor="team-tournament-code-replace-confirm"
|
||||
className="mt-5 block text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
계속하려면 예 입력
|
||||
</label>
|
||||
<input
|
||||
id="team-tournament-code-replace-confirm"
|
||||
value={replaceCodeConfirmText}
|
||||
onChange={(event) => setReplaceCodeConfirmText(event.target.value)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Escape") {
|
||||
closeReplaceTournamentCodeDialog();
|
||||
}
|
||||
if (
|
||||
event.key === "Enter" &&
|
||||
replaceCodeConfirmText.trim() === "예" &&
|
||||
!replaceTournamentCodeMutation.isPending
|
||||
) {
|
||||
handleConfirmReplaceTournamentCode();
|
||||
}
|
||||
}}
|
||||
className="mt-2 h-10 w-full border border-base-content/15 bg-base-100 px-3 text-sm text-base-content outline-none transition-colors focus:border-warning/60"
|
||||
placeholder="예"
|
||||
/>
|
||||
|
||||
<div className="mt-5 flex flex-wrap justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-ghost btn-sm px-4 text-xs"
|
||||
onClick={closeReplaceTournamentCodeDialog}
|
||||
disabled={replaceTournamentCodeMutation.isPending}
|
||||
토너먼트 코드
|
||||
</h2>
|
||||
{teamView.tournamentCodes.length > 0 ? (
|
||||
<ul className="grid gap-3 sm:grid-cols-2">
|
||||
{teamView.tournamentCodes.map((assignment) => (
|
||||
<li
|
||||
key={assignment.gameSlotId}
|
||||
className="border border-base-content/10 bg-base-100 p-4"
|
||||
>
|
||||
닫기
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-warning btn-sm px-4 text-xs"
|
||||
onClick={handleConfirmReplaceTournamentCode}
|
||||
disabled={
|
||||
replaceCodeConfirmText.trim() !== "예" ||
|
||||
replaceTournamentCodeMutation.isPending
|
||||
}
|
||||
>
|
||||
{replaceTournamentCodeMutation.isPending
|
||||
? "교체 중..."
|
||||
: "코드 교체 진행"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-xs font-bold text-base-content/45">
|
||||
Game {assignment.displayNumber}
|
||||
</span>
|
||||
<span className="text-[11px] text-base-content/35">
|
||||
{assignment.state === "used"
|
||||
? "사용됨"
|
||||
: assignment.state === "reserved"
|
||||
? "사용 가능"
|
||||
: "발급 대기"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<code className="min-w-0 flex-1 truncate font-mono text-sm font-bold text-primary">
|
||||
{assignment.code ?? "발급 대기"}
|
||||
</code>
|
||||
{assignment.code && assignment.state !== "used" && (
|
||||
<button
|
||||
type="button"
|
||||
className="border border-base-content/10 px-2 py-1 text-xs font-bold hover:border-primary/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
|
||||
onClick={() =>
|
||||
void copyCode(assignment.gameSlotId, assignment.code)
|
||||
}
|
||||
>
|
||||
{copiedSlotId === assignment.gameSlotId
|
||||
? "복사됨"
|
||||
: "복사"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<EmptyState message="배정된 토너먼트 코드가 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mb-6" aria-labelledby="completed-heading">
|
||||
<h2
|
||||
id="completed-heading"
|
||||
className="mb-3 text-xs font-bold uppercase tracking-wider text-base-content/40"
|
||||
>
|
||||
종료된 Series
|
||||
</h2>
|
||||
{completedSeries.length > 0 ? (
|
||||
<div className="grid gap-3 md:grid-cols-2">
|
||||
{completedSeries.map((series) => (
|
||||
<SeriesScoreCard
|
||||
key={series.seriesId}
|
||||
series={series}
|
||||
teamById={teamById}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="아직 종료된 대진이 없습니다." />
|
||||
)}
|
||||
</section>
|
||||
|
||||
{team && (
|
||||
<section className="border border-base-content/10 bg-base-100">
|
||||
<h2 className="border-b border-base-content/10 bg-base-200/40 px-4 py-2 text-xs font-bold uppercase tracking-wider text-base-content/40">
|
||||
팀 구성
|
||||
</h2>
|
||||
<ul className="divide-y divide-base-content/8">
|
||||
{team.members.map((member) => (
|
||||
<li
|
||||
key={member.userId}
|
||||
className="flex items-center gap-3 px-4 py-3"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-bold">
|
||||
{member.displayName}
|
||||
</p>
|
||||
{member.assignedPosition && (
|
||||
<p className="mt-0.5 text-xs text-base-content/35">
|
||||
{member.assignedPosition}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{member.userId === team.captainUserId && (
|
||||
<span className="text-xs font-bold text-warning">팀장</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function EmptyState({ message }: { message: string }) {
|
||||
return (
|
||||
<p
|
||||
role="status"
|
||||
className="border border-dashed border-base-content/10 px-4 py-8 text-center text-sm text-base-content/40"
|
||||
>
|
||||
{message}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
@@ -32,7 +32,6 @@ const DEFAULT_FORM: MatchMutationRequest = {
|
||||
|
||||
const GAME_MODE_LABEL: Record<MatchGameMode, string> = {
|
||||
pair: '페어',
|
||||
bracket: '브래킷',
|
||||
'round-robin': '라운드 로빈',
|
||||
'double-elimination': '더블 엘리미네이션',
|
||||
};
|
||||
@@ -131,7 +130,7 @@ function makeForm(match?: ApiMatch): MatchMutationRequest & {
|
||||
gameMode: match.gameMode ?? 'pair',
|
||||
roundRobinMaxRounds: match.roundRobinMaxRounds,
|
||||
doubleEliminationResetFinalEnabled:
|
||||
match.doubleElimination?.resetFinalEnabled ?? true,
|
||||
match.doubleEliminationResetFinalEnabled ?? true,
|
||||
prizes: match.prizes,
|
||||
notices: match.notices,
|
||||
schedule: match.schedule,
|
||||
@@ -533,7 +532,7 @@ export default function MatchAdminPage() {
|
||||
{match.gameMode === 'double-elimination' && (
|
||||
<span className="block text-xs text-base-content/30">
|
||||
GF 리셋{' '}
|
||||
{match.doubleElimination?.resetFinalEnabled
|
||||
{match.doubleEliminationResetFinalEnabled
|
||||
? '허용'
|
||||
: '없음'}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user