front module mobilité solidaire
This commit is contained in:
parent
13a34ad124
commit
de060b2ecf
|
@ -27,15 +27,26 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
bookingData := solidarity_service.CreateBookingSolidarityRequest {
|
bookingData := solidarity_service.CreateBookingSolidarityRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method == "GET" {
|
if r.Method != "GET" {
|
||||||
|
|
||||||
DepartureAddress := r.FormValue("departure");
|
DepartureAddress := r.FormValue("departure");
|
||||||
DestinationAddress := r.FormValue("destination");
|
DestinationAddress := r.FormValue("destination");
|
||||||
PickupDate := r.FormValue("date");
|
PickupDate := r.FormValue("date");
|
||||||
|
|
||||||
|
|
||||||
layout := "2006-01-02T15:04"
|
layout := "2006-01-02T15:04"
|
||||||
|
if PickupDate != "" {
|
||||||
|
fmt.Println("no date selected")
|
||||||
|
return
|
||||||
|
}
|
||||||
dateParsed, err := time.Parse(layout, PickupDate)
|
dateParsed, err := time.Parse(layout, PickupDate)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
departuregeo *geojson.Feature
|
departuregeo *geojson.Feature
|
||||||
destinationgeo *geojson.Feature
|
destinationgeo *geojson.Feature
|
||||||
|
@ -63,7 +74,7 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request := &solidarity_service.DriverJourneysRequest{
|
request := solidarity_service.DriverJourneysRequest{
|
||||||
DepartureDate: timestamp,
|
DepartureDate: timestamp,
|
||||||
Departure: &solidarity_service.Feature{
|
Departure: &solidarity_service.Feature{
|
||||||
Lat: departuregeo.Geometry.Point[0],
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
|
@ -72,8 +83,13 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
drivers, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), request)
|
drivers, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), &request)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||||
Booking : &solidarity_service.BookingSolidarityRequest {
|
Booking : &solidarity_service.BookingSolidarityRequest {
|
||||||
|
@ -94,30 +110,24 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &bookingData, accounts, cacheid)
|
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &bookingData, accounts, cacheid)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
h.Renderer.SolidarityService(w, r, accounts, cacheid)
|
h.Renderer.SolidarityService(w, r, accounts, cacheid)
|
||||||
}
|
}
|
||||||
// if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
|
|
||||||
// booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &bookingData)
|
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &bookingData)
|
||||||
|
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// fmt.Println(err)
|
fmt.Println(err)
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
// h.Renderer.SolidarityServiceBooking(w, r, booking )
|
h.Renderer.SolidarityServiceBooking(w, r, booking )
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue