import { dt } from "@/lib/dt" import type { IntlShape } from "react-intl" import type { BookingConfirmation } from "@/types/trpc/routers/booking/confirmation" export function formatStayDetails({ booking, lang, intl, }: { booking: BookingConfirmation["booking"] lang: string intl: IntlShape }) { const checkInDate = dt(booking.checkInDate) .locale(lang) .format("dddd D MMM YYYY") const checkOutDate = dt(booking.checkOutDate) .locale(lang) .format("dddd D MMM YYYY") const diff = dt(checkOutDate).diff(checkInDate, "days") const nightsText = intl.formatMessage( { id: "{totalNights, plural, one {# night} other {# nights}}" }, { totalNights: diff } ) const adultsText = intl.formatMessage( { id: "{totalAdults, plural, one {# adult} other {# adults}}" }, { totalAdults: booking.adults } ) const childrenText = intl.formatMessage( { id: "{totalChildren, plural, one {# child} other {# children}}" }, { totalChildren: booking.childrenAges?.length } ) return { checkInDate, checkOutDate, nightsText, adultsText, childrenText, } }