import { Routes, Route, Navigate } from 'react-router-dom';
import ProtectedRoute from './ProtectedRoute/ProtectedRoute';
import Login from '../pages/Login/Login';
import Layout from '../components/Layout/Layout';
import Dashboard from '../pages/Dashboard/Dashboard';
import CafeManagement from '../pages/CafeManagement/CafeManagement';
import EditCafe from '../pages/CafeManagement/EditCafe';
import Stats from '../pages/Stats/Stats';

export default function AppRoutes() {
    return (
        <Routes>
            <Route path="/login" element={<Login />} />

            <Route path="/" element={<ProtectedRoute> <Layout /> </ProtectedRoute>}>
            {/* <Route path="/" element={ <Layout />}> */}
                <Route path="dashboard" element={<Dashboard />} />
                <Route path="cafe-management" element={<CafeManagement />} />
                <Route path="edit-cafe/:id" element={<EditCafe />} />
                <Route path="stats" element={<Stats />} />

                <Route index element={<Navigate to="/dashboard" replace />} />
            </Route>

            <Route path="*" element={<Navigate to="/" replace />} />
        </Routes>
    );
}