<!-- GUIPropertiesViewAndSortCustomizer -->
<div>
  <h2 id="page-heading" data-cy="UnitTypeHeading">
    <span jhiTranslate="resilientApp.unitType.home.title">Unit Types</span>

    <div class="d-flex justify-content-end">
      <button class="btn btn-info me-2" (click)="load()" [disabled]="isLoading">
        <fa-icon icon="sync" [spin]="isLoading"></fa-icon>
        <span jhiTranslate="resilientApp.unitType.home.refreshListLabel">Refresh list</span>
      </button>

      <button
        *ngIf="hasCreatePermission(Resources.UNIT_TYPE)"
        id="jh-create-entity"
        data-cy="entityCreateButton"
        class="btn btn-primary jh-create-entity create-unit-type"
        [routerLink]="['/unit-type/new']"
      >
        <fa-icon icon="plus"></fa-icon>
        <span jhiTranslate="resilientApp.unitType.home.createLabel">Criar novo(a) Unit Type</span>
      </button>
    </div>
  </h2>

  <jhi-alert-error></jhi-alert-error>

  <jhi-alert></jhi-alert>

  @if (unitTypes?.length === 0) {
    <div class="alert alert-warning" id="no-result">
      <span jhiTranslate="resilientApp.unitType.home.notFound">Nenhum Unit Types encontrado</span>
    </div>
  }

  @if (unitTypes && unitTypes.length > 0) {
    <div class="table-responsive table-entities" id="entities">
      <table class="table table-striped" aria-describedby="page-heading">
        <thead>
          <tr jhiSort [sortState]="sortState" (sortChange)="navigateToWithComponentValues($event)">
            <th scope="col" jhiSortBy="name">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitType.name">Name</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="description">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitType.description">Description</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="valueType">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitType.valueType">Value Type</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>

            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
          @for (unitType of unitTypes; track trackId) {
            <tr data-cy="entityTable">
              <td>{{ unitType.name }}</td>
              <td>{{ unitType.description }}</td>
              <td [jhiTranslate]="'resilientApp.UnitValueType.' + (unitType.valueType ?? 'null')">
                {{ { null: '', DECIMAL: 'DECIMAL', BOOLEAN: 'BOOLEAN', STRING: 'STRING' }[unitType.valueType ?? 'null'] }}
              </td>

              <td class="text-end">
                <div class="btn-group">
                  <a *ngIf="hasReadPermission(Resources.UNIT_TYPE)" [routerLink]="['/unit-type', unitType.id, 'view']" class="btn btn-info btn-sm" data-cy="entityDetailsButton">
                    <fa-icon icon="eye"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.view">Visualizar</span>
                  </a>

                  <a *ngIf="hasUpdatePermission(Resources.UNIT_TYPE)" [routerLink]="['/unit-type', unitType.id, 'edit']" class="btn btn-primary btn-sm" data-cy="entityEditButton">
                    <fa-icon icon="pencil-alt"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Editar</span>
                  </a>

                  <button *ngIf="hasDeletePermission(Resources.UNIT_TYPE)" type="submit" (click)="delete(unitType)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
                    <fa-icon icon="times"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Eliminar</span>
                  </button>
                </div>
              </td>
            </tr>
          }
        </tbody>
      </table>
    </div>
  }
</div>
