fix: close competition cutover integrity gaps

This commit is contained in:
dahyeon committed 2026-07-12 21:22:22 +00:00
1 parent 7ea2002975
commit 683d602d63
57 files changed
+4805 -1582

No files matched your search

+144 -20
View File
@@ -1,41 +1,112 @@
import { useState } from "react";
import { useEffect, useRef, useState } from "react";
import { Link, useParams } from "react-router";
import { useCompetition, useTeamCompetition } from "../api/hooks";
import { SeriesScoreCard } from "../components/competition/SeriesScoreCard";
import { DEFAULT_COMMUNITY_ID } from "../config";
import {
getTeamProgressErrorContent,
isConsistentTeamProgressSnapshot,
type TeamProgressErrorContent,
} from "./match-team-progress-state";
export default function MatchTeamProgressPage() {
const { id } = useParams();
const competitionQuery = useCompetition(id, DEFAULT_COMMUNITY_ID);
const teamQuery = useTeamCompetition(id, DEFAULT_COMMUNITY_ID);
const refetchCompetition = competitionQuery.refetch;
const refetchTeam = teamQuery.refetch;
const [copiedSlotId, setCopiedSlotId] = useState<string | null>(null);
const lastAutoRefetchedMismatchRef = useRef<string | null>(null);
const competition = competitionQuery.data;
const teamView = teamQuery.data;
const hasQueryError = Boolean(
competitionQuery.error || teamQuery.error,
);
const isRefetching = competitionQuery.isFetching || teamQuery.isFetching;
const revisionsMatch = isConsistentTeamProgressSnapshot(
competition,
teamView,
);
const revisionMismatchKey =
competition && teamView && !revisionsMatch
? `${competition.revision}:${teamView.revision}`
: null;
useEffect(() => {
if (!revisionMismatchKey) {
lastAutoRefetchedMismatchRef.current = null;
return;
}
if (
hasQueryError ||
isRefetching ||
lastAutoRefetchedMismatchRef.current === revisionMismatchKey
) {
return;
}
lastAutoRefetchedMismatchRef.current = revisionMismatchKey;
void Promise.all([refetchCompetition(), refetchTeam()]).catch(
() => undefined,
);
}, [
hasQueryError,
isRefetching,
refetchCompetition,
refetchTeam,
revisionMismatchKey,
]);
function retryBoth() {
void Promise.all([refetchCompetition(), refetchTeam()]).catch(
() => undefined,
);
}
if (competitionQuery.isLoading || teamQuery.isLoading) {
return <TeamProgressLoadingState />;
}
if (hasQueryError) {
return (
<main
className="mx-auto max-w-5xl space-y-3 px-4 py-12 sm:px-6"
aria-busy="true"
aria-label="팀 진행 정보를 불러오는 중"
>
<div className="h-7 w-48 animate-pulse bg-base-200" />
<div className="h-32 animate-pulse bg-base-200/70" />
</main>
<TeamProgressProblemState
content={getTeamProgressErrorContent(
[competitionQuery.error, teamQuery.error].filter(Boolean),
)}
isRetrying={isRefetching}
matchId={id}
onRetry={retryBoth}
/>
);
}
const competition = competitionQuery.data;
const teamView = teamQuery.data;
if (!competition || !teamView) {
return (
<main className="mx-auto max-w-5xl px-4 py-20 text-center">
<h1 className="text-lg font-bold">팀 진행 정보를 볼 수 없습니다</h1>
<p className="mt-2 text-sm text-base-content/45">
이 내전에 참여한 계정으로 로그인했는지 확인해주세요.
</p>
<Link to={`/match/${id}`} className="btn btn-primary btn-sm mt-5">
내전 상세로
</Link>
</main>
<TeamProgressProblemState
content={getTeamProgressErrorContent([])}
isRetrying={isRefetching}
matchId={id}
onRetry={retryBoth}
/>
);
}
if (!revisionsMatch) {
return (
<TeamProgressProblemState
content={{
kind: "unknown",
title: isRefetching
? "최신 경기 정보를 맞추는 중입니다"
: "경기 정보의 revision이 일치하지 않습니다",
description: isRefetching
? "Competition과 팀 정보를 함께 다시 불러오고 있습니다."
: "일관된 경기 정보를 표시할 수 없어 두 응답을 다시 확인해야 합니다.",
}}
isRetrying={isRefetching}
matchId={id}
onRetry={retryBoth}
/>
);
}
@@ -208,6 +279,59 @@ export default function MatchTeamProgressPage() {
);
}
function TeamProgressLoadingState() {
return (
<main
className="mx-auto max-w-5xl space-y-3 px-4 py-12 sm:px-6"
aria-busy="true"
aria-label="팀 진행 정보를 불러오는 중"
>
<div className="h-7 w-48 animate-pulse bg-base-200" />
<div className="h-32 animate-pulse bg-base-200/70" />
</main>
);
}
function TeamProgressProblemState({
content,
isRetrying,
matchId,
onRetry,
}: {
content: TeamProgressErrorContent;
isRetrying: boolean;
matchId: string | undefined;
onRetry: () => void;
}) {
return (
<main className="mx-auto max-w-5xl px-4 py-20 sm:px-6">
<section
role="alert"
aria-busy={isRetrying}
className="border border-base-content/10 bg-base-100 px-5 py-8 text-center"
>
<h1 className="text-lg font-bold">{content.title}</h1>
<p className="mt-2 text-sm text-base-content/45">
{content.description}
</p>
<div className="mt-5 flex flex-wrap justify-center gap-2">
<button
type="button"
className="btn btn-primary btn-sm"
disabled={isRetrying}
onClick={onRetry}
>
{isRetrying ? "다시 불러오는 중..." : "다시 시도"}
</button>
<Link to={`/match/${matchId}`} className="btn btn-ghost btn-sm">
내전 상세로
</Link>
</div>
</section>
</main>
);
}
function EmptyState({ message }: { message: string }) {
return (
<p