import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { WrenchService } from 'src/app/services/wrench.service';
import {SessionDataProviderService} from "../../store/session-data-provider.service";
import {NavController} from "@ionic/angular";

@Component({
  selector: 'app-joblist',
  templateUrl: './joblist.page.html',
  styleUrls: ['./joblist.page.scss'],
})
export class JoblistPage implements OnInit {

  tabs = 'about';
  session_image_server:string='';
  curr_session:string="";
  constructor(
      private navctr: NavController,
      private router: Router,
      public sessionDataProviderService: SessionDataProviderService,
      private wrenchService: WrenchService
  ) {


  }

  ngOnInit() {
    this.getJobManagerList();
  }

  onBack() {
    this.navctr.back();
  }

  jobOwnerJobDetails(item){
    var jobEData ={
      jobData: item,
      session_image_server: this.session_image_server
    };

    this.router.navigate(['ownersjob'],{state: jobEData});
  }
  onMentor() {
    this.router.navigate(['mentor']);
  }

  onEnroll() {

  }
  usrData: {
    action:13005, member_id: number, uid: string, sessionid: string, limit:20, page:1,offset: 0
  };
  jobManagerJobsTotalData:any;
  jobManagerJobsData: [];
  total_jobs:number=0;

  getJobManagerList(){
    this.curr_session =  this.sessionDataProviderService.session;
    this.usrData = {action:13005,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session ,
      limit:20, page:1,offset: 0}

    this.wrenchService.getJobManagerList(this.usrData).subscribe(
        jobManagerJobsTotalData => {
          this.jobManagerJobsTotalData = jobManagerJobsTotalData;
          console.log("jobManagerJobsTotalData  RETURN->", this.jobManagerJobsTotalData);
          this.jobManagerJobsData = this.jobManagerJobsTotalData.result_list;
          // debugger;
          this.session_image_server = this.jobManagerJobsTotalData.session_image_server;
          this.total_jobs=this.jobManagerJobsData.length;
          console.log("jobManagerJobsData RETURN DATA->", this.jobManagerJobsData);
        }
    );

  }
}
