createBooking
This commit is contained in:
		
							parent
							
								
									66c2c31090
								
							
						
					
					
						commit
						127a3c44bf
					
				| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			fmt.Println(err)
 | 
			
		||||
			w.WriteHeader(http.StatusInternalServerError)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		h.Renderer.SolidarityServiceBooking(w, r, booking )
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
// func (h *ApplicationHandler) CreatePendingBooking(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
 | 
			
		||||
// 	if r.Method == "POST"  {
 | 
			
		||||
 | 
			
		||||
// 		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)
 | 
			
		||||
 | 
			
		||||
// 	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Reque
 | 
			
		|||
	renderer.Render("solidarity_service", w, r, files, state)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, booking *solidarity_service.BookingSolidarityRequest) {
 | 
			
		||||
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, booking *solidarity_service.CreateBookingSolidarityResponse) {
 | 
			
		||||
	files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
 | 
			
		||||
	state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
 | 
			
		||||
	state.ViewState = map[string]any{
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *htt
 | 
			
		|||
	renderer.Render("solidarity_service", w, r, files, state)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(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, bookingData *solidarity_service.CreateBookingSolidarityRequest, cacheid string) {
 | 
			
		||||
	files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
 | 
			
		||||
	state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
 | 
			
		||||
	state.ViewState = SolidarityListState {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue