admin/services/reviews.ts
alisaza 82593dc18c refactor(events): update event management components and remove unused files
- Replaced `LIST_PUBLIC_CATEGORIES` with `LIST_ADMIN_CATEGORIES_FLAT` in `ArticleFormModal.tsx`.
- Removed the "Add Event" button from the dashboard page.
- Simplified the `EventsPage` by removing the button and adjusting the layout.
- Cleaned up the `AdminEventEditPage` by removing unnecessary props.
- Deleted unused layout and page files related to event creation.
- Updated `AdminAuthContent` to use `useAdminCitiesQuery` instead of `useDiscoveryCitiesQuery`.
- Refactored `EventGuestListAccessPanel` to remove the `accessMode` prop and adjust API calls accordingly.
- Removed several unused components and tests related to event creation, enhancing project maintainability.
2026-09-07 18:09:55 +03:30

49 lines
1.5 KiB
TypeScript

import type { AdminReviewResponseDto } from '@/api/generated/models'
import { getAdminReviews } from '@/api/generated/admin-reviews/admin-reviews'
import { parseRemittanceList } from '@/helpers/listResponse'
import {
errorResult,
handleServiceError,
type ServiceCallOptions,
type ServiceResult,
shouldBubbleErrorToParent,
successResult,
} from '@/services/errorHandler'
export type AdminEventReview = AdminReviewResponseDto
const adminReviewsApi = getAdminReviews()
export const EVENT_REVIEWS_PAGE_SIZE = 10
/** Admin list for one event — includes published, hidden, and deleted reviews. */
export const LIST_ADMIN_EVENT_REVIEWS_PAGE = async (
eventId: string,
page = 1,
pageSize = EVENT_REVIEWS_PAGE_SIZE,
options?: ServiceCallOptions
): Promise<ServiceResult<{ items: AdminEventReview[]; page: number; totalItemsCount: number; totalPages: number }>> => {
try {
const res = await adminReviewsApi.adminReviewsControllerList({
sort: '-createdAt',
page,
pageSize,
'filters[eventId]': eventId,
})
const parsed = parseRemittanceList<AdminEventReview>(res.data, 'items', page, pageSize)
return successResult({
items: parsed.items,
page: parsed.pagination.page,
totalItemsCount: parsed.pagination.totalItemsCount,
totalPages: parsed.pagination.totalPages ?? 0,
})
} catch (error) {
const normalizedError = handleServiceError(error, options)
if (shouldBubbleErrorToParent(options)) throw normalizedError
return errorResult(normalizedError)
}
}