<!--
  ~ Copyright (C) 2022 StApps
  ~  This program is free software: you can redistribute it and/or modify it
  ~  under the terms of the GNU General Public License as published by the Free
  ~  Software Foundation, version 3.
  ~
  ~  This program is distributed in the hope that it will be useful, but WITHOUT
  ~  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  ~  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licens for
  ~  more details.
  ~
  ~  You should have received a copy of the GNU General Public License along with
  ~  this program. If not, see <https://www.gnu.org/licenses/>.
  -->
<div>
  <ion-card-header>
    <ion-card-title>{{
      'schedule.toCalendar.reviewModal.TITLE' | translate
    }}</ion-card-title>
    <ion-button fill="clear" (click)="dismissAction()">
      <ion-label>{{ 'modal.DISMISS' | translate }}</ion-label>
    </ion-button>
  </ion-card-header>

  <ion-card-content>
    <ion-list lines="none">
      <ion-item-group *ngFor="let event of iCalEvents">
        <ion-item-divider>
          <ion-label>{{ event.title }}</ion-label>
          <ion-note slot="start" *ngIf="event.events.length > 1">
            <ion-icon name="warning"></ion-icon>
          </ion-note>
        </ion-item-divider>
        <ion-item *ngFor="let iCalEvent of event.events">
          <ion-label>
            <s *ngIf="iCalEvent.cancelled; else date"
              ><ng-container [ngTemplateOutlet]="date"></ng-container>
            </s>
            <ng-template #date>
              {{ moment(iCalEvent.start) | amDateFormat: 'll, HH:mm' }}
            </ng-template>
          </ion-label>
          <ion-note *ngIf="iCalEvent.rrule">
            {{ iCalEvent.rrule.interval }}
            {{ iCalEvent.rrule.freq | sentencecase }}
          </ion-note>
          <ion-icon *ngIf="iCalEvent.rrule" name="repeat"></ion-icon>
        </ion-item>
      </ion-item-group>
    </ion-list>
  </ion-card-content>

  <div class="horizontal-flex">
    <ion-item lines="none">
      <ion-label>{{
        'schedule.toCalendar.reviewModal.INCLUDE_CANCELLED' | translate
      }}</ion-label>
      <ion-checkbox [(ngModel)]="includeCancelled" slot="end"></ion-checkbox>
    </ion-item>
  </div>
  <div class="horizontal-flex">
    <ion-button fill="clear" (click)="export()">
      {{ 'share' | translate }}
      <ion-icon slot="end" name="share"></ion-icon>
    </ion-button>
    <ion-button
      fill="outline"
      (click)="download()"
      *ngIf="isWeb; else exportButton"
    >
      {{ 'schedule.toCalendar.reviewModal.DOWNLOAD' | translate }}
      <ion-icon slot="end" name="download"></ion-icon>
    </ion-button>
    <ng-template #exportButton>
      <ion-button fill="outline" (click)="toCalendar()">
        {{ 'schedule.toCalendar.reviewModal.EXPORT' | translate }}
        <ion-icon slot="end" name="calendar"></ion-icon>
      </ion-button>
    </ng-template>
  </div>
</div>
