set driver availabilities
This commit is contained in:
parent
7a648ccd1b
commit
3ad5711ae7
|
@ -2,6 +2,7 @@ package application
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -177,7 +178,6 @@ func (h *ApplicationHandler) CreateDriver (w http.ResponseWriter, r *http.Reques
|
|||
|
||||
resp, err := h.services.GRPC.MobilityAccounts.Register(context.TODO(), userRequest)
|
||||
|
||||
fmt.Println("resp : ", resp)
|
||||
address := resp.Account.Data.GetFields()["address"].GetStructValue();
|
||||
geometry := address.GetFields()["geometry"].GetStructValue();
|
||||
coordinates:= geometry.GetFields()["coordinates"].GetListValue();
|
||||
|
@ -192,6 +192,15 @@ func (h *ApplicationHandler) CreateDriver (w http.ResponseWriter, r *http.Reques
|
|||
radius = 0
|
||||
}
|
||||
|
||||
availabilitiesJSON := r.PostFormValue("availabilities")
|
||||
|
||||
var availabilities []solidarity_service.RegularAvailabilitySlot
|
||||
|
||||
jsonerr:= json.Unmarshal([]byte(availabilitiesJSON), &availabilities)
|
||||
if jsonerr != nil {
|
||||
fmt.Printf("Erreur lors de la conversion de availabilitiesJSON : %v", err)
|
||||
}
|
||||
|
||||
driverRequest := solidarity_service.DriverRegularAvailabilities {
|
||||
DriverRequest : &solidarity_service.DriverRequest {
|
||||
DriverAddress: &solidarity_service.Feature{
|
||||
|
@ -222,13 +231,15 @@ func (h *ApplicationHandler) CreateDriver (w http.ResponseWriter, r *http.Reques
|
|||
Brand: r.PostFormValue("brand"),
|
||||
},
|
||||
},
|
||||
DriverAvailabilities: []*solidarity_service.RegularAvailabilitySlot{
|
||||
{
|
||||
DayOfWeek: 4,
|
||||
StartTime: "10H00",
|
||||
EndTime: "11H00",
|
||||
},
|
||||
},
|
||||
DriverAvailabilities: []*solidarity_service.RegularAvailabilitySlot{},
|
||||
}
|
||||
|
||||
for _, slot := range availabilities{
|
||||
driverRequest.DriverAvailabilities = append( driverRequest.DriverAvailabilities, &solidarity_service.RegularAvailabilitySlot{
|
||||
DayOfWeek: slot.DayOfWeek,
|
||||
StartTime: slot.StartTime,
|
||||
EndTime: slot.EndTime,
|
||||
})
|
||||
}
|
||||
|
||||
driverResponse, err := h.services.GRPC.SolidarityService.SetDriverRegularAvailabilities(context.TODO(), &driverRequest)
|
||||
|
|
Loading…
Reference in New Issue