import { fetchEvents } from '@/fetch/events'
import { fetchWorship } from '@/fetch/worship'
import { fetchBlog } from '@/fetch/blog'
import { fetchHighlights } from '@/fetch/highlights'
import { Home } from '@/pageComponents/Home/Home'
import moment from 'moment'

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 fetchBlog()
  const highlights = await fetchHighlights()


  return (
    <Home
      events={events?.docs || []}
      worship={worship?.docs || []}
      blog={blog?.docs || []}
      highlights={highlights?.docs || []}
    />
  )
}
