Solidarity transport implementation

This commit is contained in:
2025-03-05 00:42:47 +01:00
parent 82773f090b
commit 0cc1c1451c
23 changed files with 701 additions and 93 deletions

View File

@@ -0,0 +1,82 @@
{{ define "solidarity_bookings_list" }}
{{if eq (len .ViewState.bookings) 0}}
<div class="m-10 text-center text-gray-600">Aucun trajet déclaré</div>
{{else}}
<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">
Conducteur
</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">
Destination
</th>
<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">
Statut
</th>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
&nbsp;
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
{{range .ViewState.bookings}}
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<a class="text-co-blue" href="/app/solidarity-transport/drivers/{{.DriverId}}">
{{ (index $.ViewState.drivers_map .DriverId).Data.first_name }}
{{ (index $.ViewState.drivers_map .DriverId).Data.last_name }}
</a>
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<a class="text-co-blue" href="/app/beneficiaries/{{.PassengerId}}">
{{ (index $.ViewState.passengers_map .PassengerId).Data.first_name }}
{{ (index $.ViewState.passengers_map .PassengerId).Data.last_name }}
</a>
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
{{ .Journey.PassengerPickup.Properties.label }}
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
{{ .Journey.PassengerDrop.Properties.label }}
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
{{ .Journey.PassengerPickupDate.Format "02/01/2006 15:04" }}
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
{{ if eq .Status "WAITING_CONFIRMATION"}}
<span class="p-1 text-xs bg-gray-300 rounded-xl">Attente confirmation</span>
{{ else if eq .Status "VALIDATED"}}
<span class="p-1 text-xs bg-co-green rounded-xl">Validé</span>
{{ else if eq .Status "CANCELLED"}}
<span class="p-1 text-xs bg-co-red text-white rounded-xl">Annulé</span>
{{ end }}
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<a class="text-co-blue" href="/app/solidarity-transport/bookings/{{.Id}}">
Voir
</a>
</td>
</tr>
{{ end }}
</tbody>
</table>
{{end}}
{{end}}

View File

@@ -9,21 +9,21 @@
</div>
<div class="border-t border-gray-200 px-4">
<div class="py-4">
{{ range .ViewState.driver.Data.solidarity_transport_availabilities }}
{{ range .ViewState.availabilities }}
<div class="flex flex-row">
<div class="flex-none">
{{ if eq .day 0.0}}Dimanche
{{ else if eq .day 1.0}}Lundi
{{ else if eq .day 2.0}}Mardi
{{ else if eq .day 3.0}}Mercredi
{{ else if eq .day 4.0}}Jeudi
{{ else if eq .day 5.0}}Vendredi
{{ else if eq .day 6.0}}Samedi
{{ if eq .Day 0}}Dimanche
{{ else if eq .Day 1}}Lundi
{{ else if eq .Day 2}}Mardi
{{ else if eq .Day 3}}Mercredi
{{ else if eq .Day 4}}Jeudi
{{ else if eq .Day 5}}Vendredi
{{ else if eq .Day 6}}Samedi
{{ end }}
{{.start_time}} - {{ .end_time }}
{{.StartTime}} - {{ .EndTime }}
</div>
<div class="flex-auto">&nbsp;</div>
<div class="flex-none text-sm"><a class="text-co-blue" href="/app/solidarity-transport/drivers/{{$.ViewState.driver.ID}}/availabilities/{{.id}}/delete">Supprimer</a></div>
<div class="flex-none text-sm"><a class="text-co-blue" href="/app/solidarity-transport/drivers/{{$.ViewState.driver.ID}}/availabilities/{{.Id}}/delete">Supprimer</a></div>
</div>
{{ end }}
</div>
@@ -49,6 +49,12 @@
</div>
</div>
<form method="POST" action="/app/solidarity-transport/drivers/{{.ViewState.driver.ID}}/availabilities" class="my-4">
<div class="my-8">
{{ $fieldName := "address" }}
{{ template "address_autocomplete" (dict "FieldName" $fieldName "Address" .ViewState.driver.Data.address) }}
</div>
<div class="my-4">
<input name="days.monday" type="checkbox" class="focus:ring-co-blue h-4 w-4 text-co-blue border-gray-300 rounded"> Lundi &nbsp;&nbsp;
<input name="days.tuesday" type="checkbox" class="focus:ring-co-blue h-4 w-4 text-co-blue border-gray-300 rounded"> Mardi &nbsp;&nbsp;

