From 72eca90d1b2edadd774db7367e19af7fff94735f Mon Sep 17 00:00:00 2001 From: Pontus Dreij Date: Mon, 14 Oct 2024 16:45:09 +0200 Subject: [PATCH 1/3] feat(SW-589): Room selection summary --- .../hotelreservation/select-rate/page.tsx | 29 +++++----- .../RoomSelection/FlexibilityOption/index.tsx | 19 +++++- .../RoomSelection/RoomCard/index.tsx | 8 +++ .../SelectRate/RoomSelection/index.tsx | 58 +++++++++++++++++-- .../RoomSelection/roomSelection.module.css | 11 +++- .../selectRate/flexibilityOption.ts | 4 ++ .../hotelReservation/selectRate/roomCard.ts | 3 + .../selectRate/roomSelection.ts | 2 + .../hotelReservation/selectRate/selectRate.ts | 18 ++++++ 9 files changed, 131 insertions(+), 21 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx index 6c3a45365..fdd5436f3 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx @@ -1,5 +1,5 @@ +import { getProfileSafely } from "@/lib/trpc/memoizedRequests" import { serverClient } from "@/lib/trpc/server" -import tempHotelData from "@/server/routers/hotels/tempHotelData.json" import RoomSelection from "@/components/HotelReservation/SelectRate/RoomSelection" import { setLang } from "@/i18n/serverContext" @@ -15,18 +15,20 @@ export default async function SelectRatePage({ }: PageArgs) { setLang(params.lang) - const hotelData = await serverClient().hotel.hotelData.get({ - hotelId: searchParams.hotel, - language: params.lang, - include: ["RoomCategories"], - }) - - const roomConfigurations = await serverClient().hotel.availability.rooms({ - hotelId: parseInt(searchParams.hotel, 10), - roomStayStartDate: "2024-11-02", - roomStayEndDate: "2024-11-03", - adults: 1, - }) + const [hotelData, roomConfigurations, user] = await Promise.all([ + serverClient().hotel.hotelData.get({ + hotelId: searchParams.hotel, + language: params.lang, + include: ["RoomCategories"], + }), + serverClient().hotel.availability.rooms({ + hotelId: parseInt(searchParams.hotel, 10), + roomStayStartDate: "2024-11-02", + roomStayEndDate: "2024-11-03", + adults: 1, + }), + getProfileSafely(), + ]) if (!roomConfigurations) { return "No rooms found" // TODO: Add a proper error message @@ -47,6 +49,7 @@ export default async function SelectRatePage({ diff --git a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx index 481b79e98..519eef78c 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx @@ -17,6 +17,8 @@ export default function FlexibilityOption({ name, paymentTerm, priceInformation, + roomType, + handleSelectRate, }: FlexibilityOptionProps) { const [rootDiv, setRootDiv] = useState(undefined) const [isPopoverOpen, setIsPopoverOpen] = useState(false) @@ -42,9 +44,24 @@ export default function FlexibilityOption({ const { public: publicPrice, member: memberPrice } = product.productType + function onChange() { + const rate = { + roomType: roomType, + priceName: name, + public: publicPrice, + member: memberPrice, + } + handleSelectRate(rate) + } + return (