From bfd14d7f4cc54287668da3f76447fdc20a100863 Mon Sep 17 00:00:00 2001 From: Nicolas Caron Date: Wed, 10 May 2023 09:52:57 +0200 Subject: [PATCH] edit handlers vehicle-management for unbooking a vehicle --- go.mod | 2 +- handlers/application/vehicles-management.go | 5 +++-- renderer/vehicle-management.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d7682bc..99a2150 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ go 1.18 // replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/ -// replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/ +replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/ // replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/ diff --git a/handlers/application/vehicles-management.go b/handlers/application/vehicles-management.go index 669a451..2e71e06 100644 --- a/handlers/application/vehicles-management.go +++ b/handlers/application/vehicles-management.go @@ -494,6 +494,7 @@ func (h ApplicationHandler) VehiclesFleetMakeUnavailable(w http.ResponseWriter, func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) bookingid := vars["bookingid"] + request := &fleets.GetBookingRequest{ Bookingid: bookingid, } @@ -515,7 +516,7 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req Startdate: resp.Booking.Startdate, Enddate: resp.Booking.Enddate, Unavailablefrom: resp.Booking.Unavailablefrom, - Unavailableto: resp.Booking.Unavailableto, + Unavailableto: timestamppb.New(time.Now().Add(-48 * time.Hour)), Data: resp.Booking.Data, Deleted: true, }, @@ -532,5 +533,5 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req http.Redirect(w, r, "/app/vehicles-management/", http.StatusFound) return } - h.Renderer.UnbookingVehicle(w, r, bookingid) + h.Renderer.UnbookingVehicle(w, r, resp.Booking.ToStorageType()) } diff --git a/renderer/vehicle-management.go b/renderer/vehicle-management.go index c8052f8..77e8dc5 100644 --- a/renderer/vehicle-management.go +++ b/renderer/vehicle-management.go @@ -79,7 +79,7 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, renderer.Render("vehicles search", w, r, files, state) } -func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Request, booking string) { +func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Request, booking any) { files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files") state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu) state.ViewState = map[string]any{