createBooking

This commit is contained in:
2024-09-17 14:42:27 +02:00
parent 66c2c31090
commit 127a3c44bf
2 changed files with 23 additions and 42 deletions

View File

@@ -12,7 +12,6 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
accounts, err := h.beneficiaries(r)
@@ -25,7 +24,10 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
cacheid := uuid.NewString()
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
if r.Method == "POST" {
bookingData := solidarity_service.CreateBookingSolidarityRequest {
}
if r.Method == "GET" {
DepartureAddress := r.FormValue("departure");
DestinationAddress := r.FormValue("destination");
@@ -73,8 +75,11 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
drivers, err := h.services.GRPC.SolidarityService.DriverJourneys(context.TODO(), request)
booking := solidarity_service.BookingSolidarityRequest {
PassengerId: r.FormValue("account_id"),
bookingData = solidarity_service.CreateBookingSolidarityRequest {
Booking : &solidarity_service.BookingSolidarityRequest {
PassengerId: r.FormValue("passenger_id"),
DriverId: r.FormValue("driver_id"),
DepartureAddress: &solidarity_service.Feature{
Lat: departuregeo.Geometry.Point[0],
Long: departuregeo.Geometry.Point[1],
@@ -86,6 +91,7 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
Address: DepartureAddress,
},
PickupDate : timestamp,
},
}
if err != nil {
@@ -94,49 +100,24 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
return
}
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, accounts, &booking, cacheid)
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, accounts, &bookingData, cacheid)
} else {
h.Renderer.SolidarityService(w, r, accounts, cacheid)
}
if r.Method == "POST" {
}
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &bookingData)
// func (h *ApplicationHandler) CreatePendingBooking(w http.ResponseWriter, r *http.Request) {
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
// if r.Method == "POST" {
h.Renderer.SolidarityServiceBooking(w, r, booking )
// formvalue := solidarity_service.BookingSolidarityRequest{
// PassengerId : "0",
// DriverId : "0",
// // Status : "0",
// DepartureAddress : booking.DepartureAddress,
// DestinationAddress : booking.DestinationAddress,
// PickupDate : booking.PickupDate,
// }
}
// request := &solidarity_service.BookingSolidarityRequest{
// // Id
// PassengerId : formvalue.PassengerId,
// DriverId : formvalue.DriverId,
// //Status : formvalue.Status,
// DepartureAddress : booking.DepartureAddress,
// DestinationAddress : booking.DestinationAddress,
// PickupDate : formvalue.PickupDate,
// }
// booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), request)
// if err != nil {
// fmt.Println(err)
// w.WriteHeader(http.StatusInternalServerError)
// return
// }
// h.Renderer.SolidarityServiceBooking(w, r , booking)
// }
// }
}