This commit is contained in:
dahyeon committed 2026-04-27 15:00:25 -07:00
1 parent c5d296d403
commit 2250b6072e
22 files changed
+1719 -42

No files matched your search

+15
View File
@@ -334,6 +334,21 @@ export function useDeleteTournamentCode(communityId = DEFAULT_COMMUNITY_ID) {
});
}
export function usePollTournamentResult(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (matchId: string) =>
apiFetch<{
jobId: string;
matchId: string;
priority: 'high' | 'low';
attempt: number;
expandedToAllPuuids: boolean;
}>(`/communities/${communityId}/matches/${matchId}/poll-tournament-result`, {
method: 'POST',
}),
});
}
export function useMe() {
const authUserId = useAuthUserId();
const { accounts, inProgress, instance } = useMsal();
+28 -3
View File
@@ -53,9 +53,27 @@ export interface MatchDetailView {
participants: ParticipantView[];
teams: TeamView[];
result?: {
winner: string;
winner?: string;
winnerSide?: TeamSide;
blueScore: number;
redScore: number;
riotMatchIds: string[];
games: Array<{
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
gameCreation: number;
gameDuration: number;
participants: Array<{
userId: string;
side: TeamSide;
championId: number;
kills: number;
deaths: number;
assists: number;
win: boolean;
}>;
}>;
};
prizes: string[];
notices: string[];
@@ -392,7 +410,7 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
}),
}));
const winnerTeam = match.result
const winnerTeam = match.result?.winnerSide
? teams.find((team) => team.side === match.result?.winnerSide)
: undefined;
@@ -412,9 +430,16 @@ export function mapApiMatchToMatchDetail(match: ApiMatch): MatchDetailView {
teams,
result: match.result
? {
winner: winnerTeam?.name ?? sideLabel(match.result.winnerSide),
winner: match.result.winnerSide
? winnerTeam?.name ?? sideLabel(match.result.winnerSide)
: undefined,
winnerSide: match.result.winnerSide,
blueScore: match.result.blueScore,
redScore: match.result.redScore,
riotMatchIds: match.result.riotMatchIds,
games: [...(match.result.games ?? [])].sort(
(left, right) => left.gameNumber - right.gameNumber,
),
}
: undefined,
prizes: match.prizes,
+21 -1
View File
@@ -146,12 +146,32 @@ export interface ApiMatchTeam {
members: ApiMatchTeamMember[];
}
export interface ApiMatchResult {
export interface ApiMatchGameResultParticipant {
userId: string;
side: TeamSide;
championId: number;
kills: number;
deaths: number;
assists: number;
win: boolean;
}
export interface ApiMatchGameResult {
gameNumber: number;
riotMatchId: string;
winnerSide: TeamSide;
gameCreation: number;
gameDuration: number;
participants: ApiMatchGameResultParticipant[];
}
export interface ApiMatchResult {
winnerSide?: TeamSide;
blueScore: number;
redScore: number;
mvpUserId?: string;
riotMatchIds: string[];
games: ApiMatchGameResult[];
}
export interface ApiMatchScheduleItem {
+1 -1
View File
@@ -208,7 +208,7 @@ export default function HomePage() {
{match.participants.length}명
</td>
<td className="py-2.5 px-4 text-xs text-base-content/50">
{match.result ? `${match.result.winner} 승리` : '-'}
{match.result?.winner ? `${match.result.winner} 승리` : '-'}
</td>
</tr>
))
+130 -30
View File
@@ -6,6 +6,7 @@ import {
useDdragonManifest,
useMatch,
useMe,
usePollTournamentResult,
useTournamentCodeStats,
} from '../api/hooks';
import {
@@ -396,6 +397,97 @@ function PoolStatsHint({ enabled }: { enabled: boolean }) {
);
}
function formatGameDuration(seconds: number) {
const minutes = Math.floor(seconds / 60);
const rest = seconds % 60;
return `${minutes}:${String(rest).padStart(2, '0')}`;
}
function resultSideLabel(side: 'blue' | 'red') {
return side === 'blue' ? '블루팀' : '레드팀';
}
function resultSideClass(side: 'blue' | 'red') {
return side === 'blue' ? 'text-blue-400' : 'text-red-400';
}
function MatchResultPanel({ match }: { match: MatchDetailView }) {
if (!match.result) return null;
const gamesByNumber = new Map(
match.result.games.map((game) => [game.gameNumber, game]),
);
const gameNumbers = Array.from(
{ length: match.gameCount },
(_, index) => index + 1,
);
return (
<div className="mb-6 border border-base-content/10 bg-base-content/[0.02] p-5">
<div className="flex items-center justify-center gap-8">
<div
className={`text-center ${match.result.winnerSide === 'blue' ? 'text-blue-400' : 'text-blue-400/30'}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.blueScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
블루팀
</div>
</div>
<div className="text-base-content/20 text-xs font-bold uppercase tracking-widest">
VS
</div>
<div
className={`text-center ${match.result.winnerSide === 'red' ? 'text-red-400' : 'text-red-400/30'}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.redScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
레드팀
</div>
</div>
</div>
<div className="text-center mt-3 text-[11px] font-bold text-amber-400 uppercase tracking-wide">
{match.result.winner
? `${match.result.winner} 승리`
: `결과 수집 중 · ${match.result.games.length}/${match.gameCount}경기`}
</div>
<div className="mt-5 border border-base-content/8 divide-y divide-base-content/8">
{gameNumbers.map((gameNumber) => {
const game = gamesByNumber.get(gameNumber);
return (
<div
key={gameNumber}
className="grid grid-cols-[56px_1fr_auto] gap-3 items-center px-3 py-2.5 text-xs"
>
<span className="text-base-content/35 font-bold">
{gameNumber}경기
</span>
{game ? (
<div>
<span className={`font-black ${resultSideClass(game.winnerSide)}`}>
{resultSideLabel(game.winnerSide)} 승
</span>
<span className="ml-2 text-base-content/35 font-mono">
{game.riotMatchId}
</span>
</div>
) : (
<span className="text-base-content/25">대기 중</span>
)}
<span className="text-base-content/35 font-mono">
{game ? formatGameDuration(game.gameDuration) : '-'}
</span>
</div>
);
})}
</div>
</div>
);
}
export default function MatchDetailPage() {
const { id } = useParams();
const navigate = useNavigate();
@@ -411,6 +503,9 @@ export default function MatchDetailPage() {
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
const [blueCaptainUserId, setBlueCaptainUserId] = useState('');
const [redCaptainUserId, setRedCaptainUserId] = useState('');
const pollTournamentResultMutation = usePollTournamentResult(
DEFAULT_COMMUNITY_ID,
);
const joinMatchMutation = useMutation({
mutationFn: () =>
@@ -461,6 +556,17 @@ export default function MatchDetailPage() {
},
});
function handlePollTournamentResult() {
if (!id) return;
pollTournamentResultMutation.mutate(id, {
onSuccess: async () => {
await queryClient.invalidateQueries({
queryKey: ['match', DEFAULT_COMMUNITY_ID, id ?? null],
});
},
});
}
useEffect(() => {
const participants = matchQuery.data?.participants ?? [];
if (!blueCaptainUserId && participants[0]) {
@@ -578,39 +684,14 @@ export default function MatchDetailPage() {
</div>
)}
{match.status === 'finished' && match.result && (
<div className="mb-6 border border-base-content/10 bg-base-content/[0.02] p-5">
<div className="flex items-center justify-center gap-8">
<div
className={`text-center ${match.result.winner === '블루팀' ? 'text-blue-400' : 'text-blue-400/30'}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.blueScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
블루팀
</div>
</div>
<div className="text-base-content/20 text-xs font-bold uppercase tracking-widest">
VS
</div>
<div
className={`text-center ${match.result.winner === '레드팀' ? 'text-red-400' : 'text-red-400/30'}`}
>
<div className="text-3xl font-black tabular-nums">
{match.result.redScore}
</div>
<div className="text-[10px] uppercase tracking-wider mt-0.5 font-semibold">
레드팀
</div>
</div>
</div>
<div className="text-center mt-3 text-[11px] font-bold text-amber-400 uppercase tracking-wide">
{match.result.winner} 승리
</div>
{pollTournamentResultMutation.error instanceof Error && (
<div className="mb-4 border border-red-500/20 bg-red-500/10 px-4 py-3 text-sm text-red-500">
{pollTournamentResultMutation.error.message}
</div>
)}
<MatchResultPanel match={match} />
<div className="flex flex-col lg:flex-row gap-5">
<div className="flex-1 min-w-0 space-y-4">
{match.status === 'recruiting' ? (
@@ -747,6 +828,25 @@ export default function MatchDetailPage() {
</SideCard>
)}
{canManageAuction &&
(match.status === 'team-built' || match.status === 'in-progress') && (
<SideCard title="결과 수집">
<p className="text-[12px] text-base-content/45 mb-3">
Riot match-v5에서 토너먼트 코드가 붙은 경기를 다시 찾습니다.
</p>
<button
type="button"
className="btn btn-primary btn-sm w-full text-xs"
disabled={pollTournamentResultMutation.isPending}
onClick={handlePollTournamentResult}
>
{pollTournamentResultMutation.isPending
? '등록 중...'
: '결과 다시 수집'}
</button>
</SideCard>
)}
{match.prizes.length > 0 && (
<SideCard title="상품">
<ul className="space-y-1.5">