feat: bunch of work done here, got comments and edit and delete

This commit is contained in:
2026-02-04 13:00:16 -08:00
parent b6d66d34cb
commit 318f3bc500
19 changed files with 1868 additions and 117 deletions
@@ -47,7 +47,6 @@ export class ApiService {
delete<T>(endpoint: string): Observable<T> {
return this.http.delete<T>(`${this.apiUrl}${endpoint}`, {
headers: this.getHeaders(),
withCredentials: true
});
}
@@ -0,0 +1,53 @@
/**
* @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<Comment[]> {
return this.api.get<Comment[]>(`/games/${gameId}/comments`);
}
getCommentsForBook(bookId: string): Observable<Comment[]> {
return this.api.get<Comment[]>(`/books/${bookId}/comments`);
}
getCommentsForMusic(musicId: string): Observable<Comment[]> {
return this.api.get<Comment[]>(`/music/${musicId}/comments`);
}
addCommentToGame(gameId: string, comment: CreateCommentDto): Observable<Comment> {
return this.api.post<Comment>(`/games/${gameId}/comments`, comment);
}
addCommentToBook(bookId: string, comment: CreateCommentDto): Observable<Comment> {
return this.api.post<Comment>(`/books/${bookId}/comments`, comment);
}
addCommentToMusic(musicId: string, comment: CreateCommentDto): Observable<Comment> {
return this.api.post<Comment>(`/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}`);
}
}