import { invoiceRepository } from "@contexts/invoices/intrastructure";
import { SequelizeTransactionManager } from "core/common/infrastructure";
import { ListInvoicesUseCase } from "../../../application";
import { InvoiceService } from "../../../domain";
import { ListInvoicesController } from "./list-invoices.controller";
import { listInvoicesPresenter } from "./presenter";

export const buildListInvoicesController = () => {
  const transactionManager = new SequelizeTransactionManager();
  const invoiceService = new InvoiceService(invoiceRepository);

  const useCase = new ListInvoicesUseCase(invoiceService, transactionManager);
  const presenter = listInvoicesPresenter;

  return new ListInvoicesController(useCase, presenter);
};
