import { formatPrice } from '../../shared/utils/localization-util';

export const formatPriceByMode = (
  price: number | undefined,
  priceMode: number,
  personCount: number,
  duration: number,
  perPersonLabel: string,
  perNightLabel: string,
  perPersonPerNightLabel: string,
  currencyCode: string
) => {
  if (!price) return '';

  switch (priceMode) {
    case 0:
      return `${formatPrice(price, currencyCode)}`;
    case 1:
      const perPersonPrice = price / personCount;
      return `${formatPrice(perPersonPrice, currencyCode)} / ${perPersonLabel}`;
    case 2:
      const perNightPrice = price / duration;
      return `${formatPrice(perNightPrice, currencyCode)} / ${perNightLabel}`;
    case 3:
      const perPersonPerNightPrice = price / duration;
      return `${formatPrice(perPersonPerNightPrice, currencyCode)} / ${perPersonPerNightLabel}`;
  }
};
