export interface Event {
  id: string;
  title: string;
  start: string;
  end: string;
  allDay: boolean;
  classNames: string[];
  extendedProps: Record<string, unknown>;
}

export async function fetchEvents(groupId: string) {
  const res = await fetch(`/api/events?group_id=${encodeURIComponent(groupId)}`);
  const data = await res.json();
  if (!res.ok || data.error) throw new Error(data.error || 'Fehler beim Laden der Termine');
  return data;
}

export async function deleteEvent(eventId: string) {
  const res = await fetch(`/api/events/${encodeURIComponent(eventId)}`, {
    method: 'DELETE',
  });
  const data = await res.json();
  if (!res.ok || data.error) throw new Error(data.error || 'Fehler beim Löschen des Termins');
  return data;
}
