import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { RightDrawer } from '@app/types';
import { TranslateService } from '@ngx-translate/core';

@Component({
  selector: 'app-layout-messenger-right-drawer',
  templateUrl: './right-drawer.component.html',
  styleUrls: ['./right-drawer.component.scss']
})
export class RightDrawerComponent implements OnInit {
  @Input()
  selectedRightDrawer: RightDrawer;

  @Output()
  openProfile = new EventEmitter<{
    userSeq: number;
  }>();
  @Output()
  closeRightDrawer = new EventEmitter();

  RightDrawer = RightDrawer;

  constructor(private translateService: TranslateService) {}

  ngOnInit() {}

  onClickOpenProfile(userSeq: number) {
    this.openProfile.emit({ userSeq });
  }

  onClickClose() {
    this.closeRightDrawer.emit();
  }

  getTitle(): string {
    let rtnStr = '';

    switch (this.selectedRightDrawer) {
      case RightDrawer.AlbumBox:
        rtnStr = this.translateService.instant('chat.albumBox.label');
        break;
      case RightDrawer.FileBox:
        rtnStr = this.translateService.instant('chat.fileBox.label');
        break;
      case RightDrawer.RoomUser:
        rtnStr = this.translateService.instant('chat.listOfRoomMember');
        break;
      case RightDrawer.Notice:
        rtnStr = this.translateService.instant('notice.label');
        break;
    }

    return rtnStr;
  }
}
