import { Component, OnInit } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import * as Parse from 'parse';
import { Router, ActivatedRoute } from '@angular/router';
import { NavComponent } from '../../../app/components/nav/nav.component';

@Component({
  selector: 'app-wattle',
  templateUrl: './wattle.component.html',
  styleUrls: ['./wattle.component.scss'],
  standalone: true,
  imports: [IonicModule,NavComponent],
})
export class WattleComponent implements OnInit {
  company: any = localStorage.getItem('company');
  constructor(private activatRoute: ActivatedRoute,
    private router: Router,) { }
  account: any = {}

  ngOnInit() {
    this.activatRoute.paramMap.subscribe(parms => {
      this.getAccount()
    })

  }
  back() {
    this.router.navigate(['account/tabs/my'])
  }
  async getAccount() {
    let id = Parse.User.current()?.id
    let Account = new Parse.Query("Account")
    Account.equalTo("user", id)
    Account.equalTo("company", this.company)
    let account = await Account.first()
    this.account = account?.toJSON()
  }

  // showBalance(balance:number) {
  //   if (balance) {
  //     return Number(balance.toFixed(2))
  //   } else {
  //     return 0
  //   }
  // }
  record() {
    this.router.navigate(['account/record'])
  }
  records() {
    this.router.navigate(['account/records'])
  }
  recharge() {
    this.router.navigate(['account/recharge'])
  }
  withdrawal() {
    this.router.navigate(['account/withdrawal'])
  }
  toBank() {
    this.router.navigate(['account/bankcard'])
  }
}
