import { UpdateDealerUseCase } from "@/contexts/sales/application";
import { registerDealerRepository } from "../../../../Dealer.repository";
import { ISalesContext } from "../../../../Sales.context";
import { UpdateDealerController } from "./UpdateDealer.controller";
import { UpdateDealerPresenter } from "./presenter/UpdateDealer.presenter";

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

  registerDealerRepository(context);
  return new UpdateDealerController(
    {
      useCase: new UpdateDealerUseCase(context),
      presenter: UpdateDealerPresenter,
    },
    context
  ).execute(req, res, next);
};
