up list silvermobiBookings

This commit is contained in:
Maxime 2024-09-26 17:42:18 +02:00
parent 0cfa78e938
commit efaa4f9f0d
2 changed files with 13 additions and 25 deletions

View File

@ -345,16 +345,6 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
func (h *ApplicationHandler) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request) { func (h *ApplicationHandler) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request) {
accounts, err := h.beneficiaries(r)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
sort.Sort(sorting.BeneficiariesByName(accounts))
vars := mux.Vars(r) vars := mux.Vars(r)
beneficiaryID := vars["beneficiaryid"] beneficiaryID := vars["beneficiaryid"]
@ -379,18 +369,18 @@ func (h *ApplicationHandler) BeneficiarySolidarityDisplay(w http.ResponseWriter,
solidarity_bookings_list, err := h.services.GRPC.SolidarityService.GetBookingsByStatus(context.TODO(), solidarity_booking) solidarity_bookings_list, err := h.services.GRPC.SolidarityService.GetBookingsByStatus(context.TODO(), solidarity_booking)
var bookings []any
for _, o := range solidarity_bookings_list.Booking {
bookings = append(bookings, o)
}
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
cacheid := uuid.NewString() h.Renderer.BeneficiarySolidarityDisplay(w, r , accountssolidarity , bookings)
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
h.cache.PutWithTTL(cacheid, solidarity_bookings_list, 1*time.Hour)
h.Renderer.BeneficiarySolidarityDisplay(w, r ,accounts, accountssolidarity , solidarity_bookings_list, cacheid)
} }

View File

@ -2,13 +2,13 @@ package renderer
import ( import (
"encoding/json" "encoding/json"
"fmt"
"html/template" "html/template"
"net/http" "net/http"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage" fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage" mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto" solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
) )
const beneficiariesMenu = "beneficiaries" const beneficiariesMenu = "beneficiaries"
@ -93,17 +93,15 @@ func (renderer *Renderer) BeneficiaryDisplay(w http.ResponseWriter, r *http.Requ
renderer.Render("beneficiaries_display", w, r, files, state) renderer.Render("beneficiaries_display", w, r, files, state)
} }
func (renderer *Renderer) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, beneficiary *solidarity_service.GetPassengerResponse, solidarity_bookings_list *solidarity_service.GetBookingsByStatusResponse, cacheid string) { func (renderer *Renderer) BeneficiarySolidarityDisplay(w http.ResponseWriter, r *http.Request, beneficiary any, solidarity_bookings_list []any ) {
files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files") files := renderer.ThemeConfig.GetStringSlice("views.beneficiaries.display.files")
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu) state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
state.ViewState = BeneficiarySolidarityState{ state.ViewState = map[string]any{
Count : len(accounts), "beneficiary": beneficiary,
CacheId : cacheid, "bookingSolidarity" : solidarity_bookings_list,
Beneficiaries: accounts,
BeneficiarySolidarity : beneficiary,
BookingSolidarity : solidarity_bookings_list,
} }
fmt.Println(solidarity_bookings_list)
renderer.Render("beneficiaries_display", w, r, files, state) renderer.Render("beneficiaries_display", w, r, files, state)
} }