import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Jobassignment } from './jobassignment';
import { environment } from '../../../environments/environment';
import { LotMaster } from 'src/app/jobconfiguration/jobmaster/jobmaster';

let header = new HttpHeaders();
header = header.set('Content-Type', 'application/json; charset=utf-8');

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

  baseUrl: string = environment.serviceUrl;

  constructor(private httpClient: HttpClient) { }

  GetStageList(data: number): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getStageList/' + data.toString());
  }
  GetUserAssignedJob(prdefid: number, wfdefid: number): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getUserAssignedJob/' + prdefid.toString() + '/' + wfdefid.toString());
  }
  GetUserAssignedUser(prdefid: number, wfdefid: number): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getUserAssignedUser/' + prdefid.toString() + '/' + wfdefid.toString());
  }
  GetUserAssignedLot(prdefid: number, wfdefid: number, jobid: number, userid: number,startdate,enddate,loadtype): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getUserAssignedLot/' + prdefid.toString() + '/' + wfdefid.toString()
                                    + '/' + jobid.toString() + '/' + userid.toString()+'/'+startdate.toString()+'/'+enddate.toString()+'/'+loadtype.toString());
  }
  GetJobAssigment(prdefid: number, wfdefid: number, jobid: number, userid: number,startdate,enddate,loadtype): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getassignjob_userlst/' + prdefid.toString() + '/' + wfdefid.toString()
                                    + '/' + jobid.toString() + '/' + userid.toString()+'/'+startdate.toString()+'/'+enddate.toString()+'/'+loadtype.toString());
  }
  SetLotAssignDetails(jobworkflowid: number, lotid: number, userid: number, sflag: number, stype: string): Observable<any> {
    return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/setLotAssignDetails/' + jobworkflowid.toString()
                                  + '/' + lotid.toString() + '/' + userid.toString() + '/' + sflag.toString() + '/' + stype.toString(),
                                  {headers: header, observe: 'response'} );
  } 
  SetLotAssignDetails_multiple(lotassign:FormData): Observable<any> {
    debugger;
    const headers = new HttpHeaders()
    return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/setLotAssignDetails_multiple', lotassign,
                                  {headers: headers, observe: 'response'} );
  }

  GetUserJobs(data: number,userid: number): Observable<any> {
  return this.httpClient.get<any>(this.baseUrl + 'api/DashboardApi/getUserJobs/' + data.toString()+ '/' + userid.toString());
}
movemailtoassignuserfold(data: FormData): Observable<any> {
  const headers = new HttpHeaders()
  return this.httpClient.post<any>(this.baseUrl + 'api/EmailReaderApi/movemailtoassignuserfold',
  data, { headers: headers, observe: 'response' });
}
getuserwiseassignlot(data: any): Observable<any> {
  let header = new HttpHeaders();
  header = header.set('Content-Type', 'application/json; charset=utf-8');
  return this.httpClient.post<any>(this.baseUrl + 'api/DashboardApi/GetUserWiseAssignLot',
    data, { headers: header, observe: 'response' });
}
}
