import { GetDealerByUserUseCase } from "@/contexts/sales/application";
import { NextFunction, Request, Response } from "express";
import { registerDealerRepository } from "../../../../Dealer.repository";
import { ISalesContext } from "../../../../Sales.context";
import { GetDealerByUserController } from "./GetDealerByUser.controller";
import { GetDealerByUserPresenter } from "./presenter";

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

  registerDealerRepository(context);

  return new GetDealerByUserController(
    {
      useCase: new GetDealerByUserUseCase(context),
      presenter: GetDealerByUserPresenter,
    },
    context
  ).execute(req, res, next);
};
