import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { GradoEducativo } from '../interfaces/GradoEducativo.interface';
import { environments } from '../../../../environments/environments';
import { map } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class GradosEducativosService {
  private URL: string = environments.baseUrl;
  constructor(private http: HttpClient) { }
  private getHeaders(): HttpHeaders {
    const token = localStorage.getItem('token') || '';
    return new HttpHeaders({
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    });
  }
  guardar(dataGrado: GradoEducativo) {
    return this.http.post(`${this.URL}/gradoEducativoSave`, dataGrado, { headers: this.getHeaders() })
  }

  getAll() {
    return this.http.get(`${this.URL}/gradoEducativoAll`, { headers: this.getHeaders() })
      
  }

  getHabilitados() {
    return this.http.get(`${this.URL}/gradoEducativoHabilitado`, { headers: this.getHeaders() });
  }

  getOne(id: string) {
    
    return this.http.get(`${this.URL}/gradoEducativoOne/${id}`, { headers: this.getHeaders() });
  }

  actualizarGrado(data: any) {
    return this.http.put(`${this.URL}/gradoEducativoE`, data, { headers: this.getHeaders() });
  }

  eliminarGrado(id: string) {
    
    return this.http.put(`${this.URL}/gradoEducativoDelete/${id}`, null, { headers: this.getHeaders() });
  }

  habilitarGrado(id: string) {
    
    return this.http.put(`${this.URL}/gradoEducativoEnable/${id}`, null, { headers: this.getHeaders() });
  }

}
