import { Component, OnInit, ChangeDetectionStrategy, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { createQueryStringFromObject } from 'src/app/shared/util/func';

@Component({
  selector: 'set-role-search',
  templateUrl: './set-role-search.component.html',
  styleUrls: ['./set-role-search.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SetRoleSearchComponent implements OnInit {
  @Output() search = new EventEmitter()
  query = {
    app_role_name_en: null,
    app_role_code: null
  }
  constructor(
    private router: Router
  ) { }

  ngOnInit(): void {
  }

  onSearch(){
    const query = createQueryStringFromObject(this.query)
    this.search.emit(query)
  }

  clear(){
    this.query = {
      app_role_name_en: null,
      app_role_code: null
    }
    const query = createQueryStringFromObject(this.query)
    this.search.emit(query)
  }

  add(){
    this.router.navigate(['set-role/add'])
  }

}
