<ion-header>
<ion-toolbar color="primary">
  <ion-buttons slot="start">
    <ion-menu-button></ion-menu-button>
  </ion-buttons>
  <ion-title>{{'contracts.header' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<h2 class="ion-text-capitalize" style="padding-bottom: 0.5em">{{'contracts.header_3' | translate}}</h2>
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
  <ion-refresher-content></ion-refresher-content>
</ion-refresher>

  <ng-container *ngIf="loading">
    <ion-card *ngFor="let _ of [1,2]">
      <ion-item style="--border-color: #fff">
        <ion-label>
          <ion-skeleton-text [animated]="true" style="width: 55%; height: 18px; margin-bottom: 8px"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 85%"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 70%"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 50%"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 40%"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 35%"></ion-skeleton-text>
          <ion-skeleton-text [animated]="true" style="width: 65%; height: 16px; margin-top: 6px"></ion-skeleton-text>
        </ion-label>
      </ion-item>
    </ion-card>
  </ng-container>

<ng-container *ngIf="!loading">
  <ng-container *ngFor="let fcontract of fcontracts; let i = index">
    <ion-card>
      <ion-item style="--border-color: #fff">
        <ion-label>
          <h2 class="ion-text-capitalize" *ngIf="lang===true">{{ fcontract.category }}</h2>
          <h2 class="ion-text-capitalize" *ngIf="lang===false">{{ fcontract.en_category }}</h2>
          <h2 class="ion-text-capitalize" *ngIf="fcontract.parent">{{'contracts.parent' | translate}}</h2>
          <p class="ion-text-wrap">{{ fcontract.address }}</p>
          <p class="ion-text-wrap ion-text-capitalize">{{ fcontracts_dates[i] }}</p>
          <p class="ion-text-wrap ion-text-capitalize">{{'contracts.supplier' | translate}}: {{ fcontract.supplier }}</p>
          <p class="ion-text-wrap ion-text-capitalize">{{'contracts.amount' | translate}}: ${{ fcontract.amount }}</p>
          <p>{{'contracts.status' | translate}}: {{ fcontract.status }}</p>
        </ion-label>
        </ion-item>
        <ion-row *ngIf="!fcontract.parent && fcontract.date_difference < 7 && fcontract.status !== 'cancelado'">
          <ion-col size="4">
            <ion-button *ngIf="!fcontract.scored && fcontract.status !== 'reportado'" expand="full" class="ion-text-wrap" color="secondary" (click)="reviewContract(fcontract.id)">{{'contracts.rate' | translate}}</ion-button>
          </ion-col>
          <ion-col size="4">
            <ion-button *ngIf="!fcontract.scored && fcontract.status !== 'reportado'" expand="full" class="ion-text-wrap" color="danger" (click)="reportContract(fcontract.id)">{{'contracts.report' | translate}}</ion-button>
          </ion-col>
        </ion-row>
    </ion-card>
  </ng-container>
</ng-container>
</ion-content>
