feat(web): add match detail tabs
This commit is contained in:
1 parent
a88562b208
commit
96bae0ce28
5 files changed
+523
-29
No files matched your search
@@ -7,6 +7,7 @@ import type {
|
|||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
import { CompetitionSeriesHistory } from "./CompetitionSeriesHistory";
|
import { CompetitionSeriesHistory } from "./CompetitionSeriesHistory";
|
||||||
import { DoubleEliminationBracket } from "./DoubleEliminationBracket";
|
import { DoubleEliminationBracket } from "./DoubleEliminationBracket";
|
||||||
|
import { createCompetitionSeriesHistory } from "./competition-series-history";
|
||||||
import { createCompetitionBracketLayout } from "./competition-display-layout";
|
import { createCompetitionBracketLayout } from "./competition-display-layout";
|
||||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||||
import { RoundRobinTable } from "./RoundRobinTable";
|
import { RoundRobinTable } from "./RoundRobinTable";
|
||||||
@@ -14,13 +15,40 @@ import { SeriesScoreCard } from "./SeriesScoreCard";
|
|||||||
|
|
||||||
export function CompetitionResults({
|
export function CompetitionResults({
|
||||||
competition,
|
competition,
|
||||||
|
view = "all",
|
||||||
}: {
|
}: {
|
||||||
competition: CompetitionDetailResponse;
|
competition: CompetitionDetailResponse;
|
||||||
|
view?: "all" | "bracket" | "games";
|
||||||
}) {
|
}) {
|
||||||
const { projection } = competition;
|
const { projection } = competition;
|
||||||
const teamById = new Map(
|
const teamById = new Map(
|
||||||
competition.teams.map((team) => [team.teamId, team]),
|
competition.teams.map((team) => [team.teamId, team]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (view === "games") {
|
||||||
|
const hasSeriesHistory =
|
||||||
|
createCompetitionSeriesHistory(projection).length > 0;
|
||||||
|
return (
|
||||||
|
<div className="mb-6">
|
||||||
|
{hasSeriesHistory ? (
|
||||||
|
<CompetitionSeriesHistory
|
||||||
|
communityId={competition.communityId}
|
||||||
|
matchId={competition.matchId}
|
||||||
|
projection={projection}
|
||||||
|
teamById={teamById}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p
|
||||||
|
className="border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/45"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
|
기록된 공식 경기가 없습니다.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const seriesById = new Map(
|
const seriesById = new Map(
|
||||||
projection.series.map((series) => [series.seriesId, series]),
|
projection.series.map((series) => [series.seriesId, series]),
|
||||||
);
|
);
|
||||||
@@ -82,12 +110,14 @@ export function CompetitionResults({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<CompetitionSeriesHistory
|
{view === "all" && (
|
||||||
communityId={competition.communityId}
|
<CompetitionSeriesHistory
|
||||||
matchId={competition.matchId}
|
communityId={competition.communityId}
|
||||||
projection={projection}
|
matchId={competition.matchId}
|
||||||
teamById={teamById}
|
projection={projection}
|
||||||
/>
|
teamById={teamById}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
import {
|
||||||
|
moveMatchDetailTabFocus,
|
||||||
|
type MatchDetailTab,
|
||||||
|
type MatchDetailTabId,
|
||||||
|
type MatchDetailTabNavigationKey,
|
||||||
|
} from "./match-detail-tabs";
|
||||||
|
|
||||||
|
export function MatchDetailTabBar({
|
||||||
|
tabs,
|
||||||
|
activeTab,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
tabs: readonly MatchDetailTab[];
|
||||||
|
activeTab: MatchDetailTabId;
|
||||||
|
onChange: (tab: MatchDetailTabId) => void;
|
||||||
|
}) {
|
||||||
|
const tabRefs = useRef<
|
||||||
|
Partial<Record<MatchDetailTabId, HTMLButtonElement | null>>
|
||||||
|
>({});
|
||||||
|
const previousActiveTabRef = useRef(activeTab);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
tabRefs.current[activeTab]?.scrollIntoView({
|
||||||
|
block: "nearest",
|
||||||
|
inline: "nearest",
|
||||||
|
});
|
||||||
|
if (previousActiveTabRef.current === activeTab) return;
|
||||||
|
|
||||||
|
const activePanel = document.getElementById(
|
||||||
|
`match-detail-panel-${activeTab}`,
|
||||||
|
);
|
||||||
|
const panelTop = activePanel?.getBoundingClientRect().top;
|
||||||
|
if (
|
||||||
|
activePanel &&
|
||||||
|
panelTop !== undefined &&
|
||||||
|
(panelTop < 96 || panelTop >= window.innerHeight)
|
||||||
|
) {
|
||||||
|
activePanel.scrollIntoView({ block: "start" });
|
||||||
|
}
|
||||||
|
previousActiveTabRef.current = activeTab;
|
||||||
|
}, [activeTab]);
|
||||||
|
|
||||||
|
function handleKeyDown(
|
||||||
|
event: React.KeyboardEvent<HTMLButtonElement>,
|
||||||
|
currentTab: MatchDetailTabId,
|
||||||
|
) {
|
||||||
|
if (!isNavigationKey(event.key)) return;
|
||||||
|
const nextTab = moveMatchDetailTabFocus(tabs, currentTab, event.key);
|
||||||
|
if (!nextTab) return;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
onChange(nextTab);
|
||||||
|
window.requestAnimationFrame(() => tabRefs.current[nextTab]?.focus());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="sticky top-12 z-40 -mx-4 border-y border-base-content/10 bg-base-100/95 px-4 backdrop-blur sm:-mx-6 sm:px-6">
|
||||||
|
<div
|
||||||
|
className="flex overflow-x-auto"
|
||||||
|
role="tablist"
|
||||||
|
aria-label="내전 상세"
|
||||||
|
>
|
||||||
|
{tabs.map((tab) => {
|
||||||
|
const selected = activeTab === tab.id;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={tab.id}
|
||||||
|
ref={(element) => {
|
||||||
|
tabRefs.current[tab.id] = element;
|
||||||
|
}}
|
||||||
|
id={`match-detail-tab-${tab.id}`}
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
aria-selected={selected}
|
||||||
|
aria-controls={`match-detail-panel-${tab.id}`}
|
||||||
|
tabIndex={selected ? 0 : -1}
|
||||||
|
onClick={() => onChange(tab.id)}
|
||||||
|
onKeyDown={(event) => handleKeyDown(event, tab.id)}
|
||||||
|
className={`min-h-11 flex-none whitespace-nowrap border-b-2 px-4 text-xs font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||||
|
selected
|
||||||
|
? "border-primary bg-primary/5 text-primary"
|
||||||
|
: "border-transparent text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{tab.label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNavigationKey(
|
||||||
|
key: string,
|
||||||
|
): key is MatchDetailTabNavigationKey {
|
||||||
|
return (
|
||||||
|
key === "ArrowLeft" ||
|
||||||
|
key === "ArrowRight" ||
|
||||||
|
key === "Home" ||
|
||||||
|
key === "End"
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
export type MatchDetailTabStatus =
|
||||||
|
| "recruiting"
|
||||||
|
| "team-built"
|
||||||
|
| "in-progress"
|
||||||
|
| "finished";
|
||||||
|
|
||||||
|
export type MatchDetailTabId =
|
||||||
|
| "bracket"
|
||||||
|
| "games"
|
||||||
|
| "teams"
|
||||||
|
| "info"
|
||||||
|
| "ops";
|
||||||
|
|
||||||
|
export type MatchDetailTab = {
|
||||||
|
id: MatchDetailTabId;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MatchDetailTabNavigationKey =
|
||||||
|
| "ArrowLeft"
|
||||||
|
| "ArrowRight"
|
||||||
|
| "Home"
|
||||||
|
| "End";
|
||||||
|
|
||||||
|
export const MATCH_DETAIL_TAB_QUERY_KEY = "tab";
|
||||||
|
|
||||||
|
const PUBLIC_MATCH_DETAIL_TABS: MatchDetailTab[] = [
|
||||||
|
{ id: "bracket", label: "대진표·순위" },
|
||||||
|
{ id: "games", label: "경기 기록" },
|
||||||
|
{ id: "teams", label: "팀" },
|
||||||
|
{ id: "info", label: "일정·안내" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const OPERATIONS_TAB: MatchDetailTab = { id: "ops", label: "운영" };
|
||||||
|
|
||||||
|
export function createMatchDetailTabs({
|
||||||
|
status,
|
||||||
|
canManage,
|
||||||
|
}: {
|
||||||
|
status: MatchDetailTabStatus;
|
||||||
|
canManage: boolean;
|
||||||
|
}): MatchDetailTab[] {
|
||||||
|
if (status !== "in-progress" && status !== "finished") return [];
|
||||||
|
return canManage
|
||||||
|
? [...PUBLIC_MATCH_DETAIL_TABS, OPERATIONS_TAB]
|
||||||
|
: [...PUBLIC_MATCH_DETAIL_TABS];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveMatchDetailTab(
|
||||||
|
requestedTab: string | null | undefined,
|
||||||
|
availableTabs: readonly MatchDetailTab[],
|
||||||
|
): MatchDetailTabId | null {
|
||||||
|
return (
|
||||||
|
availableTabs.find((tab) => tab.id === requestedTab)?.id ??
|
||||||
|
availableTabs[0]?.id ??
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createMatchDetailTabSearchParams(
|
||||||
|
current: URLSearchParams,
|
||||||
|
nextTab: MatchDetailTabId,
|
||||||
|
): URLSearchParams {
|
||||||
|
const next = new URLSearchParams(current);
|
||||||
|
next.set(MATCH_DETAIL_TAB_QUERY_KEY, nextTab);
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moveMatchDetailTabFocus(
|
||||||
|
tabs: readonly MatchDetailTab[],
|
||||||
|
currentTab: MatchDetailTabId,
|
||||||
|
key: MatchDetailTabNavigationKey,
|
||||||
|
): MatchDetailTabId | null {
|
||||||
|
if (tabs.length === 0) return null;
|
||||||
|
if (key === "Home") return tabs[0].id;
|
||||||
|
if (key === "End") return tabs[tabs.length - 1].id;
|
||||||
|
|
||||||
|
const currentIndex = tabs.findIndex((tab) => tab.id === currentTab);
|
||||||
|
const safeIndex = currentIndex === -1 ? 0 : currentIndex;
|
||||||
|
const direction = key === "ArrowRight" ? 1 : -1;
|
||||||
|
const nextIndex = (safeIndex + direction + tabs.length) % tabs.length;
|
||||||
|
return tabs[nextIndex].id;
|
||||||
|
}
|
||||||
@@ -5,7 +5,13 @@ import type {
|
|||||||
MatchParticipantView,
|
MatchParticipantView,
|
||||||
} from "@lolympus/contracts";
|
} from "@lolympus/contracts";
|
||||||
import { ChevronLeft, Search, X } from "lucide-react";
|
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 {
|
import {
|
||||||
useAuction,
|
useAuction,
|
||||||
useCollectTournamentResultByRiotMatch,
|
useCollectTournamentResultByRiotMatch,
|
||||||
@@ -28,7 +34,14 @@ import {
|
|||||||
import { RankBadge } from "../components/RankBadge";
|
import { RankBadge } from "../components/RankBadge";
|
||||||
import { CompetitionAdminControls } from "../components/competition/CompetitionAdminControls";
|
import { CompetitionAdminControls } from "../components/competition/CompetitionAdminControls";
|
||||||
import { CompetitionResults } from "../components/competition/CompetitionResults";
|
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 { 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 { DEFAULT_COMMUNITY_ID, useAuthUserId } from "../config";
|
||||||
import { apiFetch, ApiError } from "../lib/api";
|
import { apiFetch, ApiError } from "../lib/api";
|
||||||
import { profileIconUrl } from "../lib/ddragon";
|
import { profileIconUrl } from "../lib/ddragon";
|
||||||
@@ -1383,6 +1396,7 @@ function formatManualCollectSummary(
|
|||||||
export default function MatchDetailPage() {
|
export default function MatchDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const authUserId = useAuthUserId();
|
const authUserId = useAuthUserId();
|
||||||
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
||||||
@@ -1401,6 +1415,10 @@ export default function MatchDetailPage() {
|
|||||||
meQuery.data?.memberships.find(
|
meQuery.data?.memberships.find(
|
||||||
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
||||||
)?.user ?? null;
|
)?.user ?? null;
|
||||||
|
const canManageAuction =
|
||||||
|
currentUser?.role === "owner" || currentUser?.role === "admin";
|
||||||
|
const isCheckingPermissions =
|
||||||
|
meQuery.isLoading || (meQuery.isFetching && !meQuery.data);
|
||||||
const canUseMemberActions = Boolean(currentUser || authUserId);
|
const canUseMemberActions = Boolean(currentUser || authUserId);
|
||||||
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
|
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
|
||||||
const [captainSelections, setCaptainSelections] = useState<
|
const [captainSelections, setCaptainSelections] = useState<
|
||||||
@@ -1702,6 +1720,33 @@ export default function MatchDetailPage() {
|
|||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
}, [matchQuery.data?.participants]);
|
}, [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) {
|
if (!DEFAULT_COMMUNITY_ID) {
|
||||||
return (
|
return (
|
||||||
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
|
<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 match = mapApiMatchToMatchDetail(matchQuery.data);
|
||||||
const si = statusBadge(match.status);
|
const si = statusBadge(match.status);
|
||||||
const canManageAuction =
|
|
||||||
currentUser?.role === "owner" || currentUser?.role === "admin";
|
|
||||||
const isCheckingPermissions =
|
|
||||||
meQuery.isLoading || (meQuery.isFetching && !meQuery.data);
|
|
||||||
const auctionNotStarted =
|
const auctionNotStarted =
|
||||||
auctionQuery.error instanceof ApiError && auctionQuery.error.status === 404;
|
auctionQuery.error instanceof ApiError && auctionQuery.error.status === 404;
|
||||||
const activeAuction = auctionNotStarted ? null : auctionQuery.data;
|
const activeAuction = auctionNotStarted ? null : auctionQuery.data;
|
||||||
@@ -1792,6 +1833,60 @@ export default function MatchDetailPage() {
|
|||||||
hasValidCaptainInitialPoints &&
|
hasValidCaptainInitialPoints &&
|
||||||
hasValidAuctionTimerSettings;
|
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 (
|
return (
|
||||||
<main
|
<main
|
||||||
className={`mx-auto px-4 py-6 sm:px-6 ${
|
className={`mx-auto px-4 py-6 sm:px-6 ${
|
||||||
@@ -1877,7 +1972,59 @@ export default function MatchDetailPage() {
|
|||||||
</div>
|
</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
|
<div
|
||||||
className="mb-6 space-y-3 border border-base-content/10 p-4"
|
className="mb-6 space-y-3 border border-base-content/10 p-4"
|
||||||
aria-busy="true"
|
aria-busy="true"
|
||||||
@@ -1888,7 +2035,8 @@ export default function MatchDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{competitionQuery.error &&
|
{showCompetitionState &&
|
||||||
|
competitionQuery.error &&
|
||||||
!(
|
!(
|
||||||
competitionQuery.error instanceof ApiError &&
|
competitionQuery.error instanceof ApiError &&
|
||||||
competitionQuery.error.status === 404
|
competitionQuery.error.status === 404
|
||||||
@@ -1898,18 +2046,32 @@ export default function MatchDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{competitionEnabled && competitionQuery.data && (
|
{showCompetitionState && competitionEnabled && competitionQuery.data && (
|
||||||
<>
|
<>
|
||||||
<CompetitionResults competition={competitionQuery.data} />
|
{showCompetitionResults && (
|
||||||
<CompetitionAdminControls
|
<CompetitionResults
|
||||||
competition={competitionQuery.data}
|
competition={competitionQuery.data}
|
||||||
communityId={DEFAULT_COMMUNITY_ID}
|
view={
|
||||||
canManage={canManageAuction}
|
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 instanceof ApiError &&
|
||||||
competitionQuery.error.status === 404 && (
|
competitionQuery.error.status === 404 && (
|
||||||
<div
|
<div
|
||||||
@@ -1920,8 +2082,23 @@ export default function MatchDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-col lg:flex-row gap-5">
|
{showEmptyOperationsState && (
|
||||||
<div className="flex-1 min-w-0 space-y-4">
|
<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" ? (
|
{match.status === "recruiting" ? (
|
||||||
<>
|
<>
|
||||||
<ParticipantTable
|
<ParticipantTable
|
||||||
@@ -2298,6 +2475,16 @@ export default function MatchDetailPage() {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-4">
|
<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) => (
|
{match.teams.map((team) => (
|
||||||
<TeamCard key={team.teamIndex} team={team} />
|
<TeamCard key={team.teamIndex} team={team} />
|
||||||
))}
|
))}
|
||||||
@@ -2313,10 +2500,20 @@ export default function MatchDetailPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="w-full lg:w-64 shrink-0 space-y-4">
|
<div className={supportingAsideClassName}>
|
||||||
{match.schedule.length > 0 && (
|
{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="일정">
|
<SideCard title="일정">
|
||||||
<ul className="space-y-2">
|
<ul className="space-y-2">
|
||||||
{match.schedule.map((item, index) => (
|
{match.schedule.map((item, index) => (
|
||||||
@@ -2331,7 +2528,8 @@ export default function MatchDetailPage() {
|
|||||||
</SideCard>
|
</SideCard>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{canManageAuction &&
|
{showOperationsPanel &&
|
||||||
|
canManageAuction &&
|
||||||
(match.status === "team-built" ||
|
(match.status === "team-built" ||
|
||||||
match.status === "in-progress") && (
|
match.status === "in-progress") && (
|
||||||
<SideCard title="결과 수집">
|
<SideCard title="결과 수집">
|
||||||
@@ -2449,7 +2647,7 @@ export default function MatchDetailPage() {
|
|||||||
</SideCard>
|
</SideCard>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{match.prizes.length > 0 && (
|
{showInfoPanel && match.prizes.length > 0 && (
|
||||||
<SideCard title="상품">
|
<SideCard title="상품">
|
||||||
<ul className="space-y-1.5">
|
<ul className="space-y-1.5">
|
||||||
{match.prizes.map((prize, index) => (
|
{match.prizes.map((prize, index) => (
|
||||||
@@ -2465,7 +2663,7 @@ export default function MatchDetailPage() {
|
|||||||
</SideCard>
|
</SideCard>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{match.notices.length > 0 && (
|
{showInfoPanel && match.notices.length > 0 && (
|
||||||
<SideCard title="안내사항">
|
<SideCard title="안내사항">
|
||||||
<ul className="space-y-1.5">
|
<ul className="space-y-1.5">
|
||||||
{match.notices.map((notice, index) => (
|
{match.notices.map((notice, index) => (
|
||||||
@@ -2482,6 +2680,8 @@ export default function MatchDetailPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import test from "node:test";
|
||||||
|
import {
|
||||||
|
createMatchDetailTabSearchParams,
|
||||||
|
createMatchDetailTabs,
|
||||||
|
moveMatchDetailTabFocus,
|
||||||
|
resolveMatchDetailTab,
|
||||||
|
} from "../src/components/competition/match-detail-tabs.ts";
|
||||||
|
|
||||||
|
test("uses tabs only in progress or when finished and exposes operations only to managers", () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
createMatchDetailTabs({ status: "recruiting", canManage: true }),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
createMatchDetailTabs({ status: "team-built", canManage: true }),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const publicTabs = createMatchDetailTabs({
|
||||||
|
status: "in-progress",
|
||||||
|
canManage: false,
|
||||||
|
});
|
||||||
|
assert.deepEqual(
|
||||||
|
publicTabs.map((tab) => tab.id),
|
||||||
|
["bracket", "games", "teams", "info"],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
publicTabs.map((tab) => tab.label),
|
||||||
|
["대진표·순위", "경기 기록", "팀", "일정·안내"],
|
||||||
|
);
|
||||||
|
|
||||||
|
const managerTabs = createMatchDetailTabs({
|
||||||
|
status: "finished",
|
||||||
|
canManage: true,
|
||||||
|
});
|
||||||
|
assert.deepEqual(
|
||||||
|
managerTabs.map((tab) => tab.id),
|
||||||
|
["bracket", "games", "teams", "info", "ops"],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("falls back to the bracket for missing, invalid, or unauthorized tabs", () => {
|
||||||
|
const publicTabs = createMatchDetailTabs({
|
||||||
|
status: "in-progress",
|
||||||
|
canManage: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(resolveMatchDetailTab(null, []), null);
|
||||||
|
assert.equal(resolveMatchDetailTab(null, publicTabs), "bracket");
|
||||||
|
assert.equal(resolveMatchDetailTab("unknown", publicTabs), "bracket");
|
||||||
|
assert.equal(resolveMatchDetailTab("ops", publicTabs), "bracket");
|
||||||
|
assert.equal(resolveMatchDetailTab("games", publicTabs), "games");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("updates the tab query without mutating or dropping unrelated parameters", () => {
|
||||||
|
const current = new URLSearchParams("season=2026&tab=teams&from=history");
|
||||||
|
const next = createMatchDetailTabSearchParams(current, "games");
|
||||||
|
|
||||||
|
assert.equal(next.get("tab"), "games");
|
||||||
|
assert.equal(next.get("season"), "2026");
|
||||||
|
assert.equal(next.get("from"), "history");
|
||||||
|
assert.equal(current.get("tab"), "teams");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("moves tab focus with wrapping arrow keys and boundary keys", () => {
|
||||||
|
const tabs = createMatchDetailTabs({
|
||||||
|
status: "in-progress",
|
||||||
|
canManage: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.equal(moveMatchDetailTabFocus(tabs, "bracket", "ArrowRight"), "games");
|
||||||
|
assert.equal(moveMatchDetailTabFocus(tabs, "bracket", "ArrowLeft"), "info");
|
||||||
|
assert.equal(moveMatchDetailTabFocus(tabs, "info", "ArrowRight"), "bracket");
|
||||||
|
assert.equal(moveMatchDetailTabFocus(tabs, "teams", "Home"), "bracket");
|
||||||
|
assert.equal(moveMatchDetailTabFocus(tabs, "games", "End"), "info");
|
||||||
|
});
|
||||||
Reference in new issue
Block a user