feat(SW-176): destructure response

This commit is contained in:
Fredrik Thorsson
2024-08-30 11:04:52 +02:00
parent 3c82a8b4b5
commit ad0f42a90d
3 changed files with 19 additions and 15 deletions

View File

@@ -20,19 +20,22 @@ export default async function SelectHotelPage({
setLang(params.lang)
const tempSearchTerm = "Stockholm"
const hotelFilters = await serverClient().hotel.filters.get({
hotelId: "879",
})
const availability = await serverClient().hotel.availability.get({
const availabilityResponse = await serverClient().hotel.availability.get({
cityId: "8ec4bba3-1c38-4606-82d1-bbe3f6738e54",
roomStayStartDate: "2024-11-02",
roomStayEndDate: "2024-11-03",
adults: 1,
})
const filterAvailability = availability?.availability.data
if (!availabilityResponse) return null
const { availability } = availabilityResponse
const filterAvailability = availability.data
.filter((hotels) => hotels.attributes.status === "Available")
.flatMap((hotels) => hotels.attributes)
@@ -53,7 +56,7 @@ export default async function SelectHotelPage({
<HotelFilter filters={hotelFilters} />
</section>
<section className={styles.hotelCards}>
{filterAvailability?.length ? (
{filterAvailability.length ? (
filterAvailability.map((hotel) => (
<HotelCard
key={hotel.hotelId}