This commit is contained in:
dahyeon committed 2026-04-27 13:16:17 -07:00
1 parent 8b8dec4c44
commit 7a43a667f1
7 files changed
+201 -122

No files matched your search

+1
View File
@@ -4,3 +4,4 @@ VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3
VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863
VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev
VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback
VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html
+1
View File
@@ -4,3 +4,4 @@ VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3
VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/<tenant-id> VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/<tenant-id>
VITE_MSAL_API_SCOPE=api://lolympus-api/access_as_user VITE_MSAL_API_SCOPE=api://lolympus-api/access_as_user
VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback
VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html
+1
View File
@@ -4,4 +4,5 @@ VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3
VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863
VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev
VITE_MSAL_REDIRECT_URI=https://lolympus.dahyeon.us/auth/callback VITE_MSAL_REDIRECT_URI=https://lolympus.dahyeon.us/auth/callback
VITE_MSAL_SILENT_REDIRECT_URI=https://lolympus.dahyeon.us/auth/silent-callback.html
@@ -0,0 +1,8 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Silent Auth</title>
</head>
<body></body>
</html>
+1
View File
@@ -0,0 +1 @@
c47e5251-44c8-4569-a3f6-3cab42fdec98
+17 -3
View File
@@ -6,6 +6,7 @@ import { apiFetch } from '../lib/api';
import { import {
isMsalConfigured, isMsalConfigured,
MSAL_API_SCOPE, MSAL_API_SCOPE,
MSAL_SILENT_REDIRECT_URI,
} from '../lib/auth/msal.config'; } from '../lib/auth/msal.config';
import type { import type {
ApiAuction, ApiAuction,
@@ -53,7 +54,8 @@ function createMatchesPath(
export function useCommunity(communityId = DEFAULT_COMMUNITY_ID) { export function useCommunity(communityId = DEFAULT_COMMUNITY_ID) {
return useQuery({ return useQuery({
queryKey: ['community', communityId], queryKey: ['community', communityId],
queryFn: () => apiFetch<ApiCommunity>(`/communities/${communityId}`), queryFn: () =>
apiFetch<ApiCommunity>(`/communities/${communityId}`, { auth: 'none' }),
enabled: Boolean(communityId), enabled: Boolean(communityId),
}); });
} }
@@ -67,6 +69,7 @@ export function useMatches(
queryFn: async () => { queryFn: async () => {
const response = await apiFetch<MatchesResponse>( const response = await apiFetch<MatchesResponse>(
createMatchesPath(communityId, options), createMatchesPath(communityId, options),
{ auth: 'none' },
); );
return response.matches; return response.matches;
}, },
@@ -78,7 +81,9 @@ export function useMatch(matchId: string | undefined, communityId = DEFAULT_COMM
return useQuery({ return useQuery({
queryKey: ['match', communityId, matchId ?? null], queryKey: ['match', communityId, matchId ?? null],
queryFn: () => queryFn: () =>
apiFetch<ApiMatch>(`/communities/${communityId}/matches/${matchId}`), apiFetch<ApiMatch>(`/communities/${communityId}/matches/${matchId}`, {
auth: 'none',
}),
enabled: Boolean(communityId && matchId), enabled: Boolean(communityId && matchId),
retry: false, retry: false,
}); });
@@ -91,7 +96,10 @@ export function useAuction(
return useQuery({ return useQuery({
queryKey: ['auction', communityId, matchId ?? null], queryKey: ['auction', communityId, matchId ?? null],
queryFn: () => queryFn: () =>
apiFetch<ApiAuction>(`/communities/${communityId}/matches/${matchId}/auction`), apiFetch<ApiAuction>(
`/communities/${communityId}/matches/${matchId}/auction`,
{ auth: 'none' },
),
enabled: Boolean(communityId && matchId), enabled: Boolean(communityId && matchId),
retry: false, retry: false,
}); });
@@ -128,6 +136,7 @@ export function useUserHistoryProfile(
queryFn: () => queryFn: () =>
apiFetch<ApiUserHistoryProfile>( apiFetch<ApiUserHistoryProfile>(
`/communities/${communityId}/users/${userId}/history-profile`, `/communities/${communityId}/users/${userId}/history-profile`,
{ auth: 'none' },
), ),
enabled: Boolean(communityId && userId), enabled: Boolean(communityId && userId),
retry: false, retry: false,
@@ -151,6 +160,7 @@ export function useChampionStats(
queryFn: () => queryFn: () =>
apiFetch<ApiChampionStatsResponse>( apiFetch<ApiChampionStatsResponse>(
createUserHistoryPath(communityId, userId ?? '', 'champion-stats', filters), createUserHistoryPath(communityId, userId ?? '', 'champion-stats', filters),
{ auth: 'none' },
), ),
enabled: Boolean(communityId && userId), enabled: Boolean(communityId && userId),
}); });
@@ -174,6 +184,7 @@ export function useRecentSummary(
queryFn: () => queryFn: () =>
apiFetch<ApiRecentSummaryResponse>( apiFetch<ApiRecentSummaryResponse>(
createUserHistoryPath(communityId, userId ?? '', 'recent-summary', filters), createUserHistoryPath(communityId, userId ?? '', 'recent-summary', filters),
{ auth: 'none' },
), ),
enabled: Boolean(communityId && userId), enabled: Boolean(communityId && userId),
}); });
@@ -200,6 +211,7 @@ export function useRecentMatches(
cursor: pageParam, cursor: pageParam,
limit: 10, limit: 10,
}), }),
{ auth: 'none' },
), ),
initialPageParam: null as number | null, initialPageParam: null as number | null,
getNextPageParam: (lastPage) => lastPage.nextCursor, getNextPageParam: (lastPage) => lastPage.nextCursor,
@@ -232,6 +244,7 @@ export function useDdragonManifest(locale = 'ko_KR') {
queryFn: () => queryFn: () =>
apiFetch<DdragonManifest>( apiFetch<DdragonManifest>(
`/riot/ddragon/manifest?locale=${encodeURIComponent(locale)}`, `/riot/ddragon/manifest?locale=${encodeURIComponent(locale)}`,
{ auth: 'none' },
), ),
staleTime: DDRAGON_MANIFEST_STALE_MS, staleTime: DDRAGON_MANIFEST_STALE_MS,
gcTime: DDRAGON_MANIFEST_STALE_MS, gcTime: DDRAGON_MANIFEST_STALE_MS,
@@ -260,6 +273,7 @@ export function useMe() {
const response = await instance.acquireTokenSilent({ const response = await instance.acquireTokenSilent({
account, account,
scopes: [MSAL_API_SCOPE], scopes: [MSAL_API_SCOPE],
redirectUri: MSAL_SILENT_REDIRECT_URI,
}); });
return apiFetch<MeResponse>('/me', { return apiFetch<MeResponse>('/me', {
headers: { headers: {
+172 -119
View File
@@ -1,6 +1,6 @@
import { useMemo, useState } from 'react'; import { useMemo, useState } from "react";
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from "@tanstack/react-query";
import { Link, useParams, useSearchParams } from 'react-router'; import { Link, useParams, useSearchParams } from "react-router";
import { import {
useChampionStats, useChampionStats,
useDdragonManifest, useDdragonManifest,
@@ -9,12 +9,9 @@ import {
useRefreshUserHistory, useRefreshUserHistory,
useUserHistoryProfile, useUserHistoryProfile,
type UserHistoryFilters, type UserHistoryFilters,
} from '../api/hooks'; } from "../api/hooks";
import { useRiotRefreshSocket } from '../api/useRiotRefreshSocket'; import { useRiotRefreshSocket } from "../api/useRiotRefreshSocket";
import { import { formatTierLabel, getTierColorToken } from "../api/mappers";
formatTierLabel,
getTierColorToken,
} from '../api/mappers';
import type { import type {
ApiChampionStatsRow, ApiChampionStatsRow,
ApiEnqueueRefreshResult, ApiEnqueueRefreshResult,
@@ -23,54 +20,54 @@ import type {
DdragonManifest, DdragonManifest,
RiotQueueGroup, RiotQueueGroup,
RiotRankFilter, RiotRankFilter,
} from '../api/types'; } from "../api/types";
import { DEFAULT_COMMUNITY_ID } from '../config'; import { DEFAULT_COMMUNITY_ID } from "../config";
import { ApiError } from '../lib/api'; import { ApiError } from "../lib/api";
import { import {
championDisplayName, championDisplayName,
championIconUrl, championIconUrl,
itemIconUrl, itemIconUrl,
profileIconUrl, profileIconUrl,
} from '../lib/ddragon'; } from "../lib/ddragon";
import { import {
isRiotQueueGroup, isRiotQueueGroup,
isRiotRankFilter, isRiotRankFilter,
LANE_LABELS, LANE_LABELS,
QUEUE_GROUP_TABS, QUEUE_GROUP_TABS,
RANK_FILTER_TABS, RANK_FILTER_TABS,
} from '../lib/riot-history'; } from "../lib/riot-history";
type ChampionSortKey = 'games' | 'winRate' | 'kda' | 'avgCsPerMin'; type ChampionSortKey = "games" | "winRate" | "kda" | "avgCsPerMin";
const SORT_LABELS: Record<ChampionSortKey, string> = { const SORT_LABELS: Record<ChampionSortKey, string> = {
games: '게임 수', games: "게임 수",
winRate: '승률', winRate: "승률",
kda: 'KDA', kda: "KDA",
avgCsPerMin: '분당 CS', avgCsPerMin: "분당 CS",
}; };
function formatDuration(seconds: number) { function formatDuration(seconds: number) {
const minutes = Math.floor(seconds / 60); const minutes = Math.floor(seconds / 60);
const rest = seconds % 60; const rest = seconds % 60;
return `${minutes}:${String(rest).padStart(2, '0')}`; return `${minutes}:${String(rest).padStart(2, "0")}`;
} }
function formatDate(ms: number) { function formatDate(ms: number) {
return new Intl.DateTimeFormat('ko-KR', { return new Intl.DateTimeFormat("ko-KR", {
month: 'long', month: "long",
day: 'numeric', day: "numeric",
hour: '2-digit', hour: "2-digit",
minute: '2-digit', minute: "2-digit",
}).format(new Date(ms)); }).format(new Date(ms));
} }
function formatLastFetched(value: string | null | undefined) { function formatLastFetched(value: string | null | undefined) {
if (!value) return '저장된 갱신 시각 없음'; if (!value) return "저장된 갱신 시각 없음";
return new Intl.DateTimeFormat('ko-KR', { return new Intl.DateTimeFormat("ko-KR", {
month: 'long', month: "long",
day: 'numeric', day: "numeric",
hour: '2-digit', hour: "2-digit",
minute: '2-digit', minute: "2-digit",
}).format(new Date(value)); }).format(new Date(value));
} }
@@ -83,28 +80,28 @@ function formatRefreshError(error: unknown) {
if (error instanceof ApiError) { if (error instanceof ApiError) {
const data = error.data; const data = error.data;
if ( if (
typeof data === 'object' && typeof data === "object" &&
data !== null && data !== null &&
'retryAfterSeconds' in data && "retryAfterSeconds" in data &&
typeof data.retryAfterSeconds === 'number' typeof data.retryAfterSeconds === "number"
) { ) {
return `잠시 후 다시 시도해 주세요. 약 ${formatEta(data.retryAfterSeconds)} 뒤에 요청할 수 있습니다.`; return `잠시 후 다시 시도해 주세요. 약 ${formatEta(data.retryAfterSeconds)} 뒤에 요청할 수 있습니다.`;
} }
return error.message; return error.message;
} }
return error instanceof Error ? error.message : '갱신 요청에 실패했습니다.'; return error instanceof Error ? error.message : "갱신 요청에 실패했습니다.";
} }
function ratioClass(value: number) { function ratioClass(value: number) {
if (value >= 55) return 'text-blue-400'; if (value >= 55) return "text-blue-400";
if (value >= 50) return 'text-amber-400'; if (value >= 50) return "text-amber-400";
return 'text-base-content/50'; return "text-base-content/50";
} }
function kdaClass(value: number) { function kdaClass(value: number) {
if (value >= 4) return 'text-amber-400'; if (value >= 4) return "text-amber-400";
if (value >= 3) return 'text-emerald-400'; if (value >= 3) return "text-emerald-400";
return 'text-base-content/60'; return "text-base-content/60";
} }
function FilterButton({ function FilterButton({
@@ -122,8 +119,8 @@ function FilterButton({
onClick={onClick} onClick={onClick}
className={`px-3 py-2 text-[12px] font-semibold border-b-2 transition-colors ${ className={`px-3 py-2 text-[12px] font-semibold border-b-2 transition-colors ${
active active
? 'border-primary text-primary bg-primary/5' ? "border-primary text-primary bg-primary/5"
: 'border-transparent text-base-content/45 hover:text-base-content' : "border-transparent text-base-content/45 hover:text-base-content"
}`} }`}
> >
{children} {children}
@@ -134,15 +131,17 @@ function FilterButton({
function ChampionIcon({ function ChampionIcon({
championId, championId,
manifest, manifest,
size = 'md', size = "md",
}: { }: {
championId: number; championId: number;
manifest: DdragonManifest | null | undefined; manifest: DdragonManifest | null | undefined;
size?: 'sm' | 'md' | 'lg'; size?: "sm" | "md" | "lg";
}) { }) {
const iconUrl = championIconUrl(manifest, championId); const iconUrl = championIconUrl(manifest, championId);
const displayName = championDisplayName(manifest, championId) ?? String(championId); const displayName =
const sizeClass = size === 'lg' ? 'w-12 h-12' : size === 'sm' ? 'w-5 h-5' : 'w-8 h-8'; championDisplayName(manifest, championId) ?? String(championId);
const sizeClass =
size === "lg" ? "w-12 h-12" : size === "sm" ? "w-5 h-5" : "w-8 h-8";
return ( return (
<div className={`${sizeClass} bg-base-content/10 overflow-hidden shrink-0`}> <div className={`${sizeClass} bg-base-content/10 overflow-hidden shrink-0`}>
@@ -175,7 +174,9 @@ function SummaryCard({
<div className="mt-2 text-2xl font-black text-base-content tabular-nums"> <div className="mt-2 text-2xl font-black text-base-content tabular-nums">
{value} {value}
</div> </div>
{sub && <div className="mt-1 text-[11px] text-base-content/40">{sub}</div>} {sub && (
<div className="mt-1 text-[11px] text-base-content/40">{sub}</div>
)}
</div> </div>
); );
} }
@@ -231,23 +232,30 @@ function ChampionStatsTable({
> >
<td className="px-3 py-2.5"> <td className="px-3 py-2.5">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<ChampionIcon championId={row.championId} manifest={manifest} /> <ChampionIcon
championId={row.championId}
manifest={manifest}
/>
<span className="text-[13px] font-bold text-base-content"> <span className="text-[13px] font-bold text-base-content">
{displayName} {displayName}
</span> </span>
</div> </div>
</td> </td>
<td className={`px-3 py-2.5 text-center text-[13px] font-bold ${ratioClass(row.winRate)}`}> <td
className={`px-3 py-2.5 text-center text-[13px] font-bold ${ratioClass(row.winRate)}`}
>
{row.winRate}% {row.winRate}%
</td> </td>
<td className="px-3 py-2.5 text-center text-[12px] tabular-nums"> <td className="px-3 py-2.5 text-center text-[12px] tabular-nums">
{row.games} {row.games}
</td> </td>
<td className="px-3 py-2.5 text-center text-[12px] tabular-nums text-base-content/55"> <td className="px-3 py-2.5 text-center text-[12px] tabular-nums text-base-content/55">
<span className="text-blue-400">{row.wins}</span> /{' '} <span className="text-blue-400">{row.wins}</span> /{" "}
<span className="text-red-400">{row.losses}</span> <span className="text-red-400">{row.losses}</span>
</td> </td>
<td className={`px-3 py-2.5 text-center text-[13px] font-bold tabular-nums ${kdaClass(row.kda)}`}> <td
className={`px-3 py-2.5 text-center text-[13px] font-bold tabular-nums ${kdaClass(row.kda)}`}
>
{row.kda} {row.kda}
</td> </td>
<td className="px-3 py-2.5 text-center text-[12px] tabular-nums"> <td className="px-3 py-2.5 text-center text-[12px] tabular-nums">
@@ -260,7 +268,8 @@ function ChampionStatsTable({
{row.totalAssists} {row.totalAssists}
</td> </td>
<td className="px-3 py-2.5 text-center text-[12px] tabular-nums text-base-content/55"> <td className="px-3 py-2.5 text-center text-[12px] tabular-nums text-base-content/55">
{row.doubleKills}/{row.tripleKills}/{row.quadraKills}/{row.pentaKills} {row.doubleKills}/{row.tripleKills}/{row.quadraKills}/
{row.pentaKills}
</td> </td>
<td className="px-3 py-2.5 text-center text-[12px] tabular-nums"> <td className="px-3 py-2.5 text-center text-[12px] tabular-nums">
{row.avgCs} · {row.avgCsPerMin}/m {row.avgCs} · {row.avgCsPerMin}/m
@@ -270,12 +279,14 @@ function ChampionStatsTable({
type="button" type="button"
className={`text-[11px] px-2 py-1 border ${ className={`text-[11px] px-2 py-1 border ${
selected selected
? 'border-primary/40 bg-primary/10 text-primary' ? "border-primary/40 bg-primary/10 text-primary"
: 'border-base-content/10 text-base-content/40 hover:text-base-content' : "border-base-content/10 text-base-content/40 hover:text-base-content"
}`} }`}
onClick={() => onChampionSelect(selected ? null : row.championId)} onClick={() =>
onChampionSelect(selected ? null : row.championId)
}
> >
{selected ? '해제' : '보기'} {selected ? "해제" : "보기"}
</button> </button>
</td> </td>
</tr> </tr>
@@ -332,7 +343,7 @@ function TeamMini({
{match.teams.map((team) => ( {match.teams.map((team) => (
<div <div
key={`${match.matchId}-${team.side}`} key={`${match.matchId}-${team.side}`}
className={`space-y-0.5 ${team.win ? 'text-base-content/70' : 'text-base-content/35'}`} className={`space-y-0.5 ${team.win ? "text-base-content/70" : "text-base-content/35"}`}
> >
{team.participants.map((participant) => { {team.participants.map((participant) => {
const championName = const championName =
@@ -369,15 +380,17 @@ function RecentMatchCard({
}) { }) {
const championName = const championName =
championDisplayName(manifest, match.championId) ?? String(match.championId); championDisplayName(manifest, match.championId) ?? String(match.championId);
const accent = match.win ? 'border-l-blue-500' : 'border-l-red-500'; const accent = match.win ? "border-l-blue-500" : "border-l-red-500";
const resultClass = match.win ? 'text-blue-400' : 'text-red-400'; const resultClass = match.win ? "text-blue-400" : "text-red-400";
return ( return (
<article className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`}> <article
className={`border border-l-4 ${accent} border-base-content/10 bg-base-100`}
>
<div className="p-4 grid lg:grid-cols-[120px_1fr_120px_1.5fr_32px] gap-4 items-center"> <div className="p-4 grid lg:grid-cols-[120px_1fr_120px_1.5fr_32px] gap-4 items-center">
<div className="text-center lg:text-left"> <div className="text-center lg:text-left">
<div className={`text-[12px] font-black ${resultClass}`}> <div className={`text-[12px] font-black ${resultClass}`}>
{match.remake ? '다시하기' : match.win ? '승리' : '패배'} {match.remake ? "다시하기" : match.win ? "승리" : "패배"}
</div> </div>
<div className="text-[11px] text-base-content/35 mt-1"> <div className="text-[11px] text-base-content/35 mt-1">
{match.queueLabel} {match.queueLabel}
@@ -391,17 +404,22 @@ function RecentMatchCard({
</div> </div>
<div className="flex items-center gap-3 min-w-0"> <div className="flex items-center gap-3 min-w-0">
<ChampionIcon championId={match.championId} manifest={manifest} size="lg" /> <ChampionIcon
championId={match.championId}
manifest={manifest}
size="lg"
/>
<div className="min-w-0"> <div className="min-w-0">
<div className="font-bold text-base-content truncate"> <div className="font-bold text-base-content truncate">
{championName} {championName}
</div> </div>
<div className="text-[11px] text-base-content/35"> <div className="text-[11px] text-base-content/35">
Lv.{match.championLevel} ·{' '} Lv.{match.championLevel} ·{" "}
{(LANE_LABELS[match.teamPosition] ?? match.teamPosition) || '포지션 없음'} {(LANE_LABELS[match.teamPosition] ?? match.teamPosition) ||
"포지션 없음"}
</div> </div>
<div className="mt-1 text-[10px] text-base-content/30"> <div className="mt-1 text-[10px] text-base-content/30">
스펠 {match.summonerSpells.join(' / ')} 스펠 {match.summonerSpells.join(" / ")}
</div> </div>
</div> </div>
</div> </div>
@@ -414,8 +432,10 @@ function RecentMatchCard({
<span className="text-base-content/25"> / </span> <span className="text-base-content/25"> / </span>
<span>{match.assists}</span> <span>{match.assists}</span>
</div> </div>
<div className={`text-[12px] font-bold tabular-nums ${kdaClass(match.kda)}`}> <div
{match.deaths === 0 ? 'Perfect' : `${match.kda} 평점`} className={`text-[12px] font-bold tabular-nums ${kdaClass(match.kda)}`}
>
{match.deaths === 0 ? "Perfect" : `${match.kda} 평점`}
</div> </div>
<div className="mt-1 text-[11px] text-base-content/35"> <div className="mt-1 text-[11px] text-base-content/35">
킬 관여 {match.killParticipation}% 킬 관여 {match.killParticipation}%
@@ -425,15 +445,21 @@ function RecentMatchCard({
<div className="grid sm:grid-cols-[100px_1fr] gap-4 items-center"> <div className="grid sm:grid-cols-[100px_1fr] gap-4 items-center">
<div className="space-y-1 text-[11px] text-base-content/45"> <div className="space-y-1 text-[11px] text-base-content/45">
<div> <div>
CS <span className="font-bold text-base-content/70">{match.totalCs}</span>{' '} CS{" "}
<span className="font-bold text-base-content/70">
{match.totalCs}
</span>{" "}
({match.csPerMin}/m) ({match.csPerMin}/m)
</div> </div>
<div> <div>
시야 <span className="font-bold text-base-content/70">{match.visionScore}</span>{' '} 시야{" "}
<span className="font-bold text-base-content/70">
{match.visionScore}
</span>{" "}
제어와드 {match.controlWardsBought} 제어와드 {match.controlWardsBought}
</div> </div>
<div> <div>
피해량{' '} 피해량{" "}
<span className="font-bold text-base-content/70"> <span className="font-bold text-base-content/70">
{match.damageDealtToChampions.toLocaleString()} {match.damageDealtToChampions.toLocaleString()}
</span> </span>
@@ -446,7 +472,9 @@ function RecentMatchCard({
</div> </div>
<div className="hidden lg:flex justify-end"> <div className="hidden lg:flex justify-end">
<div className={`w-2 h-14 ${match.win ? 'bg-blue-500/70' : 'bg-red-500/70'}`} /> <div
className={`w-2 h-14 ${match.win ? "bg-blue-500/70" : "bg-red-500/70"}`}
/>
</div> </div>
</div> </div>
</article> </article>
@@ -457,26 +485,27 @@ export default function UserHistoryPage() {
const { userId } = useParams(); const { userId } = useParams();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const [championSearch, setChampionSearch] = useState(''); const [championSearch, setChampionSearch] = useState("");
const [sortKey, setSortKey] = useState<ChampionSortKey>('games'); const [sortKey, setSortKey] = useState<ChampionSortKey>("games");
const [refreshResult, setRefreshResult] = const [refreshResult, setRefreshResult] =
useState<ApiEnqueueRefreshResult | null>(null); useState<ApiEnqueueRefreshResult | null>(null);
const [refreshNotice, setRefreshNotice] = useState<string | null>(null); const [refreshNotice, setRefreshNotice] = useState<string | null>(null);
const queueGroupParam = searchParams.get('queueGroup'); const queueGroupParam = searchParams.get("queueGroup");
const rankParam = searchParams.get('rank'); const rankParam = searchParams.get("rank");
const queueGroup: RiotQueueGroup = isRiotQueueGroup(queueGroupParam) const queueGroup: RiotQueueGroup = isRiotQueueGroup(queueGroupParam)
? queueGroupParam ? queueGroupParam
: 'summoners-rift'; : "summoners-rift";
const rank: RiotRankFilter = isRiotRankFilter(rankParam) ? rankParam : 'all'; const rank: RiotRankFilter = isRiotRankFilter(rankParam) ? rankParam : "all";
const championIdParam = Number(searchParams.get('championId')); const championIdParam = Number(searchParams.get("championId"));
const championId = Number.isFinite(championIdParam) && championIdParam > 0 const championId =
? championIdParam Number.isFinite(championIdParam) && championIdParam > 0
: undefined; ? championIdParam
: undefined;
const filters: UserHistoryFilters = { const filters: UserHistoryFilters = {
queueGroup, queueGroup,
rank, rank,
championId, championId,
seasonId: searchParams.get('seasonId') ?? undefined, seasonId: searchParams.get("seasonId") ?? undefined,
}; };
const aggregateFilters: UserHistoryFilters = { const aggregateFilters: UserHistoryFilters = {
queueGroup, queueGroup,
@@ -491,17 +520,21 @@ export default function UserHistoryPage() {
DEFAULT_COMMUNITY_ID, DEFAULT_COMMUNITY_ID,
); );
const summaryQuery = useRecentSummary(userId, filters, DEFAULT_COMMUNITY_ID); const summaryQuery = useRecentSummary(userId, filters, DEFAULT_COMMUNITY_ID);
const recentMatchesQuery = useRecentMatches(userId, filters, DEFAULT_COMMUNITY_ID); const recentMatchesQuery = useRecentMatches(
userId,
filters,
DEFAULT_COMMUNITY_ID,
);
const refreshMutation = useRefreshUserHistory(userId, DEFAULT_COMMUNITY_ID); const refreshMutation = useRefreshUserHistory(userId, DEFAULT_COMMUNITY_ID);
const profile = profileQuery.data; const profile = profileQuery.data;
const primaryTier = const primaryTier =
profile?.tiers.find((tier) => tier.queueType === 'RANKED_SOLO_5x5') ?? profile?.tiers.find((tier) => tier.queueType === "RANKED_SOLO_5x5") ??
profile?.tiers[0]; profile?.tiers[0];
const matches = const matches =
recentMatchesQuery.data?.pages.flatMap((page) => page.matches) ?? []; recentMatchesQuery.data?.pages.flatMap((page) => page.matches) ?? [];
const selectedChampionName = championId const selectedChampionName = championId
? championDisplayName(ddragon, championId) ?? String(championId) ? (championDisplayName(ddragon, championId) ?? String(championId))
: null; : null;
const visibleChampionRows = useMemo(() => { const visibleChampionRows = useMemo(() => {
@@ -511,7 +544,8 @@ export default function UserHistoryPage() {
.filter((row) => { .filter((row) => {
if (!keyword) return true; if (!keyword) return true;
const displayName = const displayName =
championDisplayName(ddragon, row.championId) ?? String(row.championId); championDisplayName(ddragon, row.championId) ??
String(row.championId);
return displayName.toLowerCase().includes(keyword); return displayName.toLowerCase().includes(keyword);
}) })
.sort((left, right) => right[sortKey] - left[sortKey]); .sort((left, right) => right[sortKey] - left[sortKey]);
@@ -523,14 +557,14 @@ export default function UserHistoryPage() {
onEvent: (event: ApiRiotRefreshEvent) => { onEvent: (event: ApiRiotRefreshEvent) => {
if (!profile || event.puuid !== profile.puuid) return; if (!profile || event.puuid !== profile.puuid) return;
void invalidateHistoryQueries(); void invalidateHistoryQueries();
if (event.state === 'completed') { if (event.state === "completed") {
setRefreshNotice('갱신이 완료되어 전적을 다시 불러왔습니다.'); setRefreshNotice("갱신이 완료되어 전적을 다시 불러왔습니다.");
} }
if (event.state === 'failed') { if (event.state === "failed") {
setRefreshNotice( setRefreshNotice(
event.error event.error
? `갱신 실패: ${event.error}` ? `갱신 실패: ${event.error}`
: '갱신에 실패했습니다. 잠시 후 다시 시도해 주세요.', : "갱신에 실패했습니다. 잠시 후 다시 시도해 주세요.",
); );
} }
}, },
@@ -539,7 +573,7 @@ export default function UserHistoryPage() {
function updateSearch(next: Partial<Record<string, string | number | null>>) { function updateSearch(next: Partial<Record<string, string | number | null>>) {
const params = new URLSearchParams(searchParams); const params = new URLSearchParams(searchParams);
for (const [key, value] of Object.entries(next)) { for (const [key, value] of Object.entries(next)) {
if (value === null || value === undefined || value === '') { if (value === null || value === undefined || value === "") {
params.delete(key); params.delete(key);
} else { } else {
params.set(key, String(value)); params.set(key, String(value));
@@ -551,16 +585,20 @@ export default function UserHistoryPage() {
async function invalidateHistoryQueries() { async function invalidateHistoryQueries() {
await Promise.all([ await Promise.all([
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ['user-history-profile', DEFAULT_COMMUNITY_ID, userId ?? null], queryKey: [
"user-history-profile",
DEFAULT_COMMUNITY_ID,
userId ?? null,
],
}), }),
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ['user-champion-stats', DEFAULT_COMMUNITY_ID, userId ?? null], queryKey: ["user-champion-stats", DEFAULT_COMMUNITY_ID, userId ?? null],
}), }),
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ['user-recent-summary', DEFAULT_COMMUNITY_ID, userId ?? null], queryKey: ["user-recent-summary", DEFAULT_COMMUNITY_ID, userId ?? null],
}), }),
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ['user-recent-matches', DEFAULT_COMMUNITY_ID, userId ?? null], queryKey: ["user-recent-matches", DEFAULT_COMMUNITY_ID, userId ?? null],
}), }),
]); ]);
} }
@@ -568,11 +606,13 @@ export default function UserHistoryPage() {
function handleRefresh() { function handleRefresh() {
if (!userId) return; if (!userId) return;
refreshMutation.mutate( refreshMutation.mutate(
{ queueGroups: [queueGroup], priority: 'high' }, { queueGroups: [queueGroup], priority: "high" },
{ {
onSuccess: (result) => { onSuccess: (result) => {
setRefreshResult(result); setRefreshResult(result);
const alreadyQueued = result.subJobs.every((job) => job.alreadyQueued); const alreadyQueued = result.subJobs.every(
(job) => job.alreadyQueued,
);
setRefreshNotice( setRefreshNotice(
alreadyQueued alreadyQueued
? `이미 갱신 작업이 대기 중입니다. 예상 ${formatEta(result.totalEtaSeconds)} 후 반영됩니다.` ? `이미 갱신 작업이 대기 중입니다. 예상 ${formatEta(result.totalEtaSeconds)} 후 반영됩니다.`
@@ -659,9 +699,10 @@ export default function UserHistoryPage() {
</div> </div>
<div className="border border-dashed border-base-content/10 px-3 py-2 text-[11px] text-base-content/35 sm:text-right space-y-2"> <div className="border border-dashed border-base-content/10 px-3 py-2 text-[11px] text-base-content/35 sm:text-right space-y-2">
<div> <div>
이 페이지는 저장된 경기 DB만 조회합니다. {/* 이 페이지는 저장된 경기 DB만 조회합니다. */}
<br /> <br />
Riot API 갱신은 버튼 클릭 시 큐에서 처리합니다. {/* Riot API 갱신은 버튼 클릭 시 큐에서 처리합니다. */}
아래 버튼을 누르면 기록이 갱신됩니다.
</div> </div>
<button <button
type="button" type="button"
@@ -669,7 +710,7 @@ export default function UserHistoryPage() {
disabled={refreshMutation.isPending || !userId} disabled={refreshMutation.isPending || !userId}
onClick={handleRefresh} onClick={handleRefresh}
> >
{refreshMutation.isPending ? '요청 중...' : '현재 탭 갱신'} {refreshMutation.isPending ? "요청 중..." : "정보 갱신"}
</button> </button>
<div className="text-[10px] text-base-content/25"> <div className="text-[10px] text-base-content/25">
갱신 소켓: {refreshSocket.connectionStatus} 갱신 소켓: {refreshSocket.connectionStatus}
@@ -689,7 +730,9 @@ export default function UserHistoryPage() {
<FilterButton <FilterButton
key={tab.value} key={tab.value}
active={queueGroup === tab.value} active={queueGroup === tab.value}
onClick={() => updateSearch({ queueGroup: tab.value, championId: null })} onClick={() =>
updateSearch({ queueGroup: tab.value, championId: null })
}
> >
{tab.label} {tab.label}
</FilterButton> </FilterButton>
@@ -701,7 +744,9 @@ export default function UserHistoryPage() {
<FilterButton <FilterButton
key={tab.value} key={tab.value}
active={rank === tab.value} active={rank === tab.value}
onClick={() => updateSearch({ rank: tab.value, championId: null })} onClick={() =>
updateSearch({ rank: tab.value, championId: null })
}
> >
{tab.label} {tab.label}
</FilterButton> </FilterButton>
@@ -751,19 +796,19 @@ export default function UserHistoryPage() {
/> />
<SummaryCard <SummaryCard
label="최고 평점" label="최고 평점"
value={summaryQuery.data?.bestRating?.rating ?? '-'} value={summaryQuery.data?.bestRating?.rating ?? "-"}
sub={ sub={
summaryQuery.data?.bestRating summaryQuery.data?.bestRating
? `${summaryQuery.data.bestRating.kills}/${summaryQuery.data.bestRating.deaths}/${summaryQuery.data.bestRating.assists}` ? `${summaryQuery.data.bestRating.kills}/${summaryQuery.data.bestRating.deaths}/${summaryQuery.data.bestRating.assists}`
: '기록 없음' : "기록 없음"
} }
/> />
<SummaryCard <SummaryCard
label="연승/연패" label="연승/연패"
value={ value={
summaryQuery.data?.streak summaryQuery.data?.streak
? `${summaryQuery.data.streak.count}${summaryQuery.data.streak.type === 'win' ? '연승' : '연패'}` ? `${summaryQuery.data.streak.count}${summaryQuery.data.streak.type === "win" ? "연승" : "연패"}`
: '-' : "-"
} }
sub="가장 최근 경기 기준" sub="가장 최근 경기 기준"
/> />
@@ -777,7 +822,9 @@ export default function UserHistoryPage() {
type="button" type="button"
key={champion.championId} key={champion.championId}
className="text-center group" className="text-center group"
onClick={() => updateSearch({ championId: champion.championId })} onClick={() =>
updateSearch({ championId: champion.championId })
}
> >
<ChampionIcon <ChampionIcon
championId={champion.championId} championId={champion.championId}
@@ -789,7 +836,9 @@ export default function UserHistoryPage() {
</button> </button>
))} ))}
{(summaryQuery.data?.topChampions ?? []).length === 0 && ( {(summaryQuery.data?.topChampions ?? []).length === 0 && (
<span className="text-[11px] text-base-content/25">기록 없음</span> <span className="text-[11px] text-base-content/25">
기록 없음
</span>
)} )}
</div> </div>
</div> </div>
@@ -799,11 +848,10 @@ export default function UserHistoryPage() {
<section className="mb-6"> <section className="mb-6">
<div className="flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3 mb-3"> <div className="flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3 mb-3">
<div> <div>
<h2 className="text-sm font-bold text-base-content"> <h2 className="text-sm font-bold text-base-content">챔피언 통계</h2>
챔피언 통계
</h2>
<p className="mt-1 text-[11px] text-base-content/35"> <p className="mt-1 text-[11px] text-base-content/35">
저장된 매치 기준으로 집계합니다. Riot API 갱신은 별도 큐 작업으로 분리 예정입니다. 저장된 데이터를 기준으로 집계합니다. 최신 데이터가 반영되지 않을
수 있습니다.
</p> </p>
</div> </div>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
@@ -815,7 +863,9 @@ export default function UserHistoryPage() {
/> />
<select <select
value={sortKey} value={sortKey}
onChange={(event) => setSortKey(event.target.value as ChampionSortKey)} onChange={(event) =>
setSortKey(event.target.value as ChampionSortKey)
}
className="border border-base-content/10 bg-transparent px-3 py-2 text-xs" className="border border-base-content/10 bg-transparent px-3 py-2 text-xs"
> >
{(Object.keys(SORT_LABELS) as ChampionSortKey[]).map((key) => ( {(Object.keys(SORT_LABELS) as ChampionSortKey[]).map((key) => (
@@ -838,11 +888,12 @@ export default function UserHistoryPage() {
<section> <section>
<div className="flex items-center justify-between gap-3 mb-3"> <div className="flex items-center justify-between gap-3 mb-3">
<h2 className="text-sm font-bold text-base-content"> <h2 className="text-sm font-bold text-base-content">매치 히스토리</h2>
매치 히스토리
</h2>
<span className="text-[11px] text-base-content/35"> <span className="text-[11px] text-base-content/35">
최근 저장: {formatLastFetched(recentMatchesQuery.data?.pages[0]?.lastFetchedAt)} 최근 저장:{" "}
{formatLastFetched(
recentMatchesQuery.data?.pages[0]?.lastFetchedAt,
)}
</span> </span>
</div> </div>
@@ -873,7 +924,9 @@ export default function UserHistoryPage() {
disabled={recentMatchesQuery.isFetchingNextPage} disabled={recentMatchesQuery.isFetchingNextPage}
onClick={() => recentMatchesQuery.fetchNextPage()} onClick={() => recentMatchesQuery.fetchNextPage()}
> >
{recentMatchesQuery.isFetchingNextPage ? '불러오는 중...' : '+ 더 보기'} {recentMatchesQuery.isFetchingNextPage
? "불러오는 중..."
: "+ 더 보기"}
</button> </button>
)} )}
</section> </section>