<ion-header class="ion-no-border">
  <app-header></app-header>
</ion-header>

<ion-header class="ion-no-border header-2">
  <div class="header-content">
    <div class="header-icon-left">
      <button class="btn-no-color cursor-pointer" (click)="goBack()">
        <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-arrow-arrow-left.svg"></ion-icon>
        <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
      </button>
    </div>
    <div class="header-title">
      <label>Eventos para Aprovação</label>
    </div>
  <ion-toolbar>
    <ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
      <ion-segment-button value="MDGPR">
        Meu calendário
      </ion-segment-button>
      <ion-segment-button value="PR">
        Presidente da República
      </ion-segment-button>
    </ion-segment>
  </ion-toolbar>

</div>
</ion-header>

<ion-content>
  <ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
    <ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar>
     <ion-refresher-content>
    </ion-refresher-content>
  </ion-refresher>
  <div class="main-content d-flex height-100" >

    <div class="content height-100 d-flex flex-column">
    <div [ngSwitch]="segment">
      <ion-list class="width-100 height-100" *ngSwitchCase="'MDGPR'">
        <div *ngIf="eventsMDGPRList" class="overflow-y-auto height-100">
            <ion-item-sliding>
              <ion-item class="Rectangle cursor-pointer" lines="none"
                *ngFor="let event of eventsMDGPRList" (click)="goToEventToApproveDetail(event.serialNumber)">

                <div class="content-mdgpr-{{event.workflowInstanceDataFields.Agenda}} width-100">
                  <div class="approve-event-time">
                    <p>{{event.workflowInstanceDataFields.StartDate | date: 'HH:mm'}}</p>
                    <p>{{event.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
                  </div>
                  <div class="approve-event-detail">
                    <p *ngIf="event.workflowInstanceDataFields.StartDate != event.workflowInstanceDataFields.EndDate">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ event.workflowInstanceDataFields.EndDate | date: 'dd/M/yy'}}  |  {{event.workflowInstanceDataFields.Location}}</p>
                    <p *ngIf="event.workflowInstanceDataFields.StartDate == event.workflowInstanceDataFields.EndDate">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }}  |  {{event.workflowInstanceDataFields.Location}}</p>
                    <h3>{{event.workflowInstanceDataFields.Subject}}</h3>
                  </div>
                </div>
              </ion-item>
            </ion-item-sliding>
        </div>
      </ion-list>
      <ion-label></ion-label>

      <ion-list *ngSwitchCase="'PR'">
        <div *ngIf="eventsPRList" class="overflow-y-auto height-100">
          <ion-item-sliding>
            <ion-item class="Rectangle cursor-pointer" lines="none"
                *ngFor="let event of eventsPRList" (click)="goToEventToApproveDetail(event.serialNumber)">
                <div class="content-pr-{{event.workflowInstanceDataFields.Agenda}} width-100">
                  <div class="approve-event-time">
                    <p>{{event.workflowInstanceDataFields.StartDate | date: 'HH:mm'}}</p>
                    <p>{{event.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
                  </div>
                  <div class="approve-event-detail">
                    <p *ngIf="event.workflowInstanceDataFields.StartDate != event.workflowInstanceDataFields.EndDate">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ event.workflowInstanceDataFields.EndDate | date: 'dd/M/yy'}}  |  {{event.workflowInstanceDataFields.Location}}</p>
                    <p *ngIf="event.workflowInstanceDataFields.StartDate == event.workflowInstanceDataFields.EndDate">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }}  |  {{event.workflowInstanceDataFields.Location}}</p>
                    <h3>{{event.workflowInstanceDataFields.Subject}}</h3>
                  </div>
                </div>
              </ion-item>
          </ion-item-sliding>
        </div>
      </ion-list>
    </div>

    <div class="height-100" [ngSwitch]="segment">
      <div *ngSwitchCase="'MDGPR'" class="d-flex height-100 align-center justify-content-center" >
        <div
          *ngIf="!skeletonLoader && eventsMDGPRList.length == 0"
          class="empty-list d-flex height-100 align-center justify-content-center"
        >
          <span>Lista vazia</span>
        </div>
      </div>

      <div *ngSwitchCase="'PR'" class="d-flex height-100 align-center justify-content-center">
        <div
          *ngIf="!skeletonLoader && eventsPRList.length == 0"
          class="empty-list d-flex height-100 align-center justify-content-center"
        >
          <span>Lista vazia</span>
        </div>
      </div>
    </div>

  </div>
  </div>
</ion-content>
