diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx
index ebd516ce7..5144cc9f5 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx
@@ -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({
- {availableHotels.length ? (
- availableHotels.map((hotel) => (
+ {availableHotels.availability.length ? (
+ availableHotels.availability.map((hotel) => (
- {price?.regularAmount} SEK / night
+ {price?.regularAmount} SEK / {intl.formatMessage({ id: "night" })}
approx 280 eur
@@ -100,7 +98,7 @@ export default async function HotelCard({
{intl.formatMessage({ id: "Member price from" })}
- {price?.memberAmount} SEK / night
+ {price?.memberAmount} SEK / {intl.formatMessage({ id: "night" })}
approx 280 eur
diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts
index 7f059aefa..a652db503 100644
--- a/server/routers/hotels/output.ts
+++ b/server/routers/hotels/output.ts
@@ -470,7 +470,7 @@ export const getHotelDataSchema = z.object({
const occupancySchema = z.object({
adults: z.number(),
- children: z.number(),
+ children: z.number().optional(),
})
const bestPricePerStaySchema = z.object({
@@ -512,7 +512,7 @@ const availabilitySchema = z.object({
attributes: z.object({
checkInDate: z.string(),
checkOutDate: z.string(),
- occupancy: occupancySchema.optional(),
+ occupancy: occupancySchema,
status: z.string(),
hotelId: z.number(),
ratePlanSet: z.string().optional(),
diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts
index 05d72c5db..f6bd0e098 100644
--- a/server/routers/hotels/query.ts
+++ b/server/routers/hotels/query.ts
@@ -37,6 +37,8 @@ import {
import tempFilterData from "./tempFilterData.json"
import tempRatesData from "./tempRatesData.json"
+import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
+
const meter = metrics.getMeter("trpc.hotels")
const getHotelCounter = meter.createCounter("trpc.hotel.get")
const getHotelSuccessCounter = meter.createCounter("trpc.hotel.get-success")
@@ -234,24 +236,16 @@ export const hotelQueryRouter = router({
attachedProfileId,
} = input
// TODO: remove undefined type from params
- const params: Record = {
+ const params: Record = {
roomStayStartDate,
roomStayEndDate,
adults,
- children,
- promotionCode,
- reservationProfileType,
- attachedProfileId,
}
availabilityCounter.add(1, {
cityId,
roomStayStartDate,
roomStayEndDate,
adults,
- children,
- promotionCode,
- reservationProfileType,
- attachedProfileId,
})
console.info(
"api.hotels.availability start",
@@ -260,7 +254,6 @@ export const hotelQueryRouter = router({
const apiResponse = await api.get(
`${api.endpoints.v0.availability}/${cityId}`,
{
- cache: "no-store",
headers: {
Authorization: `Bearer ${ctx.serviceToken}`,
},
@@ -274,10 +267,6 @@ export const hotelQueryRouter = router({
roomStayStartDate,
roomStayEndDate,
adults,
- children,
- promotionCode,
- reservationProfileType,
- attachedProfileId,
error_type: "http_error",
error: JSON.stringify({
status: apiResponse.status,
@@ -307,10 +296,6 @@ export const hotelQueryRouter = router({
roomStayStartDate,
roomStayEndDate,
adults,
- children,
- promotionCode,
- reservationProfileType,
- attachedProfileId,
error_type: "validation_error",
error: JSON.stringify(validateAvailabilityData.error),
})
@@ -328,18 +313,20 @@ export const hotelQueryRouter = router({
roomStayStartDate,
roomStayEndDate,
adults,
- children,
- promotionCode,
- reservationProfileType,
- attachedProfileId,
})
console.info(
+ "api.hotels.availability success",
JSON.stringify({
query: { cityId, params: params },
})
)
return {
- availability: validateAvailabilityData.data,
+ availability: validateAvailabilityData.data.data
+ .filter(
+ (hotels) =>
+ hotels.attributes.status === AvailabilityEnum.Available
+ )
+ .flatMap((hotels) => hotels.attributes),
}
}),
}),