import {
  useNavigate,
  useLocation,
  Routes,
  Route,
  Navigate,
} from "react-router-dom";
import { DashboardLayout, type SidebarItem } from "@edr/ui-common";

import DashboardPage from "./pages/dashboard/DashboardPage";

const sidebarItems: SidebarItem[] = [{ label: "Dashboard", href: "/" }];

const App = () => {
  const navigate = useNavigate();
  const location = useLocation();

  return (
    <DashboardLayout
      title="EDR Passenger Backoffice"
      sidebarItems={sidebarItems}
      activeHref={location.pathname}
      onNavigate={navigate}
    >
      <Routes>
        <Route path="/" element={<DashboardPage />} />
        <Route path="*" element={<Navigate to="/" replace />} />
      </Routes>
    </DashboardLayout>
  );
};

export default App;
