import { useEffect } from "react";
import { Routes, Route } from "react-router-dom";
import Dashboard from "./pages/Dashboard";
import MatchDetail from "./pages/MatchDetail";
import Leaderboard from "./pages/Leaderboard";
import NotFound from "./pages/NotFound";
import { recordVisit } from "./lib/api";
import { PlayerProvider } from "./lib/usePlayer";
import MusicBar from "./components/MusicBar";

export default function App() {
  // 접속 시 1회 방문 기록 (하루 1기기 1회 집계는 백엔드가 처리)
  useEffect(() => {
    recordVisit();
  }, []);

  return (
    <PlayerProvider>
      <Routes>
        <Route path="/" element={<Dashboard />} />
        <Route path="/match/:matchId" element={<MatchDetail />} />
        <Route path="/leaderboard" element={<Leaderboard />} />
        <Route path="*" element={<NotFound />} />
      </Routes>
      <MusicBar />
    </PlayerProvider>
  );
}
