import { Collection, ensureString } from "@repo/rdx-utils";

import { CustomerInvoice } from "@/contexts/customer-billing/domain";
import { IListCustomerInvoicesResponseDTO } from "../../../dto";

export interface IListCustomerInvoicesPresenter {
  toDTO: (customers: Collection<CustomerInvoice>) => IListCustomerInvoicesResponseDTO[];
}

export const listCustomerInvoicesPresenter: IListCustomerInvoicesPresenter = {
  toDTO: (invoice: Collection<CustomerInvoice>): IListCustomerInvoicesResponseDTO[] =>
    invoice.map((customer) => ({
      id: ensureString(customer.id.toString()),
      /*reference: ensureString(customer.),

      is_freelancer: ensureBoolean(customer.isFreelancer),
      name: ensureString(customer.name),
      trade_name: ensureString(customer.tradeName.getValue()),
      tin: ensureString(customer.tin.toString()),

      street: ensureString(customer.address.street),
      city: ensureString(customer.address.city),
      state: ensureString(customer.address.state),
      postal_code: ensureString(customer.address.postalCode),
      country: ensureString(customer.address.country),

      email: ensureString(customer.email.toString()),
      phone: ensureString(customer.phone.toString()),
      fax: ensureString(customer.fax.getValue()?.toString()),
      website: ensureString(customer.website.getValue()),

      legal_record: ensureString(customer.legalRecord),

      default_tax: ensureNumber(customer.defaultTax),
      status: ensureString(customer.isActive ? "active" : "inactive"),
      lang_code: ensureString(customer.langCode),
      currency_code: ensureString(customer.currencyCode),*/
    })),
};
