/**
 * @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 { Manga, CreateMangaDto, UpdateMangaDto } from '@library/shared-types';

@Injectable({
  providedIn: 'root'
})
export class MangaService {
  private api = inject(ApiService);


  getAllManga(): Observable<Manga[]> {
    return this.api.get<Manga[]>('/manga');
  }

  getMangaById(id: string): Observable<Manga | null> {
    return this.api.get<Manga | null>(`/manga/${id}`);
  }

  createManga(manga: CreateMangaDto): Observable<Manga> {
    return this.api.post<Manga>('/manga', manga);
  }

  updateManga(id: string, manga: UpdateMangaDto): Observable<Manga> {
    return this.api.put<Manga>(`/manga/${id}`, manga);
  }

  deleteManga(id: string): Observable<{ success: boolean }> {
    return this.api.delete<{ success: boolean }>(`/manga/${id}`);
  }
}
