diff --git a/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/ancillaryChoiceCard.module.css b/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/ancillaryChoiceCard.module.css new file mode 100644 index 000000000..be166de5e --- /dev/null +++ b/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/ancillaryChoiceCard.module.css @@ -0,0 +1,3 @@ +.ancillaryChoiceCard:hover { + cursor: pointer; +} diff --git a/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/index.tsx b/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/index.tsx new file mode 100644 index 000000000..a6a1d7df0 --- /dev/null +++ b/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard/index.tsx @@ -0,0 +1,39 @@ +import { useFormContext } from "react-hook-form" + +import { AncillaryCard } from "@/components/TempDesignSystem/AncillaryCard" + +import styles from "./ancillaryChoiceCard.module.css" + +import type { BreakfastChoiceCardProps } from "@/types/components/ancillaryCard" + +export default function BreakfastChoiceCard({ + name, + id, + value, + ancillary, +}: BreakfastChoiceCardProps) { + const { register, setValue } = useFormContext() + + function onLabelClick(event: React.MouseEvent) { + // Preventing click event on label elements firing twice: https://github.com/facebook/react/issues/14295 + event.preventDefault() + setValue(name, value) + } + return ( + + ) +} diff --git a/components/HotelReservation/EnterDetails/Breakfast/index.tsx b/components/HotelReservation/EnterDetails/Breakfast/index.tsx index fd1f62cca..13e74fbb4 100644 --- a/components/HotelReservation/EnterDetails/Breakfast/index.tsx +++ b/components/HotelReservation/EnterDetails/Breakfast/index.tsx @@ -8,10 +8,8 @@ import { useIntl } from "react-intl" import { useEnterDetailsStore } from "@/stores/enter-details" import { selectRoom } from "@/stores/enter-details/helpers" -import { Highlight } from "@/components/TempDesignSystem/Form/ChoiceCard/_Card" -import RadioCard from "@/components/TempDesignSystem/Form/ChoiceCard/Radio" +import BreakfastChoiceCard from "@/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard" import Body from "@/components/TempDesignSystem/Text/Body" -import { formatPrice } from "@/utils/numberFormatting" import { breakfastFormSchema } from "./schema" @@ -93,52 +91,41 @@ export default function Breakfast({ ) : null}
{packages.map((pkg) => ( - ( - { - id: "{amount} 0 {currency}/night per adult", - }, - { - amount: formatPrice( - intl, - parseInt(pkg.localPrice.price), - pkg.localPrice.currency - ), - currency: pkg.localPrice.currency, - free: (str) => {str}, - strikethrough: (str) => {str}, - } - ) - : intl.formatMessage( - { id: "{amount}/night per adult" }, - { - amount: formatPrice( - intl, - parseInt(pkg.localPrice.price), - pkg.localPrice.currency - ), - } - ) - } - text={intl.formatMessage({ - id: "All our breakfast buffets offer gluten free, vegan, and allergy-friendly options.", - })} - title={intl.formatMessage({ id: "Breakfast buffet" })} + ancillary={{ + title: intl.formatMessage({ id: "Breakfast buffet" }), + price: { + total: parseInt(pkg.localPrice.price), + currency: pkg.localPrice.currency, + included: + pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST, + text: intl.formatMessage({ id: "/night per adult" }), + }, + description: intl.formatMessage({ + id: "All our breakfast buffets offer gluten free, vegan, and allergy-friendly options.", + }), + imageUrl: "/_static/img/enter-details/breakfast.png", // TODO: Add dynamic image + }} value={pkg.code} + id={pkg.code} /> ))} - diff --git a/components/TempDesignSystem/AncillaryCard/index.tsx b/components/TempDesignSystem/AncillaryCard/index.tsx index 443bf110e..c2bcc68df 100644 --- a/components/TempDesignSystem/AncillaryCard/index.tsx +++ b/components/TempDesignSystem/AncillaryCard/index.tsx @@ -32,11 +32,13 @@ export function AncillaryCard({ ancillary }: AncillaryCardProps) {
- {formatPrice( - intl, - ancillary.price.total, - ancillary.price.currency - )} + {ancillary.price.included + ? intl.formatMessage({ id: "Included" }) + : `${formatPrice( + intl, + ancillary.price.total, + ancillary.price.currency + )} ${ancillary.price.text}`} {ancillary.points && ( diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 4c3d0fbff..8d5f42edb 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -1,4 +1,5 @@ { + "/night per adult": "/nat per voksen", "Included (based on availability)": "Inkluderet (baseret på tilgængelighed)", "Total price (incl VAT)": "Samlet pris (inkl. moms)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/nat per voksen", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index d2d2a2802..61a77a64d 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -1,4 +1,5 @@ { + "/night per adult": "/Nacht pro Erwachsenem", "Included (based on availability)": "Inbegriffen (je nach Verfügbarkeit)", "Total price (incl VAT)": "Gesamtpreis (inkl. MwSt.)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/Nacht pro Erwachsenem", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index dff710e7d..2c19b3125 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -1,5 +1,6 @@ { "+46 8 517 517 00": "+46 8 517 517 00", + "/night per adult": "/night per adult", "Included (based on availability)": "Included (based on availability)", "Total price (incl VAT)": "Total price (incl VAT)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/night per adult", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index c1511dfe3..1e217aaa5 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -1,4 +1,5 @@ { + "/night per adult": "/yötä aikuista kohti", "Included (based on availability)": "Sisältyy (saatavuuden mukaan)", "Total price (incl VAT)": "Kokonaishinta (sis. ALV)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/yötä aikuista kohti", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index e59f707b7..c7ee12543 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -1,4 +1,5 @@ { + "/night per adult": "/natt per voksen", "Included (based on availability)": "Inkludert (basert på tilgjengelighet)", "Total price (incl VAT)": "Totalpris (inkl. mva)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/natt per voksen", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index a845a4311..4c1e0119a 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -1,4 +1,5 @@ { + "/night per adult": "/natt per vuxen", "Included (based on availability)": "Ingår (baserat på tillgänglighet)", "Total price (incl VAT)": "Totalpris (inkl moms)", "{amount} 0 {currency}/night per adult": "{amount} 0 {currency}/natt per vuxen", diff --git a/public/_static/img/enter-details/breakfast.png b/public/_static/img/enter-details/breakfast.png new file mode 100644 index 000000000..56f8c7047 Binary files /dev/null and b/public/_static/img/enter-details/breakfast.png differ diff --git a/types/components/ancillaryCard.ts b/types/components/ancillaryCard.ts index dc8516a35..bfada87c9 100644 --- a/types/components/ancillaryCard.ts +++ b/types/components/ancillaryCard.ts @@ -6,8 +6,16 @@ export interface AncillaryCardProps { price: { total: number currency: string + text?: string + included?: boolean } points?: number description?: string } } + +export interface BreakfastChoiceCardProps extends AncillaryCardProps { + name: string + id?: string + value: string +}