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 = (
  participant: IInvoiceParticipant,
  context: IInvoicingContext,
): 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: InvoiceParticipantAddressPresenter(
      participant.billingAddress!,
      context,
    ),
    shipping_address: InvoiceParticipantAddressPresenter(
      participant.shippingAddress!,
      context,
    ),
  };
};
