import { Injectable, Inject, LOCALE_ID } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';

export interface Questionario {
  dataValidade: any;
  dataPublicacao: any;
  id: number;
  titulo: string;
}

@Injectable({
  providedIn: 'root'
})
export class RelatoriosService {
  private readonly BASE_URL = 'http://localhost:8080';
  private readonly httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'application/json'
    }),
    withCredentials: true
  };

  constructor(
    private httpClient: HttpClient,
    @Inject(LOCALE_ID) public locale: string
  ) {}

  listarQuestionarios(): Observable<Questionario[]> {
    return this.httpClient.get<Questionario[]>(
      `${this.BASE_URL}/listaquestionarios`,
      this.httpOptions
    );
  }

  getRelatorioQuestionario(id: number): Observable<any> {
    return this.httpClient.get<any>(
      `${this.BASE_URL}/relatorios/questionario/${id}`,
      this.httpOptions
    );
  }
}