add members data

This commit is contained in:
soukainna
2023-02-22 11:04:09 +01:00
parent d1818b6251
commit f023a7bbff
4 changed files with 103 additions and 4 deletions

View File

@@ -52,10 +52,16 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
}
}
vehiicles := []fleetsstorage.Vehicle{}
for i, vehiicle := range resp.Vehicles {
if len(resp.Vehicles[i].Bookings) == 0 {
v := vehiicle.ToStorageType()
vehiicles = append(vehiicles, v)
}
}
fmt.Println(vehiicles)
sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
sort.Sort(sorting.BookingsByStartdate(bookings))
h.Renderer.VehiclesManagementOverview(w, r, vehicles, vehicles_map, bookings)
}
@@ -184,7 +190,10 @@ func (h *ApplicationHandler) VehiclesFleetDisplay(w http.ResponseWriter, r *http
w.WriteHeader(http.StatusInternalServerError)
return
}
if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
fmt.Println("lol")
}
fmt.Println(resp.Vehicle.ToStorageType().Bookings)
h.Renderer.VehiclesFleetDisplay(w, r, resp.Vehicle.ToStorageType())
}
@@ -457,3 +466,28 @@ func (h ApplicationHandler) VehiclesFleetMakeUnavailable(w http.ResponseWriter,
http.Redirect(w, r, fmt.Sprintf("/app/vehicles-management/fleet/%s", vehicleid), http.StatusFound)
}
// func (h *ApplicationHandler) UnbookingVehicles(w http.ResponseWriter, r *http.Request) {
// request := &fleets.GetVehiclesRequest{
// Namespaces: []string{"parcoursmob"},
// }
// resp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), request)
// if err != nil {
// fmt.Println(err)
// w.WriteHeader(http.StatusInternalServerError)
// }
// vehicles := []fleetsstorage.Vehicle{}
// fmt.Println(resp.Vehicles[0].Bookings)
// for i, vehicle := range resp.Vehicles {
// if len(resp.Vehicles[i].Bookings) == 0 {
// v := vehicle.ToStorageType()
// vehicles = append(vehicles, v)
// }
// }
// // if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
// // h.Renderer.UnbookingVehicles(w, r, resp.Vehicle.ToStorageType())
// // }
// // fmt.Println(resp.Vehicle.ToStorageType().Bookings)
// fmt.Println(vehicles)
// h.Renderer.UnbookingVehicles(w, r, vehicles)
// }