add onglet beneficiaries_silvermobi
This commit is contained in:
parent
8f21248c29
commit
163ffefbfb
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
solidarity_service "git.coopgo.io/sbouaram/solidarity-service/servers/grpc/proto"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
geojson "github.com/paulmach/go.geojson"
|
geojson "github.com/paulmach/go.geojson"
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
@ -21,22 +22,11 @@ type Booking struct {
|
||||||
|
|
||||||
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
|
||||||
parcourmobAccounts, err := h.beneficiaries(r)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
cacheid := uuid.NewString()
|
|
||||||
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
|
||||||
|
|
||||||
|
|
||||||
if r.Method == "GET" && r.FormValue("date") != ""{
|
if r.Method == "GET" && r.FormValue("date") != ""{
|
||||||
|
|
||||||
DepartureAddress := r.FormValue("departure");
|
DepartureAddress := r.FormValue("departure");
|
||||||
DestinationAddress := r.FormValue("destination");
|
DestinationAddress := r.FormValue("destination");
|
||||||
PickupDate := r.FormValue("date");
|
PickupDate := r.FormValue("date");
|
||||||
PassengerId := r.FormValue("passenger_id")
|
|
||||||
|
|
||||||
layout := "2006-01-02T15:04"
|
layout := "2006-01-02T15:04"
|
||||||
|
|
||||||
|
@ -95,7 +85,6 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
BookingData.bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
BookingData.bookingData = solidarity_service.CreateBookingSolidarityRequest {
|
||||||
Booking : &solidarity_service.BookingSolidarityRequest {
|
Booking : &solidarity_service.BookingSolidarityRequest {
|
||||||
|
|
||||||
PassengerId: PassengerId,
|
|
||||||
DepartureAddress: &solidarity_service.Feature{
|
DepartureAddress: &solidarity_service.Feature{
|
||||||
Lat: departuregeo.Geometry.Point[0],
|
Lat: departuregeo.Geometry.Point[0],
|
||||||
Long: departuregeo.Geometry.Point[1],
|
Long: departuregeo.Geometry.Point[1],
|
||||||
|
@ -110,15 +99,18 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &BookingData.bookingData, accounts, parcourmobAccounts, cacheid)
|
h.Renderer.SolidarityServiceListAvailableDrivers(w, r, drivers, &BookingData.bookingData)
|
||||||
|
|
||||||
} else if r.Method == "POST" {
|
} else if r.Method == "POST" {
|
||||||
|
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
beneficiaryID := vars["id"]
|
||||||
|
|
||||||
driverId := r.FormValue("driver_id")
|
driverId := r.FormValue("driver_id")
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
|
|
||||||
|
|
||||||
BookingData.bookingData.Booking.DriverId = driverId
|
BookingData.bookingData.Booking.DriverId = driverId
|
||||||
|
BookingData.bookingData.Booking.PassengerId= beneficiaryID
|
||||||
BookingData.bookingData.Booking.Id = id
|
BookingData.bookingData.Booking.Id = id
|
||||||
|
|
||||||
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
booking, err := h.services.GRPC.SolidarityService.CreateBookingSolidarity(context.TODO(), &BookingData.bookingData)
|
||||||
|
@ -129,11 +121,26 @@ func (h *ApplicationHandler) DriversJourney(w http.ResponseWriter, r *http.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
h.Renderer.SolidarityServiceBooking(w, r, booking, accounts, parcourmobAccounts)
|
h.Renderer.SolidarityServiceBooking(w, r, booking)
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
h.Renderer.SolidarityService(w, r, accounts, parcourmobAccounts, cacheid)
|
h.Renderer.SolidarityService(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *ApplicationHandler) SolidarityService (w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
accounts, err := h.services.GRPC.SolidarityService.GetAllPassengers(context.TODO(), &emptypb.Empty{})
|
||||||
|
parcourmobAccounts, err := h.beneficiaries(r)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
cacheid := uuid.NewString()
|
||||||
|
h.cache.PutWithTTL(cacheid, accounts, 1*time.Hour)
|
||||||
|
|
||||||
|
|
||||||
|
h.Renderer.BeneficiariesSolidarity(w, r, accounts, parcourmobAccounts, cacheid)
|
||||||
}
|
}
|
3
main.go
3
main.go
|
@ -138,7 +138,8 @@ func main() {
|
||||||
/*********************** CODE GROUP **************************/
|
/*********************** CODE GROUP **************************/
|
||||||
|
|
||||||
//=================================silvermobi====================================
|
//=================================silvermobi====================================
|
||||||
application.HandleFunc("/solidarity_service/", applicationHandler.DriversJourney)
|
application.HandleFunc("/solidarity_service/", applicationHandler.SolidarityService)
|
||||||
|
application.HandleFunc("/solidarity_service/create/{id}", applicationHandler.DriversJourney)
|
||||||
|
|
||||||
appGroup := application.PathPrefix("/group_module").Subrouter()
|
appGroup := application.PathPrefix("/group_module").Subrouter()
|
||||||
appGroup.HandleFunc("/", applicationHandler.Groups)
|
appGroup.HandleFunc("/", applicationHandler.Groups)
|
||||||
|
|
|
@ -73,7 +73,14 @@ func (s SolidarityBookingsState) JSONWithLimits(a int, b int) template.JS {
|
||||||
return s.JSON()
|
return s.JSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
|
func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Request) {
|
||||||
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
|
|
||||||
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *Renderer) BeneficiariesSolidarity(w http.ResponseWriter, r *http.Request, accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
state.ViewState = BeneficiariesSolidarityListState{
|
state.ViewState = BeneficiariesSolidarityListState{
|
||||||
|
@ -87,28 +94,21 @@ func (renderer *Renderer) SolidarityService(w http.ResponseWriter, r *http.Reque
|
||||||
renderer.Render("solidarity_service", w, r, files, state)
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, bookings *solidarity_service.CreateBookingSolidarityResponse,accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account) {
|
func (renderer *Renderer) SolidarityServiceBooking(w http.ResponseWriter, r *http.Request, bookings *solidarity_service.CreateBookingSolidarityResponse) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
state.ViewState = SolidarityBookingsState{
|
state.ViewState = SolidarityBookingsState{
|
||||||
Bookings: bookings,
|
Bookings: bookings,
|
||||||
Beneficiaries: parcourmobAccounts,
|
|
||||||
BeneficiariesSolidarity: accounts,
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("solidarity_service", w, r, files, state)
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, booking *solidarity_service.CreateBookingSolidarityRequest,accounts *solidarity_service.GetAllPassengersResponse, parcourmobAccounts []mobilityaccountsstorage.Account, cacheid string) {
|
func (renderer *Renderer) SolidarityServiceListAvailableDrivers(w http.ResponseWriter, r *http.Request, drivers *solidarity_service.DriverJourneysResponse, booking *solidarity_service.CreateBookingSolidarityRequest) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.list.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.solidarity_service.create.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
state := NewState(r, renderer.ThemeConfig, solidarityserviceMenu)
|
||||||
state.ViewState = SolidarityListState {
|
state.ViewState = SolidarityListState {
|
||||||
Count: len(parcourmobAccounts),
|
|
||||||
CacheId: cacheid,
|
|
||||||
Drivers: drivers,
|
Drivers: drivers,
|
||||||
Beneficiaries: parcourmobAccounts,
|
|
||||||
BeneficiariesSolidarity: accounts,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("solidarity_service", w, r, files, state)
|
renderer.Render("solidarity_service", w, r, files, state)
|
||||||
|
|
Loading…
Reference in New Issue