<main class="main-container animated fadeIn prevent-select">

  <app-btn-navigate navigate="/sam/GPRS/GEPE/GEPE" nameButton="Lista de empleados"/>

  <mat-card class="override-card override-elevation-z8">
    <section class="override-section">
      <nav class="override-nav">
        <mat-card-title class="mat-card-title centre">Intervenciones del empleado {{ employeeName }}</mat-card-title>
        <div class="override-actions">
          <app-search-card
            [dataSource]="dataSource"
            [disabled]="isLoading"
            (dataValue)="dataSource = $event"
          />
          <div class="override-buttons">
            <button mat-mini-fab (click)="getData()" [disabled]="isLoading" matTooltip="Actualizar datos" class="orange_primary_background white_font override_no_shadow mr-10">
              <mat-icon>refresh</mat-icon>
            </button>
          </div>
        </div>
      </nav>

      <app-loading-card [isLoading]="isLoading" txtLoading="Cargando información" />

      @if (!isLoading && hasError) {
        <div class="is-loading animated fadeIn fast">
          <mat-icon  class="red_primary_font">error</mat-icon>
          <h3>{{ errorStr }}</h3>
        </div>
      }

      <!-- CONTENEDOR DE LA TABLA -->
      <div class="override-table" [ngClass]="{ hidden: isLoading || hasError }">
        <!-- TABLA  -->
        <table mat-table [dataSource]="dataSource!" matSort #MatSort2="matSort" class="animated fadeIn" 
        [style.display]="!isLoading && !hasError ? 'revert' : 'none'">
          <ng-container matColumnDef="IDORDEN">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Orden</th>
            <td mat-cell *matCellDef="let element">{{ element.IDORDEN }}</td>
          </ng-container>

          <ng-container matColumnDef="TIPOORDEN">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Tipo de orden</th>
            <td mat-cell *matCellDef="let element">{{ element.TIPOORDEN }}</td>
          </ng-container>

          <ng-container matColumnDef="DESCRIPCION">
            <th mat-header-cell *matHeaderCellDef mat-sort-header>Descripción</th>
            <td mat-cell *matCellDef="let element">{{ element.DESCRIPCION }}</td>
          </ng-container>

          <ng-container matColumnDef="ACCIONES">
            <th mat-header-cell *matHeaderCellDef>Acciones</th>
            <td mat-cell *matCellDef="let element">
              <button mat-mini-fab color="accent" class="override_no_shadow mr-4 pink_primary_background white_font" (click)="openDetails(element)" matTooltip="Detalles Orden">
                <mat-icon>description</mat-icon>
              </button>
            </td>
          </ng-container>

          <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
          <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
          <tr class="mat-row" *matNoDataRow>
            <td class="mat-cell p-20 align-center" colspan="12">
              <object data="assets/img/empty_data.svg" width="300"></object>
              <h2>Sin datos</h2>
            </td>
          </tr>
        </table>
      </div>
    </section>
    <mat-paginator [pageSizeOptions]="[10, 50, 100]" #MatPaginator2="matPaginator" class="override-paginator"></mat-paginator>
  </mat-card>
</main>