{{define "organized_carpool_driver_history"}}
<div class="py-6">
  {{if .ViewState.stats}}
  <div class="py-5 text-center">
    <p class="text-lg">Covoiturages réalisés : {{ .ViewState.stats.bookings.confirmed }}</p>
    <p class="text-lg">Kilomètres parcourus : {{ .ViewState.stats.bookings.km }} km</p>
  </div>
  {{end}}

  {{if .ViewState.bookings}}
  <div class="py-5">
    <h4 class="text-lg font-medium text-gray-900 mb-4 text-center">Historique des covoiturages</h4>
    <table class="min-w-full divide-y divide-gray-300 border-gray-300 border-t-1">
      <thead class="bg-gray-50">
        <tr>
          <th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Date</th>
          <th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Passager</th>
          <th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Départ</th>
          <th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Arrivée</th>
          <th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Actions</th>
        </tr>
      </thead>
      <tbody class="divide-y divide-gray-200 bg-white">
        {{range .ViewState.bookings}}
        {{if eq .Status.String "CONFIRMED"}}
        <tr>
          <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
            {{if .PassengerPickupDate}}
              {{timeFormat .PassengerPickupDate.AsTime "02/01/2006 15:04"}}
            {{end}}
          </td>
          <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
            {{if .Passenger}}
              <a class="text-co-blue" href="/app/beneficiaries/{{.Passenger.Id}}">
                {{ (index $.ViewState.beneficiaries_map .Passenger.Id).Data.first_name }}
                {{ (index $.ViewState.beneficiaries_map .Passenger.Id).Data.last_name }}
              </a>
            {{end}}
          </td>
          <td class="py-4 pl-4 pr-3 text-sm sm:pl-6">
            {{.PassengerPickupAddress}}
          </td>
          <td class="py-4 pl-4 pr-3 text-sm sm:pl-6">
            {{.PassengerDropAddress}}
          </td>
          <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
            <a class="text-co-blue" href="/app/organized-carpool/bookings/{{.Id}}">Voir</a>
          </td>
        </tr>
        {{end}}
        {{end}}
      </tbody>
    </table>
  </div>
  {{else}}
  <div class="py-5">
    <p class="text-sm text-gray-500 text-center">Aucun covoiturage enregistré</p>
  </div>
  {{end}}
</div>
{{end}}
