<!--
~ 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 License 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/>.
-->

<ng-container>
  <ion-card>
    <ion-card-header> {{ 'hebisSearch.daia.availability' | translate }} </ion-card-header>
    <ion-card-content>
      @if (holdingsByDepartments) {
        @for (holdingsByDepartment of holdingsByDepartments | keyvalue; track holdingsByDepartment) {
          <ion-label>
            @if (holdingsByDepartment.value[0].department.href) {
              <stapps-external-link
                [text]="holdingsByDepartment.value[0].department.content"
                [link]="holdingsByDepartment.value[0].department.href"
              >
              </stapps-external-link>
            }
          </ion-label>
          @for (holding of holdingsByDepartment.value; track holding) {
            <stapps-daia-holding [holding]="holding"></stapps-daia-holding>
          }
        }
      }
      @if (!holdings) {
        <ion-label> {{ 'hebisSearch.daia.unavailableAvailability' | translate }} </ion-label>
      }
      @if (holdings?.length === 0) {
        <ion-label> {{ 'hebisSearch.daia.unknownAvailability' | translate }} </ion-label>
      }
    </ion-card-content>
  </ion-card>
</ng-container>
