import { checkIsAdmin, checkUser } from "@/contexts/auth";
import {
  getDealerController,
  listDealersController,
} from "@/contexts/sales/infrastructure/express/controllers/dealers";
import { getDealerMiddleware } from "@/contexts/sales/infrastructure/express/middlewares/Dealer.middleware";
import { Router } from "express";

export const dealerRouter = (appRouter: Router) => {
  const dealerRoutes: Router = Router({ mergeParams: true });

  dealerRoutes.get("/", checkIsAdmin, listDealersController);
  dealerRoutes.get("/:dealerId", checkUser, getDealerMiddleware, getDealerController);
  ///dealerRoutes.post("/", checkisAdmin, createDealerController);
  //dealerRoutes.put("/:dealerId", checkisAdmin, updateDealerController);
  //dealerRoutes.delete("/:dealerId", checkisAdmin, deleteDealerController);

  // Anidar quotes en /dealers/:dealerId
  //dealerRoutes.use("/:dealerId/quotes", quoteRoutes);

  appRouter.use("/dealers", dealerRoutes);
};
