// src/App.tsx
import { CssBaseline, ThemeProvider, createTheme } from '@mui/material'
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import { useAuth } from './contexts/AuthContext'
import Layout from './components/Layout'
import Home from './pages/Home'
import LoginPage from './pages/Login'
import RegisterCharacter from './pages/RegisterCharacter'
import RegisterHomework from './pages/RegisterHomework'
import CharacterList from './pages/CharacterList'
import HomeworkList from './pages/HomeworkList'
import CharacterHomeworkSelect from './pages/CharacterHomeworkSelect' // 정확한 경로로 수정
import Dashboard from './pages/Dashboard'
import Signup from './pages/Signup'

const darkTheme = createTheme({
  palette: {
    mode: 'dark',
  },
})

function App() {
    const { isLoggedIn } = useAuth()

  return (
      <ThemeProvider theme={darkTheme}>
        <CssBaseline />
        <Router>
          <Layout key={isLoggedIn ? 'in' : 'out'}>
            <Routes>
              <Route path="/" element={<Home />} />
              <Route path="/login" element={<LoginPage />} />
              <Route path="/characters/register" element={<RegisterCharacter />} />
              <Route path="/characters" element={<CharacterList />} />
              <Route path="/homeworks" element={<HomeworkList />} />
              <Route path="/homeworks/register" element={<RegisterHomework />} />
              <Route path="/characters/:characterId/homeworks" element={<CharacterHomeworkSelect />} />
              <Route path="/dashboard" element={<Dashboard />} />
              <Route path="/signup" element={<Signup />} />
            </Routes>
          </Layout>
        </Router>
      </ThemeProvider>
  )
}

export default App
