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

@Injectable({
  providedIn: 'root'
})
export class RegistroAcademicoService {
  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}`
    });
  }
  createRegistroAcademico(data: any) {
    return this.http.post(`${this.URL}/registroAca`, data, { headers: this.getHeaders() })
  }
  getRegistroAcademico() {
    return this.http.get(`${this.URL}/getRegistro`, { headers: this.getHeaders() });
  }
  getOneRegistroAcademico(id: string) {
    let qId = btoa(id);
    return this.http.get(`${this.URL}/getOneRegistro/${qId}`, { headers: this.getHeaders() });
  }
  ActualizarRegistroAcademico(data: any) {
    let id = btoa(data.idAlumno);
    return this.http.put(`${this.URL}/updateRegistro/${id}`, data, { headers: this.getHeaders() });
  }

  crearRegistroAdministrativo(data: any){
    return this.http.post(`${this.URL}/registroAdministrativo`, data, { headers: this.getHeaders() });
  }
}