From 8c530658c5e84ff91649a8697189498e675d6db9 Mon Sep 17 00:00:00 2001 From: Fredrik Thorsson Date: Mon, 9 Sep 2024 10:02:35 +0200 Subject: [PATCH] feat(SW-251): use availability to get hotel --- .../hotelreservation/select-hotel/page.tsx | 11 +-- .../HotelReservation/HotelCard/index.tsx | 23 +++-- .../SelectHotel/HotelFilter/index.tsx | 17 +--- server/routers/hotels/input.ts | 8 +- server/routers/hotels/output.ts | 30 ------- server/routers/hotels/query.ts | 90 +++++++++---------- .../selectHotel/hotelFilterProps.ts | 5 -- 7 files changed, 64 insertions(+), 120 deletions(-) delete mode 100644 types/components/hotelReservation/selectHotel/hotelFilterProps.ts diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx index 1a75c56f5..bc5231f08 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx @@ -20,15 +20,6 @@ export default async function SelectHotelPage({ setLang(params.lang) const tempSearchTerm = "Stockholm" - const getHotelFitlers = await serverClient().hotel.filters.get({ - language: params.lang, - country: "Sweden", - city: "Helsingborg", - }) - - if (!getHotelFitlers) return null - - const { filters } = getHotelFitlers const getAvailableHotels = await serverClient().hotel.availability.get({ cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54", @@ -56,7 +47,7 @@ export default async function SelectHotelPage({ {intl.formatMessage({ id: "Show map" })} - +
{availability.length ? ( diff --git a/components/HotelReservation/HotelCard/index.tsx b/components/HotelReservation/HotelCard/index.tsx index 43cf56a03..0f37287f1 100644 --- a/components/HotelReservation/HotelCard/index.tsx +++ b/components/HotelReservation/HotelCard/index.tsx @@ -1,3 +1,4 @@ +import { serverClient } from "@/lib/trpc/server" import tempHotelData from "@/server/routers/hotels/tempHotelData.json" import { mapFacilityToIcon } from "@/components/ContentType/HotelPage/data" @@ -15,6 +16,7 @@ import Caption from "@/components/TempDesignSystem/Text/Caption" import Footnote from "@/components/TempDesignSystem/Text/Footnote" import Title from "@/components/TempDesignSystem/Text/Title" import { getIntl } from "@/i18n" +import { getLang } from "@/i18n/serverContext" import styles from "./hotelCard.module.css" @@ -31,7 +33,16 @@ export default async function HotelCard({ // TODO: Use real endpoint. const hotel = tempHotelData.data.attributes - const sortedAmenities = hotel.detailedFacilities + const hotelResponse = await serverClient().hotel.hotel.get({ + hotelId: hotelId.toString(), + language: getLang(), + }) + + if (!hotelResponse) return null + + const { data } = hotelResponse + + const sortedAmenities = data.attributes.detailedFacilities .sort((a, b) => b.sortOrder - a.sortOrder) .slice(0, 5) @@ -39,8 +50,8 @@ export default async function HotelCard({
{hotel.hotelContent.images.metaData.altText} - {hotel.ratings?.tripAdvisor.rating} + {data.attributes.ratings?.tripAdvisor.rating}
@@ -58,10 +69,10 @@ export default async function HotelCard({ {hotel.name} - {`${hotel.address.streetAddress}, ${hotel.address.city}`} + {`${data.attributes.address.streetAddress}, ${data.attributes.address.city}`} - {`${hotel.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`} + {`${data.attributes.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`}
diff --git a/components/HotelReservation/SelectHotel/HotelFilter/index.tsx b/components/HotelReservation/SelectHotel/HotelFilter/index.tsx index f002c83b9..81230461d 100644 --- a/components/HotelReservation/SelectHotel/HotelFilter/index.tsx +++ b/components/HotelReservation/SelectHotel/HotelFilter/index.tsx @@ -2,28 +2,13 @@ import { getIntl } from "@/i18n" import styles from "./hotelFilter.module.css" -import { HotelFilterProps } from "@/types/components/hotelReservation/selectHotel/hotelFilterProps" - -export default async function HotelFilter({ filters }: HotelFilterProps) { +export default async function HotelFilter() { const { formatMessage } = await getIntl() - console.log(filters) - return (