import { Routes, Route, Navigate } from "react-router-dom";
import Login from "./pages/Login";
import Home from "./pages/Home.jsx";
import Accessories from "./pages/Accessories.jsx";
import PrivateRoute from "./components/PrivateRoute";
import Cities from "./pages/Cities.jsx";
import FederalDistricts from "./pages/FederalDistricts.jsx";
import Roles from "./pages/Roles.jsx";
import Statuses from "./pages/Statuses.jsx";
import Trucks from "./pages/Trucks.jsx";
import Users from "./pages/Users.jsx";
import DeliveryOrderDetails from "./pages/DeliveryOrderDetails.jsx";
import RoleRoute from "./components/RoleRoute.jsx";

const RoutesComponent = () => (
  <Routes>
    <Route path="/login" element={<Login />} />
    <Route element={<PrivateRoute />}>
      <Route path="/" element={<Home />} />
      <Route path="/sub-orders/:id" element={<DeliveryOrderDetails />} />

      <Route element={<RoleRoute allowedRoles={["Администратор"]} />}>
        <Route path="/accessories" element={<Accessories />} />
        <Route path="/cities" element={<Cities />} />
        <Route path="/federal_districts" element={<FederalDistricts />} />
        <Route path="/roles" element={<Roles />} />
        <Route path="/statuses" element={<Statuses />} />
        <Route path="/trucks" element={<Trucks />} />
        <Route path="/users" element={<Users />} />
      </Route>
    </Route>
  </Routes>
);

export default RoutesComponent;
