This commit is contained in:
Maxime 2024-10-04 18:57:37 +02:00
parent efaa4f9f0d
commit 4f1cc21aeb
3 changed files with 25 additions and 8 deletions

View File

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

View File

@ -99,7 +99,6 @@ func (renderer *Renderer) BeneficiarySolidarityDisplay(w http.ResponseWriter, r
state.ViewState = map[string]any{ state.ViewState = map[string]any{
"beneficiary": beneficiary, "beneficiary": beneficiary,
"bookingSolidarity" : solidarity_bookings_list, "bookingSolidarity" : solidarity_bookings_list,
} }
fmt.Println(solidarity_bookings_list) fmt.Println(solidarity_bookings_list)
renderer.Render("beneficiaries_display", w, r, files, state) renderer.Render("beneficiaries_display", w, r, files, state)

View File

@ -25,6 +25,20 @@ func TimeFrom(d any) *time.Time {
return nil return nil
} }
func TimestampFrom(d any) *time.Time {
if date, ok := d.(time.Time); ok {
return &date
} else if date, ok := d.(string); ok {
datetime, err := time.Parse("2006-01-02T15:04:05Z", date)
if err != nil {
panic(err)
}
return &datetime
}
return nil
}
func TimeFormat(d any, f string) string { func TimeFormat(d any, f string) string {
date := TimeFrom(d) date := TimeFrom(d)
if date == nil { if date == nil {