2022-08-12 12:53:54 +00:00
{{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" > Véhicules partagés< / h1 >
< div class = "sm:flex sm:items-center" >
< div class = "sm:flex-auto" >
< p class = "mt-2 text-sm text-gray-700" > < / p >
< / div >
< div class = "mt-4 sm:mt-0 sm:ml-16 sm:flex-none" >
2022-09-05 05:25:05 +00:00
< a href = "/app/vehicles/bookings/" >
2022-08-12 12:53:54 +00:00
< button type = "button"
class="inline-flex items-center justify-center rounded-2xl border border-transparent bg-co-blue px-4 py-2 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:w-auto">
2022-10-30 19:11:36 +00:00
Voir les mises à disposition
2022-08-12 12:53:54 +00:00
< / button >
< / a >
< / div >
< / div >
< div class = "mt-8 max-w-3xl mx-auto grid grid-cols-1 gap-6 lg:max-w-7xl lg:grid-flow-col-dense lg:grid-cols-3" >
< div class = "space-y-6 lg:col-start-1 lg:col-span-1" >
< div class = "bg-white shadow sm:rounded-2xl" >
< h2 id = "timeline-title" class = "text-lg font-medium text-gray-900 p-4 sm:px-6" > Chercher un véhicule< / h2 >
< div class = "border-t border-gray-200 px-4 py-5 sm:px-6" >
< form method = "GET" >
< div x-data = "{
text: '{{if .ViewState.search}}{{.ViewState.search.beneficiary.Data.first_name}} {{.ViewState.search.beneficiary.Data.last_name}}{{end}}',
beneficiariesListOpen: false,
beneficiaries: {{json .ViewState.beneficiaries}},
2022-11-01 10:32:13 +00:00
filteredBeneficiaries: (beneficiaries, text) => {
if(text=='') {
return beneficiaries
}
return beneficiaries.filter(b => b['data']['first_name'].toLowerCase().includes(text.toLowerCase()) || b['data']['last_name'].toLowerCase().includes(text.toLowerCase()))
2022-08-12 12:53:54 +00:00
},
fields: {
2022-09-05 05:25:05 +00:00
beneficiaryid: {{if .ViewState.search}}'{{.ViewState.search.beneficiary.ID}}'{{else}}null{{end}},
2022-08-12 12:53:54 +00:00
},
selectbeneficiary(beneficiary) {
console.log(beneficiary)
this.fields.beneficiaryid = beneficiary.id
this.text = beneficiary.data.first_name + ' ' + beneficiary.data.last_name
this.beneficiariesListOpen = false
}
}">
< input type = "hidden" name = "beneficiaryid" x-model = "fields.beneficiaryid" >
< label for = "combobox" class = "block text-sm font-medium text-gray-700" > Bénéficiaire< / label >
< div class = "relative mt-1 mb-4" >
2022-11-01 10:32:13 +00:00
< input autocomplete = "off" @ focus = "beneficiariesListOpen = true" x-model = "text" id = "combobox" type = "text" class = "w-full rounded-2xl border border-gray-300 bg-white py-2 pl-3 pr-12 shadow-sm focus:border-co-blue focus:outline-none focus:ring-1 focus:ring-co-blue sm:text-sm" role = "combobox" aria-controls = "options" aria-expanded = "false" >
2022-08-12 12:53:54 +00:00
< button @ click = "beneficiariesListOpen = ! beneficiariesListOpen" type = "button" class = "absolute inset-y-0 right-0 flex items-center rounded-r-2xl px-2 focus:outline-none" >
<!-- Heroicon name: solid/selector -->
< svg class = "h-5 w-5 text-gray-400" xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 20 20" fill = "currentColor" aria-hidden = "true" >
< path fill-rule = "evenodd" d = "M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule = "evenodd" / >
< / svg >
< / button >
< ul x-show = "beneficiariesListOpen" class = "absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-xl bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" id = "options" role = "listbox" >
<!--
Combobox option, manage highlight styles based on mouseenter/mouseleave and keyboard navigation.
Active: "text-white bg-indigo-600", Not Active: "text-gray-900"
-->
2022-11-01 10:32:13 +00:00
< template x-for = "beneficiary in filteredBeneficiaries(beneficiaries, text)" >
2022-08-12 12:53:54 +00:00
< li @ click = "selectbeneficiary(beneficiary)" class = "relative cursor-default hover:bg-gray-100 select-none py-2 pl-3 pr-9 text-gray-900" id = "option-0" role = "option" tabindex = "-1" >
<!-- Selected: "font - semibold" -->
< span class = "truncate" x-text = "beneficiary.data.first_name" > < / span > < span class = "truncate" x-text = "beneficiary.data.last_name" > < / span >
<!--
Checkmark, only display for selected option.
Active: "text-white", Not Active: "text-indigo-600"
-->
< span class = "absolute inset-y-0 right-0 flex items-center pr-4 text-co-blue" >
<!-- Heroicon name: solid/check -->
<!-- <svg class="h - 5 w - 5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria - hidden="true">
< path fill-rule = "evenodd" d = "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule = "evenodd" / >
< / svg > -->
< / span >
< / li >
< / template >
<!-- More items... -->
< / ul >
< / div >
< / div >
<!-- {{ $fieldName := "address" }}
{{ template "address_autocomplete" dict "FieldName" $fieldName }} -->
< div class = "py-4 grid grid-cols-2" >
< div class = "lg:col-span-1" >
< label for = "startdate" class = "block text-sm font-medium text-gray-700" > Du< / label >
< div class = "mt-1" >
< input type = "date" id = "startdate" name = "startdate" value = "{{.ViewState.search.startdate}}"
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-l-2xl border-r-1">
< / div >
< / div >
< div class = "lg:col-span-1" >
< label for = "enddate" class = "block text-sm font-medium text-gray-700" > Au< / label >
< div class = "mt-1" >
< input type = "date" id = "enddate" name = "enddate" value = "{{.ViewState.search.enddate}}"
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-r-2xl border-l-0">
< / div >
< / div >
< / div >
{{template "vehicle_type_select" .}}
< button type = "submit"
class="rounded-2xl border border-transparent bg-co-blue px-4 py-2 my-4 mt-8 w-full text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:w-auto">
Chercher
< / button >
< / form >
< / div >
< / div >
< / div >
< div class = "lg:col-start-2 lg:col-span-2" >
{{if .ViewState.searched}}
< div class = "bg-white px-4 py-5 shadow sm:rounded-2xl sm:px-6" >
< h2 id = "timeline-title" class = "text-lg font-medium text-gray-900" > Véhicules disponibles< / h2 >
< div class = "mt-8 flex flex-col" >
< div class = "-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8" >
< div class = "inline-block min-w-full py-2 align-middle md:px-6 lg:px-8" >
< table class = "min-w-full divide-y divide-gray-300" >
< thead >
< tr >
< th scope = "col" class = "py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 md:pl-0" > Véhicule< / th >
< th scope = "col" class = "py-3.5 px-3 text-left text-sm font-semibold text-gray-900" > Numéro< / th >
< th scope = "col" class = "py-3.5 px-3 text-left text-sm font-semibold text-gray-900" > Gestionnaire< / th >
< th scope = "col" class = "py-3.5 px-3 text-left text-sm font-semibold text-gray-900" > Lieu< / th >
< th scope = "col" class = "relative py-3.5 pl-3 pr-4 sm:pr-6 md:pr-0" >
< span class = "sr-only" > Réserver< / span >
< / th >
< / tr >
< / thead >
< tbody class = "divide-y divide-gray-200" >
{{range .ViewState.search.vehicles}}
< tr >
< td class = "whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 md:pl-0" > {{.Data.name}}< / td >
< td class = "whitespace-nowrap py-4 px-3 text-sm text-gray-500" > {{.Data.licence_plate}}< / td >
< td class = "whitespace-nowrap py-4 px-3 text-sm text-gray-500" > COOPGO< / td >
< td class = "whitespace-nowrap py-4 px-3 text-sm text-gray-500" > {{if .Data.address}}{{.Data.address.properties.label}}{{end}}< / td >
< td class = "relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 md:pr-0" >
< a href = "/app/vehicles/v/{{.ID}}/b/{{$.ViewState.search.beneficiary.ID}}?startdate={{$.ViewState.search.startdate}}&enddate={{$.ViewState.search.enddate}}" class = "text-co-blue hover:text-co-blue" > Réserver< span class = "sr-only" > pour {{$.ViewState.search.beneficiary.Data.first_name}} {{$.ViewState.search.beneficiary.Data.last_name}}< / span > < / a >
< / td >
< / tr >
{{end}}
< / tbody >
< / table >
< / div >
< / div >
< / div >
< / div >
{{end}}
< / div >
< / div >
< / div >
{{end}}