diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx index 634c4cf1c..4e5f85841 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx @@ -1,5 +1,4 @@ import { serverClient } from "@/lib/trpc/server" -import { notFound } from "@/server/errors/next" import HotelCardListing from "@/components/HotelReservation/HotelCardListing" import HotelFilter from "@/components/HotelReservation/SelectHotel/HotelFilter" @@ -24,7 +23,7 @@ async function getAvailableHotels({ promotionCode, attachedProfileId, reservationProfileType, -}: AvailabilityInput): Promise { +}: AvailabilityInput): Promise { const getAvailableHotels = await serverClient().hotel.availability.get({ cityId: cityId, roomStayStartDate: roomStayStartDate, @@ -36,7 +35,7 @@ async function getAvailableHotels({ reservationProfileType: reservationProfileType, }) - if (!getAvailableHotels) return null + if (!getAvailableHotels) throw new Error() const { availability } = getAvailableHotels @@ -46,8 +45,10 @@ async function getAvailableHotels({ language: getLang(), }) + if (!hotelData) throw new Error() + return { - hotelData: hotelData?.data.attributes, + hotelData: hotelData.data.attributes, price: hotel.bestPricePerNight, } }) @@ -70,12 +71,9 @@ export default async function SelectHotelPage({ adults: 1, }) - if (!hotels) return null - if (hotels.some((item) => item?.hotelData === undefined)) return notFound() + const filters = hotels.flatMap((data) => data.hotelData.detailedFacilities) - const filters = hotels.flatMap((data) => data.hotelData?.detailedFacilities) - - const filterId = [...new Set(filters.map((data) => data?.id))] + const filterId = [...new Set(filters.map((data) => data.id))] const filterList: { name: string id: number @@ -86,7 +84,7 @@ export default async function SelectHotelPage({ code?: string iconName?: string }[] = filterId - .map((data) => filters.find((find) => find?.id === data)) + .map((data) => filters.find((find) => find.id === data)) .filter( ( filter diff --git a/components/HotelReservation/HotelCard/index.tsx b/components/HotelReservation/HotelCard/index.tsx index 83d830515..76d702b98 100644 --- a/components/HotelReservation/HotelCard/index.tsx +++ b/components/HotelReservation/HotelCard/index.tsx @@ -25,7 +25,7 @@ export default function HotelCard({ hotel }: HotelCardProps) { const { hotelData } = hotel const { price } = hotel - const sortedAmenities = hotelData?.detailedFacilities + const sortedAmenities = hotelData.detailedFacilities .sort((a, b) => b.sortOrder - a.sortOrder) .slice(0, 5) @@ -33,8 +33,8 @@ export default function HotelCard({ hotel }: HotelCardProps) {
{hotelData?.hotelContent.images.metaData.altText - {hotelData?.ratings?.tripAdvisor.rating} + {hotelData.ratings?.tripAdvisor.rating}
- {hotelData?.name} + {hotelData.name} - {`${hotelData?.address?.streetAddress}, ${hotelData?.address?.city}`} + {`${hotelData.address.streetAddress}, ${hotelData.address.city}`} - {`${hotelData?.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`} + {`${hotelData.location.distanceToCentre} ${intl.formatMessage({ id: "km to city center" })}`}
- {sortedAmenities?.map((facility) => { + {sortedAmenities.map((facility) => { const IconComponent = mapFacilityToIcon(facility.name) return (
diff --git a/components/HotelReservation/HotelCardListing/index.tsx b/components/HotelReservation/HotelCardListing/index.tsx index a98e0e906..8a3da1dba 100644 --- a/components/HotelReservation/HotelCardListing/index.tsx +++ b/components/HotelReservation/HotelCardListing/index.tsx @@ -9,13 +9,11 @@ import styles from "./hotelCardListing.module.css" import { HotelCardListingProps } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps" export default function HotelCardListing({ hotelData }: HotelCardListingProps) { - if (!hotelData) return null - return (
{hotelData && hotelData.length ? ( hotelData.map((hotel) => ( - + )) ) : ( No hotels found diff --git a/components/HotelReservation/SelectHotel/HotelFilter/index.tsx b/components/HotelReservation/SelectHotel/HotelFilter/index.tsx index 52bf5a7fe..f10191cec 100644 --- a/components/HotelReservation/SelectHotel/HotelFilter/index.tsx +++ b/components/HotelReservation/SelectHotel/HotelFilter/index.tsx @@ -9,6 +9,10 @@ import { HotelFiltersProps } from "@/types/components/hotelReservation/selectHot export default function HotelFilter({ filters }: HotelFiltersProps) { const intl = useIntl() + function handleOnChange() { + // TODO: Update URL with selected values + } + return (