From 3e858cb0641bb3bca4760a670786599848627f7a Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Tue, 5 Nov 2024 14:05:11 +0100 Subject: [PATCH] Refactor --- server/routers/hotels/query.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index ed84f3f17..4a42d2410 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -287,22 +287,13 @@ export const hotelQueryRouter = router({ ctx.serviceToken ) - const validatedHotelData = getHotelDataSchema.safeParse(hotelData) - - if (!validatedHotelData.success) { - console.error( - "api.hotels.hotel validation error", - JSON.stringify({ - query: { hotelId }, - error: validatedHotelData.error, - }) - ) - throw badRequestError() + if (!hotelData) { + throw notFound() } - const included = validatedHotelData.data.included || [] + const included = hotelData.included || [] - const hotelAttributes = validatedHotelData.data.data.attributes + const hotelAttributes = hotelData.data.attributes const images = hotelAttributes.gallery?.smallerImages const hotelAlerts = hotelAttributes.meta?.specialAlerts || [] @@ -316,6 +307,7 @@ export const hotelQueryRouter = router({ const facilities: Facility[] = [ { + ...hotelData.data.attributes.restaurantImages, id: FacilityCardTypeEnum.restaurant, headingText: hotelData?.data.attributes.restaurantImages?.headingText ?? "", @@ -323,6 +315,7 @@ export const hotelQueryRouter = router({ hotelData?.data.attributes.restaurantImages?.heroImages ?? [], }, { + ...hotelData.data.attributes.conferencesAndMeetings, id: FacilityCardTypeEnum.conference, headingText: hotelData?.data.attributes.conferencesAndMeetings?.headingText ?? "", @@ -330,6 +323,7 @@ export const hotelQueryRouter = router({ hotelData?.data.attributes.conferencesAndMeetings?.heroImages ?? [], }, { + ...hotelData.data.attributes.healthAndWellness, id: FacilityCardTypeEnum.wellness, headingText: hotelData?.data.attributes.healthAndWellness?.headingText ?? "",