import { Routes, Route } from 'react-router-dom'
import { AuthProvider } from './auth/AuthContext'
import { ProtectedRoute } from './auth/ProtectedRoute'
import { Layout } from './components/Layout'
import { Home } from './pages/Home'
import { AddDrink } from './pages/AddDrink'
import { EditDrink } from './pages/EditDrink'
import { DrinkDetail } from './pages/DrinkDetail'
import { Login } from './pages/Login'
import { Register } from './pages/Register'
import { Invitations } from './pages/Invitations'
import { Admin } from './pages/Admin'

export default function App() {
  return (
    <AuthProvider>
      <Routes>
        <Route path="/login" element={<Login />} />
        <Route path="/register" element={<Register />} />
        <Route
          path="/*"
          element={
            <ProtectedRoute>
              <Layout>
                <Routes>
                  <Route path="/" element={<Home />} />
                  <Route path="/add" element={<AddDrink />} />
                  <Route path="/drink/:id" element={<DrinkDetail />} />
                  <Route path="/drink/:id/edit" element={<EditDrink />} />
                  <Route path="/invitations" element={<Invitations />} />
                  <Route path="/admin" element={<Admin />} />
                </Routes>
              </Layout>
            </ProtectedRoute>
          }
        />
      </Routes>
    </AuthProvider>
  )
}
