From c2c1a676cad69fa6fe3062afb750ba3aeadf7b3f Mon Sep 17 00:00:00 2001 From: Niclas Edenvin Date: Tue, 8 Oct 2024 15:22:51 +0200 Subject: [PATCH] SW-454 Use the API on select room page --- .../hotelreservation/select-rate/page.tsx | 28 ++-- .../RoomSelection/FlexibilityOption/index.tsx | 35 ++++- .../RoomSelection/RoomCard/index.tsx | 80 +++++++---- .../SelectRate/RoomSelection/index.tsx | 51 ++++--- .../RoomSelection/roomSelection.module.css | 2 + lib/api/endpoints.ts | 1 + server/routers/hotels/input.ts | 11 ++ server/routers/hotels/output.ts | 80 +++++++++++ server/routers/hotels/query.ts | 129 ++++++++++++++++++ .../selectRate/flexibilityOption.ts | 6 +- .../hotelReservation/selectRate/roomCard.ts | 11 +- .../selectRate/roomSelection.ts | 6 +- 12 files changed, 348 insertions(+), 92 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx index 235eeda52..796c0fedb 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-rate/page.tsx @@ -2,7 +2,6 @@ import { serverClient } from "@/lib/trpc/server" import tempHotelData from "@/server/routers/hotels/tempHotelData.json" import RoomSelection from "@/components/HotelReservation/SelectRate/RoomSelection" -import { getIntl } from "@/i18n" import { setLang } from "@/i18n/serverContext" import styles from "./page.module.css" @@ -19,18 +18,15 @@ export default async function SelectRatePage({ // TODO: Use real endpoint. const hotel = tempHotelData.data.attributes - const rates = await serverClient().hotel.rates.get({ - // TODO: pass the correct hotel ID and all other parameters that should be included in the search - hotelId: searchParams.hotel, + const roomConfigurations = await serverClient().hotel.availability.rooms({ + hotelId: parseInt(searchParams.hotel, 10), + roomStayStartDate: "2024-11-02", + roomStayEndDate: "2024-11-03", + adults: 1, }) - - // const rates = await serverClient().hotel.availability.getForHotel({ - // hotelId: 811, - // roomStayStartDate: "2024-11-02", - // roomStayEndDate: "2024-11-03", - // adults: 1, - // }) - const intl = await getIntl() + if (!roomConfigurations) { + return "No rooms found" + } return (
@@ -39,13 +35,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 5760c219f..dd92ab7f8 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx @@ -9,17 +9,23 @@ import styles from "./flexibilityOption.module.css" import { FlexibilityOptionProps } from "@/types/components/hotelReservation/selectRate/flexibilityOption" export default function FlexibilityOption({ - currency, - standardPrice, - memberPrice, + product, name, - value, paymentTerm, }: FlexibilityOptionProps) { const intl = useIntl() + + if (!product) { + // TODO: Implement empty state when this rate can't be booked + return
TBI: Rate not available
+ } return (