diff --git a/apps/web/src/pages/MatchDetailPage.tsx b/apps/web/src/pages/MatchDetailPage.tsx index cf330b08..9d76a0c2 100644 --- a/apps/web/src/pages/MatchDetailPage.tsx +++ b/apps/web/src/pages/MatchDetailPage.tsx @@ -24,6 +24,7 @@ import { DEFAULT_COMMUNITY_ID, useAuthUserId } from "../config"; import { apiFetch, ApiError } from "../lib/api"; import { profileIconUrl } from "../lib/ddragon"; import { + POSITION_ORDER, positionIcon, positionLabel, sideShortLabel, @@ -52,6 +53,38 @@ type CaptainSelection = { const DEFAULT_AUCTION_MAX_TIMER_SECONDS = 30; const DEFAULT_AUCTION_BID_EXTENSION_SECONDS = 5; const MAX_AUCTION_TIMER_SECONDS = 3600; +const ALL_PARTICIPANT_FILTER = "all"; + +type ParticipantPositionFilter = Position | typeof ALL_PARTICIPANT_FILTER; +type ParticipantTierFilter = string | typeof ALL_PARTICIPANT_FILTER; + +const PARTICIPANT_TIER_FILTERS = [ + "CHALLENGER", + "GRANDMASTER", + "MASTER", + "DIAMOND", + "EMERALD", + "PLATINUM", + "GOLD", + "SILVER", + "BRONZE", + "IRON", + "UNRANKED", +] as const; + +const PARTICIPANT_TIER_LABELS: Record = { + CHALLENGER: "챌린저", + GRANDMASTER: "그랜드마스터", + MASTER: "마스터", + DIAMOND: "다이아몬드", + EMERALD: "에메랄드", + PLATINUM: "플래티넘", + GOLD: "골드", + SILVER: "실버", + BRONZE: "브론즈", + IRON: "아이언", + UNRANKED: "언랭크", +}; function captainSlotKey(slot: CaptainSelectionSlot) { return String(slot.teamIndex); @@ -270,6 +303,19 @@ function statusBadge(status: MatchDetailView["status"]) { } } +function participantTierFilterValue(participant: ParticipantView) { + return participant.tier?.tier ?? "UNRANKED"; +} + +// PARTICIPANT_TIER_FILTERS는 높은 티어 → 낮은 티어 순서이므로 +// 인덱스가 작을수록 상위 티어. (없는 값은 최하위로 취급) +function tierRank(tier: string) { + const index = PARTICIPANT_TIER_FILTERS.indexOf( + tier as (typeof PARTICIPANT_TIER_FILTERS)[number], + ); + return index === -1 ? PARTICIPANT_TIER_FILTERS.length : index; +} + function ParticipantRow({ participant, index, @@ -353,6 +399,47 @@ function ParticipantTable({ onJoin: () => void; isJoining: boolean; }) { + const [positionFilter, setPositionFilter] = + useState(ALL_PARTICIPANT_FILTER); + const [tierFilter, setTierFilter] = useState( + ALL_PARTICIPANT_FILTER, + ); + const filteredParticipants = participants.filter((participant) => { + const matchesPosition = + positionFilter === ALL_PARTICIPANT_FILTER || + participant.mainPosition === positionFilter; + const matchesTier = + tierFilter === ALL_PARTICIPANT_FILTER || + tierRank(participantTierFilterValue(participant)) <= tierRank(tierFilter); + + return matchesPosition && matchesTier; + }); + const isFiltered = + positionFilter !== ALL_PARTICIPANT_FILTER || + tierFilter !== ALL_PARTICIPANT_FILTER; + const positionFilteredParticipants = participants.filter( + (participant) => + positionFilter === ALL_PARTICIPANT_FILTER || + participant.mainPosition === positionFilter, + ); + // "이상" 임계값으로 쓸 수 있는 티어 = 참가자 중 실제 존재하는 티어. + // 언랭크는 "이상" 기준으로 전체와 동일하므로 임계값 후보에서 제외한다. + const presentTiers = new Set( + positionFilteredParticipants.map(participantTierFilterValue), + ); + const availableTiers = PARTICIPANT_TIER_FILTERS.filter( + (tier) => tier !== "UNRANKED" && presentTiers.has(tier), + ); + const tierAtOrAboveCounts = new Map( + availableTiers.map((tier) => [ + tier, + positionFilteredParticipants.filter( + (participant) => + tierRank(participantTierFilterValue(participant)) <= tierRank(tier), + ).length, + ]), + ); + return (
@@ -368,6 +455,84 @@ function ParticipantTable({ {joined ? "참가 완료" : isJoining ? "신청 중..." : "참가 신청"}
+
+
+
+ + {POSITION_ORDER.map((position) => { + const active = positionFilter === position; + return ( + + ); + })} +
+ +
+ + {filteredParticipants.length}/{participants.length}명 + + {isFiltered && ( + + )} +
+
+
@@ -380,13 +545,24 @@ function ParticipantTable({ - {participants.map((participant, index) => ( - - ))} + {filteredParticipants.length > 0 ? ( + filteredParticipants.map((participant, index) => ( + + )) + ) : ( + + + + )}
+ 조건에 맞는 참가자가 없습니다. +