import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@msfa-environment';
import { AvvikelseReportResponse } from '@msfa-models/api/avvikelse-response.model';
import { FranvaroReportResponse } from '@msfa-models/api/franvaro-response.model';
import { GemensamPlaneringResponse } from '@msfa-models/api/gemensam-planering.response.model';
import { InformativRapportResponse } from '@msfa-models/api/informativ-rapport.response.model';
import { SlutredovisningResponse } from '@msfa-models/api/slutredovisning.response.model';
import { Observable } from 'rxjs';
import { SignalResponse } from '@msfa-models/api/signal.response.model';

@Injectable({
  providedIn: 'root',
})
export class HandlingarApiService {
  private _apiBaseUrl = `${environment.api.url}/handlingar`;

  constructor(private httpClient: HttpClient) {}

  public fetchGemensamPlanering$(handlingId: string): Observable<{ data: GemensamPlaneringResponse }> {
    return this.httpClient.get<{ data: GemensamPlaneringResponse }>(
      `${this._apiBaseUrl}/gemensam-planering/${handlingId}`
    );
  }

  public fetchInformativRapport$(handlingId: string): Observable<{ data: InformativRapportResponse }> {
    return this.httpClient.get<{ data: InformativRapportResponse }>(
      `${this._apiBaseUrl}/informativ-rapport/${handlingId}`
    );
  }
  public fetchSignal$(handlingId: string): Observable<{ data: SignalResponse }> {
    return this.httpClient.get<{ data: SignalResponse }>(`${this._apiBaseUrl}/signal/${handlingId}`);
  }

  public fetchFranvaroReport$(handlingId: string): Observable<{ data: FranvaroReportResponse }> {
    return this.httpClient.get<{ data: FranvaroReportResponse }>(`${this._apiBaseUrl}/franvaro/${handlingId}`);
  }

  public fetchAvvikelseReport$(handlingId: string): Observable<{ data: AvvikelseReportResponse }> {
    return this.httpClient.get<{ data: AvvikelseReportResponse }>(`${this._apiBaseUrl}/avvikelse/${handlingId}`);
  }

  public fetchSlutredovisning$(handlingId: string): Observable<{ data: SlutredovisningResponse }> {
    return this.httpClient.get<{ data: SlutredovisningResponse }>(`${this._apiBaseUrl}/slutredovisning/${handlingId}`);
  }
}
