import { IInvoiceParticipant } from "@/contexts/invoicing/domain";
import { IInvoicingContext } from "@/contexts/invoicing/intrastructure/InvoicingContext";
import { ICreateInvoice_Participant_Response_DTO } from "@shared/contexts";
import { InvoiceParticipantAddressPresenter } from "./InvoiceParticipantAddress.presenter";

export const InvoiceParticipantPresenter = async (
  participant: IInvoiceParticipant,
  context: IInvoicingContext,
): Promise<ICreateInvoice_Participant_Response_DTO | undefined> => {
  return {
    id: participant.id.toString(),
    tin: participant.tin.toString(),
    first_name: participant.firstName.toString(),
    last_name: participant.lastName.toString(),
    company_name: participant.companyName.toString(),

    billing_address: await InvoiceParticipantAddressPresenter(
      participant.billingAddress!,
      context,
    ),
    shipping_address: await InvoiceParticipantAddressPresenter(
      participant.shippingAddress!,
      context,
    ),
  };
};
