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-myfiles',
  templateUrl: './myfiles.page.html',
  styleUrls: ['./myfiles.page.scss'],
})
export class MyfilesPage implements OnInit {


  tabs = 'myfiles';

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


  }


  ngOnInit() {
    this.getMyFiles();
  }

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

  onMentor() {
    this.router.navigate(['mentor']);
  }

  onEnroll() {
    this.router.navigate(['enroll']);
  }

  usrData: {
    action:number, member_id: number, uid: string, sessionid: string, limit:20, page:1
  };
 myFilesTotalData:any;
  myFilesData: [];

  getMyFiles(){
    this.usrData = {action:11309,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session ,
      limit:20, page:1}

    this.wrenchService.getMyFiles(this.usrData).subscribe(
        myFilesTotalData => {
          this.myFilesTotalData = myFilesTotalData;
          console.log("myFilesData  RETURN->", this.myFilesTotalData);
          this.myFilesData = this.myFilesTotalData.result_list;
          // debugger;

          console.log("myFilesData RETURN DATA->", this.myFilesData);
        }
    );

  }

}
