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

@Component({
  selector: 'app-waitinterest',
  templateUrl: './waitinterest.component.html',
  styleUrls: ['./waitinterest.component.scss'],
})
export class WaitinterestComponent implements OnInit {
  //@Input('interestJobsData') interestJobsData:any;
    session_image_server:string='';
    curr_session:string='';

    constructor(
        public sessionDataProviderService: SessionDataProviderService,
        private router: Router,
        private wrenchService: WrenchService
    ) { }

    ngOnInit() {
      this.getInterestList();
    }
    usrData: {
      action: number, member_id: number, uid: string, sessionid: string, limit: 20, page: 1, offset: 0
    };

    jobInterest(item) {
        this.router.navigate(['marketdetail'],{state: item});
    }

    interestTotalData: any;
    interestJobsData: [];
    total_jobs: number = 0;

  getInterestList() {
    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.getWaitingInterest(this.usrData).subscribe(
        interestTotalData => {
          this.interestTotalData = interestTotalData;
          console.log("interestTotalData  RETURN->", this.interestTotalData);
          this.interestJobsData = this.interestTotalData.result_list;
            this.session_image_server = this.interestTotalData.session_image_server;
          this.total_jobs = this.interestJobsData.length;
          console.log("jobManagerJobsData RETURN DATA->", this.interestJobsData);
        }
    );
  }
}
