import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params, RouterLink} from "@angular/router";
import {TradeOrderService} from "../../../services/trade-order.service";
import {SalesmanStatusPipe} from "../../../pipes/salesman-status.pipe";
import {DatePipe, NgForOf, NgIf} from "@angular/common";
import {BreadcrumbComponent} from "../../common/breadcrumb/breadcrumb.component";
import {NzFormDirective} from "ng-zorro-antd/form";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {ReactiveFormsModule} from "@angular/forms";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzCellFixedDirective, NzTableComponent, NzThMeasureDirective} from "ng-zorro-antd/table";
import {AgentStatusPipe} from "../../../pipes/agent-status.pipe";
import {NzSpinComponent} from "ng-zorro-antd/spin";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {SettleTypePipe} from "../../../pipes/trade-order/settle-type.pipe";
import {PayModePipe} from "../../../pipes/trade-order/pay-mode.pipe";
import {NzModalComponent, NzModalModule} from "ng-zorro-antd/modal";
import {NzDividerComponent, NzDividerModule} from "ng-zorro-antd/divider";
import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs";
import {NzDescriptionsComponent, NzDescriptionsItemComponent} from "ng-zorro-antd/descriptions";
import {TradeOrderRefundStatusPipe} from "../../../pipes/trade-order/trade-order-refund-status.pipe";
import {TradeOrderStatusPipe} from "../../../pipes/trade-order/trade-order-status.pipe";
import {CreateTypePipe} from "../../../pipes/trade-order/create-type.pipe";
import {NzBreadCrumbComponent, NzBreadCrumbItemComponent} from "ng-zorro-antd/breadcrumb";

@Component({
  selector: 'app-trade-order-detail',
  standalone: true,
  imports: [
    RouterLink,
    SalesmanStatusPipe,
    DatePipe,
    BreadcrumbComponent,
    NzFormDirective,
    NzRowDirective,
    NzColDirective,
    NzSelectComponent,
    NzOptionComponent,
    ReactiveFormsModule,
    NgIf,
    NzInputDirective,
    NzButtonComponent,
    NzIconDirective,
    NzTableComponent,
    NzThMeasureDirective,
    NzCellFixedDirective,
    NgForOf,
    AgentStatusPipe,
    NzSpinComponent,
    NzDatePickerComponent,
    SettleTypePipe,
    PayModePipe,
    NzModalComponent,
    NzDividerComponent,
    NzTabComponent,
    NzDescriptionsComponent,
    NzDescriptionsItemComponent,
    TradeOrderRefundStatusPipe,
    TradeOrderStatusPipe,
    CreateTypePipe,
    NzTabSetComponent,
    NzBreadCrumbComponent,
    NzBreadCrumbItemComponent,
    NzModalModule,
    NzDividerModule
  ],
  templateUrl: './trade-order-detail.component.html',
  styleUrl: './trade-order-detail.component.less'
})
export class TradeOrderDetailComponent implements OnInit {

  dataObject = {
    order: {},
    orderRefund: [],
  };

  constructor(
    private activatedRoute: ActivatedRoute,
    private tradeOrderService: TradeOrderService
  ) { }

  ngOnInit(): void {
    this.activatedRoute.queryParams.subscribe((queryParams: Params) => {
      if (queryParams['outTradeNo'] != null && queryParams['outTradeNo'].length > 0) {
        this.tradeOrderService.getOrderByOutTradeOrder(queryParams['outTradeNo'], data => {
          if (data['return_code'] === '000000') {
            this.dataObject = data['return_data'];
            console.log(this.dataObject);
          }
        });
      }
    });

  }

}
