/** * @copyright NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import type { CommentReportWithDetails, CreateCommentReportDto, UpdateCommentReportDto, ReportStatus, } from '@library/shared-types'; import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root', }) export class CommentReportService { private readonly http = inject(HttpClient); private readonly apiUrl = `${environment.apiUrl}/comment-reports`; createReport( dto: CreateCommentReportDto, ): Observable { return this.http.post(this.apiUrl, dto); } getAllReports( status?: ReportStatus, ): Observable { const params: Record = {}; if (status) { params['status'] = status; } return this.http.get(this.apiUrl, { params }); } getReportById(id: string): Observable { return this.http.get(`${this.apiUrl}/${id}`); } updateReport( id: string, dto: UpdateCommentReportDto, ): Observable { return this.http.put(`${this.apiUrl}/${id}`, dto); } }