- Refactored `updateUser` method in `admin.service.ts` to accept `Partial<User>` instead of `any`. - Added `User` type import for more precise typing.
37 lines
951 B
TypeScript
37 lines
951 B
TypeScript
import api from "@/lib/api";
|
|
import type { User } from "@/types/user";
|
|
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: Partial<User>): Promise<void> => {
|
|
await api.patch(`/users/admin/${userId}`, data);
|
|
},
|
|
};
|