This commit is contained in:
dahyeon committed 2026-05-02 11:51:01 -07:00
1 parent fedca82c81
commit 3607e3a99c
13 files changed
+1838 -793

No files matched your search

+37
View File
@@ -10,6 +10,7 @@ import {
} from '../lib/auth/msal.config';
import type {
ApiAuction,
ApiAuctionHistoryEntry,
ApiChampionStatsResponse,
ApiCommunity,
ApiEnqueueRefreshResult,
@@ -133,6 +134,42 @@ export function useAuction(
});
}
export function useAuctionHistory(
matchId: string | undefined,
communityId = DEFAULT_COMMUNITY_ID,
options: { enabled?: boolean; refetchInterval?: number | false } = {},
) {
return useQuery({
queryKey: ['auction-history', communityId, matchId ?? null],
queryFn: () =>
apiFetch<ApiAuctionHistoryEntry[]>(
`/communities/${communityId}/matches/${matchId}/auction/history`,
),
enabled: Boolean(communityId && matchId && (options.enabled ?? true)),
retry: false,
refetchInterval: options.refetchInterval,
});
}
export function useUndoAuction(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: ({
matchId,
sequence,
}: {
matchId: string;
sequence: number;
}) =>
apiFetch<ApiAuction>(
`/communities/${communityId}/matches/${matchId}/auction/undo`,
{
method: 'POST',
body: JSON.stringify({ sequence }),
},
),
});
}
export function useCreateMatch(communityId = DEFAULT_COMMUNITY_ID) {
return useMutation({
mutationFn: (body: MatchMutationRequest) =>
+9
View File
@@ -85,6 +85,7 @@ export interface MatchDetailView {
}
export interface AuctionPlayerView extends ParticipantView {
passCount: number;
masteries: {
championId: number;
level: number;
@@ -118,6 +119,8 @@ export interface AuctionStateView {
currentPlayerIndex: number;
totalPlayers: number;
auctionOrder: AuctionPlayerView[];
passedQueue: AuctionPlayerView[];
auctionRound: number;
bids: {
teamIndex: number;
amount: number;
@@ -235,6 +238,7 @@ function mapAuctionPlayerToView(
mainPosition,
subPosition,
profileIconId: player.profileIconId,
passCount: player.passCount ?? 0,
masteries: player.masteries.slice(0, 5).map((mastery) => ({
championId: mastery.championId,
level: mastery.championLevel,
@@ -281,11 +285,13 @@ function mapAuctionTeamToView(
(participant
? {
...participant,
passCount: 0,
masteries: [],
recentStats: createEmptyRecentStatsView(),
}
: {
...createFallbackParticipant(member.userId),
passCount: 0,
masteries: [],
recentStats: createEmptyRecentStatsView(),
});
@@ -464,6 +470,7 @@ export function mapApiAuctionToAuctionState(
.map((participant) => [participant.userId, participant]),
);
const auctionOrder = auction.order.map(mapAuctionPlayerToView);
const passedQueue = (auction.passedQueue ?? []).map(mapAuctionPlayerToView);
const auctionPlayerLookup = new Map(
auctionOrder.map((player) => [player.userId, player]),
);
@@ -499,6 +506,8 @@ export function mapApiAuctionToAuctionState(
currentPlayerIndex,
totalPlayers,
auctionOrder,
passedQueue,
auctionRound: auction.auctionRound ?? 1,
bids: auction.bids.map((bid) => ({
teamIndex: bid.teamIndex,
amount: bid.amount,
+24
View File
@@ -12,7 +12,13 @@ export type AuctionPhase =
| 'presenting'
| 'bidding'
| 'sold'
| 'passed'
| 'complete';
export type AuctionTopTierThreshold =
| 'NONE'
| 'EMERALD'
| 'DIAMOND'
| 'MASTER';
export type CommunityRole = 'owner' | 'admin' | 'member';
export interface ApiPositionPreference {
@@ -226,6 +232,7 @@ export interface ApiAuctionPlayerSnapshot {
tiers: ApiTierInfo[];
masteries: ApiChampionMasteryEntry[];
recentStatsSummary?: ApiRiotRecentStatsSummary;
passCount: number;
}
export interface ApiAuctionTeamMember {
@@ -254,6 +261,8 @@ export interface ApiAuction {
phase: AuctionPhase;
teams: ApiAuctionTeam[];
order: ApiAuctionPlayerSnapshot[];
passedQueue: ApiAuctionPlayerSnapshot[];
auctionRound: number;
currentIndex: number;
bids: ApiAuctionBid[];
currentBid: number;
@@ -261,12 +270,27 @@ export interface ApiAuction {
maxTimerSeconds: number;
currentDeadline?: string;
initialPoints: number;
topTierThreshold: AuctionTopTierThreshold;
startedAt?: string;
completedAt?: string;
createdAt: string;
updatedAt: string;
}
export interface ApiAuctionHistoryEntry {
sequence: number;
action:
| 'start'
| 'open-bidding'
| 'bid'
| 'sold'
| 'passed'
| 'next'
| 'complete';
actionLabel: string;
takenAt: string;
}
export interface ApiIdentity {
id: string;
entraOid: string;
File diff suppressed because it is too large. Load diff
+99 -39
View File
@@ -29,6 +29,7 @@ import {
teamIndexLabel,
} from '../lib/league';
import type {
AuctionTopTierThreshold,
ApiMatchParticipant,
Position,
TeamSide,
@@ -839,9 +840,11 @@ export default function MatchDetailPage() {
)?.user ?? null;
const canUseMemberActions = Boolean(currentUser || authUserId);
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
const [captainSelections, setCaptainSelections] = useState<Record<string, string>>(
{},
);
const [captainSelections, setCaptainSelections] = useState<
Record<string, { userId: string; initialPoints: number }>
>({});
const [topTierThreshold, setTopTierThreshold] =
useState<AuctionTopTierThreshold>('NONE');
const pollTournamentResultMutation = usePollTournamentResult(
DEFAULT_COMMUNITY_ID,
);
@@ -877,10 +880,13 @@ export default function MatchDetailPage() {
captains: buildCaptainSlots(matchQuery.data?.participants ?? []).map(
(slot) => ({
teamIndex: slot.teamIndex,
userId: captainSelections[captainSlotKey(slot)],
userId: captainSelections[captainSlotKey(slot)]?.userId,
initialPoints:
captainSelections[captainSlotKey(slot)]?.initialPoints ?? 1000,
}),
),
initialPoints: 1000,
topTierThreshold,
maxTimerSeconds: 30,
}),
}),
@@ -919,19 +925,23 @@ export default function MatchDetailPage() {
}
setCaptainSelections((current) => {
const next: Record<string, string> = {};
const next: Record<string, { userId: string; initialPoints: number }> = {};
const usedUserIds = new Set<string>();
for (const slot of slots) {
const key = captainSlotKey(slot);
const currentUserId = current[key];
const currentSelection = current[key];
const currentUserId = currentSelection?.userId;
const currentIsValid =
currentUserId &&
participants.some((participant) => participant.userId === currentUserId) &&
!usedUserIds.has(currentUserId);
if (currentIsValid) {
next[key] = currentUserId;
next[key] = {
userId: currentUserId,
initialPoints: currentSelection?.initialPoints ?? 1000,
};
usedUserIds.add(currentUserId);
continue;
}
@@ -939,7 +949,10 @@ export default function MatchDetailPage() {
const fallback = participants.find(
(participant) => !usedUserIds.has(participant.userId),
);
next[key] = fallback?.userId ?? '';
next[key] = {
userId: fallback?.userId ?? '',
initialPoints: currentSelection?.initialPoints ?? 1000,
};
if (fallback) usedUserIds.add(fallback.userId);
}
@@ -990,8 +1003,8 @@ export default function MatchDetailPage() {
);
const captainSlots = buildCaptainSlots(matchQuery.data.participants);
const selectedCaptainIds = captainSlots
.map((slot) => captainSelections[captainSlotKey(slot)])
.filter(Boolean);
.map((slot) => captainSelections[captainSlotKey(slot)]?.userId)
.filter((userId): userId is string => Boolean(userId));
const hasUniqueCaptainSelections =
selectedCaptainIds.length === captainSlots.length &&
new Set(selectedCaptainIds).size === selectedCaptainIds.length;
@@ -1120,41 +1133,71 @@ export default function MatchDetailPage() {
<div className="grid sm:grid-cols-2 gap-3">
{captainSlots.map((slot) => {
const key = captainSlotKey(slot);
const currentValue = captainSelections[key] ?? '';
const currentSelection = captainSelections[key];
const currentValue = currentSelection?.userId ?? '';
return (
<label
key={key}
className="text-xs text-base-content/45"
>
{teamIndexLabel(slot.teamIndex)} 팀장
<select
className="mt-1 w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm"
value={currentValue}
onChange={(event) =>
setCaptainSelections((current) => ({
...current,
[key]: event.target.value,
}))
}
>
<option value="">선택하세요</option>
{auctionParticipantPool.map((participant) => {
const selectedByOtherSlot =
selectedCaptainIds.includes(
participant.userId,
) && currentValue !== participant.userId;
return (
<option
key={`${key}-${participant.userId}`}
value={participant.userId}
disabled={selectedByOtherSlot}
>
{participant.gameName ?? participant.userId}
{selectedByOtherSlot ? ' (선택됨)' : ''}
</option>
);
})}
</select>
<div className="mt-1 grid grid-cols-[minmax(0,1fr)_96px] gap-2">
<select
className="w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm"
value={currentValue}
onChange={(event) =>
setCaptainSelections((current) => ({
...current,
[key]: {
userId: event.target.value,
initialPoints:
current[key]?.initialPoints ?? 1000,
},
}))
}
>
<option value="">선택하세요</option>
{auctionParticipantPool.map((participant) => {
const selectedByOtherSlot =
selectedCaptainIds.includes(
participant.userId,
) && currentValue !== participant.userId;
return (
<option
key={`${key}-${participant.userId}`}
value={participant.userId}
disabled={selectedByOtherSlot}
>
{participant.gameName ?? participant.userId}
{selectedByOtherSlot ? ' (선택됨)' : ''}
</option>
);
})}
</select>
<input
type="number"
min={100}
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}
onChange={(event) =>
setCaptainSelections((current) => ({
...current,
[key]: {
userId: current[key]?.userId ?? '',
initialPoints: Math.min(
100000,
Math.max(
100,
Number(event.target.value) || 100,
),
),
},
}))
}
/>
</div>
</label>
);
})}
@@ -1164,6 +1207,23 @@ export default function MatchDetailPage() {
경매를 시작하려면 최소 10명이 필요합니다.
</div>
)}
<label className="block text-xs text-base-content/45">
상위 티어 우선 등장
<select
className="mt-1 w-full max-w-xs border border-base-content/10 bg-transparent px-2 py-2 text-sm"
value={topTierThreshold}
onChange={(event) =>
setTopTierThreshold(
event.target.value as AuctionTopTierThreshold,
)
}
>
<option value="NONE">없음</option>
<option value="EMERALD">EMERALD+</option>
<option value="DIAMOND">DIAMOND+</option>
<option value="MASTER">MASTER+</option>
</select>
</label>
<div className="sm:col-span-2 flex items-center gap-3">
<button
type="button"