.
This commit is contained in:
1 parent
fedca82c81
commit
3607e3a99c
13 files changed
+1838
-793
No files matched your search
+834
-744
File diff suppressed because it is too large.
Load diff
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user