import { checkUser } from "@/contexts/auth";
import {
  createQuoteController,
  getQuoteController,
  listQuotesController,
  reportQuoteController,
  setStatusQuoteController,
  updateQuoteController,
} from "@/contexts/sales/infrastructure/express/controllers";
import { getDealerMiddleware } from "@/contexts/sales/infrastructure/express/middlewares/dealerMiddleware";
import { Router } from "express";

export const QuoteRouter = (appRouter: Router) => {
  const quoteRoutes: Router = Router({ mergeParams: true });

  // Users CRUD
  quoteRoutes.get("/", checkUser, getDealerMiddleware, listQuotesController);
  quoteRoutes.get("/:quoteId", checkUser, getDealerMiddleware, getQuoteController);
  quoteRoutes.post("/", checkUser, getDealerMiddleware, createQuoteController);
  quoteRoutes.put("/:quoteId", checkUser, getDealerMiddleware, updateQuoteController);

  // Reports
  quoteRoutes.get("/:quoteId/report", checkUser, getDealerMiddleware, reportQuoteController);

  // Status
  quoteRoutes.put(
    "/:quoteId/setStatus",
    checkUser,
    /*getDealerMiddleware, */ setStatusQuoteController
  );
  /*
  quoteRoutes.post("/", isAdmin, createQuoteController);
  
  quoteRoutes.delete("/:quoteId", isAdmin, getDealerMiddleware, deleteQuoteController);*/

  appRouter.use("/quotes", quoteRoutes);
};
