generated from nhcarrigan/template
feat: add art component
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @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 { Art, CreateArtDto, UpdateArtDto } from '@library/shared-types';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ArtService {
|
||||
constructor(private api: ApiService) {}
|
||||
|
||||
getAllArt(): Observable<Art[]> {
|
||||
return this.api.get<Art[]>('/art');
|
||||
}
|
||||
|
||||
getArtById(id: string): Observable<Art | null> {
|
||||
return this.api.get<Art | null>(`/art/${id}`);
|
||||
}
|
||||
|
||||
createArt(art: CreateArtDto): Observable<Art> {
|
||||
return this.api.post<Art>('/art', art);
|
||||
}
|
||||
|
||||
updateArt(id: string, art: UpdateArtDto): Observable<Art> {
|
||||
return this.api.put<Art>(`/art/${id}`, art);
|
||||
}
|
||||
|
||||
deleteArt(id: string): Observable<{ success: boolean }> {
|
||||
return this.api.delete<{ success: boolean }>(`/art/${id}`);
|
||||
}
|
||||
}
|
||||
@@ -50,4 +50,16 @@ export class CommentsService {
|
||||
deleteCommentFromMusic(musicId: string, commentId: string): Observable<{ success: boolean }> {
|
||||
return this.api.delete<{ success: boolean }>(`/music/${musicId}/comments/${commentId}`);
|
||||
}
|
||||
|
||||
getCommentsForArt(artId: string): Observable<Comment[]> {
|
||||
return this.api.get<Comment[]>(`/art/${artId}/comments`);
|
||||
}
|
||||
|
||||
addCommentToArt(artId: string, comment: CreateCommentDto): Observable<Comment> {
|
||||
return this.api.post<Comment>(`/art/${artId}/comments`, comment);
|
||||
}
|
||||
|
||||
deleteCommentFromArt(artId: string, commentId: string): Observable<{ success: boolean }> {
|
||||
return this.api.delete<{ success: boolean }>(`/art/${artId}/comments/${commentId}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user