<div class="message-box container">
  <div class="current-head">
    <h3>{{ 'message.label' | translate }}</h3>
    <div class="btn-box">
      <!-- <button mat-icon-button>
        <mat-icon>timer</mat-icon>
      </button>
      <button mat-icon-button>
        <mat-icon> add_comment</mat-icon>
      </button> -->
    </div>
  </div>
  <div class="list-search">
    <div class="searchbox">
      <form [formGroup]="fgSearch" class="w-100-p">
        <mat-form-field floatLabel="never">
          <input
            matInput
            #inputSearch
            type="text"
            maxlength="20"
            placeholder="{{ 'message.placeholderForSearch' | translate }}"
            value=""
            formControlName="searchInput"
            (keydown.enter)="onKeyDownEnter($event, inputSearch.value)"
          />
          <button
            mat-button
            matSuffix
            mat-icon-button
            aria-label="Clear"
            (click)="inputSearch.value = ''; onClickSearchCancel()"
          >
            <mat-icon>close</mat-icon>
          </button>
        </mat-form-field>
      </form>
    </div>
  </div>
  <div class="message-section" [style.display]="isSearch ? 'none' : 'block'">
    <mat-tab-group
      #tabs
      mat-stretch-tabs
      animationDuration="0ms"
      [selectedIndex]="0"
      (selectedIndexChange)="onSelectedIndexChange($event)"
      class="message-tab"
    >
      <mat-tab [label]="MessageType.Receive">
        <ng-template mat-tab-label>
          {{ 'message.messageTypeReceiving' | translate }}
        </ng-template>
        <perfect-scrollbar fxFlex="1 1 auto">
          <ucap-message-list-item
            *ngFor="let message of messageRetrieveList$ | async"
            [message]="message"
            (click)="onClickDetail(message)"
            class="message-item"
          ></ucap-message-list-item>
        </perfect-scrollbar>
      </mat-tab>
      <mat-tab [label]="MessageType.Send">
        <ng-template mat-tab-label>
          {{ 'message.messageTypeOutgoing' | translate }}
        </ng-template>
        <perfect-scrollbar fxFlex="1 1 auto">
          <ucap-message-list-item
            *ngFor="let message of messageSendList$ | async"
            [message]="message"
            (click)="onClickDetail(message)"
            class="message-item"
          ></ucap-message-list-item>
        </perfect-scrollbar>
      </mat-tab>
      <mat-tab [label]="MessageType.Reservation">
        <ng-template mat-tab-label>
          {{ 'message.messageTypeReservation' | translate }}
        </ng-template>
        <perfect-scrollbar fxFlex="1 1 auto">
          <ucap-message-list-item
            *ngFor="let message of messageReservationList$ | async"
            [message]="message"
            (click)="onClickDetail(message)"
            class="message-item"
          ></ucap-message-list-item>
        </perfect-scrollbar>
      </mat-tab>
    </mat-tab-group>
  </div>

  <div [style.display]="isSearch ? 'block' : 'none'">
    <div class="search-sub">
      <form [formGroup]="fgSearchType" class="w-100-p">
        <mat-form-field>
          <mat-select
            formControlName="searchMessageType"
            (selectionChange)="onChangeSelection($event)"
          >
            <mat-option [value]="MessageType.All">{{
              'message.messageTypeAll' | translate
            }}</mat-option>
            <mat-option [value]="MessageType.Receive">{{
              'message.messageTypeReceiving' | translate
            }}</mat-option>
            <mat-option [value]="MessageType.Send">{{
              'message.messageTypeOutgoing' | translate
            }}</mat-option>
            <mat-option [value]="MessageType.Reservation">{{
              'message.messageTypeReservation' | translate
            }}</mat-option>
          </mat-select>
        </mat-form-field>
        <mat-radio-group
          formControlName="searchMessageSearchType"
          aria-label="Select an searchType"
          (change)="onChangeSearchType($event)"
        >
          <mat-radio-button [value]="MessageSearchType.Name" [checked]="true">{{
            'message.searchTypeName' | translate
          }}</mat-radio-button>
          <mat-radio-button [value]="MessageSearchType.Title">{{
            'message.searchTypeTitle' | translate
          }}</mat-radio-button>
          <mat-radio-button [value]="MessageSearchType.Contents">{{
            'message.searchTypeContent' | translate
          }}</mat-radio-button>
        </mat-radio-group>
      </form>
    </div>
    <div>
      <ucap-message-list-item
        *ngFor="let message of messageSearchList$ | async"
        [message]="message"
        (click)="onClickDetail(message)"
        class="message-item"
      ></ucap-message-list-item>
    </div>
  </div>
</div>
