feat: Add user reports management dashboard with status filtering, counts, and review functionality including admin notes.

This commit is contained in:
pradeepkumar
2026-03-19 05:20:10 +05:30
parent 9036e9f32f
commit b27cdaeb27
3 changed files with 318 additions and 0 deletions

View 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();