list all bookings

This commit is contained in:
Maxime 2024-12-16 10:12:40 +01:00
parent 3ad5711ae7
commit 50e939c455
2 changed files with 25 additions and 13 deletions

View File

@ -130,15 +130,31 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
}else {
h.Renderer.SolidarityService(w, r)
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
drivers, err := h.services.GRPC.SolidarityService.GetAllDrivers(context.TODO(), &emptypb.Empty{})
bookings, err := h.services.GRPC.SolidarityService.GetAllBookingsSolidarity(context.TODO(), &emptypb.Empty{})
parcourmobAccounts, err := h.beneficiaries(r)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
}
cacheid := uuid.NewString()
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
h.Renderer.SolidarityService(w, r, accounts, drivers, parcourmobAccounts, bookings, cacheid)
}
}
func (h *ApplicationHandler) SolidarityService (w http.ResponseWriter, r *http.Request) {
func (h *ApplicationHandler) SolidarityService(w http.ResponseWriter, r *http.Request) {
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
drivers, err := h.services.GRPC.SolidarityService.GetAllDrivers(context.TODO(), &emptypb.Empty{})
bookings, err := h.services.GRPC.SolidarityService.GetAllBookingsSolidarity(context.TODO(), &emptypb.Empty{})
parcourmobAccounts, err := h.beneficiaries(r)
if err != nil {
@ -148,10 +164,10 @@ func (h *ApplicationHandler) SolidarityService (w http.ResponseWriter, r *http.R
cacheid := uuid.NewString()
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
h.Renderer.BeneficiariesSolidarity(w, r, accounts, drivers, parcourmobAccounts, cacheid)
h.Renderer.SolidarityService(w, r, accounts, drivers, parcourmobAccounts, bookings ,cacheid)
}
func (h *ApplicationHandler) CreateDriver (w http.ResponseWriter, r *http.Request) {
func (h *ApplicationHandler) CreateDriver(w http.ResponseWriter, r *http.Request) {
if r.Method== "POST" {

View File

@ -17,6 +17,7 @@ type SolidarityListState struct {
CacheId string `json:"cache_id"`
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
Drivers *solidarity_service.DriverJourneysResponse `json:"drivers"`
Bookings *solidarity_service.GetAllBookingsSolidarityResponse `json:"bookings"`
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
}
@ -27,6 +28,7 @@ type BeneficiariesSolidarityListState struct {
BeneficiariesSolidarity *solidarity_service.GetAllPassengersResponse `json:"beneficiariessolidarity"`
Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"`
Drivers *solidarity_service.GetAllDriversResponse `json:"drivers"`
Bookings *solidarity_service.GetAllBookingsSolidarityResponse `json:"bookings"`
}
@ -73,14 +75,7 @@ func (s SolidarityBookingsState) JSONWithLimits(a int, b int) template.JS {
return s.JSON()
}
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request) {
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
renderer.Render("solidarity_service", w, r, files, state)
}
func (renderer *Renderer) BeneficiariesSolidarity(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, drivers *solidarity_service.GetAllDriversResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, drivers *solidarity_service.GetAllDriversResponse, parcourmobAccounts []mobilityaccountsstorage.Account, bookings *solidarity_service.GetAllBookingsSolidarityResponse, cacheid string) {
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
state.ViewState = BeneficiariesSolidarityListState{
@ -89,6 +84,7 @@ func (renderer *Renderer) BeneficiariesSolidarity(w http.ResponseWriter, r *http
Beneficiaries: parcourmobAccounts,
BeneficiariesSolidarity: accounts,
Drivers: drivers,
Bookings: bookings,
}