import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, RouterOutlet } from '@angular/router';
import { CompTableListComponent } from '../../../app/comp-table/comp-table-list/comp-table-list.component';
import EduCollection from '../../../schemas/EduCollection';
// import { TranslateService } from '@ngx-translate/core';
import * as Parse from "parse";
import { CommonModule } from '@angular/common';
import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { NzDropDownModule } from 'ng-zorro-antd/dropdown';


@Component({
  selector: 'app-page-collection',
  templateUrl: './page-collection.component.html',
  styleUrls: ['./page-collection.component.scss'],
  imports: [
    CommonModule,RouterOutlet,CompTableListComponent,
    NzPageHeaderModule,NzBreadCrumbModule,NzTagModule,NzButtonModule,NzIconModule,NzSpaceModule,
    NzDropDownModule,
  ],
  standalone: true,
})
export class PageCollectionComponent  implements OnInit {
  @ViewChild(CompTableListComponent) list:CompTableListComponent|undefined

  EduCollection = EduCollection
  className:string|undefined
  queryParams:any|undefined
  fieldsArray:Array<any>|undefined

  constructor(
    private route: ActivatedRoute,
    private activeRoute: ActivatedRoute,
    // private translate:TranslateService,
  ) {
    this.className = this.EduCollection.className
    this.fieldsArray = this.EduCollection.fieldsArray
    this.queryParams = {where:{
      // Collection:this.Collection?.toPointer(),
      isDeleted:{$ne:true},
    }}
  }

  ngOnInit(): void {
    this.activeRoute.paramMap.subscribe(async (params) => {
      let isDeleted = params.get('isDeleted')
      if(isDeleted){
        this.queryParams.where['isDeleted'] = {$eq:true}
      }else{
        this.queryParams.where['isDeleted'] = {$ne:true}
      }
      this.list?.ngOnInit()
    });
  }

}
