From a620be9331e1212475aab962275a028f577950c2 Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Wed, 8 Jan 2025 14:22:01 +0000 Subject: [PATCH] Merged in fix/SW-1145-occupancy-room-api-change (pull request #1148) Fix/SW-1145 occupancy room api change * fix(SW-1145): change occupancy to min and max * fix(SW-1145): small edit * fix(SW-1145): refactor to transform total room occupancy * fix(SW-1145): remove space * fix(SW-1145): small fix * fix(SW-1145): change to max for readability Approved-by: Erik Tiekstra Approved-by: Linus Flood --- .../HotelPage/Rooms/RoomCard/index.tsx | 8 ++++++-- .../HotelPage/SidePeeks/Room/index.tsx | 5 ++--- .../SelectRate/RoomSelection/RoomCard/index.tsx | 6 +++--- components/SidePeeks/RoomSidePeek/index.tsx | 3 +-- i18n/dictionaries/da.json | 6 +++--- i18n/dictionaries/de.json | 6 +++--- i18n/dictionaries/en.json | 6 +++--- i18n/dictionaries/fi.json | 6 +++--- i18n/dictionaries/no.json | 6 +++--- i18n/dictionaries/sv.json | 6 +++--- server/routers/hotels/schemas/room.ts | 15 ++++++++++++--- 11 files changed, 42 insertions(+), 31 deletions(-) diff --git a/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx b/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx index dba816cb5..1d8214451 100644 --- a/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx +++ b/components/ContentType/HotelPage/Rooms/RoomCard/index.tsx @@ -16,7 +16,7 @@ import styles from "./roomCard.module.css" import type { RoomCardProps } from "@/types/components/hotelPage/room" export function RoomCard({ room }: RoomCardProps) { - const { images, name, roomSize, occupancy } = room + const { images, name, roomSize, totalOccupancy } = room const intl = useIntl() const size = @@ -46,7 +46,11 @@ export function RoomCard({ room }: RoomCardProps) { {intl.formatMessage( { id: "hotelPages.rooms.roomCard.persons" }, - { size, totalOccupancy: occupancy.total } + { + size, + max: totalOccupancy.max, + range: totalOccupancy.range, + } )} diff --git a/components/ContentType/HotelPage/SidePeeks/Room/index.tsx b/components/ContentType/HotelPage/SidePeeks/Room/index.tsx index ded1acf8d..4736c89c3 100644 --- a/components/ContentType/HotelPage/SidePeeks/Room/index.tsx +++ b/components/ContentType/HotelPage/SidePeeks/Room/index.tsx @@ -17,9 +17,8 @@ import type { RoomSidePeekProps } from "@/types/components/hotelPage/sidepeek/ro export default async function RoomSidePeek({ room }: RoomSidePeekProps) { const intl = await getIntl() - const { roomSize, occupancy, descriptions, images } = room + const { roomSize, totalOccupancy, descriptions, images } = room const roomDescription = descriptions.medium - const totalOccupancy = occupancy.total // TODO: Not defined where this should lead. const ctaUrl = "" @@ -34,7 +33,7 @@ export default async function RoomSidePeek({ room }: RoomSidePeekProps) { m².{" "} {intl.formatMessage( { id: "booking.accommodatesUpTo" }, - { nrOfGuests: totalOccupancy } + { range: totalOccupancy.range, max: totalOccupancy.max } )}
diff --git a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx index ee15f3b5e..43faad1bd 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/RoomCard/index.tsx @@ -85,7 +85,7 @@ export default function RoomCard({ ) ) - const { name, roomSize, occupancy, images } = selectedRoom || {} + const { name, roomSize, totalOccupancy, images } = selectedRoom || {} const freeCancelation = intl.formatMessage({ id: "Free cancellation" }) const nonRefundable = intl.formatMessage({ id: "Non-refundable" }) @@ -150,13 +150,13 @@ export default function RoomCard({
- {occupancy?.total && ( + {totalOccupancy && ( {intl.formatMessage( { id: "booking.guests", }, - { nrOfGuests: occupancy.total } + { max: totalOccupancy.max, range: totalOccupancy.range } )} )} diff --git a/components/SidePeeks/RoomSidePeek/index.tsx b/components/SidePeeks/RoomSidePeek/index.tsx index 175eb14a0..86a1bb592 100644 --- a/components/SidePeeks/RoomSidePeek/index.tsx +++ b/components/SidePeeks/RoomSidePeek/index.tsx @@ -21,7 +21,6 @@ export default function RoomSidePeek({ const intl = useIntl() const roomSize = room.roomSize - const occupancy = room.occupancy.total const roomDescription = room.descriptions.medium const images = room.images @@ -40,7 +39,7 @@ export default function RoomSidePeek({ m².{" "} {intl.formatMessage( { id: "booking.accommodatesUpTo" }, - { nrOfGuests: occupancy } + { max: room.totalOccupancy.max, range: room.totalOccupancy.range } )}
diff --git a/i18n/dictionaries/da.json b/i18n/dictionaries/da.json index 2c988c4f0..7050f7cb8 100644 --- a/i18n/dictionaries/da.json +++ b/i18n/dictionaries/da.json @@ -494,7 +494,7 @@ "Zoom in": "Zoom ind", "Zoom out": "Zoom ud", "as of today": "pr. dags dato", - "booking.accommodatesUpTo": "Plads til {nrOfGuests, plural, one {# person} other {op til # personer}}", + "booking.accommodatesUpTo": "Plads til {max, plural, one {{range} person} other {op til {range} personer}}", "booking.adults": "{totalAdults, plural, one {# voksen} other {# voksne}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# voksen} other {# voksne}}, {totalBreakfasts, plural, one {# morgenmad} other {# morgenmad}}", "booking.basedOnAvailability": "Baseret på tilgængelighed", @@ -505,7 +505,7 @@ "booking.confirmation.membershipInfo.text": "Din booking er bekræftet, men vi kunne ikke verificere dit medlemskab. Hvis du har booket med et medlemstilbud, skal du enten vise dit eksisterende medlemskab ved check-in, blive medlem eller betale prisdifferencen ved check-in. Tilmelding er foretrukket online før opholdet.", "booking.confirmation.text": "Tak fordi du bookede hos os! Vi glæder os til at byde dig velkommen og håber du får et behageligt ophold. Hvis du har spørgsmål eller har brug for at foretage ændringer i din reservation, bedes du kontakte os.", "booking.confirmation.title": "Booking bekræftelse", - "booking.guests": "Maks {nrOfGuests, plural, one {# gæst} other {# gæster}}", + "booking.guests": "Maks {max, plural, one {{range} gæst} other {{range} gæster}}", "booking.nights": "{totalNights, plural, one {# nat} other {# nætter}}", "booking.rooms": "{totalRooms, plural, one {# værelse} other {# værelser}}", "booking.selectRoom": "Zimmer auswählen", @@ -524,7 +524,7 @@ "guaranteeing": "garanti", "guest": "gæst", "guests": "gæster", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# person} other {# personer}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} person} other {{range} personer}})", "hotelPages.rooms.roomCard.seeRoomDetails": "Se værelsesdetaljer", "km to city center": "km til byens centrum", "lowercase letter": "lille bogstav", diff --git a/i18n/dictionaries/de.json b/i18n/dictionaries/de.json index 881059090..f42805b1d 100644 --- a/i18n/dictionaries/de.json +++ b/i18n/dictionaries/de.json @@ -493,7 +493,7 @@ "Zoom in": "Vergrößern", "Zoom out": "Verkleinern", "as of today": "Stand heute", - "booking.accommodatesUpTo": "Bietet Platz für {nrOfGuests, plural, one {# Person } other {bis zu # Personen}}", + "booking.accommodatesUpTo": "Bietet Platz für {max, plural, one {{range} Person } other {bis zu {range} Personen}}", "booking.adults": "{totalAdults, plural, one {# erwachsene} other {# erwachsene}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# erwachsene} other {# erwachsene}}, {totalBreakfasts, plural, one {# frühstück} other {# frühstücke}}", "booking.basedOnAvailability": "Abhängig von der Verfügbarkeit", @@ -504,7 +504,7 @@ "booking.confirmation.membershipInfo.text": "Ihre Buchung ist bestätigt, aber wir konnten Ihr Mitglied nicht verifizieren. Wenn Sie mit einem Mitgliederrabatt gebucht haben, müssen Sie entweder Ihr vorhandenes Mitgliedschaftsnummer bei der Anreise präsentieren, ein Mitglied werden oder die Preisdifferenz bei der Anreise bezahlen. Die Anmeldung ist vorzugsweise online vor der Aufenthaltsdauer erfolgreich.", "booking.confirmation.text": "Vielen Dank, dass Sie bei uns gebucht haben! Wir freuen uns, Sie bei uns begrüßen zu dürfen und wünschen Ihnen einen angenehmen Aufenthalt. Wenn Sie Fragen haben oder Änderungen an Ihrer Buchung vornehmen müssen, kontaktieren Sie uns bitte..", "booking.confirmation.title": "Buchungsbestätigung", - "booking.guests": "Max {nrOfGuests, plural, one {# gast} other {# gäste}}", + "booking.guests": "Max {max, plural, one {{range} gast} other {{range} gäste}}", "booking.nights": "{totalNights, plural, one {# nacht} other {# Nächte}}", "booking.rooms": "{totalRooms, plural, one {# zimmer} other {# räume}}", "booking.selectRoom": "Vælg værelse", @@ -523,7 +523,7 @@ "guaranteeing": "garantiert", "guest": "gast", "guests": "gäste", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# person} other {# personen}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} person} other {{range} personen}})", "hotelPages.rooms.roomCard.seeRoomDetails": "Zimmerdetails ansehen", "km to city center": "km bis zum Stadtzentrum", "lowercase letter": "Kleinbuchstabe", diff --git a/i18n/dictionaries/en.json b/i18n/dictionaries/en.json index d58076530..ff1238111 100644 --- a/i18n/dictionaries/en.json +++ b/i18n/dictionaries/en.json @@ -537,7 +537,7 @@ "Zoom in": "Zoom in", "Zoom out": "Zoom out", "as of today": "as of today", - "booking.accommodatesUpTo": "Accommodates up to {nrOfGuests, plural, one {# person} other {# people}}", + "booking.accommodatesUpTo": "Accommodates up to {max, plural, one {{range} person} other {{range} people}}", "booking.adults": "{totalAdults, plural, one {# adult} other {# adults}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# adult} other {# adults}}, {totalBreakfasts, plural, one {# breakfast} other {# breakfasts}}", "booking.basedOnAvailability": "Based on availability", @@ -548,7 +548,7 @@ "booking.confirmation.membershipInfo.text": "Your booking(s) is confirmed but we could not verify your membership. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay.", "booking.confirmation.text": "Thank you for booking with us! We look forward to welcoming you and hope you have a pleasant stay. If you have any questions or need to make changes to your reservation, please contact us.", "booking.confirmation.title": "Booking confirmation", - "booking.guests": "Max {nrOfGuests, plural, one {# guest} other {# guests}}", + "booking.guests": "Max {max, plural, one {{range} guest} other {{range} guests}}", "booking.nights": "{totalNights, plural, one {# night} other {# nights}}", "booking.rooms": "{totalRooms, plural, one {# room} other {# rooms}}", "booking.selectRoom": "Select room", @@ -569,7 +569,7 @@ "guest.paid": "{amount} {currency} has been paid", "guests": "guests", "has been paid": "has been paid", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# person} other {# persons}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} person} other {{range} persons}})", "hotelPages.rooms.roomCard.seeRoomDetails": "See room details", "km to city center": "km to city center", "lowercase letter": "lowercase letter", diff --git a/i18n/dictionaries/fi.json b/i18n/dictionaries/fi.json index 707506af9..6e20af368 100644 --- a/i18n/dictionaries/fi.json +++ b/i18n/dictionaries/fi.json @@ -492,7 +492,7 @@ "Zoom in": "Lähennä", "Zoom out": "Loitonna", "as of today": "tänään", - "booking.accommodatesUpTo": "Huoneeseen {nrOfGuests, plural, one {# person} other {mahtuu 2 henkilöä}}", + "booking.accommodatesUpTo": "Huoneeseen {max, plural, one {{range} henkilö} other {mahtuu enintään {range} henkilöä}", "booking.adults": "{totalAdults, plural, one {# aikuinen} other {# aikuiset}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# aikuinen} other {# aikuiset}}, {totalBreakfasts, plural, one {# aamiainen} other {# aamiaista}}", "booking.basedOnAvailability": "Saatavuuden mukaan", @@ -503,7 +503,7 @@ "booking.confirmation.membershipInfo.text": "Varauksesi on vahvistettu, mutta jäsenyytesi ei voitu vahvistaa. Jos olet bookeutunut jäsenyysalennoilla, sinun on joko esitettävä olemassa olevan jäsenyysnumero tarkistukseen, tulla jäseneksi tai maksamaan hinnan eron hotellissa. Jäsenyyden tilittäminen on suositeltavampaa tehdä verkkoon ennen majoittumista.", "booking.confirmation.text": "Kiitos, että teit varauksen meiltä! Toivotamme sinut tervetulleeksi ja toivomme sinulle miellyttävää oleskelua. Jos sinulla on kysyttävää tai haluat tehdä muutoksia varaukseesi, ota meihin yhteyttä.", "booking.confirmation.title": "Varausvahvistus", - "booking.guests": "Max {nrOfGuests, plural, one {# vieras} other {# vieraita}}", + "booking.guests": "Max {max, plural, one {{range} vieras} other {{range} vieraita}}", "booking.nights": "{totalNights, plural, one {# yö} other {# yötä}}", "booking.rooms": "{totalRooms, plural, one {# huone} other {# sviitti}}", "booking.selectRoom": "Valitse huone", @@ -522,7 +522,7 @@ "guaranteeing": "varmistetaan", "guest": "Vieras", "guests": "Vieraita", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# henkilö} other {# Henkilöä}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} henkilö} other {{range} Henkilöä}})", "hotelPages.rooms.roomCard.seeRoomDetails": "Katso huoneen tiedot", "km to city center": "km keskustaan", "lowercase letter": "pien kirjain", diff --git a/i18n/dictionaries/no.json b/i18n/dictionaries/no.json index 5e4948dc6..28237b83b 100644 --- a/i18n/dictionaries/no.json +++ b/i18n/dictionaries/no.json @@ -492,7 +492,7 @@ "Zoom in": "Zoom inn", "Zoom out": "Zoom ut", "as of today": "per i dag", - "booking.accommodatesUpTo": "Plass til {nrOfGuests, plural, one {# person} other {opptil # personer}}", + "booking.accommodatesUpTo": "Plass til {max, plural, one {{range} person} other {opptil {range} personer}}", "booking.adults": "{totalAdults, plural, one {# voksen} other {# voksne}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# voksen} other {# voksne}}, {totalBreakfasts, plural, one {# frokost} other {# frokoster}}", "booking.basedOnAvailability": "Basert på tilgjengelighet", @@ -503,7 +503,7 @@ "booking.confirmation.membershipInfo.text": "Din bestilling er bekreftet, men vi kunne ikke verifisere medlemskapet ditt. Hvis du har booke ut med et medlemsrabatt, må du enten presentere eksisterende medlemsnummer ved check-in, bli medlem eller betale prisdifferansen ved hotellet. Registrering er foretrukket gjort online før oppholdet.", "booking.confirmation.text": "Takk for at du booket hos oss! Vi ser frem til å ønske deg velkommen og håper du får et hyggelig opphold. Hvis du har spørsmål eller trenger å gjøre endringer i bestillingen din, vennligst kontakt oss.", "booking.confirmation.title": "Bestillingsbekreftelse", - "booking.guests": "Maks {nrOfGuests, plural, one {# gjest} other {# gjester}}", + "booking.guests": "Maks {max, plural, one {{range} gjest} other {{range} gjester}}", "booking.nights": "{totalNights, plural, one {# natt} other {# netter}}", "booking.rooms": "{totalRooms, plural, one {# rom} other {# rom}}", "booking.selectRoom": "Velg rom", @@ -522,7 +522,7 @@ "guaranteeing": "garantiert", "guest": "gjest", "guests": "gjester", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# person} other {# personer}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} person} other {{range} personer}})", "hotelPages.rooms.roomCard.seeRoomDetails": "Se detaljer om rommet", "km to city center": "km til sentrum", "lowercase letter": "liten bokstav", diff --git a/i18n/dictionaries/sv.json b/i18n/dictionaries/sv.json index ecdd2e364..d7c9327d7 100644 --- a/i18n/dictionaries/sv.json +++ b/i18n/dictionaries/sv.json @@ -492,7 +492,7 @@ "Zoom in": "Zooma in", "Zoom out": "Zooma ut", "as of today": "från och med idag", - "booking.accommodatesUpTo": "Rymmer {nrOfGuests, plural, one {# person} other {upp till # personer}}", + "booking.accommodatesUpTo": "Rymmer {max, plural, one {{range} person} other {upp till {range} personer}}", "booking.adults": "{totalAdults, plural, one {# vuxen} other {# vuxna}}", "booking.adults.breakfasts": "{totalAdults, plural, one {# vuxen} other {# vuxna}}, {totalBreakfasts, plural, one {# frukost} other {# frukostar}}", "booking.basedOnAvailability": "Baserat på tillgänglighet", @@ -503,7 +503,7 @@ "booking.confirmation.membershipInfo.text": "Din bokning är bekräftad, men vi kunde inte verifiera ditt medlemskap. Om du har bokat med ett medlemsrabatt måste du antingen presentera ditt befintliga medlemsnummer vid check-in, bli medlem eller betala prisdifferensen vid hotell. Registrering är föredragen gjord online före vistelsen.", "booking.confirmation.text": "Tack för att du bokar hos oss! Vi ser fram emot att välkomna dig och hoppas att du får en trevlig vistelse. Om du har några frågor eller behöver göra ändringar i din bokning, vänligen kontakta oss.", "booking.confirmation.title": "Bokningsbekräftelse", - "booking.guests": "Max {nrOfGuests, plural, one {# gäst} other {# gäster}}", + "booking.guests": "Max {max, plural, one {{range} gäst} other {{range} gäster}}", "booking.nights": "{totalNights, plural, one {# natt} other {# nätter}}", "booking.rooms": "{totalRooms, plural, one {# rum} other {# rum}}", "booking.selectRoom": "Välj rum", @@ -522,7 +522,7 @@ "guaranteeing": "garanterar", "guest": "gäst", "guests": "gäster", - "hotelPages.rooms.roomCard.persons": "{size} ({totalOccupancy, plural, one {# person} other {# personer}})", + "hotelPages.rooms.roomCard.persons": "{size} ({max, plural, one {{range} person} other {{range} personer}})", "hotelPages.rooms.roomCard.seeRoomDetails": "Se information om rummet", "km to city center": "km till stadens centrum", "lowercase letter": "liten bokstav", diff --git a/server/routers/hotels/schemas/room.ts b/server/routers/hotels/schemas/room.ts index b12232708..caf6317a0 100644 --- a/server/routers/hotels/schemas/room.ts +++ b/server/routers/hotels/schemas/room.ts @@ -83,9 +83,8 @@ export const roomSchema = z roomTypes: z.array(roomTypesSchema), roomFacilities: z.array(roomFacilitiesSchema), occupancy: z.object({ - total: z.number().optional(), - adults: z.number().optional(), - children: z.number().optional(), + min: z.number(), + max: z.number(), }), roomSize: z.object({ min: z.number(), @@ -102,6 +101,16 @@ export const roomSchema = z images: data.attributes.content.images, name: data.attributes.name, occupancy: data.attributes.occupancy, + totalOccupancy: + data.attributes.occupancy.min === data.attributes.occupancy.max + ? { + max: data.attributes.occupancy.max, + range: `${data.attributes.occupancy.max}`, + } + : { + max: data.attributes.occupancy.max, + range: `${data.attributes.occupancy.min}-${data.attributes.occupancy.max}`, + }, roomSize: data.attributes.roomSize, roomTypes: data.attributes.roomTypes, sortOrder: data.attributes.sortOrder,