diff --git a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx index cd1d11f98..8c4971f06 100644 --- a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx +++ b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx @@ -91,7 +91,7 @@ export default function HotelInfoCard({ hotelData }: HotelInfoCardProps) { )} - {hotelAttributes?.meta?.specialAlerts.map((alert) => { + {hotelAttributes?.specialAlerts.map((alert) => { return (
{ - const now = dt().utc().format("YYYY-MM-DD") - const filteredAlerts = data.filter((alert) => { - const shouldShowNow = alert.startDate <= now && alert.endDate >= now - const hasText = alert.description || alert.title - return shouldShowNow && hasText - }) - return filteredAlerts.map((alert, idx) => ({ - id: `alert-${alert.type}-${idx}`, - type: AlertTypeEnum.Info, - heading: alert.title || null, - text: alert.description || null, - })) +const specialAlertsSchema = z + .array(specialAlertSchema) + .transform((data) => { + const now = dt().utc().format("YYYY-MM-DD") + const filteredAlerts = data.filter((alert) => { + const shouldShowNow = + alert.startDate && alert.endDate + ? alert.startDate <= now && alert.endDate >= now + : true + const hasText = alert.description || alert.title + return shouldShowNow && hasText }) - .default([]), -}) + return filteredAlerts.map((alert, idx) => ({ + id: `alert-${alert.type}-${idx}`, + type: AlertTypeEnum.Info, + heading: alert.title || null, + text: alert.description || null, + })) + }) + .default([]) const relationshipsSchema = z.object({ restaurants: z.object({ @@ -425,7 +426,7 @@ export const getHotelDataSchema = z.object({ parking: z.array(parkingSchema), specialNeedGroups: z.array(specialNeedGroupSchema), socialMedia: socialMediaSchema, - meta: metaSchema.optional(), + specialAlerts: specialAlertsSchema, isActive: z.boolean(), conferencesAndMeetings: facilitySchema.optional(), healthAndWellness: facilitySchema.optional(), diff --git a/server/routers/hotels/query.ts b/server/routers/hotels/query.ts index 2938616c5..e59d61a02 100644 --- a/server/routers/hotels/query.ts +++ b/server/routers/hotels/query.ts @@ -294,7 +294,7 @@ export const hotelQueryRouter = router({ const hotelAttributes = hotelData.data.attributes const images = hotelAttributes.gallery?.smallerImages - const hotelAlerts = hotelAttributes.meta?.specialAlerts || [] + const hotelAlerts = hotelAttributes.specialAlerts const roomCategories = included ? included.filter((item) => item.type === "roomcategories")