Merged in feat/SW-1504-UI-update-breakfast-component (pull request #1284)
feat(SW-1504): Used AncillaryCard and added to breakfast choice * feat(SW-1504): Craeted AncillaryCard and added to breakfast choice * feat(SW-1504): Using of AncillaryCard * feat(SW-1504) Removed unused imports * feat(SW-1504): Added price text * feat(SW-1504): added /night per adult * feat(SW-1504) Removed type prop Approved-by: Arvid Norlin
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
.ancillaryChoiceCard:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
@@ -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 (
|
||||||
|
<label
|
||||||
|
onClick={onLabelClick}
|
||||||
|
tabIndex={0}
|
||||||
|
className={styles.ancillaryChoiceCard}
|
||||||
|
>
|
||||||
|
<AncillaryCard ancillary={ancillary} />
|
||||||
|
<input
|
||||||
|
{...register(name)}
|
||||||
|
aria-hidden
|
||||||
|
id={id || name}
|
||||||
|
hidden
|
||||||
|
type="radio"
|
||||||
|
value={value}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -8,10 +8,8 @@ import { useIntl } from "react-intl"
|
|||||||
import { useEnterDetailsStore } from "@/stores/enter-details"
|
import { useEnterDetailsStore } from "@/stores/enter-details"
|
||||||
import { selectRoom } from "@/stores/enter-details/helpers"
|
import { selectRoom } from "@/stores/enter-details/helpers"
|
||||||
|
|
||||||
import { Highlight } from "@/components/TempDesignSystem/Form/ChoiceCard/_Card"
|
import BreakfastChoiceCard from "@/components/HotelReservation/EnterDetails/Breakfast/BreakfastChoiceCard"
|
||||||
import RadioCard from "@/components/TempDesignSystem/Form/ChoiceCard/Radio"
|
|
||||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||||
import { formatPrice } from "@/utils/numberFormatting"
|
|
||||||
|
|
||||||
import { breakfastFormSchema } from "./schema"
|
import { breakfastFormSchema } from "./schema"
|
||||||
|
|
||||||
@@ -93,52 +91,41 @@ export default function Breakfast({
|
|||||||
) : null}
|
) : null}
|
||||||
<form className={styles.form} onSubmit={methods.handleSubmit(onSubmit)}>
|
<form className={styles.form} onSubmit={methods.handleSubmit(onSubmit)}>
|
||||||
{packages.map((pkg) => (
|
{packages.map((pkg) => (
|
||||||
<RadioCard
|
<BreakfastChoiceCard
|
||||||
key={pkg.code}
|
key={pkg.code}
|
||||||
id={pkg.code}
|
|
||||||
name="breakfast"
|
name="breakfast"
|
||||||
subtitle={
|
ancillary={{
|
||||||
pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST
|
title: intl.formatMessage({ id: "Breakfast buffet" }),
|
||||||
? intl.formatMessage<React.ReactNode>(
|
price: {
|
||||||
{
|
total: parseInt(pkg.localPrice.price),
|
||||||
id: "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult",
|
currency: pkg.localPrice.currency,
|
||||||
},
|
included:
|
||||||
{
|
pkg.code === BreakfastPackageEnum.FREE_MEMBER_BREAKFAST,
|
||||||
amount: formatPrice(
|
text: intl.formatMessage({ id: "/night per adult" }),
|
||||||
intl,
|
},
|
||||||
parseInt(pkg.localPrice.price),
|
description: intl.formatMessage({
|
||||||
pkg.localPrice.currency
|
id: "All our breakfast buffets offer gluten free, vegan, and allergy-friendly options.",
|
||||||
),
|
}),
|
||||||
currency: pkg.localPrice.currency,
|
imageUrl: "/_static/img/enter-details/breakfast.png", // TODO: Add dynamic image
|
||||||
free: (str) => <Highlight>{str}</Highlight>,
|
}}
|
||||||
strikethrough: (str) => <s>{str}</s>,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
: 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" })}
|
|
||||||
value={pkg.code}
|
value={pkg.code}
|
||||||
|
id={pkg.code}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<RadioCard
|
<BreakfastChoiceCard
|
||||||
name="breakfast"
|
name="breakfast"
|
||||||
subtitle={formatPrice(intl, 0, packages[0].localPrice.currency)}
|
ancillary={{
|
||||||
text={intl.formatMessage({
|
title: intl.formatMessage({ id: "No breakfast" }),
|
||||||
id: "You can always change your mind later and add breakfast at the hotel.",
|
price: {
|
||||||
})}
|
total: 0,
|
||||||
title={intl.formatMessage({ id: "No breakfast" })}
|
currency: packages[0].localPrice.currency,
|
||||||
|
},
|
||||||
|
description: intl.formatMessage({
|
||||||
|
id: "You can always change your mind later and add breakfast at the hotel.",
|
||||||
|
}),
|
||||||
|
imageUrl: "/_static/img/enter-details/breakfast.png", // TODO: Add dynamic image
|
||||||
|
imageOpacity: 0.1,
|
||||||
|
}}
|
||||||
value="false"
|
value="false"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -32,11 +32,13 @@ export function AncillaryCard({ ancillary }: AncillaryCardProps) {
|
|||||||
|
|
||||||
<div className={styles.price}>
|
<div className={styles.price}>
|
||||||
<Body color="uiTextHighContrast">
|
<Body color="uiTextHighContrast">
|
||||||
{formatPrice(
|
{ancillary.price.included
|
||||||
intl,
|
? intl.formatMessage({ id: "Included" })
|
||||||
ancillary.price.total,
|
: `${formatPrice(
|
||||||
ancillary.price.currency
|
intl,
|
||||||
)}
|
ancillary.price.total,
|
||||||
|
ancillary.price.currency
|
||||||
|
)} ${ancillary.price.text}`}
|
||||||
</Body>
|
</Body>
|
||||||
|
|
||||||
{ancillary.points && (
|
{ancillary.points && (
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"/night per adult": "/nat per voksen",
|
||||||
"<b>Included</b> (based on availability)": "<b>Inkluderet</b> (baseret på tilgængelighed)",
|
"<b>Included</b> (based on availability)": "<b>Inkluderet</b> (baseret på tilgængelighed)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Samlet pris</b> (inkl. moms)",
|
"<b>Total price</b> (incl VAT)": "<b>Samlet pris</b> (inkl. moms)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/nat per voksen",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/nat per voksen",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"/night per adult": "/Nacht pro Erwachsenem",
|
||||||
"<b>Included</b> (based on availability)": "<b>Inbegriffen</b> (je nach Verfügbarkeit)",
|
"<b>Included</b> (based on availability)": "<b>Inbegriffen</b> (je nach Verfügbarkeit)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Gesamtpreis</b> (inkl. MwSt.)",
|
"<b>Total price</b> (incl VAT)": "<b>Gesamtpreis</b> (inkl. MwSt.)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/Nacht pro Erwachsenem",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/Nacht pro Erwachsenem",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"+46 8 517 517 00": "+46 8 517 517 00",
|
"+46 8 517 517 00": "+46 8 517 517 00",
|
||||||
|
"/night per adult": "/night per adult",
|
||||||
"<b>Included</b> (based on availability)": "<b>Included</b> (based on availability)",
|
"<b>Included</b> (based on availability)": "<b>Included</b> (based on availability)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Total price</b> (incl VAT)",
|
"<b>Total price</b> (incl VAT)": "<b>Total price</b> (incl VAT)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"/night per adult": "/yötä aikuista kohti",
|
||||||
"<b>Included</b> (based on availability)": "<b>Sisältyy</b> (saatavuuden mukaan)",
|
"<b>Included</b> (based on availability)": "<b>Sisältyy</b> (saatavuuden mukaan)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Kokonaishinta</b> (sis. ALV)",
|
"<b>Total price</b> (incl VAT)": "<b>Kokonaishinta</b> (sis. ALV)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/yötä aikuista kohti",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/yötä aikuista kohti",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"/night per adult": "/natt per voksen",
|
||||||
"<b>Included</b> (based on availability)": "<b>Inkludert</b> (basert på tilgjengelighet)",
|
"<b>Included</b> (based on availability)": "<b>Inkludert</b> (basert på tilgjengelighet)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Totalpris</b> (inkl. mva)",
|
"<b>Total price</b> (incl VAT)": "<b>Totalpris</b> (inkl. mva)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/natt per voksen",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/natt per voksen",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"/night per adult": "/natt per vuxen",
|
||||||
"<b>Included</b> (based on availability)": "<b>Ingår</b> (baserat på tillgänglighet)",
|
"<b>Included</b> (based on availability)": "<b>Ingår</b> (baserat på tillgänglighet)",
|
||||||
"<b>Total price</b> (incl VAT)": "<b>Totalpris</b> (inkl moms)",
|
"<b>Total price</b> (incl VAT)": "<b>Totalpris</b> (inkl moms)",
|
||||||
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/natt per vuxen",
|
"<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/night per adult": "<strikethrough>{amount}</strikethrough> <free>0 {currency}</free>/natt per vuxen",
|
||||||
|
|||||||
BIN
public/_static/img/enter-details/breakfast.png
Normal file
BIN
public/_static/img/enter-details/breakfast.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 MiB |
@@ -6,8 +6,16 @@ export interface AncillaryCardProps {
|
|||||||
price: {
|
price: {
|
||||||
total: number
|
total: number
|
||||||
currency: string
|
currency: string
|
||||||
|
text?: string
|
||||||
|
included?: boolean
|
||||||
}
|
}
|
||||||
points?: number
|
points?: number
|
||||||
description?: string
|
description?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BreakfastChoiceCardProps extends AncillaryCardProps {
|
||||||
|
name: string
|
||||||
|
id?: string
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user