import { Routes, Route } from "react-router-dom";
import { WarehouseProvider } from "./contexts/WarehouseContext";
import {
  WarehouseDashboard,
  ArticlesPage,
  ArticleFormPage,
  WarehouseLocationsPage,
  MovementsPage,
  InboundMovementPage,
  OutboundMovementPage,
  TransferMovementPage,
  StockLevelsPage,
  InventoryListPage,
  InventoryFormPage,
  InventoryCountPage,
} from "./pages";

import WarehouseLayout from "./components/WarehouseLayout";

export default function WarehouseRoutes() {
  return (
    <WarehouseProvider>
      <Routes>
        <Route element={<WarehouseLayout />}>
          {/* Dashboard */}
          <Route index element={<WarehouseDashboard />} />

          {/* Articles */}
          <Route path="articles" element={<ArticlesPage />} />
          <Route path="articles/new" element={<ArticleFormPage />} />
          <Route path="articles/:id" element={<ArticleFormPage />} />
          <Route path="articles/:id/edit" element={<ArticleFormPage />} />

          {/* Warehouse Locations */}
          <Route path="locations" element={<WarehouseLocationsPage />} />

          {/* Movements */}
          <Route path="movements" element={<MovementsPage />} />
          <Route path="movements/:id" element={<MovementsPage />} />
          <Route path="movements/inbound/new" element={<InboundMovementPage />} />
          <Route
            path="movements/outbound/new"
            element={<OutboundMovementPage />}
          />
          <Route
            path="movements/transfer/new"
            element={<TransferMovementPage />}
          />

          {/* Stock */}
          <Route path="stock" element={<StockLevelsPage />} />

          {/* Inventory */}
          <Route path="inventory" element={<InventoryListPage />} />
          <Route path="inventory/new" element={<InventoryFormPage />} />
          <Route path="inventory/:id" element={<InventoryFormPage />} />
          <Route path="inventory/:id/count" element={<InventoryCountPage />} />

          {/* Fallback */}
          <Route path="*" element={<WarehouseDashboard />} />
        </Route>
      </Routes>
    </WarehouseProvider>
  );
}
