{{define "content"}}
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8">
    <h1 class="text-2xl font-semibold text-gray-900">
      Transport solidaire
    </h1>
    {{if and .ViewState.booking.Data.motivation (or (or (eq .ViewState.booking.Data.motivation "Santé") (eq .ViewState.booking.Data.motivation "Insertion")) (eq .ViewState.booking.Data.motivation "Administratif"))}}<div class="mt-4"><span class="text-sm p-2 bg-co-green text-white rounded-2xl">Trajet garanti : {{.ViewState.booking.Data.motivation}}</span></div>{{end}}
      {{ if eq .ViewState.booking.Status "WAITING_CONFIRMATION"}}
      <div class="mt-4"><span class="p-2 text-sm bg-gray-300 rounded-2xl px-4">Attente confirmation</span></div>
      {{ else if eq .ViewState.booking.Status "VALIDATED"}}
      <div class="mt-4"><span class="p-1 text-sm bg-co-green rounded-2xl px-4">Validé</span></div>
      {{ else if eq .ViewState.booking.Status "CANCELLED"}}
  <div class="mt-4"><span class="p-1 text-sm bg-co-red text-white rounded-2xl px-4">Annulé : {{.ViewState.booking.Data.reason}}</span></div>
      {{ end }}
<div
  class="mt-6 flex flex-col-reverse justify-stretch space-y-4 space-y-reverse sm:flex-row-reverse sm:justify-end sm:space-x-reverse sm:space-y-0 sm:space-x-3 md:mt-0 md:flex-row md:space-x-3">


    {{$dialog := "modif"}}
<div  x-data="{ {{ $dialog }}: false}">
  <button @click="{{ $dialog }} = !{{ $dialog }}" type="button" class="bg-white border-gray-300 border px-4 py-2 text-gray-700 items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
    Modifier
  </button>
  <div x-show="{{$dialog}}" class="relative z-10" aria-labelledby="modal-title" role="dialog" aria-modal="true">
     <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
        
     <div class="fixed inset-0 z-10 overflow-y-auto">
       <div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">

         <div class="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full max-w-lg sm:p-6">
           <form method="POST">
             <div class="mx-auto flex h-12 w-12 items-center justify-center rounded-co bg-co-blue text-white">
                    {{$.IconSet.Icon "hero:outline/information-circle" "h-6 w-6"}}
             </div>
             <div class="mt-3 text-center sm:mt-5">
               <h3 class="text-lg font-medium leading-6 text-gray-900" id="modal-title">Modifier</h3>
               <div class="mt-2">
                 <p class="text-sm text-gray-500"></p>
               </div>
               <div>
                 <label for="driver_distance" class="block text-sm font-medium text-gray-700">Kilomètres conducteur</label>
                 <div class="mt-1">
                    <input type="text" name="driver_distance" id="driver_distance" class="block w-full rounded-2xl border-gray-300 shadow-sm focus:border-co-blue focus:ring-co-blue sm:text-sm" value="{{.ViewState.booking.Journey.DriverDistance}}" />
                 </div>
               </div>
             </div>
             <div class="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2">
               <button @click="{{$dialog}} = !{{$dialog}}" type="button" class="mt-3 inline-flex w-full justify-center rounded-l-2xl border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-1 sm:mt-0 sm:text-sm">Annuler</button>
               <button type="submit" class="inline-flex w-full justify-center rounded-r-2xl border border-transparent bg-co-blue px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-2 sm:text-sm">Valider</button>
             </div>
           </form>
         </div>
       </div>
     </div>
