/** * @copyright 2026 NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { ApiService } from './api.service'; import { Comment, CreateCommentDto } from '@library/shared-types'; @Injectable({ providedIn: 'root' }) export class CommentsService { constructor(private api: ApiService) {} getCommentsForGame(gameId: string): Observable { return this.api.get(`/games/${gameId}/comments`); } getCommentsForBook(bookId: string): Observable { return this.api.get(`/books/${bookId}/comments`); } getCommentsForMusic(musicId: string): Observable { return this.api.get(`/music/${musicId}/comments`); } addCommentToGame(gameId: string, comment: CreateCommentDto): Observable { return this.api.post(`/games/${gameId}/comments`, comment); } addCommentToBook(bookId: string, comment: CreateCommentDto): Observable { return this.api.post(`/books/${bookId}/comments`, comment); } addCommentToMusic(musicId: string, comment: CreateCommentDto): Observable { return this.api.post(`/music/${musicId}/comments`, comment); } deleteCommentFromGame(gameId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/games/${gameId}/comments/${commentId}`); } deleteCommentFromBook(bookId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/books/${bookId}/comments/${commentId}`); } deleteCommentFromMusic(musicId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/music/${musicId}/comments/${commentId}`); } getCommentsForArt(artId: string): Observable { return this.api.get(`/art/${artId}/comments`); } addCommentToArt(artId: string, comment: CreateCommentDto): Observable { return this.api.post(`/art/${artId}/comments`, comment); } deleteCommentFromArt(artId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/art/${artId}/comments/${commentId}`); } getCommentsForShow(showId: string): Observable { return this.api.get(`/shows/${showId}/comments`); } addCommentToShow(showId: string, comment: CreateCommentDto): Observable { return this.api.post(`/shows/${showId}/comments`, comment); } deleteCommentFromShow(showId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/shows/${showId}/comments/${commentId}`); } getCommentsForManga(mangaId: string): Observable { return this.api.get(`/manga/${mangaId}/comments`); } addCommentToManga(mangaId: string, comment: CreateCommentDto): Observable { return this.api.post(`/manga/${mangaId}/comments`, comment); } deleteCommentFromManga(mangaId: string, commentId: string): Observable<{ success: boolean }> { return this.api.delete<{ success: boolean }>(`/manga/${mangaId}/comments/${commentId}`); } updateCommentOnGame(gameId: string, commentId: string, content: string): Observable { return this.api.put(`/games/${gameId}/comments/${commentId}`, { content }); } updateCommentOnBook(bookId: string, commentId: string, content: string): Observable { return this.api.put(`/books/${bookId}/comments/${commentId}`, { content }); } updateCommentOnMusic(musicId: string, commentId: string, content: string): Observable { return this.api.put(`/music/${musicId}/comments/${commentId}`, { content }); } updateCommentOnArt(artId: string, commentId: string, content: string): Observable { return this.api.put(`/art/${artId}/comments/${commentId}`, { content }); } updateCommentOnShow(showId: string, commentId: string, content: string): Observable { return this.api.put(`/shows/${showId}/comments/${commentId}`, { content }); } updateCommentOnManga(mangaId: string, commentId: string, content: string): Observable { return this.api.put(`/manga/${mangaId}/comments/${commentId}`, { content }); } }