feat(web): build home and player history pages

This commit is contained in:
dahyeon committed 2026-04-23 05:41:00 +09:00
1 parent 74abbd7aab
commit ec4daea814
4 files changed
+1365

No files matched your search

+1
View File
@@ -0,0 +1 @@
/* App-specific styles — currently using Tailwind + daisyUI */
+106
View File
@@ -0,0 +1,106 @@
import { BrowserRouter, Link, Route, Routes } from 'react-router';
import { useMsal } from '@azure/msal-react';
import DevAuthSwitcher from './components/DevAuthSwitcher';
import { DEFAULT_COMMUNITY_ID } from './config';
import { useCommunity } from './api/hooks';
import { isMsalConfigured } from './lib/auth/msal.config';
import AuthCallbackPage from './pages/AuthCallback';
import HomePage from './pages/HomePage';
import LoginPage from './pages/Login';
import MatchDetailPage from './pages/MatchDetailPage';
import AuctionPage from './pages/AuctionPage';
import UserHistoryPage from './pages/UserHistoryPage';
import CommunityInternalStatsPage from './pages/CommunityInternalStatsPage';
import InternalMatchDetailPage from './pages/InternalMatchDetailPage';
import LegacyImportPage from './pages/admin/LegacyImportPage';
import LegacyMatchesPage from './pages/admin/LegacyMatchesPage';
import TournamentCodesPage from './pages/admin/TournamentCodesPage';
function MsalHeaderActions() {
const { accounts, instance } = useMsal();
const account = instance.getActiveAccount() ?? accounts[0];
if (!account) {
return (
<Link className="btn btn-primary btn-xs px-3" to="/login">
로그인
</Link>
);
}
return (
<button
type="button"
className="btn btn-ghost btn-xs px-3"
onClick={() => void instance.logoutRedirect()}
>
{account.name ?? account.username} 로그아웃
</button>
);
}
function App() {
const communityQuery = useCommunity(DEFAULT_COMMUNITY_ID);
const communityLabel = communityQuery.data?.name ?? 'LOLYMPUS';
return (
<BrowserRouter>
<div className="min-h-screen bg-base-100">
<nav className="bg-base-100 border-b border-base-content/10 sticky top-0 z-50">
<div className="max-w-5xl mx-auto px-4 sm:px-6 flex items-center justify-between h-11">
<Link
className="text-sm font-bold tracking-tight text-base-content"
to="/"
>
{communityLabel}
</Link>
<div className="flex items-center gap-3">
{DEFAULT_COMMUNITY_ID ? (
<span className="text-[10px] uppercase tracking-wider text-base-content/25">
API Live
</span>
) : (
<span className="text-[10px] uppercase tracking-wider text-amber-500/70">
Set `VITE_DEFAULT_COMMUNITY_ID`
</span>
)}
{isMsalConfigured && <MsalHeaderActions />}
</div>
</div>
</nav>
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/auth/callback" element={<AuthCallbackPage />} />
<Route path="/match/:id" element={<MatchDetailPage />} />
<Route path="/match/:id/auction" element={<AuctionPage />} />
<Route path="/users/:userId/history" element={<UserHistoryPage />} />
<Route
path="/communities/:cid/internal-stats"
element={<CommunityInternalStatsPage />}
/>
<Route
path="/communities/:cid/internal-stats/match/:matchId"
element={<InternalMatchDetailPage />}
/>
<Route
path="/admin/communities/:cid/tournament-codes"
element={<TournamentCodesPage />}
/>
<Route
path="/admin/communities/:cid/legacy-import"
element={<LegacyImportPage />}
/>
<Route
path="/admin/communities/:cid/legacy-matches"
element={<LegacyMatchesPage />}
/>
</Routes>
<DevAuthSwitcher />
</div>
</BrowserRouter>
);
}
export default App;
+239
View File
@@ -0,0 +1,239 @@
import { Link } from 'react-router';
import { mapApiMatchToMatchDetail } from '../api/mappers';
import { useMatches } from '../api/hooks';
import { DEFAULT_COMMUNITY_ID } from '../config';
function StatusBadge({ status }: { status: string }) {
const styles: Record<string, string> = {
모집중: 'bg-green-500/15 text-green-500 border-green-500/20',
팀빌딩: 'bg-amber-500/15 text-amber-500 border-amber-500/20',
진행중: 'bg-blue-500/15 text-blue-400 border-blue-500/20',
종료: 'bg-base-content/8 text-base-content/40 border-base-content/10',
};
return (
<span
className={`inline-flex items-center text-[11px] font-semibold px-1.5 py-0.5 border ${styles[status] ?? 'bg-base-content/10 text-base-content/50 border-base-content/10'}`}
>
{status}
</span>
);
}
function MapBadge({ map }: { map: string }) {
return (
<span className="inline-flex items-center text-[11px] px-1.5 py-0.5 border border-base-content/10 text-base-content/50">
{map}
</span>
);
}
function getStatusLabel(status: string) {
switch (status) {
case 'recruiting':
return '모집중';
case 'team-built':
return '팀빌딩';
case 'in-progress':
return '진행중';
case 'finished':
return '종료';
default:
return status;
}
}
export default function HomePage() {
const upcomingMatchesQuery = useMatches({ limit: 20 }, DEFAULT_COMMUNITY_ID);
const finishedMatchesQuery = useMatches(
{ status: 'finished', limit: 10 },
DEFAULT_COMMUNITY_ID,
);
if (!DEFAULT_COMMUNITY_ID) {
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-16">
<div className="border border-amber-500/20 bg-amber-500/10 p-5 text-sm text-amber-700">
`apps/web/.env.development`의 `VITE_DEFAULT_COMMUNITY_ID`를 먼저 설정해주세요.
</div>
</main>
);
}
if (upcomingMatchesQuery.isLoading || finishedMatchesQuery.isLoading) {
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center">
<span className="text-sm text-base-content/40">매치 목록을 불러오는 중...</span>
</main>
);
}
if (upcomingMatchesQuery.error || finishedMatchesQuery.error) {
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center">
<span className="text-sm text-red-500">
매치 목록을 불러오지 못했습니다.
</span>
</main>
);
}
const upcomingMatches =
upcomingMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? [];
const finishedMatches =
finishedMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? [];
const nextMatch = upcomingMatches[0];
const upcomingCards = nextMatch ? upcomingMatches.slice(1) : upcomingMatches;
return (
<main className="max-w-5xl mx-auto px-4 sm:px-6">
<section className="pt-8 pb-6">
<div className="flex items-center justify-between gap-3 mb-3">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest">
다음 내전
</h2>
<Link
to={`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`}
className="text-xs font-bold text-primary hover:underline"
>
내전 전적 보기
</Link>
</div>
{nextMatch ? (
<Link to={`/match/${nextMatch.id}`} className="block group">
<div className="border border-base-content/10 bg-base-200/50 hover:bg-base-200 transition-colors">
<div className="p-5 sm:p-6">
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
<div className="space-y-2.5">
<div className="flex items-center gap-2.5 flex-wrap">
<h3 className="text-xl sm:text-2xl font-bold text-base-content leading-tight">
{nextMatch.title}
</h3>
<StatusBadge status={getStatusLabel(nextMatch.status)} />
</div>
<p className="text-sm text-base-content/50 max-w-xl leading-relaxed">
{nextMatch.description}
</p>
<div className="flex items-center gap-3 text-xs text-base-content/40 flex-wrap">
<span>{nextMatch.date} {nextMatch.time}</span>
<span className="text-base-content/15">|</span>
<span>
{nextMatch.participants.length}/{nextMatch.maxParticipants}명
</span>
<span className="text-base-content/15">|</span>
<MapBadge map={nextMatch.map} />
</div>
</div>
<div className="sm:shrink-0">
<span className="btn btn-primary btn-sm px-6 text-xs font-semibold">
상세 보기
</span>
</div>
</div>
</div>
</div>
</Link>
) : (
<div className="border border-base-content/10 bg-base-100 px-5 py-10 text-center text-sm text-base-content/40">
아직 등록된 내전이 없습니다.
</div>
)}
</section>
<section className="pb-6">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
예정된 내전
</h2>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-px bg-base-content/10 border border-base-content/10">
{upcomingCards.length > 0 ? (
upcomingCards.map((match) => (
<Link key={match.id} to={`/match/${match.id}`}>
<div className="bg-base-100 hover:bg-base-200/50 transition-colors cursor-pointer h-full p-4">
<div className="flex items-center justify-between mb-2.5">
<h3 className="text-sm font-bold text-base-content truncate mr-2">
{match.title}
</h3>
<StatusBadge status={getStatusLabel(match.status)} />
</div>
<div className="space-y-1 text-xs text-base-content/40">
<div>{match.date} {match.time}</div>
<div>
{match.participants.length}/{match.maxParticipants}명
</div>
</div>
<div className="mt-2.5">
<MapBadge map={match.map} />
</div>
</div>
</Link>
))
) : (
<div className="bg-base-100 px-4 py-6 text-sm text-base-content/35 col-span-full">
예정된 추가 매치가 없습니다.
</div>
)}
</div>
</section>
<section className="pb-12">
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
지난 내전 기록
</h2>
<div className="border border-base-content/10 overflow-x-auto">
<table className="w-full text-left">
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
<th className="py-2.5 px-4 font-semibold">날짜</th>
<th className="py-2.5 px-4 font-semibold">내전</th>
<th className="py-2.5 px-4 font-semibold">맵</th>
<th className="py-2.5 px-4 font-semibold">참가</th>
<th className="py-2.5 px-4 font-semibold">결과</th>
</tr>
</thead>
<tbody>
{finishedMatches.length > 0 ? (
finishedMatches.map((match) => (
<tr
key={match.id}
className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors"
>
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
{match.date}
</td>
<td className="py-2.5 px-4">
<Link
to={`/match/${match.id}`}
className="text-sm font-medium text-base-content hover:text-primary transition-colors"
>
{match.title}
</Link>
</td>
<td className="py-2.5 px-4">
<MapBadge map={match.map} />
</td>
<td className="py-2.5 px-4 text-xs text-base-content/50">
{match.participants.length}명
</td>
<td className="py-2.5 px-4 text-xs text-base-content/50">
{match.result?.winner ? `${match.result.winner} 승리` : '-'}
</td>
</tr>
))
) : (
<tr>
<td
colSpan={5}
className="py-6 px-4 text-sm text-base-content/35 text-center"
>
아직 종료된 내전 기록이 없습니다.
</td>
</tr>
)}
</tbody>
</table>
</div>
</section>
</main>
);
}
File diff suppressed because it is too large. Load diff