40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
"use client"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import { useMyStayStore } from "@/stores/my-stay"
|
|
|
|
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import Row from "./Row"
|
|
|
|
export default function Breakfast() {
|
|
const intl = useIntl()
|
|
|
|
const { breakfast, breakfastChildren, rateDefinition } = useMyStayStore(
|
|
(state) => ({
|
|
breakfast: state.bookedRoom.breakfast,
|
|
breakfastChildren: state.bookedRoom.breakfastChildren,
|
|
rateDefinition: state.bookedRoom.rateDefinition,
|
|
})
|
|
)
|
|
|
|
let breakfastPrice = intl.formatMessage({
|
|
defaultMessage: "No breakfast",
|
|
})
|
|
if (rateDefinition.breakfastIncluded) {
|
|
breakfastPrice = intl.formatMessage({
|
|
defaultMessage: "Included",
|
|
})
|
|
} else if (breakfast) {
|
|
const childPrice = breakfastChildren?.localPrice.totalPrice || 0
|
|
breakfastPrice = formatPrice(
|
|
intl,
|
|
breakfast.localPrice.totalPrice + childPrice,
|
|
breakfast.localPrice.currency
|
|
)
|
|
}
|
|
|
|
const title = intl.formatMessage({ defaultMessage: "Breakfast" })
|
|
return <Row icon="coffee" text={breakfastPrice} title={title} />
|
|
}
|