This commit is contained in:
dahyeon committed 2026-05-02 14:16:00 -07:00
1 parent 3607e3a99c
commit 905e72fbed
13 files changed
+389 -40

No files matched your search

+220 -31
View File
@@ -8,11 +8,11 @@ import {
useMe,
usePollTournamentResult,
useTournamentCodeStats,
useUserHistoryProfile,
} from '../api/hooks';
import {
buildDefaultPreferredPositions,
formatTierLabel,
getTierColorToken,
mapApiMatchToMatchDetail,
type MatchDetailView,
type ParticipantView,
@@ -31,6 +31,7 @@ import {
import type {
AuctionTopTierThreshold,
ApiMatchParticipant,
ApiTierInfo,
Position,
TeamSide,
TournamentCodeSlotView,
@@ -40,10 +41,24 @@ type CaptainSelectionSlot = {
teamIndex: number;
};
type CaptainSelection = {
userId: string;
initialPoints: string;
};
function captainSlotKey(slot: CaptainSelectionSlot) {
return String(slot.teamIndex);
}
function parseInitialPointsInput(value: string) {
if (!value.trim()) return null;
const points = Number(value);
if (!Number.isInteger(points) || points < 100 || points > 100000) {
return null;
}
return points;
}
function buildAuctionParticipantPool(participants: ApiMatchParticipant[]) {
const ordered = [...participants].sort(
(left, right) =>
@@ -81,25 +96,120 @@ function PosBadge({ pos, sub }: { pos: Position; sub?: boolean }) {
);
}
function TierCell({ participant }: { participant: ParticipantView }) {
if (!participant.tier) {
return (
<div className="text-[11px] text-base-content/25 whitespace-nowrap">
티어 정보 없음
</div>
);
function tierByQueue(tiers: ApiTierInfo[], queueType: string) {
return tiers.find((tier) => tier.queueType === queueType);
}
function normalizeRank(rank: string | undefined) {
switch (rank) {
case 'I':
return '1';
case 'II':
return '2';
case 'III':
return '3';
case 'IV':
return '4';
default:
return rank;
}
}
function formatRankTooltip(tier: ApiTierInfo | undefined) {
if (!tier) return '언랭크';
const highTier = ['MASTER', 'GRANDMASTER', 'CHALLENGER'].includes(tier.tier);
const normalizedTier = {
...tier,
rank: normalizeRank(tier.rank) ?? tier.rank,
};
const label = highTier
? formatTierLabel({ ...normalizedTier, leaguePoints: 0 })
: formatTierLabel(normalizedTier);
return `${label} - ${tier.leaguePoints}LP`;
}
function formatRankBadge(tier: ApiTierInfo | undefined) {
if (!tier) return 'U';
const tierInitial =
tier.tier === 'GRANDMASTER' ? 'GM' : tier.tier.slice(0, 1);
const rank = normalizeRank(tier.rank);
return rank ? `${tierInitial}${rank}` : tierInitial;
}
function rankBadgeClass(tier: ApiTierInfo | undefined) {
switch (tier?.tier) {
case 'CHALLENGER':
return 'border-amber-500/60 bg-amber-100 text-amber-900 dark:border-amber-400/40 dark:bg-amber-400/20 dark:text-amber-200';
case 'GRANDMASTER':
return 'border-red-500/60 bg-red-100 text-red-800 dark:border-red-400/40 dark:bg-red-400/20 dark:text-red-200';
case 'MASTER':
return 'border-fuchsia-500/60 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-400/40 dark:bg-fuchsia-400/20 dark:text-fuchsia-200';
case 'DIAMOND':
return 'border-cyan-500/60 bg-cyan-100 text-cyan-800 dark:border-cyan-400/40 dark:bg-cyan-400/20 dark:text-cyan-200';
case 'EMERALD':
return 'border-emerald-500/60 bg-emerald-100 text-emerald-800 dark:border-emerald-400/40 dark:bg-emerald-400/20 dark:text-emerald-200';
case 'PLATINUM':
return 'border-teal-500/60 bg-teal-100 text-teal-800 dark:border-teal-400/40 dark:bg-teal-400/20 dark:text-teal-200';
case 'GOLD':
return 'border-amber-500/70 bg-amber-100 text-amber-900 dark:border-yellow-400/40 dark:bg-yellow-400/20 dark:text-yellow-200';
case 'SILVER':
return 'border-slate-400/60 bg-slate-100 text-slate-700 dark:border-slate-300/40 dark:bg-slate-300/15 dark:text-slate-200';
case 'BRONZE':
return 'border-orange-600/60 bg-orange-100 text-orange-800 dark:border-orange-500/40 dark:bg-orange-500/20 dark:text-orange-200';
case 'IRON':
return 'border-stone-500/60 bg-stone-100 text-stone-700 dark:border-stone-400/40 dark:bg-stone-400/15 dark:text-stone-300';
default:
return 'border-base-content/30 bg-transparent text-base-content/50';
}
}
function RankBadge({ tier }: { tier?: ApiTierInfo }) {
const tooltip = formatRankTooltip(tier);
return (
<div className="flex items-center gap-1.5 text-[11px] whitespace-nowrap">
<span className={`font-bold ${getTierColorToken(participant.tier)}`}>
{formatTierLabel(participant.tier)}
<span className="tooltip tooltip-left" data-tip={tooltip}>
<span
className={`inline-flex h-[17px] min-w-[18px] shrink-0 items-center justify-center whitespace-nowrap rounded-[3px] border px-1 text-[10px] font-black leading-none ${rankBadgeClass(tier)}`}
aria-label={tooltip}
>
{formatRankBadge(tier)}
</span>
{participant.tier.leaguePoints > 0 && (
<span className="text-base-content/25">
{participant.tier.leaguePoints}LP
</span>
)}
</span>
);
}
function QueueRankCell({
label,
tier,
}: {
label: 'SOLO' | 'FLEX';
tier?: ApiTierInfo;
}) {
return (
<span className="inline-flex items-center gap-1">
<span>{label}</span>
<RankBadge tier={tier} />
</span>
);
}
function TierCell({ participant }: { participant: ParticipantView }) {
const profileQuery = useUserHistoryProfile(
participant.userId,
DEFAULT_COMMUNITY_ID,
);
const tiers = profileQuery.data?.tiers ?? [];
const soloTier =
tierByQueue(tiers, 'RANKED_SOLO_5x5') ??
(participant.tier?.queueType === 'RANKED_SOLO_5x5'
? participant.tier
: undefined);
const flexTier = tierByQueue(tiers, 'RANKED_FLEX_SR');
return (
<div className="flex items-center gap-2 text-[10px] font-black text-base-content/35 whitespace-nowrap">
<QueueRankCell label="SOLO" tier={soloTier} />
<QueueRankCell label="FLEX" tier={flexTier} />
</div>
);
}
@@ -841,10 +951,11 @@ export default function MatchDetailPage() {
const canUseMemberActions = Boolean(currentUser || authUserId);
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
const [captainSelections, setCaptainSelections] = useState<
Record<string, { userId: string; initialPoints: number }>
Record<string, CaptainSelection>
>({});
const [topTierThreshold, setTopTierThreshold] =
useState<AuctionTopTierThreshold>('NONE');
const [manualTopTierUserIds, setManualTopTierUserIds] = useState<string[]>([]);
const pollTournamentResultMutation = usePollTournamentResult(
DEFAULT_COMMUNITY_ID,
);
@@ -882,11 +993,15 @@ export default function MatchDetailPage() {
teamIndex: slot.teamIndex,
userId: captainSelections[captainSlotKey(slot)]?.userId,
initialPoints:
captainSelections[captainSlotKey(slot)]?.initialPoints ?? 1000,
parseInitialPointsInput(
captainSelections[captainSlotKey(slot)]?.initialPoints ?? '',
) ?? 1000,
}),
),
initialPoints: 1000,
topTierThreshold,
manualTopTierUserIds:
topTierThreshold === 'MANUAL' ? selectedManualTopTierUserIds : [],
maxTimerSeconds: 30,
}),
}),
@@ -925,7 +1040,7 @@ export default function MatchDetailPage() {
}
setCaptainSelections((current) => {
const next: Record<string, { userId: string; initialPoints: number }> = {};
const next: Record<string, CaptainSelection> = {};
const usedUserIds = new Set<string>();
for (const slot of slots) {
@@ -940,7 +1055,7 @@ export default function MatchDetailPage() {
if (currentIsValid) {
next[key] = {
userId: currentUserId,
initialPoints: currentSelection?.initialPoints ?? 1000,
initialPoints: currentSelection?.initialPoints ?? '1000',
};
usedUserIds.add(currentUserId);
continue;
@@ -951,7 +1066,7 @@ export default function MatchDetailPage() {
);
next[key] = {
userId: fallback?.userId ?? '',
initialPoints: currentSelection?.initialPoints ?? 1000,
initialPoints: currentSelection?.initialPoints ?? '1000',
};
if (fallback) usedUserIds.add(fallback.userId);
}
@@ -1008,6 +1123,22 @@ export default function MatchDetailPage() {
const hasUniqueCaptainSelections =
selectedCaptainIds.length === captainSlots.length &&
new Set(selectedCaptainIds).size === selectedCaptainIds.length;
const hasValidCaptainInitialPoints = captainSlots.every((slot) =>
Boolean(
parseInitialPointsInput(
captainSelections[captainSlotKey(slot)]?.initialPoints ?? '',
),
),
);
const manualPriorityCandidates = auctionParticipantPool.filter(
(participant) => !selectedCaptainIds.includes(participant.userId),
);
const manualPriorityCandidateIds = new Set(
manualPriorityCandidates.map((participant) => participant.userId),
);
const selectedManualTopTierUserIds = manualTopTierUserIds.filter((userId) =>
manualPriorityCandidateIds.has(userId),
);
const waitingParticipantCount =
matchQuery.data.participants.length - auctionParticipantPool.length;
const canStartAuction =
@@ -1015,7 +1146,8 @@ export default function MatchDetailPage() {
match.status === 'recruiting' &&
auctionParticipantPool.length >= 10 &&
auctionNotStarted &&
hasUniqueCaptainSelections;
hasUniqueCaptainSelections &&
hasValidCaptainInitialPoints;
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-6">
@@ -1151,7 +1283,7 @@ export default function MatchDetailPage() {
[key]: {
userId: event.target.value,
initialPoints:
current[key]?.initialPoints ?? 1000,
current[key]?.initialPoints ?? '1000',
},
}))
}
@@ -1180,22 +1312,31 @@ export default function MatchDetailPage() {
max={100000}
step={50}
className="w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm tabular-nums"
value={currentSelection?.initialPoints ?? 1000}
value={currentSelection?.initialPoints ?? '1000'}
onChange={(event) =>
setCaptainSelections((current) => ({
...current,
[key]: {
userId: current[key]?.userId ?? '',
initialPoints: Math.min(
100000,
Math.max(
100,
Number(event.target.value) || 100,
),
),
initialPoints: event.target.value,
},
}))
}
onBlur={() =>
setCaptainSelections((current) => {
const points = parseInitialPointsInput(
current[key]?.initialPoints ?? '',
);
if (points !== null) return current;
return {
...current,
[key]: {
userId: current[key]?.userId ?? '',
initialPoints: '1000',
},
};
})
}
/>
</div>
</label>
@@ -1222,8 +1363,56 @@ export default function MatchDetailPage() {
<option value="EMERALD">EMERALD+</option>
<option value="DIAMOND">DIAMOND+</option>
<option value="MASTER">MASTER+</option>
<option value="MANUAL">수동 선택</option>
</select>
</label>
{topTierThreshold === 'MANUAL' && (
<div className="border border-base-content/10 bg-base-200/20 p-3">
<div className="mb-2 text-[11px] font-bold uppercase tracking-wider text-base-content/35">
우선 등장 선수
</div>
<div className="max-h-48 overflow-y-auto space-y-1">
{manualPriorityCandidates.map((participant) => {
const checked = selectedManualTopTierUserIds.includes(
participant.userId,
);
return (
<label
key={participant.userId}
className="flex cursor-pointer items-center justify-between gap-3 border border-base-content/8 px-2 py-1.5 text-xs text-base-content/55 transition-colors hover:border-primary/25 hover:bg-primary/5"
>
<span className="min-w-0 truncate">
{participant.gameName ?? participant.userId}
<span className="ml-1 text-base-content/25">
#{participant.tagLine ?? '----'}
</span>
</span>
<input
type="checkbox"
className="checkbox checkbox-primary checkbox-xs"
checked={checked}
onChange={(event) =>
setManualTopTierUserIds((current) =>
event.target.checked
? [...new Set([...current, participant.userId])]
: current.filter(
(userId) =>
userId !== participant.userId,
),
)
}
/>
</label>
);
})}
{manualPriorityCandidates.length === 0 && (
<div className="border border-dashed border-base-content/10 px-3 py-4 text-xs text-base-content/35">
팀장을 제외한 우선 등장 후보가 없습니다.
</div>
)}
</div>
</div>
)}
<div className="sm:col-span-2 flex items-center gap-3">
<button
type="button"
+99 -8
View File
@@ -12,10 +12,10 @@ import {
type UserHistoryFilters,
} from "../api/hooks";
import { useRiotRefreshSocket } from "../api/useRiotRefreshSocket";
import { formatTierLabel, getTierColorToken } from "../api/mappers";
import type {
ApiChampionStatsRow,
ApiEnqueueRefreshResult,
ApiTierInfo,
ApiRiotRefreshEvent,
ApiRecentMatchView,
DdragonManifest,
@@ -47,6 +47,103 @@ const SORT_LABELS: Record<ChampionSortKey, string> = {
avgCsPerMin: "분당 CS",
};
const TIER_NAMES: Record<string, string> = {
IRON: "아이언",
BRONZE: "브론즈",
SILVER: "실버",
GOLD: "골드",
PLATINUM: "플래티넘",
EMERALD: "에메랄드",
DIAMOND: "다이아몬드",
MASTER: "마스터",
GRANDMASTER: "그랜드마스터",
CHALLENGER: "챌린저",
};
function normalizeRank(rank: string | undefined) {
switch (rank) {
case "I":
return "1";
case "II":
return "2";
case "III":
return "3";
case "IV":
return "4";
default:
return rank;
}
}
function formatRankBadge(tier: ApiTierInfo | undefined) {
if (!tier) return "U";
const tierInitial =
tier.tier === "GRANDMASTER" ? "GM" : tier.tier.slice(0, 1);
const rank = normalizeRank(tier.rank);
return rank ? `${tierInitial}${rank}` : tierInitial;
}
function formatRankDetail(tier: ApiTierInfo | undefined) {
if (!tier) return "랭크 정보 없음";
const tierName = TIER_NAMES[tier.tier] ?? tier.tier;
const rank = normalizeRank(tier.rank);
const label = rank ? `${tierName} ${rank}` : tierName;
return `${label} - ${tier.leaguePoints} LP`;
}
function rankBadgeClass(tier: ApiTierInfo | undefined) {
switch (tier?.tier) {
case "CHALLENGER":
return "border-amber-500/60 bg-amber-100 text-amber-900 dark:border-amber-400/40 dark:bg-amber-400/20 dark:text-amber-200";
case "GRANDMASTER":
return "border-red-500/60 bg-red-100 text-red-800 dark:border-red-400/40 dark:bg-red-400/20 dark:text-red-200";
case "MASTER":
return "border-fuchsia-500/60 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-400/40 dark:bg-fuchsia-400/20 dark:text-fuchsia-200";
case "DIAMOND":
return "border-cyan-500/60 bg-cyan-100 text-cyan-800 dark:border-cyan-400/40 dark:bg-cyan-400/20 dark:text-cyan-200";
case "EMERALD":
return "border-emerald-500/60 bg-emerald-100 text-emerald-800 dark:border-emerald-400/40 dark:bg-emerald-400/20 dark:text-emerald-200";
case "PLATINUM":
return "border-teal-500/60 bg-teal-100 text-teal-800 dark:border-teal-400/40 dark:bg-teal-400/20 dark:text-teal-200";
case "GOLD":
return "border-amber-500/70 bg-amber-100 text-amber-900 dark:border-yellow-400/40 dark:bg-yellow-400/20 dark:text-yellow-200";
case "SILVER":
return "border-slate-400/60 bg-slate-100 text-slate-700 dark:border-slate-300/40 dark:bg-slate-300/15 dark:text-slate-200";
case "BRONZE":
return "border-orange-600/60 bg-orange-100 text-orange-800 dark:border-orange-500/40 dark:bg-orange-500/20 dark:text-orange-200";
case "IRON":
return "border-stone-500/60 bg-stone-100 text-stone-700 dark:border-stone-400/40 dark:bg-stone-400/15 dark:text-stone-300";
default:
return "border-base-content/30 bg-transparent text-base-content/50";
}
}
function RankBadge({ tier }: { tier?: ApiTierInfo }) {
const tooltip = formatRankDetail(tier);
return (
<span className="tooltip tooltip-bottom" data-tip={tooltip}>
<span
className={`inline-flex h-[18px] min-w-[20px] shrink-0 items-center justify-center whitespace-nowrap rounded-[3px] border px-1 text-[10px] font-black leading-none ${rankBadgeClass(tier)}`}
aria-label={tooltip}
>
{formatRankBadge(tier)}
</span>
</span>
);
}
function ResponsiveTierLabel({ tier }: { tier?: ApiTierInfo }) {
return (
<span className="inline-flex items-center gap-1.5 whitespace-nowrap">
<RankBadge tier={tier} />
<span className="hidden font-bold text-base-content/55 sm:inline">
{formatRankDetail(tier)}
</span>
</span>
);
}
function formatDuration(seconds: number) {
const minutes = Math.floor(seconds / 60);
const rest = seconds % 60;
@@ -749,13 +846,7 @@ export default function UserHistoryPage() {
</div>
<div className="mt-2 flex flex-wrap items-center gap-3 text-xs text-base-content/40">
<span>Lv.{profile.summonerLevel}</span>
{primaryTier ? (
<span className={`font-bold ${getTierColorToken(primaryTier)}`}>
{formatTierLabel(primaryTier)} {primaryTier.leaguePoints}LP
</span>
) : (
<span>랭크 정보 없음</span>
)}
<ResponsiveTierLabel tier={primaryTier} />
<span>시즌: {profile.season.label}</span>
<span>최근 저장: {formatLastFetched(profile.lastFetchedAt)}</span>
</div>