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

@Injectable({
  providedIn: 'root'
})
export class LoginService {

  constructor(private http: HttpClient) { }

  login (userInfo: any) {
    return this.postQuery("login", userInfo).pipe(map((data: any) => data))
  }

  verifyToken(token: string){
    return this.postQuery("verify-token", {token: token, linea: 1}).pipe(map((data: any) => data));
  }

  postQuery(query: string, body: any){
    const URL = `${apiTemp}${query}`;
    
    return this.http.post(URL, body);
  }
}
