.
This commit is contained in:
1 parent
09286e7711
commit
feeb30c6a9
8 files changed
+196
-22
No files matched your search
@@ -130,6 +130,7 @@ export interface AuctionStateView {
|
||||
currentBidder: { teamIndex: number } | null;
|
||||
timer: number;
|
||||
maxTimer: number;
|
||||
bidExtensionSeconds: number;
|
||||
deadline?: string;
|
||||
}
|
||||
|
||||
@@ -521,6 +522,7 @@ export function mapApiAuctionToAuctionState(
|
||||
: null,
|
||||
timer,
|
||||
maxTimer: auction.maxTimerSeconds,
|
||||
bidExtensionSeconds: auction.bidExtensionSeconds ?? 5,
|
||||
deadline: auction.currentDeadline,
|
||||
};
|
||||
}
|
||||
@@ -269,6 +269,7 @@ export interface ApiAuction {
|
||||
currentBid: number;
|
||||
currentBidderTeamIndex?: number;
|
||||
maxTimerSeconds: number;
|
||||
bidExtensionSeconds: number;
|
||||
currentDeadline?: string;
|
||||
initialPoints: number;
|
||||
topTierThreshold: AuctionTopTierThreshold;
|
||||
|
||||
@@ -46,6 +46,10 @@ type CaptainSelection = {
|
||||
initialPoints: string;
|
||||
};
|
||||
|
||||
const DEFAULT_AUCTION_MAX_TIMER_SECONDS = 30;
|
||||
const DEFAULT_AUCTION_BID_EXTENSION_SECONDS = 5;
|
||||
const MAX_AUCTION_TIMER_SECONDS = 3600;
|
||||
|
||||
function captainSlotKey(slot: CaptainSelectionSlot) {
|
||||
return String(slot.teamIndex);
|
||||
}
|
||||
@@ -59,6 +63,19 @@ function parseInitialPointsInput(value: string) {
|
||||
return points;
|
||||
}
|
||||
|
||||
function parseAuctionSecondsInput(value: string, min: number) {
|
||||
if (!value.trim()) return null;
|
||||
const seconds = Number(value);
|
||||
if (
|
||||
!Number.isInteger(seconds) ||
|
||||
seconds < min ||
|
||||
seconds > MAX_AUCTION_TIMER_SECONDS
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return seconds;
|
||||
}
|
||||
|
||||
function buildAuctionParticipantPool(participants: ApiMatchParticipant[]) {
|
||||
const ordered = [...participants].sort(
|
||||
(left, right) =>
|
||||
@@ -969,6 +986,12 @@ export default function MatchDetailPage() {
|
||||
const [manualTopTierUserIds, setManualTopTierUserIds] = useState<string[]>(
|
||||
[],
|
||||
);
|
||||
const [maxTimerSeconds, setMaxTimerSeconds] = useState(
|
||||
String(DEFAULT_AUCTION_MAX_TIMER_SECONDS),
|
||||
);
|
||||
const [bidExtensionSeconds, setBidExtensionSeconds] = useState(
|
||||
String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS),
|
||||
);
|
||||
const pollTournamentResultMutation =
|
||||
usePollTournamentResult(DEFAULT_COMMUNITY_ID);
|
||||
|
||||
@@ -1016,7 +1039,12 @@ export default function MatchDetailPage() {
|
||||
topTierThreshold,
|
||||
manualTopTierUserIds:
|
||||
topTierThreshold === "MANUAL" ? selectedManualTopTierUserIds : [],
|
||||
maxTimerSeconds: 30,
|
||||
maxTimerSeconds:
|
||||
parseAuctionSecondsInput(maxTimerSeconds, 5) ??
|
||||
DEFAULT_AUCTION_MAX_TIMER_SECONDS,
|
||||
bidExtensionSeconds:
|
||||
parseAuctionSecondsInput(bidExtensionSeconds, 0) ??
|
||||
DEFAULT_AUCTION_BID_EXTENSION_SECONDS,
|
||||
}),
|
||||
}),
|
||||
onSuccess: async () => {
|
||||
@@ -1157,6 +1185,13 @@ export default function MatchDetailPage() {
|
||||
const selectedManualTopTierUserIds = manualTopTierUserIds.filter((userId) =>
|
||||
manualPriorityCandidateIds.has(userId),
|
||||
);
|
||||
const parsedMaxTimerSeconds = parseAuctionSecondsInput(maxTimerSeconds, 5);
|
||||
const parsedBidExtensionSeconds = parseAuctionSecondsInput(
|
||||
bidExtensionSeconds,
|
||||
0,
|
||||
);
|
||||
const hasValidAuctionTimerSettings =
|
||||
parsedMaxTimerSeconds !== null && parsedBidExtensionSeconds !== null;
|
||||
const waitingParticipantCount =
|
||||
matchQuery.data.participants.length - auctionParticipantPool.length;
|
||||
const canStartAuction =
|
||||
@@ -1165,7 +1200,8 @@ export default function MatchDetailPage() {
|
||||
auctionParticipantPool.length >= 10 &&
|
||||
auctionNotStarted &&
|
||||
hasUniqueCaptainSelections &&
|
||||
hasValidCaptainInitialPoints;
|
||||
hasValidCaptainInitialPoints &&
|
||||
hasValidAuctionTimerSettings;
|
||||
|
||||
return (
|
||||
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-6">
|
||||
@@ -1384,24 +1420,91 @@ 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>
|
||||
<option value="MANUAL">수동 선택</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="grid gap-x-3 gap-y-4 sm:grid-cols-2">
|
||||
<label className="block text-xs text-base-content/45">
|
||||
경매 제한 시간
|
||||
<div className="mt-1 flex items-center border border-base-content/10 bg-transparent focus-within:border-primary/30">
|
||||
<input
|
||||
type="number"
|
||||
min={5}
|
||||
max={MAX_AUCTION_TIMER_SECONDS}
|
||||
step={5}
|
||||
className="min-w-0 flex-1 bg-transparent px-2 py-2 text-sm tabular-nums focus:outline-none"
|
||||
value={maxTimerSeconds}
|
||||
onChange={(event) =>
|
||||
setMaxTimerSeconds(event.target.value)
|
||||
}
|
||||
onBlur={() => {
|
||||
if (
|
||||
parseAuctionSecondsInput(maxTimerSeconds, 5)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setMaxTimerSeconds(
|
||||
String(DEFAULT_AUCTION_MAX_TIMER_SECONDS),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<span className="shrink-0 px-2 text-[11px] text-base-content/30">
|
||||
초
|
||||
</span>
|
||||
</div>
|
||||
</label>
|
||||
<label className="block text-xs text-base-content/45">
|
||||
최저 입찰 보장 시간
|
||||
<div className="mt-1 flex items-center border border-base-content/10 bg-transparent focus-within:border-primary/30">
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={MAX_AUCTION_TIMER_SECONDS}
|
||||
step={1}
|
||||
className="min-w-0 flex-1 bg-transparent px-2 py-2 text-sm tabular-nums focus:outline-none"
|
||||
value={bidExtensionSeconds}
|
||||
onChange={(event) =>
|
||||
setBidExtensionSeconds(event.target.value)
|
||||
}
|
||||
onBlur={() => {
|
||||
if (
|
||||
parseAuctionSecondsInput(
|
||||
bidExtensionSeconds,
|
||||
0,
|
||||
) !== null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setBidExtensionSeconds(
|
||||
String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<span className="shrink-0 px-2 text-[11px] text-base-content/30">
|
||||
초
|
||||
</span>
|
||||
</div>
|
||||
<span className="mt-1 block text-[11px] text-base-content/30">
|
||||
남은 시간이 이 값보다 적을 때 입찰하면 이 시간까지
|
||||
늘어납니다.
|
||||
</span>
|
||||
</label>
|
||||
<label className="block text-xs text-base-content/45">
|
||||
상위 티어 우선 등장
|
||||
<select
|
||||
className="mt-1 h-[38px] w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm focus:border-primary/30 focus:outline-none"
|
||||
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>
|
||||
<option value="MANUAL">수동 선택</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{topTierThreshold === "MANUAL" && (
|
||||
<div className="border border-base-content/10 bg-base-200/20 p-3">
|
||||
<div className="mb-2 text-[11px] font-bold uppercase tracking-wider text-base-content/35">
|
||||
|
||||
Reference in new issue
Block a user