- Adjusted inconsistent formatting for better readability across components and services. - Enhanced type safety by adding placeholders for ignored error parameters and improving types across services. - Improved component organization by reordering imports consistently and applying formatting updates in UI components.
36 lines
899 B
TypeScript
36 lines
899 B
TypeScript
import api from "@/lib/api";
|
|
import type { Report, ReportStatus } from "./report.service";
|
|
|
|
export interface AdminStats {
|
|
users: number;
|
|
contents: number;
|
|
categories: number;
|
|
}
|
|
|
|
export const adminService = {
|
|
getStats: async (): Promise<AdminStats> => {
|
|
const response = await api.get("/admin/stats");
|
|
return response.data;
|
|
},
|
|
|
|
getReports: async (limit = 10, offset = 0): Promise<Report[]> => {
|
|
const response = await api.get("/reports", { params: { limit, offset } });
|
|
return response.data;
|
|
},
|
|
|
|
updateReportStatus: async (
|
|
reportId: string,
|
|
status: ReportStatus,
|
|
): Promise<void> => {
|
|
await api.patch(`/reports/${reportId}/status`, { status });
|
|
},
|
|
|
|
deleteUser: async (userId: string): Promise<void> => {
|
|
await api.delete(`/users/${userId}`);
|
|
},
|
|
|
|
updateUser: async (userId: string, data: any): Promise<void> => {
|
|
await api.patch(`/users/admin/${userId}`, data);
|
|
},
|
|
};
|