import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { environment } from 'src/environments/environment';
import { AuthService } from '../auth/services/auth.service';

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

  constructor(private http: HttpClient,
    private auth: AuthService) { }

  getTodaySale() {
    console.log('getTodaySale');
    let url = environment.url + `dashboard/sale`;
    return this.http.get<any>(url);
  }

  getSellerSale() {
    const supervisorId = this.auth.getSupervisor();
    let url = environment.url + `dashboard/sale/${supervisorId}`;
    return this.http.get<any>(url);
  }

  getStoresSale(supervisorIds: string[]) {
    let params = new HttpParams().set('ids', supervisorIds.toString());
    let url = environment.url + `dashboard/sale/store`;
    return this.http.get<any>(url, { params: params });
  }

  getSaleCompany() {
    let url = environment.url + `dashboard/sale/company`;
    return this.http.get<any>(url);
  }


}
