Refactor
This commit is contained in:
@@ -287,22 +287,13 @@ export const hotelQueryRouter = router({
|
|||||||
ctx.serviceToken
|
ctx.serviceToken
|
||||||
)
|
)
|
||||||
|
|
||||||
const validatedHotelData = getHotelDataSchema.safeParse(hotelData)
|
if (!hotelData) {
|
||||||
|
throw notFound()
|
||||||
if (!validatedHotelData.success) {
|
|
||||||
console.error(
|
|
||||||
"api.hotels.hotel validation error",
|
|
||||||
JSON.stringify({
|
|
||||||
query: { hotelId },
|
|
||||||
error: validatedHotelData.error,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
throw badRequestError()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 images = hotelAttributes.gallery?.smallerImages
|
||||||
const hotelAlerts = hotelAttributes.meta?.specialAlerts || []
|
const hotelAlerts = hotelAttributes.meta?.specialAlerts || []
|
||||||
|
|
||||||
@@ -316,6 +307,7 @@ export const hotelQueryRouter = router({
|
|||||||
|
|
||||||
const facilities: Facility[] = [
|
const facilities: Facility[] = [
|
||||||
{
|
{
|
||||||
|
...hotelData.data.attributes.restaurantImages,
|
||||||
id: FacilityCardTypeEnum.restaurant,
|
id: FacilityCardTypeEnum.restaurant,
|
||||||
headingText:
|
headingText:
|
||||||
hotelData?.data.attributes.restaurantImages?.headingText ?? "",
|
hotelData?.data.attributes.restaurantImages?.headingText ?? "",
|
||||||
@@ -323,6 +315,7 @@ export const hotelQueryRouter = router({
|
|||||||
hotelData?.data.attributes.restaurantImages?.heroImages ?? [],
|
hotelData?.data.attributes.restaurantImages?.heroImages ?? [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
...hotelData.data.attributes.conferencesAndMeetings,
|
||||||
id: FacilityCardTypeEnum.conference,
|
id: FacilityCardTypeEnum.conference,
|
||||||
headingText:
|
headingText:
|
||||||
hotelData?.data.attributes.conferencesAndMeetings?.headingText ?? "",
|
hotelData?.data.attributes.conferencesAndMeetings?.headingText ?? "",
|
||||||
@@ -330,6 +323,7 @@ export const hotelQueryRouter = router({
|
|||||||
hotelData?.data.attributes.conferencesAndMeetings?.heroImages ?? [],
|
hotelData?.data.attributes.conferencesAndMeetings?.heroImages ?? [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
...hotelData.data.attributes.healthAndWellness,
|
||||||
id: FacilityCardTypeEnum.wellness,
|
id: FacilityCardTypeEnum.wellness,
|
||||||
headingText:
|
headingText:
|
||||||
hotelData?.data.attributes.healthAndWellness?.headingText ?? "",
|
hotelData?.data.attributes.healthAndWellness?.headingText ?? "",
|
||||||
|
|||||||
Reference in New Issue
Block a user