feat: add finished match detail tabs
This commit is contained in:
1 parent
0434a5db66
commit
65bc214fb2
1 file changed
+137
-24
@@ -1872,31 +1872,24 @@ function RoundRobinStandingsTable({ match }: { match: MatchDetailView }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MatchResultPanel({ match }: { match: MatchDetailView }) {
|
function MatchStandingsSection({ match }: { match: MatchDetailView }) {
|
||||||
if (!match.result) return null;
|
if (!match.result) return null;
|
||||||
|
|
||||||
const gamesByNumber = new Map(
|
|
||||||
match.result.games.map((game) => [game.gameNumber, game]),
|
|
||||||
);
|
|
||||||
const maxGameNumber = Math.max(
|
const maxGameNumber = Math.max(
|
||||||
match.gameCount,
|
match.gameCount,
|
||||||
match.tournamentCodes.length,
|
match.tournamentCodes.length,
|
||||||
...match.result.games.map((game) => game.gameNumber),
|
...match.result.games.map((game) => game.gameNumber),
|
||||||
);
|
);
|
||||||
const gameNumbers = Array.from(
|
|
||||||
{ length: maxGameNumber },
|
|
||||||
(_, index) => index + 1,
|
|
||||||
);
|
|
||||||
const seriesResults = match.result.seriesResults ?? [];
|
const seriesResults = match.result.seriesResults ?? [];
|
||||||
const primarySeries = seriesResults[0];
|
const primarySeries = seriesResults[0];
|
||||||
const showRoundRobinStandings =
|
const showRoundRobinStandings =
|
||||||
match.gameMode === "round-robin" && match.teams.length > 2;
|
match.gameMode === "round-robin" && match.teams.length > 2;
|
||||||
|
|
||||||
|
if (showRoundRobinStandings) {
|
||||||
|
return <RoundRobinStandingsTable match={match} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-6 border border-base-content/10 bg-base-content/[0.02] p-5">
|
|
||||||
{showRoundRobinStandings ? (
|
|
||||||
<RoundRobinStandingsTable match={match} />
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
{primarySeries && (
|
{primarySeries && (
|
||||||
<div className="flex items-center justify-center gap-8">
|
<div className="flex items-center justify-center gap-8">
|
||||||
@@ -1942,15 +1935,11 @@ function MatchResultPanel({ match }: { match: MatchDetailView }) {
|
|||||||
{resolveMatchTeamName(match, series.teamBIndex)}
|
{resolveMatchTeamName(match, series.teamBIndex)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 flex items-center justify-between">
|
<div className="mt-1 flex items-center justify-between">
|
||||||
<span
|
<span className={teamIndexColorClasses(series.teamAIndex).text}>
|
||||||
className={teamIndexColorClasses(series.teamAIndex).text}
|
|
||||||
>
|
|
||||||
{series.teamAWins}
|
{series.teamAWins}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-base-content/20">:</span>
|
<span className="text-base-content/20">:</span>
|
||||||
<span
|
<span className={teamIndexColorClasses(series.teamBIndex).text}>
|
||||||
className={teamIndexColorClasses(series.teamBIndex).text}
|
|
||||||
>
|
|
||||||
{series.teamBWins}
|
{series.teamBWins}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -1959,8 +1948,27 @@ function MatchResultPanel({ match }: { match: MatchDetailView }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
);
|
||||||
<div className="mt-5 border border-base-content/8 divide-y divide-base-content/8">
|
}
|
||||||
|
|
||||||
|
function MatchGameListSection({ match }: { match: MatchDetailView }) {
|
||||||
|
if (!match.result) return null;
|
||||||
|
|
||||||
|
const gamesByNumber = new Map(
|
||||||
|
match.result.games.map((game) => [game.gameNumber, game]),
|
||||||
|
);
|
||||||
|
const maxGameNumber = Math.max(
|
||||||
|
match.gameCount,
|
||||||
|
match.tournamentCodes.length,
|
||||||
|
...match.result.games.map((game) => game.gameNumber),
|
||||||
|
);
|
||||||
|
const gameNumbers = Array.from(
|
||||||
|
{ length: maxGameNumber },
|
||||||
|
(_, index) => index + 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="border border-base-content/8 divide-y divide-base-content/8">
|
||||||
{gameNumbers.map((gameNumber) => {
|
{gameNumbers.map((gameNumber) => {
|
||||||
const game = gamesByNumber.get(gameNumber);
|
const game = gamesByNumber.get(gameNumber);
|
||||||
const rowClass =
|
const rowClass =
|
||||||
@@ -2016,15 +2024,114 @@ function MatchResultPanel({ match }: { match: MatchDetailView }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={gameNumber} className={rowClass}>
|
||||||
key={gameNumber}
|
|
||||||
className={rowClass}
|
|
||||||
>
|
|
||||||
{content}
|
{content}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MatchResultPanel({ match }: { match: MatchDetailView }) {
|
||||||
|
if (!match.result) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-6 border border-base-content/10 bg-base-content/[0.02] p-5">
|
||||||
|
<MatchStandingsSection match={match} />
|
||||||
|
<div className="mt-5">
|
||||||
|
<MatchGameListSection match={match} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type FinishedResultTab = "standings" | "games" | "teams" | "info";
|
||||||
|
|
||||||
|
function FinishedMatchTabs({ match }: { match: MatchDetailView }) {
|
||||||
|
const [resultTab, setResultTab] = useState<FinishedResultTab>("standings");
|
||||||
|
const hasInfo = match.prizes.length > 0 || match.notices.length > 0;
|
||||||
|
const tabs: Array<{ id: FinishedResultTab; label: string }> = [
|
||||||
|
{ id: "standings", label: "순위표" },
|
||||||
|
{ id: "games", label: "경기결과" },
|
||||||
|
{ id: "teams", label: "팀 빌딩" },
|
||||||
|
...(hasInfo
|
||||||
|
? [{ id: "info" as FinishedResultTab, label: "대회 정보" }]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
const activeTab =
|
||||||
|
resultTab === "info" && !hasInfo ? "standings" : resultTab;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mb-6 space-y-4">
|
||||||
|
<div className="flex overflow-x-auto border border-base-content/10 bg-base-100">
|
||||||
|
{tabs.map((item) => (
|
||||||
|
<button
|
||||||
|
key={item.id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setResultTab(item.id)}
|
||||||
|
className={`min-w-[7.5rem] border-r border-base-content/8 px-4 py-3 text-xs font-black transition-colors last:border-r-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${
|
||||||
|
activeTab === item.id
|
||||||
|
? "bg-primary text-primary-content"
|
||||||
|
: "text-base-content/45 hover:bg-base-content/[0.03] hover:text-base-content"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{activeTab === "standings" && (
|
||||||
|
<div className="border border-base-content/10 bg-base-content/[0.02] p-5">
|
||||||
|
<MatchStandingsSection match={match} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{activeTab === "games" && <MatchGameListSection match={match} />}
|
||||||
|
{activeTab === "teams" && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{match.teams.map((team) => (
|
||||||
|
<TeamCard
|
||||||
|
key={team.teamIndex}
|
||||||
|
team={team}
|
||||||
|
matchId={match.id}
|
||||||
|
isWinner={match.result?.winnerTeamIndex === team.teamIndex}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{activeTab === "info" && (
|
||||||
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
|
{match.prizes.length > 0 && (
|
||||||
|
<SideCard title="상품">
|
||||||
|
<ul className="space-y-1.5">
|
||||||
|
{match.prizes.map((prize, index) => (
|
||||||
|
<li
|
||||||
|
key={index}
|
||||||
|
className="flex items-start gap-2 text-sm text-base-content/60"
|
||||||
|
>
|
||||||
|
<span className="text-accent shrink-0 text-xs">▸</span>
|
||||||
|
<span>{prize}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</SideCard>
|
||||||
|
)}
|
||||||
|
{match.notices.length > 0 && (
|
||||||
|
<SideCard title="안내사항">
|
||||||
|
<ul className="space-y-1.5">
|
||||||
|
{match.notices.map((notice, index) => (
|
||||||
|
<li
|
||||||
|
key={index}
|
||||||
|
className="flex items-start gap-2 text-sm text-base-content/60"
|
||||||
|
>
|
||||||
|
<span className="text-info shrink-0 font-bold">•</span>
|
||||||
|
<span>{notice}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</SideCard>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2537,6 +2644,10 @@ export default function MatchDetailPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{match.status === "finished" ? (
|
||||||
|
<FinishedMatchTabs match={match} />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<MatchResultPanel match={match} />
|
<MatchResultPanel match={match} />
|
||||||
|
|
||||||
<div className="flex flex-col lg:flex-row gap-5">
|
<div className="flex flex-col lg:flex-row gap-5">
|
||||||
@@ -3116,6 +3227,8 @@ export default function MatchDetailPage() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{replaceCodeSlot && (
|
{replaceCodeSlot && (
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in new issue
Block a user