import { GetDealerUseCase } from "@/contexts/sales/application";
import { NextFunction, Request, Response } from "express";
import { registerDealerRepository } from "../../../../Dealer.repository";
import { ISalesContext } from "../../../../Sales.context";
import { GetDealerController } from "./GetDealer.controller";
import { GetDealerPresenter } from "./presenter";

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

  registerDealerRepository(context);

  return new GetDealerController(
    {
      useCase: new GetDealerUseCase(context),
      presenter: GetDealerPresenter,
    },
    context
  ).execute(req, res, next);
};
