import { getPayload } from 'payload'
import config from '@/payload.config'

export async function fetchParish(slug: string, draft: boolean = false) {
  const payload = await getPayload({ config })
  const result = await payload.find({
    collection: 'parish',
    where: {
      slug: {
        equals: slug,
      },
    },
    draft,
  })
  return result.docs[0] ?? null
}
