import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { DeleteFormSymtom, FormSymptom, ResponseDataGet } from 'src/app/interfaces/ANFA/symptom.interface';
import { ResponseData } from 'src/app/interfaces/response-data';
import { HttpRequestService } from '../resources/http-request.service';

@Injectable({
  providedIn: 'root'
})
export class SymptomService {

  private _url: string;
  constructor( private _httpRequestService: HttpRequestService ) {
    this._url = 'failure-analysis';
  }

  public getSymptom(): Observable<ResponseDataGet> {
    return this._httpRequestService.getQuery(`${this._url}/get-symptom`).pipe(map((data: any) => data));
  }

  public registerSymptom(response:FormSymptom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/register-symptom`, response).pipe(map((data:any) => data));
  }

  public updateSymptom(response:FormSymptom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/update-symptom`, response).pipe(map((data:any) => data));
  }

  public deteleProvSymptom(response:DeleteFormSymtom): Observable<ResponseData> {
    return this._httpRequestService.postQuery(`${this._url}/delete-symptom`, response).pipe(map((data:any) => data));
  }
}
