"use client" import { useIntl } from "react-intl" import { Typography } from "@scandic-hotels/design-system/Typography" import { formatPrice } from "@/utils/numberFormatting" import { getPeriod } from "./utils" import styles from "./parkingPrices.module.css" import { type ParkingPricesProps, Periods, } from "@/types/components/hotelPage/sidepeek/parking" export default function ParkingPrices({ currency = "", freeParking, pricing, }: ParkingPricesProps) { const intl = useIntl() if (freeParking) { return (

{intl.formatMessage({ defaultMessage: "Free parking" })}

) } const filteredPricing = pricing.filter((price) => price.amount > 0) if (filteredPricing.length === 0) { return (
{getPeriod(intl, "Hour")}
{intl.formatMessage({ defaultMessage: "At a cost", })}
) } return (
{filteredPricing.map(({ period, amount, startTime, endTime }) => (
{getPeriod(intl, period)}
{formatPrice(intl, amount, currency)}
{startTime && endTime && period !== Periods.allDay ? (
{intl.formatMessage({ defaultMessage: "From" })}
{/* eslint-disable formatjs/no-literal-string-in-jsx */}
{`${startTime}-${endTime}`}
) : null}
))}
) }