View File

@@ -29,7 +29,15 @@
</th>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
Disponibilités
Adresse
</th>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
Téléphone
</th>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
Profil validé
</th>
<th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
@@ -41,7 +49,11 @@
{{ range .ViewState.drivers }}
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">{{ .Data.first_name }} {{ .Data.last_name }}</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6"></td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">{{if .Data.address}}{{.Data.address.properties.label}}{{end}}</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">{{ .Data.phone_number }}</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<span class="p-1 px-2 text-xs bg-co-green rounded-2xl">Oui</span>
</td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<a class="text-co-blue hover:text-co-blue"
href="/app/solidarity-transport/drivers/{{.ID}}">

View File

@@ -0,0 +1,268 @@
{{define "journey_preview"}}
<div class="col-span-1 bg-white rounded-2xl shadow divide-y divide-gray-200 flex flex-col">
<div class="px-4 py-2 flex items-center justify-between flex-wrap sm:flex-nowrap">
<div class="ml-4 mt-2 grid-cols-2">
<h3 class="text-lg leading-6 font-medium text-gray-900">Le trajet</h3>
<h2 class="text-sm leading-6 font-medium text-gray-600">Informations sur le trajet</h2>
</div>
</div>
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div class="p-4 py-5 sm:px-6">
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Départ passager</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.PassengerPickup.Properties.label}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Destination passager</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.PassengerDrop.Properties.label}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Départ conducteur</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.DriverDeparture.Properties.label}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Destination conducteur</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.DriverArrival.Properties.label}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Kilomètres passager</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.PassengerDistance}} km</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Kilomètres conducteur</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver_journey.DriverDistance}} km</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Horaire départ conducteur</dt>
<dd class="mt-1 text-sm text-gray-900">{{ .driver_journey.DriverDepartureDate.Format "02/01/2006 15:04"}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Horaire rendez vous passager</dt>
<dd class="mt-1 text-sm text-gray-900">{{ .driver_journey.PassengerPickupDate.Format "02/01/2006 15:04"}}</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Temps de trajet (passager)</dt>
<dd class="mt-1 text-sm text-gray-900">{{ printf "%.0f" .driver_journey.Duration.Minutes }} min</dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Prix (passager)</dt>
<dd class="mt-1 text-sm text-gray-900">{{ .driver_journey.Price.Amount }} {{ .driver_journey.Price.Currency}}</dd>
</div>
</dl>
</div>
<div>
<div id="map" class="w-full h-full"></div>
<script>
var map = new maplibregl.Map({
container: 'map', // container id
style: {
version: 8,
glyphs:'https://protomaps.github.io/basemaps-assets/fonts/{fontstack}/{range}.pbf',
sprite: "https://protomaps.github.io/basemaps-assets/sprites/v4/light",
sources: {
"protomaps": {
type: "vector",
url: "pmtiles://https://coopgo-gis-data.s3.fr-par.scw.cloud/vector-tiles/pmtiles/europe-latest.pmtiles",
// ^-- Remember to prefix the URL with pmtiles://
attribution: '<a href="https://protomaps.com">Protomaps</a> © <a href="https://openstreetmap.org">OpenStreetMap</a>'
},
"points": {
type: "geojson",
data: {
"type": "FeatureCollection",
"features": [
{{ json .driver_journey.DriverDeparture }},
{{ json .driver_journey.PassengerPickup }},
{{ json .driver_journey.PassengerDrop }},
{{ json .driver_journey.DriverArrival }}
]
}
}
},
layers: basemaps.layers("protomaps",basemaps.namedFlavor("light"),{lang:"en"})
}
});
</script>
</div>
</div>
</div>
<div class="py-4 grid grid-cols-1 gap-6 sm:grid-cols-2">
<div class="col-span-1 bg-white rounded-2xl shadow divide-y divide-gray-200 flex flex-col">
<div class="px-4 py-2 flex items-center justify-between flex-wrap sm:flex-nowrap">
<div class="ml-4 mt-2 grid-cols-2">
<h3 class="text-lg leading-6 font-medium text-gray-900">Conducteur</h3>
<h2 class="text-sm leading-6 font-medium text-gray-600">{{.driver.Data.first_name}} {{.driver.Data.last_name}}</h2>
</div>
</div>
<div class="border-t border-gray-200 px-4 py-5 sm:px-6">
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
{{if .driver.Data.email}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Email</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver.Data.email}}</dd>
</div>
{{end}}
{{if .driver.Data.phone_number}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Téléphone</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver.Data.phone_number}}</dd>
</div>
{{end}}
{{if .driver.Data.birthdate}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Date de naissance</dt>
<dd class="mt-1 text-sm text-gray-900">{{(timeFrom .driver.Data.birthdate).Format
"02/01/2006"}}</dd>
</div>
{{end}}
{{if and .driver.Data.gender (ne .driver.Data.gender "0")}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Genre</dt>
<dd class="mt-1 text-sm text-gray-900">{{genderISO5218 .driver.Data.gender}}</dd>
</div>
{{end}}
{{if .driver.Data.address}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Adresse</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver.Data.address.properties.label}}</dd>
</div>
{{end}}
{{if .driver.Data.file_number}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Numéro de dossier (CAF / Pole emploi)</dt>
<dd class="mt-1 text-sm text-gray-900">{{.driver.Data.file_number}}</dd>
</div>
{{end}}
</dl>
</div>
</div>
<div class="col-span-1 bg-white rounded-2xl shadow divide-y divide-gray-200 flex flex-col">
<div class="px-4 py-2 flex items-center justify-between flex-wrap sm:flex-nowrap">
<div class="ml-4 mt-2">
<h3 class="text-lg leading-6 font-medium text-gray-900">Passager</h3>
<h2 class="text-sm leading-6 font-medium text-gray-600">{{if ne .passenger.ID "" }}{{.passenger.Data.first_name}} {{.passenger.Data.last_name}}{{end}}</h2>
</div>
</div>
<div class="border-t border-gray-200 px-4 py-5 sm:px-6">
{{if eq .passenger.ID ""}}
<form method="GET">
<div x-data="{
text: '',
beneficiariesListOpen: false,
beneficiaries: {{json .beneficiaries}},
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()))
},
fields: {
beneficiaryid: {{if .search}}'{{.search.beneficiary.ID}}'{{else}}null{{end}},
},
selectbeneficiary(beneficiary) {
this.fields.beneficiaryid = beneficiary.id
this.text = beneficiary.data.first_name + ' ' + beneficiary.data.last_name
this.beneficiariesListOpen = false
},
}">
<input type="hidden" name="passengerid" x-model="fields.beneficiaryid">
<label for="combobox" class="block text-sm font-medium text-gray-700">Selectionner un bénéficiaire</label>
<div class="relative mt-1 mb-4">
<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">
<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"
-->
<template x-for="beneficiary in filteredBeneficiaries(beneficiaries, text)">
<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>
<button type="submit" class="inline-flex w-full justify-center max-w-xs bg-co-blue 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">
Valider
</button>
</div>
</form>
{{ else }}
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
{{if .passenger.Data.email}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Email</dt>
<dd class="mt-1 text-sm text-gray-900">{{.passenger.Data.email}}</dd>
</div>
{{end}}
{{if .passenger.Data.phone_number}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Téléphone</dt>
<dd class="mt-1 text-sm text-gray-900">{{.passenger.Data.phone_number}}</dd>
</div>
{{end}}
{{if .passenger.Data.birthdate}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Date de naissance</dt>
<dd class="mt-1 text-sm text-gray-900">{{(timeFrom .passenger.Data.birthdate).Format
"02/01/2006"}}</dd>
</div>
{{end}}
{{if and .passenger.Data.gender (ne .passenger.Data.gender "0")}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Genre</dt>
<dd class="mt-1 text-sm text-gray-900">{{genderISO5218 .passenger.Data.gender}}</dd>
</div>
{{end}}
{{if .passenger.Data.address}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Adresse</dt>
<dd class="mt-1 text-sm text-gray-900">{{.passenger.Data.address.properties.label}}</dd>
</div>
{{end}}
{{if .passenger.Data.file_number}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Numéro de dossier (CAF / Pole emploi)</dt>
<dd class="mt-1 text-sm text-gray-900">{{.passenger.Data.file_number}}</dd>
</div>
{{end}}
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500">Compte mobilié (solde)</dt>
<dd class="mt-1 text-sm text-gray-900">{{if .passenger.Data.wallet}}{{ .passenger.Data.wallet }}{{else}}0{{end}} EUR</dd>
</div>
</dl>
</div>
{{end}}
</div>
</div>
{{end}}