import { Outlet, RouterProvider, createBrowserRouter } from "react-router-dom"; import { DealerLayout, DealersList, ErrorPage, LoginPage, LogoutPage, QuoteCreate, QuoteEdit, SettingsEditor, SettingsLayout, StartPage, } from "./app"; import { CatalogLayout, CatalogList } from "./app/catalog"; import { DashboardPage } from "./app/dashboard"; import { QuotesLayout } from "./app/quotes/layout"; import { QuotesList } from "./app/quotes/list"; import { ProtectedRoute } from "./components"; export const Routes = () => { // Define public routes accessible to all users const routesForPublic = [ { path: "/", Component: StartPage, }, ]; const routesForErrors = [ { path: "*", Component: ErrorPage, }, ]; // Define routes accessible only to authenticated users const routesForAuthenticatedOnly = [ { path: "/home", element: ( ), }, { path: "/catalog", element: ( ), children: [ { index: true, element: , }, ], }, { path: "/dealers", element: ( ), children: [ { index: true, element: , }, ], }, { path: "/quotes", element: , children: [ { index: true, element: , }, { path: "add", element: , }, { path: "edit/:id", element: , }, ], }, { path: "/settings", element: ( ), children: [ { index: true, element: , }, ], }, { path: "/logout", element: , }, ]; // Define routes accessible only to non-authenticated users const routesForNotAuthenticatedOnly = [ { path: "/login", Component: LoginPage, }, ]; // Combine and conditionally include routes based on authentication status const router = createBrowserRouter( [ ...routesForPublic, ...routesForAuthenticatedOnly, ...routesForNotAuthenticatedOnly, ...routesForErrors, ], { //basename: "/app", } ); // Provide the router configuration using RouterProvider return ; };