import { Component, OnInit, ViewChild, Input } from '@angular/core';
import { ActivatedRoute, RouterOutlet, Router } from '@angular/router';
import { CompTableListComponent } from '../../../../app/comp-table/comp-table-list/comp-table-list.component';
import { EduTextbook } from '../../../../schemas/EduTextbook';
// import { TranslateService } from '@ngx-translate/core';
import * as Parse from 'parse';
import { CommonModule } from '@angular/common';
@Component({
  selector: 'app-page-textbook',
  templateUrl: './page-textbook.component.html',
  styleUrls: ['./page-textbook.component.scss'],
  imports: [CommonModule, RouterOutlet, CompTableListComponent],
  standalone: true,
})
export class PageTextbookComponent implements OnInit {
  @ViewChild(CompTableListComponent) list: CompTableListComponent | undefined;
  @Input('discard') discard: boolean = false;
  @Input('render') render: boolean = false;

  EduTextbook = EduTextbook;
  user: Parse.User | undefined;
  className: string | undefined;
  queryParams: any | undefined;
  fieldsArray: Array<any> | undefined;

  constructor(
    private router: Router,
    private activeRoute: ActivatedRoute
  ) // private translate:TranslateService,
  {
    this.user = Parse.User.current();
    this.className = this.EduTextbook.className;
    this.fieldsArray = this.EduTextbook.fieldsArray;
    this.queryParams = {
      where: {
        isDeleted: { $ne: true },
        discard: this.discard ? { $eq: true } : { $ne: true },
        render: this.render ? { $eq: true } : { $ne: true },
      },
    };
  }

  ngOnInit(): void {
    console.log(this.discard);
    console.log(this.render);
    this.queryParams.where = {
      isDeleted: { $ne: true },
      discard: this.discard ? { $eq: true } : { $ne: true },
      render: this.render ? { $eq: true } : { $ne: true },
    };
  }
}
