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

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

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

  ngOnInit() {
    this.marketJobMessages();
  }

  onBack() {
    const event = new Event("app-myjob-offers-clear-modals");
    // Dispatch the event.
    dispatchEvent(event);
    this.navctr.back();
  }

  reqData: {
    action:number,
    member_id: number,
    uid: string,
    sessionid: string,
    page:number,
    offer_code:string,
    limit: number
  };

  messageTotalResult:any;
  messageResult:any;
  async marketJobMessages(){

    this.reqData = {
      action:15044,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session,
      page: 0,
      offer_code: "",
      limit: 20
    };


    this.wrenchService.marketJobMessages(this.reqData).subscribe(
        messageTotalResult => {
          this.messageTotalResult = messageTotalResult;
          console.log("messageTotalResult  RETURN->", this.messageTotalResult);
          this.messageResult = this.messageTotalResult.result_list;

        }
    );

  }

}
