feat(SW-176): filter in route
This commit is contained in:
@@ -11,7 +11,6 @@ import { setLang } from "@/i18n/serverContext"
|
||||
|
||||
import styles from "./page.module.css"
|
||||
|
||||
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||
import { LangParams, PageArgs } from "@/types/params"
|
||||
|
||||
export default async function SelectHotelPage({
|
||||
@@ -25,20 +24,14 @@ export default async function SelectHotelPage({
|
||||
hotelId: "879",
|
||||
})
|
||||
|
||||
const availabilityResponse = await serverClient().hotel.availability.get({
|
||||
const availableHotels = await serverClient().hotel.availability.get({
|
||||
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
|
||||
roomStayStartDate: "2024-11-02",
|
||||
roomStayEndDate: "2024-11-03",
|
||||
adults: 1,
|
||||
})
|
||||
|
||||
if (!availabilityResponse) return null
|
||||
|
||||
const { availability } = availabilityResponse
|
||||
|
||||
const availableHotels = availability.data
|
||||
.filter((hotels) => hotels.attributes.status === AvailabilityEnum.Available)
|
||||
.flatMap((hotels) => hotels.attributes)
|
||||
if (!availableHotels) return null
|
||||
|
||||
console.log(availableHotels)
|
||||
|
||||
@@ -59,8 +52,8 @@ export default async function SelectHotelPage({
|
||||
<HotelFilter filters={hotelFilters} />
|
||||
</section>
|
||||
<section className={styles.hotelCards}>
|
||||
{availableHotels.length ? (
|
||||
availableHotels.map((hotel) => (
|
||||
{availableHotels.availability.length ? (
|
||||
availableHotels.availability.map((hotel) => (
|
||||
<HotelCard
|
||||
key={hotel.hotelId}
|
||||
checkInDate={hotel.checkInDate}
|
||||
|
||||
Reference in New Issue
Block a user