Sermon dates
This commit is contained in:
@@ -153,28 +153,39 @@ const upcomingSermons = computed(() => {
|
||||
const today = new Date()
|
||||
today.setHours(0, 0, 0, 0)
|
||||
|
||||
return activeSermons.value.filter((s: any) => {
|
||||
// Check primary date
|
||||
const sermonDate = new Date(s.date + 'T00:00:00')
|
||||
sermonDate.setHours(0, 0, 0, 0)
|
||||
if (sermonDate.getTime() > today.getTime()) return true
|
||||
|
||||
// Check additional dates if they exist
|
||||
if (s.dates) {
|
||||
try {
|
||||
const additionalDates = JSON.parse(s.dates)
|
||||
return additionalDates.some((dateStr: string) => {
|
||||
const additionalDate = new Date(dateStr + 'T00:00:00')
|
||||
additionalDate.setHours(0, 0, 0, 0)
|
||||
return additionalDate.getTime() > today.getTime()
|
||||
})
|
||||
} catch {
|
||||
return false
|
||||
return activeSermons.value
|
||||
.map((s: any) => {
|
||||
// Check primary date
|
||||
const sermonDate = new Date(s.date + 'T00:00:00')
|
||||
sermonDate.setHours(0, 0, 0, 0)
|
||||
|
||||
// If primary date is in the future, use it
|
||||
if (sermonDate.getTime() > today.getTime()) {
|
||||
return { ...s, displayDate: s.date }
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
// Check additional dates if they exist
|
||||
if (s.dates) {
|
||||
try {
|
||||
const additionalDates = JSON.parse(s.dates)
|
||||
// Find the first future date from additional dates
|
||||
const futureDate = additionalDates.find((dateStr: string) => {
|
||||
const additionalDate = new Date(dateStr + 'T00:00:00')
|
||||
additionalDate.setHours(0, 0, 0, 0)
|
||||
return additionalDate.getTime() > today.getTime()
|
||||
})
|
||||
|
||||
if (futureDate) {
|
||||
return { ...s, displayDate: futureDate }
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
.filter((s: any) => s !== null)
|
||||
})
|
||||
|
||||
// Get archived sermons only for the previous sermons dropdown
|
||||
|
||||
Reference in New Issue
Block a user