import { notFound } from 'next/navigation'
import { Worship as WorshipType } from '@/payload-types'
import { Worship } from '@/pageComponents/Worship/Worship'

export default async function WorshipPage({ params }: { params: Promise<{id: string}>}) {

  const id = (await params).id;
  const res = await fetch(`http://localhost:3000/api/worship/${id}`);
  if (!res.ok) {
    notFound()
  }

  const worship = await res.json() as WorshipType;

  return (
    <Worship worship={worship} />
  )
}