import { ListQuotesUseCase } from "@/contexts/sales/application";
import { registerQuoteRepository } from "@/contexts/sales/infrastructure/Quote.repository";
import { ISalesContext } from "@/contexts/sales/infrastructure/Sales.context";
import { NextFunction, Request, Response } from "express";
import { ListQuotesController } from "./ListQuotes.controller";
import { ListQuotesPresenter } from "./presenter";

export const listQuotesController = (req: Request, res: Response, next: NextFunction) => {
  const context: ISalesContext = res.locals.context;

  registerQuoteRepository(context);

  return new ListQuotesController(
    {
      useCase: new ListQuotesUseCase(context),
      presenter: ListQuotesPresenter,
    },
    context
  ).execute(req, res, next);
};
