// src/routes.tsx
import { createBrowserRouter } from 'react-router-dom'
import { Shell } from './components/layout/Shell'
import { RequireAuth } from './components/auth/RequireAuth'

import Landing from './pages/Landing'
import AuthLogin from './pages/AuthLogin'
import AuthRegister from './pages/AuthRegister'
import Explore from './pages/Explore'
import ShopDetails from './pages/ShopDetails'
import Booking from './pages/Booking'
import Cart from './pages/Cart'
import Profile from './pages/Profile'
import Dashboard from './pages/Dashboard'
import EventsCreate from './pages/EventsCreate'

export const router = createBrowserRouter([
  {
    element: <Shell />,
    children: [
      { path: '/', element: <Landing /> },
      { path: '/login', element: <AuthLogin /> },
      { path: '/registo', element: <AuthRegister /> },
      { path: '/explorar', element: <Explore /> },
      { path: '/barbearia/:id', element: <ShopDetails /> },

      // ✅ PROTEGIDAS
      {
        path: '/agendar/:id',
        element: (
          <RequireAuth>
            <Booking />
          </RequireAuth>
        ),
      },
      {
        path: '/carrinho',
        element: (
          <RequireAuth>
            <Cart />
          </RequireAuth>
        ),
      },
      {
        path: '/perfil',
        element: (
          <RequireAuth>
            <Profile />
          </RequireAuth>
        ),
      },
      {
        path: '/painel',
        element: (
          <RequireAuth>
            <Dashboard />
          </RequireAuth>
        ),
      },
      {
        path: '/eventos/novo',
        element: (
          <RequireAuth>
            <EventsCreate />
          </RequireAuth>
        ),
      },
    ],
  },
])
