list silvermobiBooking by silvermobiUsers

This commit is contained in:
2024-09-26 13:34:08 +02:00
parent 5a89c8b24a
commit 0cfa78e938
5 changed files with 104 additions and 9 deletions

View File

@@ -30,8 +30,10 @@ import (
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
"github.com/google/uuid"
"github.com/gorilla/mux"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/structpb"
)
@@ -118,9 +120,17 @@ func (h *ApplicationHandler) BeneficiariesList(w http.ResponseWriter, r *http.Re
sort.Sort(sorting.BeneficiariesByName(accounts))
accountssolidarity, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
cacheid := uuid.NewString()
h.cache.PutWithTTL(cacheid, accountssolidarity, 1*time.Hour)
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
h.Renderer.BeneficiariesList(w, r, accounts, cacheid)
h.Renderer.BeneficiariesList(w, r, accounts,accountssolidarity, cacheid)
}
func (h *ApplicationHandler) BeneficiaryCreate(w http.ResponseWriter, r *http.Request) {
@@ -327,6 +337,39 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
organizations = append(organizations, o.ToStorageType())
}
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
file_types_map := h.config.GetStringMapString("storage.files.file_types")
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list)
}
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"]
passenger := solidarity_service.GetPassengerRequest{
Passenger: &solidarity_service.User{
Id: beneficiaryID,
},
}
accountssolidarity, err := h.services.GRPC.SolidarityService.GetPassenger(context.TODO(), &passenger)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
solidarity_booking := &solidarity_service.GetBookingsByStatusRequest{
Status : 0, /// 0 : pending
@@ -342,10 +385,13 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
return
}
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
file_types_map := h.config.GetStringMapString("storage.files.file_types")
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.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list, solidarity_bookings_list)
}
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {

View File

@@ -132,8 +132,6 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
BookingData.bookingData.Booking.DriverId = driverId
BookingData.bookingData.Booking.Id = id
fmt.Println(BookingData.bookingData, "booking")
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
if err != nil {