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

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