church-website/src/pageComponents/Home/Home.tsx
2026-04-17 14:49:41 +02:00

39 lines
1.5 KiB
TypeScript

import moment from 'moment'
import { fetchUpcomingOccurrences } from '@/fetch/eventOccurrences'
import { fetchWorship } from '@/fetch/worship'
import { fetchBlogPosts } from '@/fetch/blog'
import { fetchHighlights } from '@/fetch/highlights'
import { fetchLastAnnouncements } from '@/fetch/announcement'
import { fetchLastCalendars } from '@/fetch/calendar'
import { perParish } from '@/utils/dto/perParish'
import { PublicationAndNewsletter } from '@/compositions/PublicationAndNewsletter/PublicationAndNewsletter'
import { HomeView } from './HomeView'
export const Home = async () => {
const fromDate = moment().isoWeekday(1).hours(0).minutes(0)
const tillDate = moment().isoWeekday(7).hours(23).minutes(59)
const events = await fetchUpcomingOccurrences()
const worship = await fetchWorship({
fromDate: fromDate.toDate(),
tillDate: tillDate.toDate(),
})
const blog = await fetchBlogPosts(true)
const highlights = await fetchHighlights()
const announcements = await fetchLastAnnouncements()
const announcementsLinks = announcements ? perParish(announcements) : []
const calendars = await fetchLastCalendars()
const calendarsLinks = calendars ? perParish(calendars) : []
return (
<HomeView
events={events?.docs || []}
worship={worship?.docs || []}
blog={blog?.docs || []}
highlights={highlights?.docs || []}
announcements={announcementsLinks}
calendars={calendarsLinks}
publicationAndNewsletter={<PublicationAndNewsletter />}
/>
)
}