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

export const fetchClassifieds = async () => {
  const date = new Date()
  date.setHours(0, 0, 0, 0)

  const payload = await getPayload({ config })
  return payload.find({
    collection: 'classifieds',
    sort: 'date',
    where: {
      until: {
        greater_than_equal: date.toISOString(),
      },
    },
    limit: 50,
  })
}
