import { notFound } from 'next/navigation'
import { Worship } from '@/pageComponents/Worship/Worship'
import { isAuthenticated } from '@/utils/auth'
import { AdminMenu } from '@/components/AdminMenu/AdminMenu'
import { fetchWorshipById } from '@/fetch/worship'

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

  const id = (await params).id;
  const worship = await fetchWorshipById(id)

  if (!worship) {
    notFound()
  }

  const authenticated = await isAuthenticated();

  return (
    <>
      <Worship
        worship={worship}
      />
      <AdminMenu
        collection={"worship"}
        id={worship.id}
        isAuthenticated={authenticated}
      />
    </>
  )
}
