base commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { apiClient } from '@/shared/api/client'
|
||||
|
||||
export type AdminReview = {
|
||||
id: string
|
||||
rating: number
|
||||
text: string | null
|
||||
status: string
|
||||
createdAt: string
|
||||
moderatedAt: string | null
|
||||
user: { id: string; email: string; name: string | null }
|
||||
product: { id: string; title: string }
|
||||
}
|
||||
|
||||
export type AdminReviewsListResponse = {
|
||||
items: AdminReview[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export async function fetchAdminReviews(
|
||||
token: string,
|
||||
params?: { status?: string; page?: number; pageSize?: number },
|
||||
): Promise<AdminReviewsListResponse> {
|
||||
const { data } = await apiClient.get<AdminReviewsListResponse>('admin/reviews', {
|
||||
params,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
export async function moderateReview(token: string, id: string, action: 'approve' | 'reject'): Promise<void> {
|
||||
await apiClient.patch(
|
||||
`admin/reviews/${id}`,
|
||||
{ action },
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user