feat: only show alerts when booking dates are affected

This commit is contained in:
Simon Emanuelsson
2025-06-16 15:41:34 +02:00
committed by Simon.Emanuelsson
parent 64b3bd71dc
commit 145a6d2365
5 changed files with 57 additions and 16 deletions

View File

@@ -22,11 +22,12 @@ export const specialAlertsSchema = z
.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
const hasDates = alert.startDate && alert.endDate
if (!hasDates) {
return hasText
}
const shouldShowNow = alert.startDate <= now && alert.endDate >= now
return shouldShowNow && hasText
})
return filteredAlerts.map((alert, idx) => ({
@@ -36,5 +37,7 @@ export const specialAlertsSchema = z
text: alert.description || null,
type: AlertTypeEnum.Info,
displayInBookingFlow: alert.displayInBookingFlow,
endDate: alert.endDate,
startDate: alert.startDate,
}))
})