feat: Add user reports management dashboard with status filtering, counts, and review functionality including admin notes.
This commit is contained in:
51
src/services/user-reports.service.ts
Normal file
51
src/services/user-reports.service.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import api, { ApiResponse } from './api';
|
||||
|
||||
interface UserInfo {
|
||||
id: string;
|
||||
email: string;
|
||||
userProfile: { firstName: string | null; lastName: string | null } | null;
|
||||
agentProfile: { firstName: string | null; lastName: string | null } | null;
|
||||
}
|
||||
|
||||
export interface UserReport {
|
||||
id: string;
|
||||
reporterId: string;
|
||||
reportedUserId: string;
|
||||
conversationId: string | null;
|
||||
reason: string;
|
||||
description: string | null;
|
||||
status: 'PENDING' | 'REVIEWED' | 'RESOLVED' | 'DISMISSED';
|
||||
adminNotes: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
reporter: UserInfo;
|
||||
reportedUser: UserInfo;
|
||||
}
|
||||
|
||||
export interface ReportCounts {
|
||||
pending: number;
|
||||
reviewed: number;
|
||||
resolved: number;
|
||||
dismissed: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
class UserReportsService {
|
||||
async getAllReports(status?: string): Promise<UserReport[]> {
|
||||
const params = status ? { status } : {};
|
||||
const response = await api.get<ApiResponse<UserReport[]>>('/user-reports/admin/all', { params });
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
async getReportCounts(): Promise<ReportCounts> {
|
||||
const response = await api.get<ApiResponse<ReportCounts>>('/user-reports/admin/counts');
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
async updateReport(id: string, status: string, adminNotes?: string): Promise<UserReport> {
|
||||
const response = await api.patch<ApiResponse<UserReport>>(`/user-reports/admin/${id}`, { status, adminNotes });
|
||||
return response.data.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const userReportsService = new UserReportsService();
|
||||
Reference in New Issue
Block a user