This commit is contained in:
dahyeon committed 2026-05-03 04:33:47 -07:00
1 parent 6767a9f61b
commit 5df3ea67e7
8 files changed
+785 -16

No files matched your search

+38
View File
@@ -33,6 +33,7 @@ import type {
MatchStatus,
MatchMutationRequest,
MatchesResponse,
ManualTournamentResultCollectResponse,
MeResponse,
RiotQueueGroup,
RiotRankFilter,
@@ -571,6 +572,43 @@ export function usePollTournamentResult(communityId = DEFAULT_COMMUNITY_ID) {
});
}
export function useCollectTournamentResultByWindow(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: {
matchId: string;
startTime: string;
endTime: string;
}) =>
apiFetch<ManualTournamentResultCollectResponse>(
`/communities/${communityId}/matches/${params.matchId}/poll-tournament-result/collect-by-window`,
{
method: 'POST',
body: JSON.stringify({
startTime: params.startTime,
endTime: params.endTime,
}),
},
),
});
}
export function useCollectTournamentResultByRiotMatch(
communityId = DEFAULT_COMMUNITY_ID,
) {
return useMutation({
mutationFn: (params: { matchId: string; riotMatchId: string }) =>
apiFetch<ManualTournamentResultCollectResponse>(
`/communities/${communityId}/matches/${params.matchId}/poll-tournament-result/collect-by-riot-match`,
{
method: 'POST',
body: JSON.stringify({ riotMatchId: params.riotMatchId }),
},
),
});
}
export function useLegacyImportMembers(
options: { windowStart?: string; windowEnd?: string },
communityId = DEFAULT_COMMUNITY_ID,
+8
View File
@@ -205,6 +205,14 @@ export interface ApiMatchGameAssignment {
teamBIndex: number;
}
export interface ManualTournamentResultCollectResponse {
scanned: number;
matched: number;
skipped: number;
riotMatchIds: string[];
gameNumbers: number[];
}
export interface ApiMatch {
_id: string;
communityId: string;
+185 -16
View File
@@ -3,6 +3,8 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { Link, useLocation, useNavigate, useParams } from "react-router";
import {
useAuction,
useCollectTournamentResultByRiotMatch,
useCollectTournamentResultByWindow,
useDdragonManifest,
useMatch,
useMe,
@@ -32,6 +34,7 @@ import type {
AuctionTopTierThreshold,
ApiMatchParticipant,
ApiTierInfo,
ManualTournamentResultCollectResponse,
Position,
TeamSide,
TournamentCodeSlotView,
@@ -548,6 +551,14 @@ function TournamentCodeDisplay({ slot }: { slot: TournamentCodeSlotView }) {
}
function TournamentCodeList({ slots }: { slots: TournamentCodeSlotView[] }) {
if (slots.length === 0) {
return (
<div className="border border-dashed border-base-content/10 px-3 py-3 text-[11px] text-base-content/30">
아직 배정된 코드가 없습니다.
</div>
);
}
return (
<div className="space-y-2">
{slots.map((slot) => (
@@ -574,6 +585,23 @@ function TournamentCodeList({ slots }: { slots: TournamentCodeSlotView[] }) {
);
}
function toIsoFromLocalDateTime(value: string): string | null {
if (!value) return null;
const date = new Date(value);
if (Number.isNaN(date.getTime())) return null;
return date.toISOString();
}
function formatManualCollectSummary(
result: ManualTournamentResultCollectResponse | undefined,
) {
if (!result) return null;
const games = result.gameNumbers.length
? ` · ${result.gameNumbers.join(", ")}경기`
: "";
return `${result.matched}/${result.scanned}개 반영${games}`;
}
function PoolStatsHint({ enabled }: { enabled: boolean }) {
const statsQuery = useTournamentCodeStats(DEFAULT_COMMUNITY_ID, enabled);
if (!enabled) return null;
@@ -1001,8 +1029,16 @@ export default function MatchDetailPage() {
const [bidExtensionSeconds, setBidExtensionSeconds] = useState(
String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS),
);
const [manualResultStartTime, setManualResultStartTime] = useState("");
const [manualResultEndTime, setManualResultEndTime] = useState("");
const [manualRiotMatchId, setManualRiotMatchId] = useState("");
const pollTournamentResultMutation =
usePollTournamentResult(DEFAULT_COMMUNITY_ID);
const collectResultByWindowMutation = useCollectTournamentResultByWindow(
DEFAULT_COMMUNITY_ID,
);
const collectResultByRiotMatchMutation =
useCollectTournamentResultByRiotMatch(DEFAULT_COMMUNITY_ID);
const joinMatchMutation = useMutation({
mutationFn: () =>
@@ -1073,13 +1109,36 @@ export default function MatchDetailPage() {
if (!id) return;
pollTournamentResultMutation.mutate(id, {
onSuccess: async () => {
await queryClient.invalidateQueries({
queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null],
});
await invalidateCurrentMatch();
},
});
}
async function invalidateCurrentMatch() {
await queryClient.invalidateQueries({
queryKey: ["match", DEFAULT_COMMUNITY_ID, id ?? null],
});
}
function handleCollectResultByWindow() {
if (!id) return;
const startTime = toIsoFromLocalDateTime(manualResultStartTime);
const endTime = toIsoFromLocalDateTime(manualResultEndTime);
if (!startTime || !endTime) return;
collectResultByWindowMutation.mutate(
{ matchId: id, startTime, endTime },
{ onSuccess: invalidateCurrentMatch },
);
}
function handleCollectResultByRiotMatch() {
if (!id || !manualRiotMatchId.trim()) return;
collectResultByRiotMatchMutation.mutate(
{ matchId: id, riotMatchId: manualRiotMatchId.trim() },
{ onSuccess: invalidateCurrentMatch },
);
}
useEffect(() => {
const participants = buildAuctionParticipantPool(
matchQuery.data?.participants ?? [],
@@ -1282,6 +1341,18 @@ export default function MatchDetailPage() {
</div>
)}
{collectResultByWindowMutation.error instanceof Error && (
<div className="mb-4 border border-red-500/20 bg-red-500/10 px-4 py-3 text-sm text-red-500">
{collectResultByWindowMutation.error.message}
</div>
)}
{collectResultByRiotMatchMutation.error instanceof Error && (
<div className="mb-4 border border-red-500/20 bg-red-500/10 px-4 py-3 text-sm text-red-500">
{collectResultByRiotMatchMutation.error.message}
</div>
)}
<MatchResultPanel match={match} />
<div className="flex flex-col lg:flex-row gap-5">
@@ -1660,19 +1731,117 @@ export default function MatchDetailPage() {
(match.status === "team-built" ||
match.status === "in-progress") && (
<SideCard title="결과 수집">
<p className="text-[12px] text-base-content/45 mb-3">
Riot match-v5에서 토너먼트 코드가 붙은 경기를 다시 찾습니다.
</p>
<button
type="button"
className="btn btn-primary btn-sm w-full text-xs"
disabled={pollTournamentResultMutation.isPending}
onClick={handlePollTournamentResult}
>
{pollTournamentResultMutation.isPending
? "등록 중..."
: "결과 다시 수집"}
</button>
<div className="space-y-4">
<div>
<div className="mb-2 text-[11px] font-bold text-base-content/45">
토너먼트 코드
</div>
<button
type="button"
className="btn btn-primary btn-sm w-full text-xs"
disabled={pollTournamentResultMutation.isPending}
onClick={handlePollTournamentResult}
>
{pollTournamentResultMutation.isPending
? "등록 중..."
: "결과 다시 수집"}
</button>
</div>
<div className="border-t border-base-content/8 pt-4">
<div className="mb-2 text-[11px] font-bold text-base-content/45">
시간 범위
</div>
<div className="space-y-2">
<label className="block text-[10px] text-base-content/35">
시작
<input
type="datetime-local"
aria-label="수집 시작 시간"
value={manualResultStartTime}
onChange={(event) =>
setManualResultStartTime(event.target.value)
}
className="mt-1 w-full border border-base-content/10 bg-transparent px-2 py-2 text-[11px] text-base-content focus:outline-none focus:border-primary/30"
/>
</label>
<label className="block text-[10px] text-base-content/35">
종료
<input
type="datetime-local"
aria-label="수집 종료 시간"
value={manualResultEndTime}
onChange={(event) =>
setManualResultEndTime(event.target.value)
}
className="mt-1 w-full border border-base-content/10 bg-transparent px-2 py-2 text-[11px] text-base-content focus:outline-none focus:border-primary/30"
/>
</label>
<button
type="button"
className="btn btn-outline btn-sm w-full text-xs"
disabled={
collectResultByWindowMutation.isPending ||
!toIsoFromLocalDateTime(manualResultStartTime) ||
!toIsoFromLocalDateTime(manualResultEndTime)
}
onClick={handleCollectResultByWindow}
>
{collectResultByWindowMutation.isPending
? "수집 중..."
: "시간 범위로 수집"}
</button>
{formatManualCollectSummary(
collectResultByWindowMutation.data,
) && (
<div className="text-[10px] text-base-content/35">
{formatManualCollectSummary(
collectResultByWindowMutation.data,
)}
</div>
)}
</div>
</div>
<div className="border-t border-base-content/8 pt-4">
<div className="mb-2 text-[11px] font-bold text-base-content/45">
Riot Match ID
</div>
<div className="space-y-2">
<input
aria-label="Riot Match ID"
value={manualRiotMatchId}
onChange={(event) =>
setManualRiotMatchId(event.target.value)
}
placeholder="KR_1234567890"
className="w-full border border-base-content/10 bg-transparent px-2 py-2 text-[11px] text-base-content focus:outline-none focus:border-primary/30"
/>
<button
type="button"
className="btn btn-outline btn-sm w-full text-xs"
disabled={
collectResultByRiotMatchMutation.isPending ||
!manualRiotMatchId.trim()
}
onClick={handleCollectResultByRiotMatch}
>
{collectResultByRiotMatchMutation.isPending
? "수집 중..."
: "Match ID로 수집"}
</button>
{formatManualCollectSummary(
collectResultByRiotMatchMutation.data,
) && (
<div className="text-[10px] text-base-content/35">
{formatManualCollectSummary(
collectResultByRiotMatchMutation.data,
)}
</div>
)}
</div>
</div>
</div>
</SideCard>
)}