/** * @copyright 2026 NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import { ApiService } from './api.service'; import type { ProfileReportWithUsers, CreateReportDto, ReportStatus } from '@library/shared-types'; @Injectable({ providedIn: 'root' }) export class ReportService { private api = inject(ApiService); /** * Create a new profile report. * * @param reportedUserId - The ID of the user being reported * @param reason - The reason for the report * @param details - Additional details about the report * @returns Observable of the created report */ createReport(reportedUserId: string, reason: string, details: string): Observable { const dto: CreateReportDto = { reportedUserId, reason: reason as CreateReportDto['reason'], details }; return this.api.post('/reports', dto); } /** * Get all reports (admin only). Optionally filter by status. * * @param status - Optional status to filter by * @returns Observable of all matching reports */ getAllReports(status?: ReportStatus): Observable { const url = status ? `/reports?status=${status}` : '/reports'; return this.api.get(url); } /** * Get a specific report by ID (admin only). * * @param id - The report ID * @returns Observable of the report */ getReportById(id: string): Observable { return this.api.get(`/reports/${id}`); } /** * Update a report's status and review notes (admin only). * * @param id - The report ID * @param status - The new status * @param reviewNotes - Optional review notes * @returns Observable of the updated report */ updateReport(id: string, status: ReportStatus, reviewNotes?: string): Observable { return this.api.put(`/reports/${id}`, { status, reviewNotes }); } }