import {
  Component,
  OnInit,
  OnDestroy,
  Output,
  EventEmitter,
  ChangeDetectorRef,
  ChangeDetectionStrategy
} from '@angular/core';

@Component({
  selector: 'app-sections-chat-chat-search',
  templateUrl: './chat-search.section.component.html',
  styleUrls: ['./chat-search.section.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ChatSearchSectionComponent implements OnInit, OnDestroy {
  searchObj: any = {
    isSearch: false,
    searchWord: ''
  };

  @Output()
  chatSearch = new EventEmitter<{
    isSearch: false;
    searchWord: '';
  }>();

  @Output()
  closeChatSearch = new EventEmitter<void>();

  constructor(private changeDetectorRef: ChangeDetectorRef) {}

  ngOnInit(): void {}

  ngOnDestroy(): void {}

  onChatSearch(searchWord: string) {
    alert(searchWord);

    this.searchObj = {
      isSearch: true,
      searchWord
    };
    this.chatSearch.emit(this.searchObj);
  }

  onCancel(): void {
    this.closeChatSearch.emit();
  }
}
