Sermon dates
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<div class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow overflow-hidden">
|
<div class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow overflow-hidden">
|
||||||
<div class="p-6">
|
<div class="p-6">
|
||||||
<h3 class="text-xl font-semibold text-gray-900 mb-2">{{ sermon.title }}</h3>
|
<h3 class="text-xl font-semibold text-gray-900 mb-2">{{ sermon.title }}</h3>
|
||||||
<p class="text-sm text-gray-500 mb-4">{{ formatDate(sermon.date) }}</p>
|
<p class="text-sm text-gray-500 mb-4">{{ formatDate(sermon.displayDate || sermon.date) }}</p>
|
||||||
|
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
@@ -24,6 +24,7 @@ interface Sermon {
|
|||||||
slug: string
|
slug: string
|
||||||
title: string
|
title: string
|
||||||
date: string
|
date: string
|
||||||
|
displayDate?: string
|
||||||
bible_references: string
|
bible_references: string
|
||||||
personal_appliance: string
|
personal_appliance: string
|
||||||
pastors_challenge: string
|
pastors_challenge: string
|
||||||
|
|||||||
@@ -153,28 +153,39 @@ const upcomingSermons = computed(() => {
|
|||||||
const today = new Date()
|
const today = new Date()
|
||||||
today.setHours(0, 0, 0, 0)
|
today.setHours(0, 0, 0, 0)
|
||||||
|
|
||||||
return activeSermons.value.filter((s: any) => {
|
return activeSermons.value
|
||||||
|
.map((s: any) => {
|
||||||
// Check primary date
|
// Check primary date
|
||||||
const sermonDate = new Date(s.date + 'T00:00:00')
|
const sermonDate = new Date(s.date + 'T00:00:00')
|
||||||
sermonDate.setHours(0, 0, 0, 0)
|
sermonDate.setHours(0, 0, 0, 0)
|
||||||
if (sermonDate.getTime() > today.getTime()) return true
|
|
||||||
|
// If primary date is in the future, use it
|
||||||
|
if (sermonDate.getTime() > today.getTime()) {
|
||||||
|
return { ...s, displayDate: s.date }
|
||||||
|
}
|
||||||
|
|
||||||
// Check additional dates if they exist
|
// Check additional dates if they exist
|
||||||
if (s.dates) {
|
if (s.dates) {
|
||||||
try {
|
try {
|
||||||
const additionalDates = JSON.parse(s.dates)
|
const additionalDates = JSON.parse(s.dates)
|
||||||
return additionalDates.some((dateStr: string) => {
|
// Find the first future date from additional dates
|
||||||
|
const futureDate = additionalDates.find((dateStr: string) => {
|
||||||
const additionalDate = new Date(dateStr + 'T00:00:00')
|
const additionalDate = new Date(dateStr + 'T00:00:00')
|
||||||
additionalDate.setHours(0, 0, 0, 0)
|
additionalDate.setHours(0, 0, 0, 0)
|
||||||
return additionalDate.getTime() > today.getTime()
|
return additionalDate.getTime() > today.getTime()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (futureDate) {
|
||||||
|
return { ...s, displayDate: futureDate }
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return null
|
||||||
})
|
})
|
||||||
|
.filter((s: any) => s !== null)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Get archived sermons only for the previous sermons dropdown
|
// Get archived sermons only for the previous sermons dropdown
|
||||||
|
|||||||
Reference in New Issue
Block a user