import { getPayload } from 'payload'
import config from '@/payload.config'
import { DonationForm } from '@/payload-types'

export async function fetchDonationForm(
  id: string,
): Promise<DonationForm | undefined> {
  try {
    const payload = await getPayload({ config })
    return await payload.findByID({
      collection: 'donation-form',
      id,
    })
  } catch {
    return undefined
  }
}
