[+] adding in beneficiary-events the agenda-widget

This commit is contained in:
2023-09-06 13:28:02 +02:00
parent 0e00a839a3
commit 0f50b5e678
14 changed files with 131 additions and 63 deletions

View File

@@ -20,6 +20,8 @@ import (
profilepictures "git.coopgo.io/coopgo-apps/parcoursmob/utils/profile-pictures"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
"git.coopgo.io/coopgo-platform/groups-management/storage"
@@ -135,6 +137,37 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
return
}
subscriptionrequest := &agenda.GetSubscriptionByUserRequest{
Subscriber: beneficiaryID,
}
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
events := []agendastorage.Event{}
for _, e := range subcriptionresp.Subscription {
eventresquest := &agenda.GetEventRequest{
Id: e.Eventid,
}
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
currentTime := time.Now().Truncate(24 * time.Hour)
if eventresp.Event.Startdate.AsTime().Equal(currentTime) || eventresp.Event.Startdate.AsTime().After(currentTime) {
events = append(events, eventresp.Event.ToStorageType())
}
}
sort.Sort(sorting.EventsByStartdate(events))
bookingsrequest := &fleets.GetDriverBookingsRequest{
Driver: beneficiaryID,
}
@@ -169,7 +202,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
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)
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events)
}
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
@@ -333,6 +366,8 @@ func filterAccount(r *http.Request, a *mobilityaccounts.Account) bool {
return true
}
// func BeneficiariesEventList()
func (h *ApplicationHandler) beneficiaries(r *http.Request) ([]mobilityaccountsstorage.Account, error) {
var accounts = []mobilityaccountsstorage.Account{}
g := r.Context().Value(identification.GroupKey)

View File

@@ -68,8 +68,10 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
Mindate: timestamppb.Now(),
})
for _, e := range eventsresp.Events {
events = append(events, e.ToStorageType())
if err == nil {
for _, e := range eventsresp.Events {
events = append(events, e.ToStorageType())
}
}
sort.Sort(sorting.EventsByStartdate(events))