This commit is contained in:
dahyeon committed 2026-05-02 02:59:33 -07:00
1 parent b152a5b0fa
commit 2379051196
32 files changed
+1682 -383

No files matched your search

@@ -0,0 +1,245 @@
import { Link, useParams } from 'react-router';
import { useDdragonManifest, useMatch } from '../api/hooks';
import type { ApiMatchParticipant, Position, TeamSide } from '../api/types';
import { DEFAULT_COMMUNITY_ID } from '../config';
import { profileIconUrl } from '../lib/ddragon';
import { positionLabel } from '../lib/league';
function teamLabel(side: TeamSide, groupIndex = 1) {
const sideText = side === 'blue' ? '블루팀' : '레드팀';
return groupIndex === 1 ? sideText : `${groupIndex}조 ${sideText}`;
}
function formatExpiry(value: string | null) {
if (!value) return '-';
return new Intl.DateTimeFormat('ko-KR', {
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}).format(new Date(value));
}
function ParticipantLine({
participant,
assignedPosition,
isCaptain,
}: {
participant?: ApiMatchParticipant;
assignedPosition?: Position;
isCaptain?: boolean;
}) {
const { data: ddragon } = useDdragonManifest();
const name = participant?.gameName ?? '알 수 없는 참가자';
const tag = participant?.tagLine ?? '----';
return (
<div className="flex items-center gap-3 border-b border-base-content/5 last:border-b-0 px-3 py-2">
<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 items-center gap-2">
<span className="truncate text-sm font-bold text-base-content">
{name}
</span>
{isCaptain && (
<span className="border border-amber-500/20 bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-bold text-amber-500">
팀장
</span>
)}
</div>
<div className="text-[11px] text-base-content/30">#{tag}</div>
</div>
<div className="text-xs font-semibold text-primary">
{assignedPosition ? positionLabel[assignedPosition] : '-'}
</div>
</div>
);
}
export default function MatchTeamProgressPage() {
const { id, side, groupIndex } = useParams();
const parsedGroupIndex = Number(groupIndex ?? 1);
const teamSide = side === 'blue' || side === 'red' ? side : null;
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
if (!DEFAULT_COMMUNITY_ID) {
return (
<main className="mx-auto max-w-5xl px-4 py-20 text-center text-sm text-amber-600">
`VITE_DEFAULT_COMMUNITY_ID` 설정이 필요합니다.
</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 (!teamSide || !matchQuery.data) {
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.side === teamSide && (item.groupIndex ?? 1) === parsedGroupIndex,
);
const participantByUserId = new Map(
match.participants.map((participant) => [participant.userId, participant]),
);
const codes = (match.tournamentCodes ?? []).filter((slot) =>
teamSide === 'blue'
? slot.blueGroupIndex === parsedGroupIndex
: slot.redGroupIndex === parsedGroupIndex,
);
const games = (match.result?.games ?? []).filter((game) =>
teamSide === 'blue'
? game.blueGroupIndex === parsedGroupIndex
: game.redGroupIndex === parsedGroupIndex,
);
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">
경매가 완료되면 팀별 진행 페이지를 사용할 수 있습니다.
</p>
<Link to={`/match/${id}`} className="btn btn-primary btn-sm mt-4 px-5 text-xs">
내전 상세로
</Link>
</main>
);
}
return (
<main className="mx-auto max-w-5xl px-4 py-6 sm:px-6">
<Link
to={`/match/${id}`}
className="mb-5 inline-flex text-xs text-base-content/40 hover:text-base-content"
>
← 내전 상세로
</Link>
<div className="mb-6 border-b border-base-content/8 pb-5">
<h1 className="text-2xl font-black text-base-content">
{team.name || teamLabel(team.side, team.groupIndex)}
</h1>
<p className="mt-1 text-sm text-base-content/45">
이 팀에 연결된 토너먼트 코드와 수집된 결과만 보여줍니다.
</p>
</div>
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
<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-[11px] 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>
<section className="space-y-4">
<div 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-[11px] font-bold uppercase tracking-wider text-base-content/40">
토너먼트 코드
</h2>
</div>
<div className="divide-y divide-base-content/5">
{codes.length > 0 ? (
codes.map((slot) => (
<div key={slot.gameNumber} className="px-4 py-3 text-xs">
<div className="flex items-center justify-between gap-2">
<span className="font-bold text-base-content/50">
{slot.gameNumber}경기
</span>
<code className="font-mono font-black text-primary">
{slot.code ?? '발급 대기'}
</code>
</div>
<div className="mt-1 text-[11px] text-base-content/30">
만료 {formatExpiry(slot.expiresAt)}
</div>
</div>
))
) : (
<div className="px-4 py-6 text-center text-xs text-base-content/30">
아직 연결된 코드가 없습니다.
</div>
)}
</div>
</div>
<div 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-[11px] font-bold uppercase tracking-wider text-base-content/40">
결과
</h2>
</div>
<div className="divide-y divide-base-content/5">
{games.length > 0 ? (
games.map((game) => {
const won = game.winnerSide === teamSide;
return (
<div key={game.gameNumber} className="px-4 py-3 text-xs">
<div className="flex items-center justify-between gap-2">
<span className="font-bold text-base-content/50">
{game.gameNumber}경기
</span>
<span
className={won ? 'font-black text-blue-400' : 'font-black text-red-400'}
>
{won ? '승리' : '패배'}
</span>
</div>
<div className="mt-1 truncate font-mono text-[11px] text-base-content/30">
{game.riotMatchId}
</div>
</div>
);
})
) : (
<div className="px-4 py-6 text-center text-xs text-base-content/30">
아직 수집된 결과가 없습니다.
</div>
)}
</div>
</div>
</section>
</div>
</main>
);
}