|
|
|
@@ -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<string, string> = {
|
|
|
|
|
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<ParticipantPositionFilter>(ALL_PARTICIPANT_FILTER);
|
|
|
|
|
const [tierFilter, setTierFilter] = useState<ParticipantTierFilter>(
|
|
|
|
|
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<string, number>(
|
|
|
|
|
availableTiers.map((tier) => [
|
|
|
|
|
tier,
|
|
|
|
|
positionFilteredParticipants.filter(
|
|
|
|
|
(participant) =>
|
|
|
|
|
tierRank(participantTierFilterValue(participant)) <= tierRank(tier),
|
|
|
|
|
).length,
|
|
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="border border-base-content/10 bg-base-100 overflow-hidden">
|
|
|
|
|
<div className="px-4 py-2.5 border-b border-base-content/10 bg-base-200/40 flex items-center justify-between gap-3">
|
|
|
|
@@ -368,6 +455,84 @@ function ParticipantTable({
|
|
|
|
|
{joined ? "참가 완료" : isJoining ? "신청 중..." : "참가 신청"}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="border-b border-base-content/10 bg-base-100 px-4 py-2.5">
|
|
|
|
|
<div className="flex flex-wrap items-center gap-x-3 gap-y-2">
|
|
|
|
|
<div className="inline-flex items-center gap-1">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setPositionFilter(ALL_PARTICIPANT_FILTER)}
|
|
|
|
|
className={`inline-flex h-8 items-center px-2.5 text-[11px] font-semibold border transition-colors ${
|
|
|
|
|
positionFilter === ALL_PARTICIPANT_FILTER
|
|
|
|
|
? "border-primary/30 bg-primary/5 text-primary"
|
|
|
|
|
: "border-base-content/10 text-base-content/40 hover:text-base-content/70"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
전체
|
|
|
|
|
</button>
|
|
|
|
|
{POSITION_ORDER.map((position) => {
|
|
|
|
|
const active = positionFilter === position;
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
key={position}
|
|
|
|
|
type="button"
|
|
|
|
|
title={positionLabel[position]}
|
|
|
|
|
aria-label={positionLabel[position]}
|
|
|
|
|
aria-pressed={active}
|
|
|
|
|
onClick={() =>
|
|
|
|
|
setPositionFilter(
|
|
|
|
|
active ? ALL_PARTICIPANT_FILTER : position,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
className={`inline-flex h-8 items-center gap-1 px-2 text-[11px] font-semibold border transition-colors ${
|
|
|
|
|
active
|
|
|
|
|
? "border-primary/30 bg-primary/5 text-primary"
|
|
|
|
|
: "border-base-content/10 text-base-content/40 hover:text-base-content/70"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={positionIcon[position]}
|
|
|
|
|
alt=""
|
|
|
|
|
className="h-3.5 w-3.5 object-contain"
|
|
|
|
|
/>
|
|
|
|
|
<span className="hidden sm:inline">
|
|
|
|
|
{positionLabel[position]}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
<select
|
|
|
|
|
className="h-8 border border-base-content/10 bg-base-100 px-2 text-xs text-base-content focus:border-primary/30 focus:outline-none"
|
|
|
|
|
value={tierFilter}
|
|
|
|
|
onChange={(event) => setTierFilter(event.target.value)}
|
|
|
|
|
>
|
|
|
|
|
<option value={ALL_PARTICIPANT_FILTER}>티어 전체</option>
|
|
|
|
|
{availableTiers.map((tier) => (
|
|
|
|
|
<option key={tier} value={tier}>
|
|
|
|
|
{PARTICIPANT_TIER_LABELS[tier]} 이상 (
|
|
|
|
|
{tierAtOrAboveCounts.get(tier)})
|
|
|
|
|
</option>
|
|
|
|
|
))}
|
|
|
|
|
</select>
|
|
|
|
|
<div className="ml-auto flex items-center gap-2 text-[11px] text-base-content/35">
|
|
|
|
|
<span>
|
|
|
|
|
{filteredParticipants.length}/{participants.length}명
|
|
|
|
|
</span>
|
|
|
|
|
{isFiltered && (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-ghost btn-xs h-8 min-h-8 px-2 text-[11px] text-base-content/40"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setPositionFilter(ALL_PARTICIPANT_FILTER);
|
|
|
|
|
setTierFilter(ALL_PARTICIPANT_FILTER);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
초기화
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="overflow-x-auto">
|
|
|
|
|
<table className="w-full text-left">
|
|
|
|
|
<thead>
|
|
|
|
@@ -380,13 +545,24 @@ function ParticipantTable({
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{participants.map((participant, index) => (
|
|
|
|
|
<ParticipantRow
|
|
|
|
|
key={participant.id}
|
|
|
|
|
participant={participant}
|
|
|
|
|
index={index}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
{filteredParticipants.length > 0 ? (
|
|
|
|
|
filteredParticipants.map((participant, index) => (
|
|
|
|
|
<ParticipantRow
|
|
|
|
|
key={participant.id}
|
|
|
|
|
participant={participant}
|
|
|
|
|
index={index}
|
|
|
|
|
/>
|
|
|
|
|
))
|
|
|
|
|
) : (
|
|
|
|
|
<tr>
|
|
|
|
|
<td
|
|
|
|
|
colSpan={5}
|
|
|
|
|
className="px-3 py-8 text-center text-sm text-base-content/35"
|
|
|
|
|
>
|
|
|
|
|
조건에 맞는 참가자가 없습니다.
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
)}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|