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) {
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)
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)
if err != nil {
var bookings []any
for _, o := range solidarity_bookings_list.Booking {
bookings = append(bookings, o)
}
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
cacheid := uuid.NewString()
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)
h.Renderer.BeneficiarySolidarityDisplay(w, r , accountssolidarity , bookings)
}

View File

@ -2,13 +2,13 @@ package renderer
import (
"encoding/json"
"fmt"
"html/template"
"net/http"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
)
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)
}
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")
state := NewState(r, renderer.ThemeConfig, beneficiariesMenu)
state.ViewState = BeneficiarySolidarityState{
Count : len(accounts),
CacheId : cacheid,
Beneficiaries: accounts,
BeneficiarySolidarity : beneficiary,
BookingSolidarity : solidarity_bookings_list,
state.ViewState = map[string]any{
"beneficiary": beneficiary,
"bookingSolidarity" : solidarity_bookings_list,
}
fmt.Println(solidarity_bookings_list)
renderer.Render("beneficiaries_display", w, r, files, state)
}