From 118f1afafa6c2b99742acef6db9fe7d055210ddc Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Wed, 18 Dec 2024 09:47:06 +0000 Subject: [PATCH] Merged in feat/SW-1023-bed-type-information (pull request #1056) Feat/SW-1023 bed type information * feat(SW-1023): add bed type info * fix: formatting of bed type string * fix(SW-1023): refactored bed type info and added default value to children beds * fix(SW-1023): fixes from PR Approved-by: Christel Westerberg Approved-by: Simon.Emanuelsson --- .../BedType/BedTypeInfo/index.tsx | 44 +++++++++++++ .../BedType/bedOptions.module.css | 6 ++ .../EnterDetails/BedType/index.tsx | 44 +++++++------ .../EnterDetails/Summary/UI/index.tsx | 61 ++++++++++++++++--- i18n/dictionaries/da.json | 4 ++ i18n/dictionaries/de.json | 4 ++ i18n/dictionaries/en.json | 4 ++ i18n/dictionaries/fi.json | 4 ++ i18n/dictionaries/no.json | 4 ++ i18n/dictionaries/sv.json | 4 ++ .../hotelReservation/enterDetails/bedType.ts | 8 ++- 11 files changed, 158 insertions(+), 29 deletions(-) create mode 100644 components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx diff --git a/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx b/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx new file mode 100644 index 000000000..2dd696349 --- /dev/null +++ b/components/HotelReservation/EnterDetails/BedType/BedTypeInfo/index.tsx @@ -0,0 +1,44 @@ +import { useIntl } from "react-intl" + +import { useEnterDetailsStore } from "@/stores/enter-details" + +import Body from "@/components/TempDesignSystem/Text/Body" + +import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums" +import type { BedTypeInfoProps } from "@/types/components/hotelReservation/enterDetails/bedType" + +export default function BedTypeInfo({ hasMultipleBedTypes }: BedTypeInfoProps) { + const intl = useIntl() + + const hasChildWithExtraBed = useEnterDetailsStore((state) => + state.booking.rooms[0].children?.some( + (child) => Number(child.bed) === ChildBedMapEnum.IN_EXTRA_BED + ) + ) + + const availabilityText = intl.formatMessage({ + id: "Your selected bed type will be provided based on availability", + }) + + const extraBedText = intl.formatMessage({ + id: "Extra bed will be provided additionally", + }) + + if (hasMultipleBedTypes && hasChildWithExtraBed) { + return ( + + {availabilityText}. {extraBedText} + + ) + } + + if (hasMultipleBedTypes) { + return {availabilityText} + } + + if (hasChildWithExtraBed) { + return {extraBedText} + } + + return null +} diff --git a/components/HotelReservation/EnterDetails/BedType/bedOptions.module.css b/components/HotelReservation/EnterDetails/BedType/bedOptions.module.css index 844ed4a6b..9bde9175b 100644 --- a/components/HotelReservation/EnterDetails/BedType/bedOptions.module.css +++ b/components/HotelReservation/EnterDetails/BedType/bedOptions.module.css @@ -1,3 +1,9 @@ +.container { + display: flex; + flex-direction: column; + gap: var(--Spacing-x2); +} + .form { display: grid; gap: var(--Spacing-x2); diff --git a/components/HotelReservation/EnterDetails/BedType/index.tsx b/components/HotelReservation/EnterDetails/BedType/index.tsx index 4f89eb2f0..9002f344e 100644 --- a/components/HotelReservation/EnterDetails/BedType/index.tsx +++ b/components/HotelReservation/EnterDetails/BedType/index.tsx @@ -9,6 +9,7 @@ import { useEnterDetailsStore } from "@/stores/enter-details" import { KingBedIcon } from "@/components/Icons" import RadioCard from "@/components/TempDesignSystem/Form/ChoiceCard/Radio" +import BedTypeInfo from "./BedTypeInfo" import { bedTypeFormSchema } from "./schema" import styles from "./bedOptions.module.css" @@ -62,26 +63,29 @@ export default function BedType({ bedTypes }: BedTypeProps) { return ( -
- {bedTypes.map((roomType) => { - const width = - roomType.size.max === roomType.size.min - ? `${roomType.size.min} cm` - : `${roomType.size.min} cm - ${roomType.size.max} cm` - return ( - - ) - })} - +
+ 1} /> +
+ {bedTypes.map((roomType) => { + const width = + roomType.size.max === roomType.size.min + ? `${roomType.size.min} cm` + : `${roomType.size.min} cm - ${roomType.size.max} cm` + return ( + + ) + })} + +
) } diff --git a/components/HotelReservation/EnterDetails/Summary/UI/index.tsx b/components/HotelReservation/EnterDetails/Summary/UI/index.tsx index 2d1e02f77..0139daa28 100644 --- a/components/HotelReservation/EnterDetails/Summary/UI/index.tsx +++ b/components/HotelReservation/EnterDetails/Summary/UI/index.tsx @@ -22,6 +22,7 @@ import Modal from "../../Modal" import styles from "./ui.module.css" +import { ChildBedMapEnum } from "@/types/components/bookingWidget/enums" import type { SummaryProps } from "@/types/components/hotelReservation/summary" import type { DetailsState } from "@/types/stores/enter-details" @@ -67,6 +68,25 @@ export default function SummaryUI({ const adults = booking.rooms[0].adults const children = booking.rooms[0].children + const childrenBeds = children?.reduce( + (acc, value) => { + const bedType = Number(value.bed) + if (bedType === ChildBedMapEnum.IN_ADULTS_BED) { + return acc + } + const count = acc.get(bedType) ?? 0 + acc.set(bedType, count + 1) + return acc + }, + new Map([ + [ChildBedMapEnum.IN_CRIB, 0], + [ChildBedMapEnum.IN_EXTRA_BED, 0], + ]) + ) + + const childBedCrib = childrenBeds?.get(ChildBedMapEnum.IN_CRIB) + const childBedExtraBed = childrenBeds?.get(ChildBedMapEnum.IN_EXTRA_BED) + const memberPrice = roomRate.memberRate ? { currency: roomRate.memberRate.localPrice.currency, @@ -179,12 +199,7 @@ export default function SummaryUI({ : null} {bedType ? (
-
- {bedType.description} - - {intl.formatMessage({ id: "Based on availability" })} - -
+ {bedType.description} {intl.formatNumber(0, { @@ -194,7 +209,39 @@ export default function SummaryUI({
) : null} - + {childBedCrib ? ( +
+
+ + {`${intl.formatMessage({ id: "Crib (child)" })} × ${childBedCrib}`} + + + {intl.formatMessage({ id: "Based on availability" })} + +
+ + {intl.formatNumber(0, { + currency: roomPrice.local.currency, + style: "currency", + })} + +
+ ) : null} + {childBedExtraBed ? ( +
+
+ + {`${intl.formatMessage({ id: "Extra bed (child)" })} × ${childBedExtraBed}`} + +
+ + {intl.formatNumber(0, { + currency: roomPrice.local.currency, + style: "currency", + })} + +
+ ) : null} {breakfast === false ? (
diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 0a8f7d820..4378a7b9a 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -105,6 +105,7 @@ "Creative spaces for meetings": "Kreative rum til møder", "Credit card": "Kreditkort", "Credit card deleted successfully": "Kreditkort blev slettet", + "Crib (child)": "Kørestol (barn)", "Currency Code": "DKK", "Current password": "Nuværende kodeord", "Customer service": "Kundeservice", @@ -142,6 +143,8 @@ "Expires at the earliest": "Udløber tidligst {date}", "Explore all levels and benefits": "Udforsk alle niveauer og fordele", "Explore nearby": "Udforsk i nærheden", + "Extra bed (child)": "Ekstra seng (barn)", + "Extra bed will be provided additionally": "Der vil blive stillet en ekstra seng til rådighed", "Extras to your booking": "Tillæg til din booking", "FAQ": "Ofte stillede spørgsmål", "Failed to delete credit card, please try again later.": "Kunne ikke slette kreditkort. Prøv venligst igen senere.", @@ -486,6 +489,7 @@ "Your level": "Dit niveau", "Your points to spend": "Dine brugbare point", "Your room": "Dit værelse", + "Your selected bed type will be provided based on availability": "Din valgte sengtype vil blive stillet til rådighed baseret på tilgængelighed", "Zip code": "Postnummer", "Zoo": "Zoo", "Zoom in": "Zoom ind", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 6fd41b9fe..03fb803f9 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -105,6 +105,7 @@ "Creative spaces for meetings": "Kreative Räume für Meetings", "Credit card": "Kreditkarte", "Credit card deleted successfully": "Kreditkarte erfolgreich gelöscht", + "Crib (child)": "Kinderbett (Kind)", "Currency Code": "EUR", "Current password": "Aktuelles Passwort", "Customer service": "Kundendienst", @@ -142,6 +143,8 @@ "Expires at the earliest": "Läuft frühestens am {date} ab", "Explore all levels and benefits": "Entdecken Sie alle Levels und Vorteile", "Explore nearby": "Erkunden Sie die Umgebung", + "Extra bed (child)": "Ekstra seng (Kind)", + "Extra bed will be provided additionally": "Ein zusätzliches Bett wird bereitgestellt", "Extras to your booking": "Extras zu Ihrer Buchung", "FAQ": "Häufig gestellte Fragen", "Failed to delete credit card, please try again later.": "Kreditkarte konnte nicht gelöscht werden. Bitte versuchen Sie es später noch einmal.", @@ -485,6 +488,7 @@ "Your level": "Dein level", "Your points to spend": "Meine Punkte", "Your room": "Ihr Zimmer", + "Your selected bed type will be provided based on availability": "Ihre ausgewählte Bettart wird basierend auf der Verfügbarkeit bereitgestellt", "Zip code": "PLZ", "Zoo": "Zoo", "Zoom in": "Vergrößern", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index efd37360f..a0be98b36 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -112,6 +112,7 @@ "Creative spaces for meetings": "Creative spaces for meetings", "Credit card": "Credit card", "Credit card deleted successfully": "Credit card deleted successfully", + "Crib (child)": "Crib (child)", "Currency Code": "EUR", "Current password": "Current password", "Customer service": "Customer service", @@ -150,6 +151,8 @@ "Expires at the earliest": "Expires at the earliest {date}", "Explore all levels and benefits": "Explore all levels and benefits", "Explore nearby": "Explore nearby", + "Extra bed (child)": "Extra bed (child)", + "Extra bed will be provided additionally": "Extra bed will be provided additionally", "Extras to your booking": "Extras to your booking", "FAQ": "FAQ", "Failed to delete credit card, please try again later.": "Failed to delete credit card, please try again later.", @@ -529,6 +532,7 @@ "Your level": "Your level", "Your points to spend": "Your points to spend", "Your room": "Your room", + "Your selected bed type will be provided based on availability": "Your selected bed type will be provided based on availability", "Zip code": "Zip code", "Zoo": "Zoo", "Zoom in": "Zoom in", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 5fb08c874..1f6ba0145 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -105,6 +105,7 @@ "Creative spaces for meetings": "Luovia tiloja kokouksille", "Credit card": "Luottokortti", "Credit card deleted successfully": "Luottokortti poistettu onnistuneesti", + "Crib (child)": "Körkkä (lasta)", "Currency Code": "EUR", "Current password": "Nykyinen salasana", "Customer service": "Asiakaspalvelu", @@ -142,6 +143,8 @@ "Expires at the earliest": "Päättyy aikaisintaan {date}", "Explore all levels and benefits": "Tutustu kaikkiin tasoihin ja etuihin", "Explore nearby": "Tutustu lähialueeseen", + "Extra bed (child)": "Lisävuode (lasta)", + "Extra bed will be provided additionally": "Lisävuode toimitetaan erikseen", "Extras to your booking": "Varauksessa lisäpalveluita", "FAQ": "Usein kysytyt kysymykset", "Failed to delete credit card, please try again later.": "Luottokortin poistaminen epäonnistui, yritä myöhemmin uudelleen.", @@ -484,6 +487,7 @@ "Your level": "Tasosi", "Your points to spend": "Käytettävissä olevat pisteesi", "Your room": "Sinun huoneesi", + "Your selected bed type will be provided based on availability": "Valitun vuodetyypin toimitetaan saatavuuden mukaan", "Zip code": "Postinumero", "Zoo": "Eläintarha", "Zoom in": "Lähennä", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 61d44b3e9..2bf19706c 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -104,6 +104,7 @@ "Country is required": "Land kreves", "Creative spaces for meetings": "Kreative rom for møter", "Credit card deleted successfully": "Kredittkort slettet", + "Crib (child)": "Kørestol (barn)", "Currency Code": "NOK", "Current password": "Nåværende passord", "Customer service": "Kundeservice", @@ -141,6 +142,8 @@ "Expires at the earliest": "Utløper tidligst {date}", "Explore all levels and benefits": "Utforsk alle nivåer og fordeler", "Explore nearby": "Utforsk i nærheten", + "Extra bed (child)": "Ekstra seng (barn)", + "Extra bed will be provided additionally": "Ekstra seng vil bli tilgjengelig", "Extras to your booking": "Tilvalg til bestillingen din", "FAQ": "Ofte stilte spørsmål", "Failed to delete credit card, please try again later.": "Kunne ikke slette kredittkortet, prøv igjen senere.", @@ -484,6 +487,7 @@ "Your level": "Ditt nivå", "Your points to spend": "Dine brukbare poeng", "Your room": "Rommet ditt", + "Your selected bed type will be provided based on availability": "Din valgte sengtype vil blive stillet til rådighed baseret på tilgængelighed", "Zip code": "Post kode", "Zoo": "Dyrehage", "Zoom in": "Zoom inn", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index 245883877..8940f9d42 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -104,6 +104,7 @@ "Country is required": "Land är obligatoriskt", "Creative spaces for meetings": "Kreativa utrymmen för möten", "Credit card deleted successfully": "Kreditkort har tagits bort", + "Crib (child)": "Spjälsäng (barn)", "Currency Code": "SEK", "Current password": "Nuvarande lösenord", "Customer service": "Kundservice", @@ -141,6 +142,8 @@ "Expires at the earliest": "Löper ut tidigast {date}", "Explore all levels and benefits": "Utforska alla nivåer och fördelar", "Explore nearby": "Utforska i närheten", + "Extra bed (child)": "Extra säng (barn)", + "Extra bed will be provided additionally": "Extra säng kommer att tillhandahållas", "Extras to your booking": "Extra tillval till din bokning", "FAQ": "FAQ", "Failed to delete credit card, please try again later.": "Det gick inte att ta bort kreditkortet, försök igen senare.", @@ -484,6 +487,7 @@ "Your level": "Din nivå", "Your points to spend": "Dina spenderbara poäng", "Your room": "Ditt rum", + "Your selected bed type will be provided based on availability": "Din valda sängtyp kommer att tillhandahållas baserat på tillgänglighet", "Zip code": "Postnummer", "Zoo": "Djurpark", "Zoom in": "Zooma in", diff --git a/types/components/hotelReservation/enterDetails/bedType.ts b/types/components/hotelReservation/enterDetails/bedType.ts index a222ece2b..9f1fae723 100644 --- a/types/components/hotelReservation/enterDetails/bedType.ts +++ b/types/components/hotelReservation/enterDetails/bedType.ts @@ -1,6 +1,6 @@ -import { z } from "zod" +import type { z } from "zod" -import { +import type { bedTypeFormSchema, bedTypeSchema, } from "@/components/HotelReservation/EnterDetails/BedType/schema" @@ -20,3 +20,7 @@ export type BedTypeProps = { export interface BedTypeFormSchema extends z.output {} export type BedTypeSchema = z.output["bedType"] + +export type BedTypeInfoProps = { + hasMultipleBedTypes: boolean +}