UNPKG

@qite/tide-booking-component

Version:

React Booking wizard & Booking product component for Tide

30 lines (27 loc) 812 B
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 ) => { if (!price) return ""; switch (priceMode) { case 0: return `${formatPrice(price)}`; case 1: const perPersonPrice = price / personCount; return `${formatPrice(perPersonPrice)} / ${perPersonLabel}`; case 2: const perNightPrice = price / duration; return `${formatPrice(perNightPrice)} / ${perNightLabel}`; case 3: const perPersonPerNightPrice = price / duration; return `${formatPrice( perPersonPerNightPrice )} / ${perPersonPerNightLabel}`; } };