import { Component } from '@angular/core';
import {NzStatisticModule} from "ng-zorro-antd/statistic";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzDividerModule} from "ng-zorro-antd/divider";
import {NzModalService} from "ng-zorro-antd/modal";
import {NzMessageService} from "ng-zorro-antd/message";
import {CompanyService} from "../../../services/company.service";
import {CommonsService} from "../../../services/commons.service";
import {UntypedFormBuilder} from "@angular/forms";
import {TradeOrderService} from "../../../services/trade-order.service";
import {NzSpinModule} from "ng-zorro-antd/spin";
import {ADMIN_INFO_OBJECT} from "../../../services/local-storage.namespace";
import {BrowserStorageService} from "../../../utils/localStorage.service";
import {NgIf} from "@angular/common";

@Component({
  selector: 'app-index',
  standalone: true,
  imports: [
    NzStatisticModule,
    NzRowDirective,
    NzColDirective,
    NzDividerModule,
    NzSpinModule,
    NgIf
  ],
  templateUrl: './index.component.html',
  styleUrl: './index.component.less'
})
export class IndexComponent {
  dataObj = {
    today : {
      count:0,
      tradePrice:0,
    },
    thisMonth : {
      count:0,
      tradePrice:0,
    },
    lastMonth : {
      count:0,
      tradePrice:0,
    },
    thisYear : {
      count:0,
      tradePrice:0,
    },
    lastYear : {
      count:0,
      tradePrice:0,
    }
  };
  spinning = true;
  roleType: number;
  constructor(private modal: NzModalService,
              private message: NzMessageService,
              private companyService: CompanyService,
              private commonsService: CommonsService,
              private tradeOrderService: TradeOrderService,
              private store: BrowserStorageService,
              private form: UntypedFormBuilder) {
    this.roleType = this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType;
    if (this.roleType == 0 || this.roleType == 1) {
      this.getData();
    }
  }

    getData() {
      this.tradeOrderService.getHomeCountData(data => {
          this.dataObj = data['return_data'];
          this.spinning = false;
      });
    }

}


