import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Show } from '../interfaces/show'; import { getAppConfig } from './app-config.service'; export interface ShowScheduleCreate { day_of_week: number; time: string; } export interface ShowCreatePayload { title: string; description: string; host: string; genre: string; show_art_url: string | null; hero_image_url: string | null; display_order: number; schedules: ShowScheduleCreate[]; } export interface ShowUpdatePayload { title?: string; description?: string; host?: string; genre?: string; show_art_url?: string | null; hero_image_url?: string | null; display_order?: number; active?: boolean; schedules?: ShowScheduleCreate[]; } @Injectable({ providedIn: 'root', }) export class ShowService { private http = inject(HttpClient); private baseUrl = `${getAppConfig().apiBaseUrl}/api/shows`; getShows(): Observable { return this.http.get(this.baseUrl); } getShow(id: number): Observable { return this.http.get(`${this.baseUrl}/${id}`); } createShow(payload: ShowCreatePayload): Observable { return this.http.post(this.baseUrl, payload); } updateShow(id: number, payload: ShowUpdatePayload): Observable { return this.http.put(`${this.baseUrl}/${id}`, payload); } deleteShow(id: number): Observable { return this.http.delete(`${this.baseUrl}/${id}`); } }