feat(SW-251): use response to render filters
This commit is contained in:
@@ -33,7 +33,7 @@ async function getAvailableHotels({
|
||||
const { availability } = getAvailableHotels
|
||||
|
||||
const hotels = availability.map(async (hotel) => {
|
||||
const hotelData = await serverClient().hotel.hotel.get({
|
||||
const hotelData = await serverClient().hotel.hotelData.get({
|
||||
hotelId: hotel.hotelId.toString(),
|
||||
language: getLang(),
|
||||
})
|
||||
@@ -53,7 +53,6 @@ export default async function SelectHotelPage({
|
||||
setLang(params.lang)
|
||||
|
||||
const tempSearchTerm = "Stockholm"
|
||||
|
||||
const intl = await getIntl()
|
||||
|
||||
const hotels = await getAvailableHotels({
|
||||
@@ -64,9 +63,37 @@ export default async function SelectHotelPage({
|
||||
})
|
||||
|
||||
if (!hotels) return null
|
||||
|
||||
if (hotels.some((item) => item?.hotelData === undefined)) return notFound()
|
||||
|
||||
const filters = hotels.flatMap((data) => data.hotelData?.detailedFacilities)
|
||||
|
||||
const filterId = [...new Set(filters.map((data) => data?.id))]
|
||||
const filterList: {
|
||||
name: string
|
||||
id: number
|
||||
applyToAllHotels: boolean
|
||||
public: boolean
|
||||
icon: string
|
||||
sortOrder: number
|
||||
code?: string
|
||||
iconName?: string
|
||||
}[] = filterId
|
||||
.map((data) => filters.find((find) => find?.id === data))
|
||||
.filter(
|
||||
(
|
||||
filter
|
||||
): filter is {
|
||||
name: string
|
||||
id: number
|
||||
applyToAllHotels: boolean
|
||||
public: boolean
|
||||
icon: string
|
||||
sortOrder: number
|
||||
code?: string
|
||||
iconName?: string
|
||||
} => filter !== undefined
|
||||
)
|
||||
|
||||
return (
|
||||
<main className={styles.main}>
|
||||
<section className={styles.section}>
|
||||
@@ -82,7 +109,7 @@ export default async function SelectHotelPage({
|
||||
{intl.formatMessage({ id: "Show map" })}
|
||||
<ChevronRightIcon color="burgundy" />
|
||||
</Link>
|
||||
<HotelFilter />
|
||||
<HotelFilter filters={filterList} />
|
||||
</section>
|
||||
<HotelCardListing hotelData={hotels} />
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user