feat(SW-251): type assertion
This commit is contained in:
@@ -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<HotelData[] | null> {
|
||||
}: AvailabilityInput): Promise<HotelData[]> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user