Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import axiosInstance from '@/config/axios'
|
|
import { unwrapApiPayload } from '@/helpers/listResponse'
|
|
import { API_ROUTES } from '@/services/config'
|
|
|
|
/**
|
|
* Consumer-facing event shell used by `/e/[uuid]` detail.
|
|
* Mirrors the fields `ConsumerEventDetail` / landing body need for layout + CTA.
|
|
*/
|
|
export interface ConsumerEventDetailData {
|
|
id: string
|
|
organizerId: string
|
|
title: string
|
|
status: string
|
|
categoryId?: number | null
|
|
/** Display labels from `GET /events/:id` — prefer these over taxonomy round-trips. */
|
|
categoryName?: string | null
|
|
cityName?: string | null
|
|
settings: {
|
|
isDiscoverable: boolean
|
|
addressVisibility: 'public' | 'attendees_only'
|
|
generalArea: string | null
|
|
}
|
|
startsAt: string
|
|
endsAt: string
|
|
capacity: number
|
|
bookedCount: number
|
|
reservedCapacity?: number
|
|
price: number
|
|
isFree: boolean
|
|
genderRestriction?: string | null
|
|
ageRestriction?: string | null
|
|
address: string | null
|
|
lat: number | null
|
|
lng: number | null
|
|
cityId: number | null
|
|
provinceId: number | null
|
|
description?: string | null
|
|
shortDescription?: string | null
|
|
avgRating?: number | null
|
|
reviewsCount?: number
|
|
}
|
|
|
|
export interface EventOwnerInsights {
|
|
bookmarkCount: number
|
|
}
|
|
|
|
/** `GET /events/:id` — any non-deleted event the caller may read. */
|
|
export async function fetchConsumerEventDetail(eventId: string): Promise<ConsumerEventDetailData> {
|
|
const response = await axiosInstance.get(API_ROUTES.EVENTS.DETAIL(eventId))
|
|
|
|
return unwrapApiPayload<ConsumerEventDetailData>(response.data)
|
|
}
|
|
|
|
/** `GET /events/:id/owner-insights` — host-only bookmark count strip. */
|
|
export async function fetchEventOwnerInsights(eventId: string): Promise<EventOwnerInsights> {
|
|
const response = await axiosInstance.get(API_ROUTES.EVENTS.OWNER_INSIGHTS(eventId))
|
|
const insights = unwrapApiPayload<{ bookmarkCount?: number }>(response.data)
|
|
|
|
return { bookmarkCount: Number(insights.bookmarkCount ?? 0) }
|
|
}
|