Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
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<EventGuestListLink[]> {
|
|
const response =
|
|
accessMode === 'admin'
|
|
? await adminEventExtrasApi.adminEventGuestListLinksControllerList(eventId)
|
|
: await eventExtrasApi.eventGuestListLinksControllerList(eventId)
|
|
|
|
const payload = unwrapApiPayload<EventGuestListLink[]>(response.data)
|
|
|
|
return Array.isArray(payload) ? payload : []
|
|
}
|
|
|
|
export async function fetchEventInvitedGuests(eventId: string, accessMode: EventGuestListAccessMode): Promise<EventInvitedGuest[]> {
|
|
if (accessMode === 'admin') {
|
|
const response = await adminEventExtrasApi.adminEventInvitedGuestsControllerGet(eventId)
|
|
const payload = unwrapApiPayload<EventInvitedGuest[]>(response.data)
|
|
|
|
return Array.isArray(payload) ? payload : []
|
|
}
|
|
|
|
const response = await eventExtrasApi.eventGuestListLinksControllerGetInvitedGuests(eventId)
|
|
const payload = unwrapApiPayload<EventInvitedGuest[]>(response.data)
|
|
|
|
return Array.isArray(payload) ? payload : []
|
|
}
|