2026-01-28 16:00:56 +08:00
|
|
|
import { api } from "./client";
|
|
|
|
|
import type { AdminBounty, AdminPaymentEvent, AdminUser, AdminProduct, PaginatedResponse } from "../types";
|
|
|
|
|
|
|
|
|
|
export const adminApi = {
|
|
|
|
|
listUsers: () => api.get<PaginatedResponse<AdminUser>>("/admin/users/").then((r) => r.data),
|
2026-01-29 10:19:27 +08:00
|
|
|
updateUser: (id: number, data: { role?: string, is_active?: boolean }) =>
|
2026-01-28 16:00:56 +08:00
|
|
|
api.patch<AdminUser>(`/admin/users/${id}`, data).then((r) => r.data),
|
2026-01-29 10:19:27 +08:00
|
|
|
listCategories: () => api.get<PaginatedResponse<{ id: number, name: string }>>("/admin/categories/").then((r) => r.data),
|
|
|
|
|
listWebsites: () => api.get<PaginatedResponse<{ id: number, name: string }>>("/admin/websites/").then((r) => r.data),
|
|
|
|
|
listProducts: () => api.get<PaginatedResponse<{ id: number, name: string }>>("/admin/products/").then((r) => r.data),
|
2026-01-28 16:00:56 +08:00
|
|
|
listBounties: (status?: string) =>
|
|
|
|
|
api.get<PaginatedResponse<AdminBounty>>("/admin/bounties/", { params: { status } }).then((r) => r.data),
|
|
|
|
|
listDisputes: (status?: string) =>
|
2026-01-29 10:19:27 +08:00
|
|
|
api.get<PaginatedResponse<{ id: number, bounty_id: number, initiator_id: number, status: string, created_at: string }>>(
|
2026-01-28 16:00:56 +08:00
|
|
|
"/admin/disputes/",
|
|
|
|
|
{ params: { status } }
|
|
|
|
|
).then((r) => r.data),
|
|
|
|
|
listPayments: () => api.get<PaginatedResponse<AdminPaymentEvent>>("/admin/payments/").then((r) => r.data),
|
|
|
|
|
|
|
|
|
|
// Product review APIs
|
|
|
|
|
listPendingProducts: () =>
|
|
|
|
|
api.get<PaginatedResponse<AdminProduct>>("/admin/products/pending/").then((r) => r.data),
|
|
|
|
|
listAllProducts: (status?: string) =>
|
|
|
|
|
api.get<PaginatedResponse<AdminProduct>>("/admin/products/all/", { params: { status } }).then((r) => r.data),
|
2026-01-29 10:19:27 +08:00
|
|
|
reviewProduct: (productId: number, data: { approved: boolean, reject_reason?: string }) =>
|
2026-01-28 16:00:56 +08:00
|
|
|
api.post<AdminProduct>(`/admin/products/${productId}/review/`, data).then((r) => r.data),
|
2026-01-29 13:18:59 +08:00
|
|
|
updateProductImages: (productId: number, data: { images: string[]; image?: string }) =>
|
|
|
|
|
api.put<AdminProduct>(`/admin/products/${productId}/images/`, data).then((r) => r.data),
|
2026-01-28 16:00:56 +08:00
|
|
|
};
|