feat(web): add match detail tabs

This commit is contained in:
dahyeon committed 2026-07-14 03:22:33 +00:00
1 parent a88562b208
commit 96bae0ce28
5 files changed
+523 -29

No files matched your search

+223 -23
View File
@@ -5,7 +5,13 @@ import type {
MatchParticipantView,
} from "@lolympus/contracts";
import { ChevronLeft, Search, X } from "lucide-react";
import { Link, useLocation, useNavigate, useParams } from "react-router";
import {
Link,
useLocation,
useNavigate,
useParams,
useSearchParams,
} from "react-router";
import {
useAuction,
useCollectTournamentResultByRiotMatch,
@@ -28,7 +34,14 @@ import {
import { RankBadge } from "../components/RankBadge";
import { CompetitionAdminControls } from "../components/competition/CompetitionAdminControls";
import { CompetitionResults } from "../components/competition/CompetitionResults";
import { MatchDetailTabBar } from "../components/competition/MatchDetailTabBar";
import { MATCH_PAGE_MAX_WIDTH_CLASS } from "../components/competition/competition-display-layout";
import {
createMatchDetailTabSearchParams,
createMatchDetailTabs,
resolveMatchDetailTab,
type MatchDetailTabId,
} from "../components/competition/match-detail-tabs";
import { DEFAULT_COMMUNITY_ID, useAuthUserId } from "../config";
import { apiFetch, ApiError } from "../lib/api";
import { profileIconUrl } from "../lib/ddragon";
@@ -1383,6 +1396,7 @@ function formatManualCollectSummary(
export default function MatchDetailPage() {
const { id } = useParams();
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const queryClient = useQueryClient();
const authUserId = useAuthUserId();
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
@@ -1401,6 +1415,10 @@ export default function MatchDetailPage() {
meQuery.data?.memberships.find(
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
)?.user ?? null;
const canManageAuction =
currentUser?.role === "owner" || currentUser?.role === "admin";
const isCheckingPermissions =
meQuery.isLoading || (meQuery.isFetching && !meQuery.data);
const canUseMemberActions = Boolean(currentUser || authUserId);
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
const [captainSelections, setCaptainSelections] = useState<
@@ -1702,6 +1720,33 @@ export default function MatchDetailPage() {
return () => window.clearTimeout(timer);
}, [matchQuery.data?.participants]);
useEffect(() => {
const status = matchQuery.data?.status;
const requestedTab = searchParams.get("tab");
if (
isCheckingPermissions ||
!requestedTab ||
(status !== "in-progress" && status !== "finished")
) return;
const resolvedTab = resolveMatchDetailTab(
requestedTab,
createMatchDetailTabs({ status, canManage: canManageAuction }),
);
if (!resolvedTab || resolvedTab === requestedTab) return;
setSearchParams(
createMatchDetailTabSearchParams(searchParams, resolvedTab),
{ replace: true, preventScrollReset: true },
);
}, [
canManageAuction,
isCheckingPermissions,
matchQuery.data?.status,
searchParams,
setSearchParams,
]);
if (!DEFAULT_COMMUNITY_ID) {
return (
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
@@ -1735,10 +1780,6 @@ export default function MatchDetailPage() {
const match = mapApiMatchToMatchDetail(matchQuery.data);
const si = statusBadge(match.status);
const canManageAuction =
currentUser?.role === "owner" || currentUser?.role === "admin";
const isCheckingPermissions =
meQuery.isLoading || (meQuery.isFetching && !meQuery.data);
const auctionNotStarted =
auctionQuery.error instanceof ApiError && auctionQuery.error.status === 404;
const activeAuction = auctionNotStarted ? null : auctionQuery.data;
@@ -1792,6 +1833,60 @@ export default function MatchDetailPage() {
hasValidCaptainInitialPoints &&
hasValidAuctionTimerSettings;
const matchTabs = createMatchDetailTabs({
status: match.status,
canManage: canManageAuction,
});
const activeMatchTab = resolveMatchDetailTab(
searchParams.get("tab"),
matchTabs,
);
const usesTabbedLayout = activeMatchTab !== null;
const showCompetitionState =
!usesTabbedLayout ||
activeMatchTab === "bracket" ||
activeMatchTab === "games" ||
activeMatchTab === "ops";
const showCompetitionResults =
!usesTabbedLayout ||
activeMatchTab === "bracket" ||
activeMatchTab === "games";
const showOperationsPanel =
!usesTabbedLayout || activeMatchTab === "ops";
const showTeamsPanel = !usesTabbedLayout || activeMatchTab === "teams";
const showInfoPanel = !usesTabbedLayout || activeMatchTab === "info";
const hasMatchInfo =
match.schedule.length > 0 ||
match.prizes.length > 0 ||
match.notices.length > 0;
const showSupportingLayout =
!usesTabbedLayout ||
showTeamsPanel ||
showInfoPanel ||
(showOperationsPanel && match.status === "in-progress");
const showEmptyOperationsState =
usesTabbedLayout &&
activeMatchTab === "ops" &&
match.status === "finished" &&
!competitionQuery.isLoading &&
!competitionQuery.error &&
(!competitionEnabled ||
competitionQuery.data?.projection.series.length === 0);
const supportingAsideClassName = usesTabbedLayout
? showInfoPanel
? "grid w-full gap-4 lg:grid-cols-2"
: showOperationsPanel
? "w-full space-y-4 lg:max-w-sm"
: "hidden"
: "w-full lg:w-64 shrink-0 space-y-4";
function handleMatchDetailTabChange(nextTab: MatchDetailTabId) {
setSearchParams(
createMatchDetailTabSearchParams(searchParams, nextTab),
{ preventScrollReset: true },
);
}
return (
<main
className={`mx-auto px-4 py-6 sm:px-6 ${
@@ -1877,7 +1972,59 @@ export default function MatchDetailPage() {
</div>
)}
{competitionQuery.isLoading && competitionEnabled && (
{usesTabbedLayout && activeMatchTab && (
<MatchDetailTabBar
tabs={matchTabs}
activeTab={activeMatchTab}
onChange={handleMatchDetailTabChange}
/>
)}
{usesTabbedLayout &&
activeMatchTab &&
matchTabs
.filter((tab) => tab.id !== activeMatchTab)
.map((tab) => (
<div
key={tab.id}
id={`match-detail-panel-${tab.id}`}
role="tabpanel"
aria-labelledby={`match-detail-tab-${tab.id}`}
hidden
/>
))}
<div
id={
usesTabbedLayout && activeMatchTab
? `match-detail-panel-${activeMatchTab}`
: undefined
}
role={usesTabbedLayout ? "tabpanel" : undefined}
aria-labelledby={
usesTabbedLayout && activeMatchTab
? `match-detail-tab-${activeMatchTab}`
: undefined
}
tabIndex={usesTabbedLayout ? 0 : undefined}
className={
usesTabbedLayout
? "scroll-mt-24 pt-5 focus-visible:outline-none"
: undefined
}
>
{usesTabbedLayout &&
showCompetitionResults &&
!competitionEnabled && (
<div
className="mb-6 border border-dashed border-base-content/15 bg-base-content/[0.02] px-4 py-5 text-sm text-base-content/45"
role="status"
>
공식 경기 결과가 아직 준비되지 않았습니다.
</div>
)}
{showCompetitionState && competitionQuery.isLoading && competitionEnabled && (
<div
className="mb-6 space-y-3 border border-base-content/10 p-4"
aria-busy="true"
@@ -1888,7 +2035,8 @@ export default function MatchDetailPage() {
</div>
)}
{competitionQuery.error &&
{showCompetitionState &&
competitionQuery.error &&
!(
competitionQuery.error instanceof ApiError &&
competitionQuery.error.status === 404
@@ -1898,18 +2046,32 @@ export default function MatchDetailPage() {
</div>
)}
{competitionEnabled && competitionQuery.data && (
{showCompetitionState && competitionEnabled && competitionQuery.data && (
<>
<CompetitionResults competition={competitionQuery.data} />
<CompetitionAdminControls
competition={competitionQuery.data}
communityId={DEFAULT_COMMUNITY_ID}
canManage={canManageAuction}
/>
{showCompetitionResults && (
<CompetitionResults
competition={competitionQuery.data}
view={
usesTabbedLayout
? activeMatchTab === "games"
? "games"
: "bracket"
: "all"
}
/>
)}
{showOperationsPanel && (
<CompetitionAdminControls
competition={competitionQuery.data}
communityId={DEFAULT_COMMUNITY_ID}
canManage={canManageAuction}
/>
)}
</>
)}
{competitionEnabled &&
{showCompetitionState &&
competitionEnabled &&
competitionQuery.error instanceof ApiError &&
competitionQuery.error.status === 404 && (
<div
@@ -1920,8 +2082,23 @@ export default function MatchDetailPage() {
</div>
)}
<div className="flex flex-col lg:flex-row gap-5">
<div className="flex-1 min-w-0 space-y-4">
{showEmptyOperationsState && (
<div
className="mb-6 border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/40"
role="status"
>
운영할 공식 경기 데이터가 없습니다.
</div>
)}
{showSupportingLayout && (
<div
className={
usesTabbedLayout ? "block" : "flex flex-col lg:flex-row gap-5"
}
>
{showTeamsPanel && (
<div className="flex-1 min-w-0 space-y-4">
{match.status === "recruiting" ? (
<>
<ParticipantTable
@@ -2298,6 +2475,16 @@ export default function MatchDetailPage() {
</>
) : (
<div className="space-y-4">
{usesTabbedLayout &&
showTeamsPanel &&
match.teams.length === 0 && (
<div
className="border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/40"
role="status"
>
등록된 팀이 없습니다.
</div>
)}
{match.teams.map((team) => (
<TeamCard key={team.teamIndex} team={team} />
))}
@@ -2313,10 +2500,20 @@ export default function MatchDetailPage() {
)}
</div>
)}
</div>
</div>
)}
<div className="w-full lg:w-64 shrink-0 space-y-4">
{match.schedule.length > 0 && (
<div className={supportingAsideClassName}>
{usesTabbedLayout && showInfoPanel && !hasMatchInfo && (
<div
className="lg:col-span-2 border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/40"
role="status"
>
등록된 일정이나 안내가 없습니다.
</div>
)}
{showInfoPanel && match.schedule.length > 0 && (
<SideCard title="일정">
<ul className="space-y-2">
{match.schedule.map((item, index) => (
@@ -2331,7 +2528,8 @@ export default function MatchDetailPage() {
</SideCard>
)}
{canManageAuction &&
{showOperationsPanel &&
canManageAuction &&
(match.status === "team-built" ||
match.status === "in-progress") && (
<SideCard title="결과 수집">
@@ -2449,7 +2647,7 @@ export default function MatchDetailPage() {
</SideCard>
)}
{match.prizes.length > 0 && (
{showInfoPanel && match.prizes.length > 0 && (
<SideCard title="상품">
<ul className="space-y-1.5">
{match.prizes.map((prize, index) => (
@@ -2465,7 +2663,7 @@ export default function MatchDetailPage() {
</SideCard>
)}
{match.notices.length > 0 && (
{showInfoPanel && match.notices.length > 0 && (
<SideCard title="안내사항">
<ul className="space-y-1.5">
{match.notices.map((notice, index) => (
@@ -2482,6 +2680,8 @@ export default function MatchDetailPage() {
)}
</div>
</div>
)}
</div>
</main>
);
}