import { Component, OnInit } from '@angular/core';
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { DatePipe } from "@angular/common";
import { Router } from '@angular/router';

@Component({
  selector: 'app-portal-create-category',
  templateUrl: './portal-create-category.component.html',
  styleUrls: ['./portal-create-category.component.scss']
})
export class PortalCreateCategoryComponent implements OnInit {

  constructor(private fb: FormBuilder, private modalService: NgbModal, private datePipe: DatePipe,private routes: Router,) {}
  page = 1;
  pageSize = 10;

  testdata: {
    id:string;
    img: String;
    name: String;
    details: String;
    document: String;
  }[] = [];

  ngOnInit() {
    this.testdata = [
      {
        id:'1',
        img: "assets/images/icon/excel.png",
        name: "Excel",
        details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        document: "จำนวนเอกสาร 8 ฉบับ"
      },
      {
        id:'2',
        img: "assets/images/icon/document.png",
        name: "Document",
        details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        document: "จำนวนเอกสาร 3 ฉบับ"
      },
      {
        id:'3',
        img: "assets/images/icon/course.png",
        name: "Course",
        details: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        document: "จำนวนเอกสาร 5 ฉบับ"
      },
    ];
  }

  openView(id:string){
    if(id =='1'){
      this.routes.navigate(['apps/list-excel']);
    }else if(id =='2'){
      this.routes.navigate(['apps/list-doc']);
    }else if(id =='3'){
      this.routes.navigate(['apps/list-course']);
    }
  }
  openModal(targetModal: NgbModal) {
    this.modalService.open(targetModal, {
      centered: true,
      backdrop: "static",
    });
  }

  closeBtnClick() {
    this.modalService.dismissAll();
    this.ngOnInit();
  }

}
