/**
 * Presentation-layer pricing utilities
 * These are UI-specific formatting helpers, not business logic
 */

import type { CatalogProductBase } from "@customer-portal/domain/catalog";

export interface PriceInfo {
  display: string;
  monthly: number | null;
  oneTime: number | null;
  currency: string;
}

export function getDisplayPrice(item: CatalogProductBase): PriceInfo | null {
  const monthlyPrice = item.monthlyPrice ?? null;
  const oneTimePrice = item.oneTimePrice ?? null;
  const currency = "JPY";

  if (monthlyPrice === null && oneTimePrice === null) {
    return null;
  }

  let display = "";
  if (monthlyPrice !== null && monthlyPrice > 0) {
    display = `¥${monthlyPrice.toLocaleString()}/month`;
  } else if (oneTimePrice !== null && oneTimePrice > 0) {
    display = `¥${oneTimePrice.toLocaleString()} (one-time)`;
  }

  return {
    display,
    monthly: monthlyPrice,
    oneTime: oneTimePrice,
    currency,
  };
}
