diff --git a/handlers/application/solidarity_service.go b/handlers/application/solidarity_service.go index 4168d55..0732a65 100644 --- a/handlers/application/solidarity_service.go +++ b/handlers/application/solidarity_service.go @@ -59,8 +59,6 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque w.WriteHeader(http.StatusBadRequest) return } - - fmt.Println(departuregeo, destinationgeo, "departuregeo") } request := &solidarity_service.DriverJourneysRequest{ @@ -96,37 +94,11 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque return } - fmt.Println("request: ", request) - h.Renderer.SolidarityServiceBookingListDrivers(w, r, drivers, accounts, &booking, cacheid) + h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, accounts, &booking, cacheid) } else { - DepartureAddress := "0 rue A"; - PickupDate := r.FormValue("date"); - - layout := "2006-01-02T15:04" - dateParsed, err := time.Parse(layout, PickupDate) - - timestamp := timestamppb.New(dateParsed) - - request := &solidarity_service.DriverJourneysRequest{ - DepartureDate: timestamp, - Departure: &solidarity_service.Feature{ - Lat: 0, - Long: 0, - Address: DepartureAddress, - }, - } - - drivers, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), request) - - if err != nil { - fmt.Println(err) - w.WriteHeader(http.StatusInternalServerError) - return - } - - h.Renderer.SolidarityService(w, r, drivers, accounts, cacheid) + h.Renderer.SolidarityService(w, r, accounts, cacheid) } } diff --git a/renderer/solidarity_service.go b/renderer/solidarity_service.go index 09c04fe..da0cc56 100644 --- a/renderer/solidarity_service.go +++ b/renderer/solidarity_service.go @@ -14,8 +14,8 @@ const solidarityserviceMenu = "solidarity_service" type SolidarityListState struct { Count int `json:"count"` - CacheId string `json:"cache_id"` - Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"` + CacheId string `json:"cache_id"` + Beneficiaries []mobilityaccountsstorage.Account `json:"beneficiaries"` Drivers *solidarity_service.DriverJourneysResponse `json:"drivers"` } @@ -32,14 +32,13 @@ func (s SolidarityListState) JSONWithLimits(a int, b int) template.JS { return s.JSON() } -func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, accounts []mobilityaccountsstorage.Account, cacheid string) { +func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts []mobilityaccountsstorage.Account, cacheid string) { files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files") state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu) - state.ViewState = SolidarityListState { - Count: len(accounts), - Beneficiaries: accounts, + state.ViewState = BeneficiariesListState{ + Count: len(accounts), CacheId: cacheid, - Drivers: drivers, + Beneficiaries: accounts, } renderer.Render("solidarity_service", w, r, files, state) @@ -55,7 +54,7 @@ func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *htt renderer.Render("solidarity_service", w, r, files, state) } -func (renderer *Renderer) SolidarityServiceBookingListDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, accounts []mobilityaccountsstorage.Account, booking *solidarity_service.BookingSolidarityRequest, cacheid string) { +func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, accounts []mobilityaccountsstorage.Account, booking *solidarity_service.BookingSolidarityRequest, cacheid string) { files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files") state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu) state.ViewState = SolidarityListState {