117 lines
4.1 KiB
TypeScript
117 lines
4.1 KiB
TypeScript
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 MatchTeamProgressPage from "./pages/MatchTeamProgressPage";
|
|
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 MatchAdminPage from "./pages/admin/MatchAdminPage";
|
|
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/team/:teamIndex"
|
|
element={<MatchTeamProgressPage />}
|
|
/>
|
|
<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/matches"
|
|
element={<MatchAdminPage />}
|
|
/>
|
|
<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;
|