Add Trajets Solidaire in Deplacement

This commit is contained in:
2024-11-22 17:26:32 +01:00
parent e811ea7a07
commit 8f21248c29
7 changed files with 164 additions and 26 deletions

View File

@@ -4,9 +4,10 @@ import (
"encoding/json"
"html/template"
"net/http"
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
models "git.coopgo.io/coopgo-apps/parcoursmob/utils/models"
)
const journeysMenu = "journeys"
@@ -23,6 +24,7 @@ type BeneficiariesCovoiturageA struct {
Beneficiaries []any `json:"beneficiaries"`
}
func (s BeneficiariesCovoiturage) JSON() template.JS {
result, _ := json.Marshal(s)
return template.JS(result)
@@ -35,7 +37,7 @@ func (s BeneficiariesCovoiturage) JSONWithLimits(a int, b int) template.JS {
return s.JSON()
}
func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request, carpools any, vehicles []any, searched bool, departure any, destination any, departuredate string, departuretime string, drivers []any) { //transitjourneys any,
func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request, carpools any, vehicles []any, searched bool, departure any, destination any, departuredate string, departuretime string, solidarity_results models.SolidarityTransport ) { //transitjourneys any,
files := renderer.ThemeConfig.GetStringSlice("views.journeys.search.files")
state := NewState(r, renderer.ThemeConfig, journeysMenu)
state.ViewState = map[string]any{
@@ -47,7 +49,7 @@ func (renderer *Renderer) JourneysSearch(w http.ResponseWriter, r *http.Request,
//"journeys": transitjourneys,
"carpools": carpools,
"vehicles": vehicles,
"drivers": drivers,
"solidarity_results": solidarity_results,
}
renderer.Render("journeys", w, r, files, state)
}

View File

@@ -253,7 +253,7 @@ func NewState(r *http.Request, themeConfig *viper.Viper, menuState string) Rende
}
if modules["solidarity_service"] != nil && modules["solidarity_service"].(bool) {
ls.MenuItems = append(ls.MenuItems, MenuItem{
Title: "Mobilité solidaire",
Title: "Transport solidaire",
Link: "/app/solidarity_service/",
Active: menuState == solidarityserviceMenu,
Icon: "hero:outline/map",

View File

@@ -32,6 +32,8 @@ type BeneficiariesSolidarityListState struct {
type SolidarityBookingsState struct {
Bookings *solidarity_service.CreateBookingSolidarityResponse `json:"bookings"`
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
}
@@ -71,31 +73,34 @@ func (s SolidarityBookingsState) JSONWithLimits(a int, b int) template.JS {
return s.JSON()
}
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
state.ViewState = BeneficiariesSolidarityListState{
Count: len(parcourmobAccounts),
CacheId: cacheid,
Beneficiaries: parcourmobAccounts,
BeneficiariesSolidarity: accounts,
}
renderer.Render("solidarity_service", w, r, files, state)
}
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, bookings *solidarity_service.CreateBookingSolidarityResponse, parcourmobAccounts []mobilityaccountsstorage.Account) {
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, bookings *solidarity_service.CreateBookingSolidarityResponse,accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account) {
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
state.ViewState = SolidarityBookingsState{
Bookings: bookings,
Beneficiaries: parcourmobAccounts,
BeneficiariesSolidarity: accounts,
}
renderer.Render("solidarity_service", w, r, files, state)
}
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, booking *solidarity_service.CreateBookingSolidarityRequest, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, booking *solidarity_service.CreateBookingSolidarityRequest,accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
state.ViewState = SolidarityListState {
@@ -103,7 +108,7 @@ func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseW
CacheId: cacheid,
Drivers: drivers,
Beneficiaries: parcourmobAccounts,
BeneficiariesSolidarity: accounts,
}
renderer.Render("solidarity_service", w, r, files, state)