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-fastreward',
  templateUrl: './fastreward.component.html',
  styleUrls: ['./fastreward.component.scss'],
})
export class FastrewardComponent implements OnInit {
  total_family:number = 0;
  family_active:number = 0;
  session_image_server:string='';
  curr_session:string='';
  constructor(private navctr: NavController,
              private router: Router,
              public sessionDataProviderService: SessionDataProviderService,
              private wrenchService: WrenchService) { }

  ngOnInit() {
      this.getFamilyData();
  }
    familyAcc(){
      this.router.navigate(['family']);
    }
  usrData: {
    action:number, member_id: number, uid: string, sessionid: string, limit:20, page:1,offset: 0
  };
  familyTotalData:any;
  familyData: [];
  getFamilyData(){
    this.usrData = {action:22010,
      member_id: this.sessionDataProviderService.member_id,
      uid: this.sessionDataProviderService.member_uid,
      sessionid: this.sessionDataProviderService.session ,
      limit:20, page:1,offset: 0};
    this.curr_session =  this.sessionDataProviderService.session;

    this.wrenchService.getFamilyList(this.usrData).subscribe(
        familyTotalData => {
          this.familyTotalData = familyTotalData;
          console.log("FAMILY  RETURN->", this.familyTotalData);
          this.familyData = this.familyTotalData.result_list; //.slice(0,3);
          // debugger;
          this.session_image_server = this.familyTotalData.session_image_server;
          console.log("FAMILY RETURN DATA->", this.familyData);
          this.total_family = this.familyData.length;
        }
    );

  }

    familyMemebr(item){

    }

}
