import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ApiService } from './api.service'; import { AuthService } from './auth.service'; // Interfaccia per i dati della definizione turno export interface ShiftDefinition { id: number; name: string; start_time: string; // Formato HH:MM:SS o HH:MM end_time: string; // Formato HH:MM:SS o HH:MM notes?: string | null; created_at: string; updated_at: string; } // Interfaccia per i dati di input export type ShiftDefinitionInput = Partial>; @Injectable({ providedIn: 'root' }) export class ShiftDefinitionService extends ApiService { constructor(authService: AuthService, http: HttpClient) { super(authService, http, 'shift-definitions'); } // GET /api/shift-definitions getShiftDefinitions(): Observable { return this.get(`${this.controllerName}`); } // GET /api/shift-definitions/{id} getShiftDefinition(id: number): Observable { return this.get(`${this.controllerName}/${id}`); } // POST /api/shift-definitions addShiftDefinition(shift: ShiftDefinitionInput): Observable { return this.post(`${this.controllerName}`, shift); // Invia come JSON } // PUT /api/shift-definitions/{id} updateShiftDefinition(id: number, shift: ShiftDefinitionInput): Observable { return this.put(`${this.controllerName}/${id}`, shift); // Invia come JSON } // DELETE /api/shift-definitions/{id} deleteShiftDefinition(id: number): Observable { return this.delete(`${this.controllerName}/${id}`); } }