diff --git a/apps/web/src/pages/AuctionPage.tsx b/apps/web/src/pages/AuctionPage.tsx index 0478e23f..abde6f8c 100644 --- a/apps/web/src/pages/AuctionPage.tsx +++ b/apps/web/src/pages/AuctionPage.tsx @@ -11,6 +11,7 @@ import { } from '../api/hooks'; import { mapApiAuctionToAuctionState, + type AuctionPlayerView, type AuctionStateView, } from '../api/mappers'; import { useAuctionSocket } from '../api/useAuctionSocket'; @@ -859,7 +860,7 @@ export default function AuctionPage() { ) : null; return ( -
+
)} -
+
+ +
{auctionState.teams.map((team) => ( )}
+ +
); } + +type PoolTab = 'waiting' | 'passed'; + +// 풀 리스트는 경매 등장 순서를 노출하면 안 되므로 게임명 알파벳 순으로 독립 정렬한다. +const POOL_COLLATOR = new Intl.Collator(['ko', 'en'], { sensitivity: 'base' }); + +function comparePoolPlayers(a: AuctionPlayerView, b: AuctionPlayerView) { + return POOL_COLLATOR.compare(a.summonerName, b.summonerName); +} + +function PoolPanel({ state }: { state: AuctionStateView }) { + const { data: ddragon } = useDdragonManifest(); + const [tab, setTab] = useState('waiting'); + + const { waitingPool, passedPool } = useMemo(() => { + const captainIds = new Set(state.teams.map((team) => team.captainUserId)); + const memberIds = new Set( + state.teams.flatMap((team) => + team.members.map((member) => member.userId), + ), + ); + const passedIds = new Set( + state.passedQueue.map((player) => player.userId), + ); + const currentId = state.currentPlayer?.userId; + + const startIndex = + state.phase === 'complete' ? state.totalPlayers : state.currentPlayerIndex + 1; + + const waiting = state.auctionOrder + .slice(startIndex) + .filter( + (player) => + !captainIds.has(player.userId) && + !memberIds.has(player.userId) && + !passedIds.has(player.userId) && + player.userId !== currentId, + ) + .sort(comparePoolPlayers); + + const passed = [...state.passedQueue].sort(comparePoolPlayers); + + return { waitingPool: waiting, passedPool: passed }; + }, [state]); + + const activePool = tab === 'waiting' ? waitingPool : passedPool; + + return ( +
+
+ setTab('waiting')} + /> + setTab('passed')} + /> +
+ +
+ {activePool.length === 0 ? ( +
+ {tab === 'waiting' + ? '대기 중인 유저가 없습니다' + : '유찰된 유저가 없습니다'} +
+ ) : ( +
    + {activePool.map((player) => ( + + ))} +
+ )} +
+
+ ); +} + +function PoolTabButton({ + label, + count, + active, + onClick, +}: { + label: string; + count: number; + active: boolean; + onClick: () => void; +}) { + return ( + + ); +} + +function PoolListItem({ + player, + ddragon, + showPassCount, +}: { + player: AuctionPlayerView; + ddragon: ReturnType['data']; + showPassCount: boolean; +}) { + return ( +
  • + +
    + + {player.summonerName} + + + {showPassCount && player.passCount > 0 ? ( + + {player.passCount}회 유찰 + + ) : null} +
    +
  • + ); +} + +function ChatPanel({ matchId: _matchId }: { matchId: string }) { + return ( +
    +
    +
    + 채팅 +
    + + 곧 활성화됩니다 + +
    + +
    + 아직 메시지가 없습니다 +
    + +
    +