import { Component, Input, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { CommonCompModule } from '../../../services/common.modules';
import { NzTabsModule } from 'ng-zorro-antd/tabs';
import { ActivatedRoute, Router } from '@angular/router';
import Parse from 'parse';
import { CompTableListComponent } from '../../../app/comp-table/comp-table-list/comp-table-list.component';
import { ProcessCreateComponent } from './process-create/process-create.component';
import { TextbookComponent } from '../../../app/textbook/textbook.component';
@Component({
  selector: 'app-page-process',
  templateUrl: './page-process.component.html',
  styleUrls: ['./page-process.component.scss'],
  imports: [
    CommonModule,
    NzSpaceModule,
    CommonCompModule,
    NzTabsModule,
    ProcessCreateComponent,
    CompTableListComponent,
    TextbookComponent
  ],
  standalone: true,
})
export class PageProcessComponent  implements OnInit {
  active: number = 0;
  eduProcess: Parse.Object | undefined;

  user: Parse.User | undefined;
  //待审核
  beforeFilterObj: any = {
    showMore: true, //显示更多字段
    isCheck: true,
    noStared:true,
    status: ['200','201','400'],
    btns: {
      reject: true, //退回教材
      star: true, //移除推荐
      export:true
    },
  };
  //已加入推荐
  afterFilterObj: any = {
    showMore: true, //显示更多字段
    isCheck: true,
    status: ['200','201','400'],
    btns: {
      verify:true,
      remove: true, //移除推荐
      export:true
    },
  };

  constructor(
    private activeRoute:ActivatedRoute,
    private router: Router,
  ) {
    this.user = Parse.User.current();
  }

  ngOnInit() {
    this.activeRoute.paramMap.subscribe(async (params) => {
      let id = params.get('id');
      if (id) {
        let query = new Parse.Query('EduProcess');
        query.include('branch', 'department');
        query.equalTo('objectId', id);
        this.eduProcess = await query.first();
      }
    })
  }

  onCreateProcess(){
    this.router.navigate(['/nav-admin/manage/process/create',{cid:this.eduProcess?.id}])
  }
}
