{{ define "content" }}
{{$defaultTab := "solidarityService"}}
<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>

    <div class="bg-white shadow sm:rounded-lg sm:overflow-hidden my-4" x-data="{
	    tab: '{{or .ViewState.tab $defaultTab}}',
        to(event) {
            this.tab = event.target.value
        }
    }">
        <div class="divide-y divide-gray-200">
            <div>
                <div class="hidden sm:block">
                    <div class="border-b border-gray-200 pl-4 flex justify-between items-center">
                        <nav class="-mb-px flex space-x-8" aria-label="Tabs"> 
                            <a href="#" @click="tab = 'solidarityService'"
                                class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm"
                                :class="tab == 'solidarityService' ? 'border-co-blue text-co-blue' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'">
                                Trajets </a>
                            
                            <a href="#" @click="tab = 'drivers'"
                                class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm"
                                :class="tab == 'drivers' ? 'border-co-blue text-co-blue' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'">
                                Conducteurs </a>
                            
                            <!--<a href="#" @click="tab = 'beneficiaries'"
                                class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm"
                                :class="tab == 'beneficiaries' ? 'border-co-blue text-co-blue' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'">
                                Bénéficiaires </a>-->

                            <a href="#" @click="tab = 'solidarityHistory'"
                                class="whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm"
                                :class="tab == 'solidarityHistory' ? 'border-co-blue text-co-blue' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'">
                                Trajets passés </a>
                        </nav>

                        <div class="pr-4" x-show="tab == 'solidarityHistory'">
                            {{$exportURL := "/exports/solidarity-transport/bookings.xlsx"}}
                            {{$hasParams := false}}
                            {{if .ViewState.hist_filters.date_start}}{{$exportURL = printf "%s?start_date=%s" $exportURL .ViewState.hist_filters.date_start}}{{$hasParams = true}}{{end}}
                            {{if .ViewState.hist_filters.date_end}}{{if $hasParams}}{{$exportURL = printf "%s&end_date=%s" $exportURL .ViewState.hist_filters.date_end}}{{else}}{{$exportURL = printf "%s?end_date=%s" $exportURL .ViewState.hist_filters.date_end}}{{$hasParams = true}}{{end}}{{end}}
                            {{if .ViewState.hist_filters.status}}{{if $hasParams}}{{$exportURL = printf "%s&status=%s" $exportURL .ViewState.hist_filters.status}}{{else}}{{$exportURL = printf "%s?status=%s" $exportURL .ViewState.hist_filters.status}}{{$hasParams = true}}{{end}}{{end}}
                            {{if .ViewState.hist_filters.departure_geo}}{{if $hasParams}}{{$exportURL = printf "%s&departure_geo=%s" $exportURL .ViewState.hist_filters.departure_geo}}{{else}}{{$exportURL = printf "%s?departure_geo=%s" $exportURL .ViewState.hist_filters.departure_geo}}{{$hasParams = true}}{{end}}{{end}}
                            {{if .ViewState.hist_filters.destination_geo}}{{if $hasParams}}{{$exportURL = printf "%s&destination_geo=%s" $exportURL .ViewState.hist_filters.destination_geo}}{{else}}{{$exportURL = printf "%s?destination_geo=%s" $exportURL .ViewState.hist_filters.destination_geo}}{{$hasParams = true}}{{end}}{{end}}
                            {{if .ViewState.hist_filters.passenger_address_geo}}{{if $hasParams}}{{$exportURL = printf "%s&passenger_address_geo=%s" $exportURL .ViewState.hist_filters.passenger_address_geo}}{{else}}{{$exportURL = printf "%s?passenger_address_geo=%s" $exportURL .ViewState.hist_filters.passenger_address_geo}}{{$hasParams = true}}{{end}}{{end}}

                            <a href="{{$exportURL}}">
                                <button type="button"
                                    class="inline-flex items-center justify-center bg-white hover:bg-gray-50 border-gray-300 border px-4 py-2 text-gray-700 flex items-center text-sm rounded-2xl focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
                                    </svg>
                                    Exporter
                                </button>
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <div x-show="tab == 'drivers'">{{template "solidarity_drivers_list" .}}</div>


            <div x-show="tab == 'beneficiaries'">1</div>
            <div x-show="tab == 'solidarityService'">{{template "solidarity_bookings_list" .}}</div>
            <div x-show="tab == 'solidarityHistory'">{{template "solidarity_bookings_history" .}}</div>

        </div>
    </div>


</div>

{{ end }}
