import { Component, OnInit } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router'
import { MermsServiceProviderService } from './../providers/merms-service-provider.service';
import { MermsSessionService } from './../merms-session.service';

import {
  NavController,
  AlertController,
  LoadingController,
} from '@ionic/angular'


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



  constructor(public navCtrl: NavController, private router: Router,
    private mermsServiceProviderService: MermsServiceProviderService,
    private mermsSessionService: MermsSessionService
  ) { 
this.getPaymentData();

  }


  paymentData: any;


  currentProviderData: {
    sessionid: string,
    member_id: number,
    card_count: number
    card_type: number
  };

  getPaymentData() {
    console.log('MermsServiceProviderService::getDashData() ########  @@@@  ########');
    this.currentProviderData = {
      sessionid: this.mermsSessionService.session,
      member_id: this.mermsSessionService.member_id,
      card_count: 100,
      card_type: 22000
    };

    try {
      this.mermsServiceProviderService.genericGetService('provider/recentpayments', this.currentProviderData).subscribe(paymentData => {
        console.log("card data result 22k: ", paymentData[0]['payload']);
        this.paymentData = paymentData[0]['payload'];
        if (paymentData.hasOwnProperty('payload') && Array.isArray(paymentData['payload'])) {
          this.paymentData = paymentData['payload'];
          console.log("card data result 22k: ", this.paymentData);
        }
      });
    } catch (e) {
      console.log(e);
    }



    //


  }

  ngOnInit() {
  }
  goBack() {
    console.log('MERMSLoginPage::goBack()')
    this.navCtrl.pop()
  }
}
