import { CreateDealerUseCase } from "@/contexts/sales/application";
import { NextFunction, Request, Response } from "express";
import { registerDealerRepository } from "../../../../Dealer.repository";
import { ISalesContext } from "../../../../Sales.context";
import { CreateDealerController } from "./CreateDealer.controller";
import { CreateDealerPresenter } from "./presenter";

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

  registerDealerRepository(context);
  return new CreateDealerController(
    {
      useCase: new CreateDealerUseCase(context),
      presenter: CreateDealerPresenter,
    },
    context
  ).execute(req, res, next);
};
