28 lines
1.7 KiB
TypeScript
28 lines
1.7 KiB
TypeScript
|
|
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),
|
||
|
|
updateUser: (id: number, data: { role?: string; is_active?: boolean }) =>
|
||
|
|
api.patch<AdminUser>(`/admin/users/${id}`, data).then((r) => r.data),
|
||
|
|
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),
|
||
|
|
listBounties: (status?: string) =>
|
||
|
|
api.get<PaginatedResponse<AdminBounty>>("/admin/bounties/", { params: { status } }).then((r) => r.data),
|
||
|
|
listDisputes: (status?: string) =>
|
||
|
|
api.get<PaginatedResponse<{ id: number; bounty_id: number; initiator_id: number; status: string; created_at: string }>>>(
|
||
|
|
"/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),
|
||
|
|
reviewProduct: (productId: number, data: { approved: boolean; reject_reason?: string }) =>
|
||
|
|
api.post<AdminProduct>(`/admin/products/${productId}/review/`, data).then((r) => r.data),
|
||
|
|
};
|