import { UpdateQuoteUseCase } from "@/contexts/sales/application";
import { NextFunction, Request, Response } from "express";
import { registerQuoteRepository } from "../../../../Quote.repository";
import { ISalesContext } from "../../../../Sales.context";
import { UpdateQuoteController } from "./UpdateQuote.controller";
import { UpdateQuotePresenter } from "./presenter/UpdateQuote.presenter";

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

  registerQuoteRepository(context);
  return new UpdateQuoteController(
    {
      useCase: new UpdateQuoteUseCase(context),
      presenter: UpdateQuotePresenter,
    },
    context
  ).execute(req, res, next);
};
