import { CreateQuoteUseCase } from "@/contexts/sales/application";
import { NextFunction, Request, Response } from "express";
import { registerQuoteRepository } from "../../../../Quote.repository";
import { ISalesContext } from "../../../../Sales.context";
import { CreateQuoteController } from "./CreateQuote.controller";
import { CreateQuotePresenter } from "./presenter";

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

  registerQuoteRepository(context);
  return new CreateQuoteController(
    {
      useCase: new CreateQuoteUseCase(context),
      presenter: CreateQuotePresenter,
    },
    context
  ).execute(req, res, next);
};
