create booking done
This commit is contained in:
@@ -28,6 +28,8 @@ import (
|
||||
"git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||
mobilityaccounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
|
||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/mux"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
@@ -324,11 +326,26 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||
for _, o := range groupsresp.Groups {
|
||||
organizations = append(organizations, o.ToStorageType())
|
||||
}
|
||||
|
||||
|
||||
solidarity_booking := &solidarity_service.GetBookingsByStatusRequest{
|
||||
Status : 0, /// 0 : pending
|
||||
UserId : beneficiaryID,
|
||||
Type: 1, /// 1 : passenger
|
||||
}
|
||||
|
||||
solidarity_bookings_list, err := h.services.GRPC.SolidarityService.GetBookingsByStatus(context.TODO(), solidarity_booking)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
beneficiaries_file_types := h.config.GetStringSlice("modules.beneficiaries.documents_types")
|
||||
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||
|
||||
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list)
|
||||
h.Renderer.BeneficiaryDisplay(w, r, resp.Account.ToStorageType(), bookings, organizations, beneficiaries_file_types, file_types_map, documents, events_list, solidarity_bookings_list)
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) BeneficiaryUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -9,12 +9,26 @@ import (
|
||||
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||
"github.com/google/uuid"
|
||||
geojson "github.com/paulmach/go.geojson"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
var BookingData Booking
|
||||
|
||||
type Booking struct {
|
||||
bookingData solidarity_service.CreateBookingSolidarityRequest
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
accounts, err := h.beneficiaries(r)
|
||||
parcourmobAccounts, err := h.beneficiaries(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@@ -23,22 +37,18 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
cacheid := uuid.NewString()
|
||||
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||
h.cache.PutWithTTL(cacheid, parcourmobAccounts, 1*time.Hour)
|
||||
|
||||
bookingData := solidarity_service.CreateBookingSolidarityRequest {
|
||||
}
|
||||
|
||||
if r.Method != "GET" {
|
||||
if r.Method == "GET" && r.FormValue("date") != ""{
|
||||
|
||||
DepartureAddress := r.FormValue("departure");
|
||||
DestinationAddress := r.FormValue("destination");
|
||||
PickupDate := r.FormValue("date");
|
||||
|
||||
PassengerId := r.FormValue("passenger_id")
|
||||
|
||||
layout := "2006-01-02T15:04"
|
||||
if PickupDate != "" {
|
||||
fmt.Println("no date selected")
|
||||
return
|
||||
}
|
||||
|
||||
dateParsed, err := time.Parse(layout, PickupDate)
|
||||
|
||||
if err != nil {
|
||||
@@ -91,11 +101,10 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||
return
|
||||
}
|
||||
|
||||
bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||
BookingData.bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||
Booking : &solidarity_service.BookingSolidarityRequest {
|
||||
|
||||
PassengerId: r.FormValue("passenger_id"),
|
||||
DriverId: r.FormValue("driver_id"),
|
||||
PassengerId: PassengerId,
|
||||
DepartureAddress: &solidarity_service.Feature{
|
||||
Lat: departuregeo.Geometry.Point[0],
|
||||
Long: departuregeo.Geometry.Point[1],
|
||||
@@ -110,15 +119,22 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||
},
|
||||
}
|
||||
|
||||
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &bookingData, accounts, cacheid)
|
||||
fmt.Println(BookingData.bookingData, "booking")
|
||||
|
||||
} else {
|
||||
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &BookingData.bookingData, accounts, parcourmobAccounts, cacheid)
|
||||
|
||||
h.Renderer.SolidarityService(w, r, accounts, cacheid)
|
||||
}
|
||||
if r.Method == "POST" {
|
||||
} else if r.Method == "POST" {
|
||||
|
||||
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &bookingData)
|
||||
driverId := r.FormValue("driver_id")
|
||||
id := uuid.New().String()
|
||||
|
||||
|
||||
BookingData.bookingData.Booking.DriverId = driverId
|
||||
BookingData.bookingData.Booking.Id = id
|
||||
|
||||
fmt.Println(BookingData.bookingData, "booking")
|
||||
|
||||
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
@@ -126,8 +142,11 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||
return
|
||||
}
|
||||
|
||||
h.Renderer.SolidarityServiceBooking(w, r, booking )
|
||||
h.Renderer.SolidarityServiceBooking(w, r, booking, parcourmobAccounts)
|
||||
|
||||
}else {
|
||||
|
||||
h.Renderer.SolidarityService(w, r, accounts, parcourmobAccounts, cacheid)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user