import { Event } from '@/payload-types'

type EventWithId = {
  id: string,
  date: string,
  title: string,
  href: string,
  location: string,
  cancelled: boolean
}

export const transformEvents = (events: Event[]): EventWithId[] => {
  return events.map(e => {
    return {
      id: e.id,
      title: e.title,
      date: e.date,
      href: `/veranstaltungen/${e.id}`,
      location: typeof e.location === "object" ? e.location.name : "Unbekannt",
      cancelled: e.cancelled,
    }
  })
}