</div>
</div>

  <!-- <button type="button"
       class="inline-flex items-center justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-2xl text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">Supprimer</button> -->
  {{if eq .ViewState.booking.Status "CANCELLED" }}
    <a href="/app/journeys/?departure={{json .ViewState.booking.Journey.PassengerPickup}}&destination={{ json .ViewState.booking.Journey.PassengerDrop }}&departuredate={{ .ViewState.booking.Journey.PassengerPickupDate.Format "2006-01-02"}}&departuretime={{ .ViewState.booking.Journey.PassengerPickupDate.Format "15:04"}}" class="inline-flex"><button type="button"
     class="w-full px-4 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm bg-white text-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">Solliciter un autre conducteur</button></a>
  {{end}}
  {{if eq .ViewState.booking.Status "WAITING_CONFIRMATION" }}
  <a href="/app/solidarity-transport/bookings/{{.ViewState.booking.Id}}/confirm" class="inline-flex"><button type="button"
     class="w-full px-4 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm text-white bg-co-blue hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">Confirmer</button></a>
  {{end}}
  {{if ne .ViewState.booking.Status "WAITING_CONFIRMATION" }}
  <a href="/app/solidarity-transport/bookings/{{.ViewState.booking.Id}}/waitconfirmation" class="inline-flex"><button type="button"
     class="w-full px-4 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm text-white bg-co-blue hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">Remettre en attente</button></a>
  {{end}}
  {{if ne .ViewState.booking.Status "CANCELLED" }}
  <!--<a href="/app/solidarity-transport/bookings/{{.ViewState.booking.Id}}/cancel" class="inline-flex"><button type="button"
     class="w-full px-4 py-2 border border-transparent text-sm font-medium rounded-2xl shadow-sm text-white bg-co-red hover:bg-co-red focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-co-blue">Annuler</button></a>-->
{{$dialog := "cancel"}}
<div  x-data="{ {{ $dialog }}: false}">
  <button @click="{{ $dialog }} = !{{ $dialog }}" type="button" class="bg-co-red border-gray-300 border px-4 py-2 text-white items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
    Annuler 
  </button>
  <div x-show="{{$dialog}}" class="relative z-10" aria-labelledby="modal-title" role="dialog" aria-modal="true">
     <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
        
     <div class="fixed inset-0 z-10 overflow-y-auto">
       <div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">

         <div class="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full max-w-lg sm:p-6">
           <form method="POST" action="/app/solidarity-transport/bookings/{{.ViewState.booking.Id}}/cancel">
             <div class="mx-auto flex h-12 w-12 items-center justify-center rounded-co bg-co-blue text-white">
                    {{$.IconSet.Icon "hero:outline/information-circle" "h-6 w-6"}}
             </div>
             <div class="mt-3 text-center sm:mt-5">
               <h3 class="text-lg font-medium leading-6 text-gray-900" id="modal-title">Annuler</h3>
               <div class="mt-2">
                 <p class="text-sm text-gray-500"></p>
               </div>
               <div>
                 <label for="reason" class="block text-sm font-medium text-gray-700">Raison de l'annulation</label>
                 <div class="mt-1">
                    <select name="reason" id="reason" class="block w-full rounded-2xl border-gray-300 shadow-sm focus:border-co-blue focus:ring-co-blue sm:text-sm">
                      <option value="Trajet annulé par le passager">Trajet annulé par le passager</option>
                      <option value="Trajet non réalisé">Trajet non réalisé</option>
                      <option value="Refusé par le bénévole">Refusé par le bénévole</option>
                      <option value="Autre" selected="selected">Autre</option>
                    </select>
                 </div>
               </div>
             </div>
             <div class="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2">
               <button @click="{{$dialog}} = !{{$dialog}}" type="button" class="mt-3 inline-flex w-full justify-center rounded-l-2xl border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-1 sm:mt-0 sm:text-sm">Annuler</button>
               <button type="submit" class="inline-flex w-full justify-center rounded-r-2xl border border-transparent bg-co-blue px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-2 sm:text-sm">Valider</button>
             </div>
           </form>
         </div>
       </div>
     </div>
  </div>
</div>
  {{end}}
</div>
</div>
<div class="max-w-7xl mx-auto py-8 px-4 sm:px-6 md:px-8">
  {{template "journey_preview" (dict "driver_journey" .ViewState.booking.Journey "driver" .ViewState.driver "passenger" .ViewState.passenger "beneficiaries" .ViewState.beneficiaries)}}
</div>

{{ end }}
