feat: route internal match game details by community
This commit is contained in:
1 parent
d6e0bbf0e8
commit
51ea9c42d3
6 files changed
+68
-7
No files matched your search
@@ -170,6 +170,10 @@ function App() {
|
|||||||
path="/communities/:cid/internal-stats/match/:matchId"
|
path="/communities/:cid/internal-stats/match/:matchId"
|
||||||
element={<InternalMatchDetailPage />}
|
element={<InternalMatchDetailPage />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="/communities/:cid/internal-stats/match/:matchId/game/:gameNumber"
|
||||||
|
element={<MatchGameDetailPage />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/admin/communities/:cid/matches"
|
path="/admin/communities/:cid/matches"
|
||||||
element={<MatchAdminPage />}
|
element={<MatchAdminPage />}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export function internalMatchDetailPath(communityId: string, matchId: string) {
|
||||||
|
return `/communities/${communityId}/internal-stats/match/${matchId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function internalMatchGamePath(
|
||||||
|
communityId: string,
|
||||||
|
matchId: string,
|
||||||
|
gameNumber: string | number,
|
||||||
|
) {
|
||||||
|
return `${internalMatchDetailPath(communityId, matchId)}/game/${gameNumber}`;
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ import {
|
|||||||
teamIndexColorClasses,
|
teamIndexColorClasses,
|
||||||
teamIndexLabel,
|
teamIndexLabel,
|
||||||
} from "../lib/league";
|
} from "../lib/league";
|
||||||
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
import { formatRankDetail, RankBadge } from "../components/RankBadge";
|
import { formatRankDetail, RankBadge } from "../components/RankBadge";
|
||||||
import type {
|
import type {
|
||||||
ApiAuction,
|
ApiAuction,
|
||||||
@@ -780,7 +781,11 @@ function InternalRecentMatchRow({
|
|||||||
const resultTone = match.win ? "text-blue-400" : "text-red-400";
|
const resultTone = match.win ? "text-blue-400" : "text-red-400";
|
||||||
const detailPath =
|
const detailPath =
|
||||||
match.internalMatchId && match.gameNumber
|
match.internalMatchId && match.gameNumber
|
||||||
? `/match/${match.internalMatchId}/game/${match.gameNumber}`
|
? internalMatchGamePath(
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
match.internalMatchId,
|
||||||
|
match.gameNumber,
|
||||||
|
)
|
||||||
: null;
|
: null;
|
||||||
const content = (
|
const content = (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
teamIndexColorClasses,
|
teamIndexColorClasses,
|
||||||
teamIndexLabel,
|
teamIndexLabel,
|
||||||
} from "../lib/league";
|
} from "../lib/league";
|
||||||
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
import { LANE_LABELS } from "../lib/riot-history";
|
import { LANE_LABELS } from "../lib/riot-history";
|
||||||
|
|
||||||
function formatDateTime(value: string | number) {
|
function formatDateTime(value: string | number) {
|
||||||
@@ -89,9 +90,13 @@ function ItemStrip({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GamePanel({
|
function GamePanel({
|
||||||
|
communityId,
|
||||||
|
matchId,
|
||||||
game,
|
game,
|
||||||
manifest,
|
manifest,
|
||||||
}: {
|
}: {
|
||||||
|
communityId: string;
|
||||||
|
matchId: string;
|
||||||
game: ApiInternalMatchDetailResponse["games"][number];
|
game: ApiInternalMatchDetailResponse["games"][number];
|
||||||
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
manifest: ReturnType<typeof useDdragonManifest>["data"];
|
||||||
}) {
|
}) {
|
||||||
@@ -112,6 +117,13 @@ function GamePanel({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
|
<Link
|
||||||
|
to={internalMatchGamePath(communityId, matchId, game.gameNumber)}
|
||||||
|
state={{ backTo: historyBackTo }}
|
||||||
|
className="border border-primary/20 px-2 py-1 text-xs font-black text-primary transition-colors hover:bg-primary/8"
|
||||||
|
>
|
||||||
|
상세 분석
|
||||||
|
</Link>
|
||||||
{game.teams.map((team) => (
|
{game.teams.map((team) => (
|
||||||
<span
|
<span
|
||||||
key={team.side}
|
key={team.side}
|
||||||
@@ -316,7 +328,13 @@ export default function InternalMatchDetailPage() {
|
|||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{detail.games.map((game) => (
|
{detail.games.map((game) => (
|
||||||
<GamePanel key={game.riotMatchId} game={game} manifest={ddragon} />
|
<GamePanel
|
||||||
|
key={game.riotMatchId}
|
||||||
|
communityId={communityId}
|
||||||
|
matchId={detail.match.matchId}
|
||||||
|
game={game}
|
||||||
|
manifest={ddragon}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import {
|
|||||||
teamIndexColorClasses,
|
teamIndexColorClasses,
|
||||||
teamIndexLabel,
|
teamIndexLabel,
|
||||||
} from "../lib/league";
|
} from "../lib/league";
|
||||||
|
import { internalMatchGamePath } from "../lib/internal-match-routes";
|
||||||
import type {
|
import type {
|
||||||
AuctionTopTierThreshold,
|
AuctionTopTierThreshold,
|
||||||
ApiCommunityUserSearchCandidate,
|
ApiCommunityUserSearchCandidate,
|
||||||
@@ -2237,7 +2238,11 @@ function MatchGameListSection({ match }: { match: MatchDetailView }) {
|
|||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={gameNumber}
|
key={gameNumber}
|
||||||
to={`/match/${match.id}/game/${gameNumber}`}
|
to={internalMatchGamePath(
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
match.id,
|
||||||
|
gameNumber,
|
||||||
|
)}
|
||||||
className={`${rowClass} group transition-colors hover:bg-primary/5 focus-visible:bg-primary/8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`}
|
className={`${rowClass} group transition-colors hover:bg-primary/5 focus-visible:bg-primary/8 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`}
|
||||||
aria-label={`${gameNumber}경기 ${resolveMatchTeamName(match, game.blueTeamIndex)} 대 ${resolveMatchTeamName(match, game.redTeamIndex)} 상세 보기`}
|
aria-label={`${gameNumber}경기 ${resolveMatchTeamName(match, game.blueTeamIndex)} 대 ${resolveMatchTeamName(match, game.redTeamIndex)} 상세 보기`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import {
|
|||||||
teamIndexColorClasses,
|
teamIndexColorClasses,
|
||||||
teamIndexLabel,
|
teamIndexLabel,
|
||||||
} from "../lib/league";
|
} from "../lib/league";
|
||||||
|
import {
|
||||||
|
internalMatchDetailPath,
|
||||||
|
internalMatchGamePath,
|
||||||
|
} from "../lib/internal-match-routes";
|
||||||
import { LANE_LABELS } from "../lib/riot-history";
|
import { LANE_LABELS } from "../lib/riot-history";
|
||||||
|
|
||||||
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
|
type MatchGameDetail = ApiInternalMatchDetailResponse["games"][number];
|
||||||
@@ -1971,10 +1975,12 @@ function GameAnalysisPanel({
|
|||||||
|
|
||||||
function GameTabs({
|
function GameTabs({
|
||||||
detail,
|
detail,
|
||||||
|
communityId,
|
||||||
currentGameNumber,
|
currentGameNumber,
|
||||||
navigationState,
|
navigationState,
|
||||||
}: {
|
}: {
|
||||||
detail: ApiInternalMatchDetailResponse;
|
detail: ApiInternalMatchDetailResponse;
|
||||||
|
communityId: string;
|
||||||
currentGameNumber: number;
|
currentGameNumber: number;
|
||||||
navigationState: MatchGameNavigationState | undefined;
|
navigationState: MatchGameNavigationState | undefined;
|
||||||
}) {
|
}) {
|
||||||
@@ -1989,7 +1995,11 @@ function GameTabs({
|
|||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
key={game.gameNumber}
|
key={game.gameNumber}
|
||||||
to={`/match/${detail.match.matchId}/game/${game.gameNumber}`}
|
to={internalMatchGamePath(
|
||||||
|
communityId,
|
||||||
|
detail.match.matchId,
|
||||||
|
game.gameNumber,
|
||||||
|
)}
|
||||||
state={navigationState}
|
state={navigationState}
|
||||||
className={`min-w-[8rem] border-r border-base-content/8 px-4 py-3 text-xs transition-colors last:border-r-0 ${
|
className={`min-w-[8rem] border-r border-base-content/8 px-4 py-3 text-xs transition-colors last:border-r-0 ${
|
||||||
active
|
active
|
||||||
@@ -2012,11 +2022,13 @@ function GameTabs({
|
|||||||
|
|
||||||
function MatchScoreHero({
|
function MatchScoreHero({
|
||||||
detail,
|
detail,
|
||||||
|
communityId,
|
||||||
selectedGame,
|
selectedGame,
|
||||||
backTarget,
|
backTarget,
|
||||||
navigationState,
|
navigationState,
|
||||||
}: {
|
}: {
|
||||||
detail: ApiInternalMatchDetailResponse;
|
detail: ApiInternalMatchDetailResponse;
|
||||||
|
communityId: string;
|
||||||
selectedGame: MatchGameDetail;
|
selectedGame: MatchGameDetail;
|
||||||
backTarget: MatchGameBackTarget;
|
backTarget: MatchGameBackTarget;
|
||||||
navigationState: MatchGameNavigationState | undefined;
|
navigationState: MatchGameNavigationState | undefined;
|
||||||
@@ -2097,6 +2109,7 @@ function MatchScoreHero({
|
|||||||
</div>
|
</div>
|
||||||
<GameTabs
|
<GameTabs
|
||||||
detail={detail}
|
detail={detail}
|
||||||
|
communityId={communityId}
|
||||||
currentGameNumber={selectedGame.gameNumber}
|
currentGameNumber={selectedGame.gameNumber}
|
||||||
navigationState={navigationState}
|
navigationState={navigationState}
|
||||||
/>
|
/>
|
||||||
@@ -2105,14 +2118,18 @@ function MatchScoreHero({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MatchGameDetailPage() {
|
export default function MatchGameDetailPage() {
|
||||||
const { id, gameNumber } = useParams();
|
const { cid, matchId, id, gameNumber } = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [activeTab, setActiveTab] = useState<DetailTab>("scoreboard");
|
const [activeTab, setActiveTab] = useState<DetailTab>("scoreboard");
|
||||||
|
const communityId = cid ?? DEFAULT_COMMUNITY_ID;
|
||||||
|
const resolvedMatchId = matchId ?? id;
|
||||||
const requestedGameNumber = Number(gameNumber);
|
const requestedGameNumber = Number(gameNumber);
|
||||||
const detailQuery = useInternalMatchDetail(id, DEFAULT_COMMUNITY_ID);
|
const detailQuery = useInternalMatchDetail(resolvedMatchId, communityId);
|
||||||
const { data: ddragon } = useDdragonManifest();
|
const { data: ddragon } = useDdragonManifest();
|
||||||
const detail = detailQuery.data;
|
const detail = detailQuery.data;
|
||||||
const fallbackBackTo = `/match/${id ?? ""}`;
|
const fallbackBackTo = resolvedMatchId
|
||||||
|
? internalMatchDetailPath(communityId, resolvedMatchId)
|
||||||
|
: `/communities/${communityId}/internal-stats`;
|
||||||
const backTarget = resolveBackTarget(location.state, fallbackBackTo);
|
const backTarget = resolveBackTarget(location.state, fallbackBackTo);
|
||||||
const navigationState = createNavigationState(backTarget, fallbackBackTo);
|
const navigationState = createNavigationState(backTarget, fallbackBackTo);
|
||||||
|
|
||||||
@@ -2157,6 +2174,7 @@ export default function MatchGameDetailPage() {
|
|||||||
<main className="mx-auto max-w-6xl px-4 py-6 sm:px-6">
|
<main className="mx-auto max-w-6xl px-4 py-6 sm:px-6">
|
||||||
<MatchScoreHero
|
<MatchScoreHero
|
||||||
detail={detail}
|
detail={detail}
|
||||||
|
communityId={communityId}
|
||||||
selectedGame={selectedGame}
|
selectedGame={selectedGame}
|
||||||
backTarget={backTarget}
|
backTarget={backTarget}
|
||||||
navigationState={navigationState}
|
navigationState={navigationState}
|
||||||
|
|||||||
Reference in new issue
Block a user