import { Component, OnInit } from '@angular/core';
import {NavController} from "@ionic/angular";
import {Router} from "@angular/router";
import { WrenchService } from 'src/app/services/wrench.service';
import {SessionDataProviderService} from "../../store/session-data-provider.service";
@Component({
  selector: 'app-jobinterest',
  templateUrl: './jobinterest.page.html',
  styleUrls: ['./jobinterest.page.scss'],
})
export class JobinterestPage 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.curr_session =  this.sessionDataProviderService.session;
  //  this.getManagerOffersData();
  }

  ionViewDidEnter(){
    this.getManagerOffersData();
  }

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

  processJobInt(item) {
  var  varintData ={
        selItem: item,
        allInterest: this.jobManagerOffersJobsData
    };
    this.router.navigate(['jobintprocess'],{state: varintData});
  }

  usrData: {
    action:number, member_id: number, uid: string,
    sessionid: string,
    limit:20,
    page:1, offset:number
  };
  jobManagerOffersTotalData:any;
  jobManagerOffersJobsData: [];
  getManagerOffersData(){
    this.usrData = {action:13024,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session ,
      limit:20, page:1,offset: 0}

    this.wrenchService.getManagerOffersList(this.usrData).subscribe(
        jobManagerOffersTotalData => {
          this.jobManagerOffersTotalData = jobManagerOffersTotalData;
          this.session_image_server = this.jobManagerOffersTotalData.session_image_server;
          console.log("jobManagerOffersTotalData  RETURN->", this.jobManagerOffersTotalData);
          this.jobManagerOffersJobsData = this.jobManagerOffersTotalData.result_list;

          // debugger;
          console.log("jobManagerOffersJobsData RETURN DATA->", this.jobManagerOffersJobsData);
        }
    );

  }

}
