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 _User from '../../../schemas/_User';
import * as Parse from 'parse';
import { CommonModule } from '@angular/common';
import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { CommonCompModule } from '../../../services/common.modules';
import { Profile } from '../../../schemas/Profile-list';
@Component({
  selector: 'app-page-user',
  templateUrl: './page-user.component.html',
  styleUrls: ['./page-user.component.scss'],
  imports: [
    CommonModule,
    RouterOutlet,
    NzSpaceModule,
    NzPageHeaderModule,
    CompTableListComponent,
    NzBreadCrumbModule,
    CommonCompModule,
  ],
  standalone: true,
})
export class PageUserComponent implements OnInit {
  @ViewChild(CompTableListComponent) list: CompTableListComponent | undefined;

  // _User = _User;
  ProfileList = Profile;
  user: Parse.User | undefined;
  className: string | undefined;
  queryParams: any | undefined;
  fieldsArray: Array<any> | undefined;

  constructor(
    private route: ActivatedRoute,
    private activeRoute: ActivatedRoute // private translate:TranslateService,
  ) {
    this.user = Parse.User.current();
    this.className = this.ProfileList.className;
    this.fieldsArray = this.ProfileList.fieldsArray;
    this.queryParams = {
      where: {
        // user:this.user?.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();
    });
  }

  createUser() {}
}
