import type { OwnerEventInsightsResponseDto } from '@/api/generated/models' import { getAdminBookings } from '@/api/generated/admin-bookings/admin-bookings' import { getAdminEvents } from '@/api/generated/admin-events/admin-events' import { unwrapApiPayload } from '@/helpers/listResponse' /** Extended until OpenAPI client is regenerated with traffic insights. */ export type EventManagementInsights = OwnerEventInsightsResponseDto & { traffic?: { instagram: { uniqueVisits: number; confirmedBookings: number } telegram: { uniqueVisits: number; confirmedBookings: number } } } const adminEventsApi = getAdminEvents() const adminBookingsApi = getAdminBookings() /** Admin can view insights for any organizer's event (no ownership check). */ export async function fetchEventInsightsAsAdmin(eventId: string): Promise { const response = await adminEventsApi.adminEventsControllerInsights(eventId) return unwrapApiPayload(response.data) } /** Admin can check in a guest for any organizer's event (no ownership check). */ export async function checkInBookingAsAdmin(bookingId: string): Promise { await adminBookingsApi.adminBookingsControllerCheckIn(bookingId) }