55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
"use client"
|
|
import { type IntlShape, useIntl } from "react-intl"
|
|
|
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
|
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
|
|
|
import RegularRow from "../Regular"
|
|
|
|
import type { Packages as PackagesType } from "@scandic-hotels/trpc/types/packages"
|
|
|
|
interface PackagesProps {
|
|
packages: PackagesType | null
|
|
}
|
|
|
|
export default function PackagesRow({ packages }: PackagesProps) {
|
|
const intl = useIntl()
|
|
|
|
if (!packages || !packages.length) {
|
|
return null
|
|
}
|
|
|
|
return packages?.map((pkg) => (
|
|
<RegularRow
|
|
key={pkg.code}
|
|
label={getFeatureDescription(pkg.code, pkg.description, intl)}
|
|
value={formatPrice(
|
|
intl,
|
|
+pkg.localPrice.totalPrice,
|
|
pkg.localPrice.currency
|
|
)}
|
|
/>
|
|
))
|
|
}
|
|
|
|
// TODO this might be duplicated, check if we can reuse
|
|
function getFeatureDescription(
|
|
code: string,
|
|
description: string,
|
|
intl: IntlShape
|
|
): string {
|
|
const roomFeatureDescriptions: Record<string, string> = {
|
|
[RoomPackageCodeEnum.ACCESSIBILITY_ROOM]: intl.formatMessage({
|
|
defaultMessage: "Accessible room",
|
|
}),
|
|
[RoomPackageCodeEnum.ALLERGY_ROOM]: intl.formatMessage({
|
|
defaultMessage: "Allergy-friendly room",
|
|
}),
|
|
[RoomPackageCodeEnum.PET_ROOM]: intl.formatMessage({
|
|
defaultMessage: "Pet-friendly room",
|
|
}),
|
|
}
|
|
|
|
return roomFeatureDescriptions[code] ?? description
|
|
}
|