<app-nav-commercant></app-nav-commercant>
<div class="container">
  <h4 class="mb-5 mt-1 font-bold wow fadeInDown text-center" style="padding-top: 5%;">Historique des cartes envoyées ({{(carteParData | async)?.length}})</h4>
  <!--<button class="btn btn-primary btn-rounded waves-light" (click)="goToOpCom()">Retour aux Opérations commerciales</button>-->
  <div class="topButtons col-md-12" style="padding-top: 2%;">
    <div *ngIf="(carteParData | async)?.length != 0" class="btnFiltre">
      <div class="dropdown" dropdown>
        <button dropdownToggle type="button" class="btn btn-info btn-rounded dropdown-toggle waves-light" mdbRippleRadius>
          Filtres
        </button>

        <div class="dropdown-menu">
          <a class="dropdown-item" id="crtActive" (click)="activeCarte('Active')">Actives</a>
          <a class="dropdown-item" id="crtToutes" (click)="activeCarte('Toutes')">Toutes</a>
          <a class="dropdown-item" id="crtInactive" (click)="activeCarte('Inactive')">Inactives</a>
        </div>
      </div>
    </div>
  </div>
  <div class="list-group wow fadeInUpBig">
    <div *ngFor="let crt of (carteParData | async); let i = index;">
      <div *ngIf="(crt.status == statutAffiche) || (statutAffiche == 'Toutes')">
        <div class="card mainCard">
          <div class="row no-margin" id="testt">
            <img class="col-md-6 card-image subCard1" id="image1" alt="Responsive image" src={{crt.carteTemplate.downloadURL}}>
            <!--<div class="col-md-6 mb-1 subCard1" id="subCard1">
              <img src="{{crt.carteTemplate.downloadURL}}" id="image1" class="mx-auto d-block flex-center card-img-overlay" alt="Responsive image">
            </div>-->
            <div class="col-md-6 card subCard2">
              <div class="card-block row no-margin">
                <div class="col-md-12" id="subCard2Part1">
                  <div id="opTitle">
                    <label>Operation Commerciale: {{crt.operationCommercialCarte.name}}</label>
                    <label>Parrain: {{crt.parrainCarte.familyname}} {{crt.parrainCarte.firstname}}</label>
                    <label>ID: {{crt.uid}}</label>
                  </div>
                  <div id="opAvantages">
                    <label>Avantages cumulés: {{crt.avantageCumule=== ''? '0' : crt.avantageCumule}} €</label>
                    <label>Avantages récupérés: {{crt.avantageRecuperer=== ''? '0' : crt.avantageRecuperer}} €</label>
                  </div>
                </div>
                <div class="btn-block d-flex flex-lg-row flex-md-column flex-sm-row" id="subCard2Part2">
                  <button class="btn btn-outline-primary btn-rounded" tooltip="Historique des scans et retours effectués sur cette carte de parrainage" placement="top" (click)="hideme[i] = !hideme[i]"><i class="fa fa-info-circle mr-1"></i>{{show ? 'Cacher Détails' : 'Détails'}}</button>
                  <!--<button class="btn btn-outline-info btn-rounded" (click)="sectionToImage(op.carteTemplate.downloadURL, commercant.image.downloadURL)">screenShot</button>-->
                </div>
              </div>
            </div>
          </div>
          <!-- Card footer -->
          <div class="card-data" id="footerCard">
            <ul>
              <li class="float-right"><i class="fa fa-info-circle" aria-hidden="true"></i>Statut:
                <label class="font-bold" *ngIf="crt.status == 'Active'" style="color:#00C851; margin-bottom: 0">{{crt.status}}</label>
                <label class="font-bold" *ngIf="crt.status == 'Inactive'" style="color:#ffbb33; margin-bottom: 0">{{crt.status}}</label>
                <label class="font-bold" *ngIf="crt.status == 'Bloqué'" style="color:#ff4444; margin-bottom: 0">{{crt.status}}</label>
              </li>
              <li class="float-left"><i class="fa fa-clock-o"></i>Valable du {{crt.dateDebut | date:'dd/MM/yyyy'}} au {{crt.dateFin | date:'dd/MM/yyyy'}}</li>
            </ul>
          </div>
          <!-- Card footer -->
        </div>
        <div class="card" [hidden]="!hideme[i]" style="height:20rem; overflow-y: auto;">
          <div class="card-body">
            <ul class="list-group wow fadeInDown">
              <p class="font-weight-normal" style="padding-top: 2%" *ngIf="crt.historique === undefined">Aucune opération n'a été effectuée sur cette carte !</p>

              <li class="list-group-item justify-content-between align-items-center" *ngFor="let hst of crt.historique">
                <p class="font-weight-normal" style="padding-top: 2%">{{hst}}</p>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
