import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import Layout from './components/Layout';
import HomePage from './pages/HomePage';
import LoginPage from './pages/LoginPage';
import SignupPage from './pages/SignupPage';
import ReservationPage from './pages/ReservationPage';
import MyReservationPage from './pages/MyReservationPage';
import AdminLayout from './pages/admin/AdminLayout';
import AdminPage from './pages/admin/AdminPage';
import AdminReservationPage from './pages/admin/ReservationPage';
import AdminTimePage from './pages/admin/TimePage';
import AdminThemePage from './pages/admin/ThemePage';
import AdminWaitingPage from './pages/admin/WaitingPage';
import { AuthProvider } from './context/AuthContext';
import AdminRoute from './components/AdminRoute';

const AdminRoutes = () => (
    <AdminLayout>
        <Routes>
            <Route path="/" element={<AdminPage />} />
            <Route path="/reservation" element={<AdminReservationPage />} />
            <Route path="/time" element={<AdminTimePage />} />
            <Route path="/theme" element={<AdminThemePage />} />
            <Route path="/waiting" element={<AdminWaitingPage />} />
        </Routes>
    </AdminLayout>
);

function App() {
  return (
    <AuthProvider>
        <Router>
            <Routes>
                <Route path="/admin/*" element={
                    <AdminRoute>
                        <AdminRoutes />
                    </AdminRoute>
                } />
                <Route path="/*" element={
                    <Layout>
                        <Routes>
                            <Route path="/" element={<HomePage />} />
                            <Route path="/login" element={<LoginPage />} />
                            <Route path="/signup" element={<SignupPage />} />
                            <Route path="/reservation" element={<ReservationPage />} />
                            <Route path="/reservation-mine" element={<MyReservationPage />} />
                        </Routes>
                    </Layout>
                } />
            </Routes>
        </Router>
    </AuthProvider>
  );
}

export default App;
