import { Injectable } from '@angular/core';
import { environments } from '../../../../environments/environments';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class AsistenciaService {
  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}`
    });
  }

  getAsistencias() {
    return this.http.get(`${this.URL}/asistenciaAll`, { headers: this.getHeaders() })
      
  }
  crear(data: any) {
    return this.http.post(`${this.URL}/asistenciaSave`, data, { headers: this.getHeaders() });
  }

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

  

  eliminar(id: number) {
    return this.http.put(`${this.URL}/asistenciaDelete/${id}`, null, { headers: this.getHeaders() });
  }

  // habilitarNivel(id: string) {
  //   let qId = btoa(id);
  //   return this.http.put(`${this.URL}/nivelEducativoEnable/${qId}`, null, { headers: this.getHeaders() });
  // }
}
