feat: only show alerts when booking dates are affected
This commit is contained in:
committed by
Simon.Emanuelsson
parent
64b3bd71dc
commit
145a6d2365
@@ -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,
|
||||
}))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user