Files
web/apps/scandic-web/components/HotelReservation/MyStay/Rooms/SingleRoom/Details/BedPreference.tsx
Simon Emanuelsson db289b80b1 feat: refactor NewDates, clean up legacy code
This reverts commit 0c7836fa59.
2025-05-03 21:45:45 +02:00

50 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useIntl } from "react-intl"
import { useMyStayStore } from "@/stores/my-stay"
import Row from "./Row"
export default function BedPreference() {
const intl = useIntl()
const bedType = useMyStayStore((state) => state.bookedRoom.room?.bedType)
if (!bedType) {
return null
}
const mainBedWidthValueMsg = intl.formatMessage(
{
defaultMessage: "{value} cm",
},
{
value: bedType.mainBed.widthRange.min,
}
)
const mainBedWidthRangeMsg = intl.formatMessage(
{
defaultMessage: "{min}{max} cm",
},
{
min: bedType.mainBed.widthRange.min,
max: bedType.mainBed.widthRange.max,
}
)
const sameWidth =
bedType.mainBed.widthRange.min === bedType.mainBed.widthRange.max
const widthMsg = sameWidth ? mainBedWidthValueMsg : mainBedWidthRangeMsg
const text = `${bedType.mainBed.description} (${widthMsg})`
return (
<Row
icon="bed"
text={text}
title={intl.formatMessage({
defaultMessage: "Bed preference",
})}
/>
)
}