import type { GuestListLinkResponseDto, InvitedGuestResponseDto } from '@/api/generated/models' import { getAdminEventExtras } from '@/api/generated/admin-event-extras/admin-event-extras' import { getEventExtras } from '@/api/generated/event-extras/event-extras' import { unwrapApiPayload } from '@/helpers/listResponse' export type EventGuestListAccessMode = 'admin' | 'owner' export type EventGuestListLink = GuestListLinkResponseDto export type EventInvitedGuest = InvitedGuestResponseDto const adminEventExtrasApi = getAdminEventExtras() const eventExtrasApi = getEventExtras() export async function fetchEventGuestListLinks(eventId: string, accessMode: EventGuestListAccessMode): Promise { const response = accessMode === 'admin' ? await adminEventExtrasApi.adminEventGuestListLinksControllerList(eventId) : await eventExtrasApi.eventGuestListLinksControllerList(eventId) const payload = unwrapApiPayload(response.data) return Array.isArray(payload) ? payload : [] } export async function fetchEventInvitedGuests(eventId: string, accessMode: EventGuestListAccessMode): Promise { if (accessMode === 'admin') { const response = await adminEventExtrasApi.adminEventInvitedGuestsControllerGet(eventId) const payload = unwrapApiPayload(response.data) return Array.isArray(payload) ? payload : [] } const response = await eventExtrasApi.eventGuestListLinksControllerGetInvitedGuests(eventId) const payload = unwrapApiPayload(response.data) return Array.isArray(payload) ? payload : [] }