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

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


  crearEvento(evento: any) {
    return this.http.post(`${this.URL}/eventoSave`, evento, { headers: this.getHeaders() });
  }
  
  savecalendarioUsuarios(evento: any) {
    return this.http.post(`${this.URL}/savecalendarioUsuarios`, evento, { headers: this.getHeaders() });
  }

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

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

}
