40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { fetchEvents } from '@/fetch/events'
|
|
import { fetchWorship } from '@/fetch/worship'
|
|
import { fetchBlogPosts } from '@/fetch/blog'
|
|
import { fetchHighlights } from '@/fetch/highlights'
|
|
import { Home } from '@/pageComponents/Home/Home'
|
|
import moment from 'moment'
|
|
import { fetchLastAnnouncement, fetchLastAnnouncements } from '@/fetch/announcement'
|
|
import { perParish } from '@/utils/dto/perParish'
|
|
import { fetchLastCalendars } from '@/fetch/calendar'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function HomePage() {
|
|
|
|
const fromDate = moment().isoWeekday(1).hours(0).minutes(0);
|
|
const tillDate = moment().isoWeekday(7).hours(23).minutes(59);
|
|
const events = await fetchEvents()
|
|
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 (
|
|
<Home
|
|
events={events?.docs || []}
|
|
worship={worship?.docs || []}
|
|
blog={blog?.docs || []}
|
|
highlights={highlights?.docs || []}
|
|
announcements={announcementsLinks}
|
|
calendars={calendarsLinks}
|
|
/>
|
|
)
|
|
}
|