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

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type': 'application/json'
  })
};
@Injectable({ providedIn: 'root' })

export class LogoutService {

  baseurl: string = environment.serviceUrl;
  //this.baseurl = environment.serviceUrl;
  constructor(private http: HttpClient) { }

  /* logout(logid: string,userid:string) {

    this.baseurl = environment.serviceUrl;
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
     return this.http.post(this.baseurl + 'api/UserApi/logout/' + logid +'/'+ userid, { logid }, { headers: header, observe: 'response' });
  } */
  PendingLotInfo(userid: string) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
     return this.http.post(this.baseurl + 'api/UserApi/PendingLotInfo/' + userid , { userid }, { headers: header, observe: 'response' });
  } 
  logout(logid: string) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
     return this.http.post(this.baseurl + 'api/UserApi/logout/' + logid , { logid }, { headers: header, observe: 'response' });
  }
  logout_(logid: string){
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
     return this.http.post(this.baseurl + 'api/UserApi/logout/' + logid , { logid }, { headers: header, observe: 'response' });
   /* const url = `${this.baseurl}api/UserApi/logout/${logid}`;

    return new Promise((resolve, reject) => {
      const success = navigator.sendBeacon(url);
      if (success) {
        resolve({ status: 'success' });
      } else {
        reject({ status: 'error' });
      }
    });*/
  }
  GetUsersPendinginfo(id: any) {
    const headers = new HttpHeaders()
      .set('Content-Type', 'application/json; charset=utf-8')
      //.set('Authorization', 'Bearer ' + token);
    return this.http.get<any>(this.baseurl + 'api/UserApi/GetUsersPendinginfo/'+id, { headers: headers, observe: 'response' });
  }

}
