From 895dce2f72715123d18f57501cdfc4aac515c954 Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Thu, 27 Feb 2025 09:06:22 +0000 Subject: [PATCH] Merged in fix/SW-1686-show-correct-room-number (pull request #1417) fix(SW-1686): display total rooms and available rooms when filtering * fix(SW-1686): display total rooms and available rooms when filtering Approved-by: Arvid Norlin Approved-by: Simon.Emanuelsson --- .../RoomTypeFilter/index.tsx | 29 +++++++++++++++---- apps/scandic-web/i18n/dictionaries/da.json | 5 ++-- apps/scandic-web/i18n/dictionaries/de.json | 5 ++-- apps/scandic-web/i18n/dictionaries/en.json | 3 +- apps/scandic-web/i18n/dictionaries/fi.json | 5 ++-- apps/scandic-web/i18n/dictionaries/no.json | 5 ++-- apps/scandic-web/i18n/dictionaries/sv.json | 5 ++-- apps/scandic-web/providers/RoomProvider.tsx | 2 ++ apps/scandic-web/types/contexts/room.ts | 1 + 9 files changed, 43 insertions(+), 17 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomTypeFilter/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomTypeFilter/index.tsx index 6d0ccd841..3258f7194 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomTypeFilter/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomTypeFilter/index.tsx @@ -21,6 +21,7 @@ export default function RoomTypeFilter() { actions: { selectFilter }, rooms, selectedPackage, + totalRooms, } = useRoomContext() const intl = useIntl() @@ -37,15 +38,31 @@ export default function RoomTypeFilter() { } } + const notAllRoomsAvailableText = intl.formatMessage( + { + id: "{availableRooms}/{numberOfRooms, plural, one {# room type} other {# room types}} available", + }, + { + availableRooms: rooms.length, + numberOfRooms: totalRooms, + } + ) + + const allRoomsAvailableText = intl.formatMessage( + { + id: "{numberOfRooms, plural, one {# room type} other {# room types}} available", + }, + { + numberOfRooms: totalRooms, + } + ) + return (
- {intl.formatMessage( - { - id: "{numberOfRooms, plural, one {# room type} other {# room types}} available", - }, - { numberOfRooms: rooms.length } - )} + {rooms.length !== totalRooms + ? notAllRoomsAvailableText + : allRoomsAvailableText} state.actions.modifyRate(idx)) const selectFilter = useRatesStore((state) => state.actions.selectFilter(idx)) const selectRate = useRatesStore((state) => state.actions.selectRate(idx)) + const totalRooms = useRatesStore((state) => state.allRooms.length) const roomNr = idx + 1 return ( {children} diff --git a/apps/scandic-web/types/contexts/room.ts b/apps/scandic-web/types/contexts/room.ts index 5a6ceda09..93b96397a 100644 --- a/apps/scandic-web/types/contexts/room.ts +++ b/apps/scandic-web/types/contexts/room.ts @@ -11,4 +11,5 @@ export interface RoomContextValue extends SelectedRoom { isActiveRoom: boolean isMainRoom: boolean roomNr: number + totalRooms: number }