add more information about beneficaire in groupCovoiturage
This commit is contained in:
@@ -24,16 +24,6 @@ import (
|
||||
var Depart any
|
||||
var Arrive any
|
||||
|
||||
// type Typep string
|
||||
|
||||
// const (
|
||||
// rec Typep = "rec"
|
||||
// pon Typep = "pon"
|
||||
// )
|
||||
|
||||
// var departdate string
|
||||
// var departTime string
|
||||
|
||||
func (h *ApplicationHandler) JourneysSearch(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
|
||||
@@ -224,16 +214,9 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
dstinationgeo *geojson.Feature
|
||||
)
|
||||
searched := false
|
||||
// var accounts = []any{}
|
||||
// cacheid := uuid.NewString()
|
||||
// accountsBeneficaire, err := h.beneficiaries(r)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// w.WriteHeader(http.StatusBadRequest)
|
||||
// return
|
||||
// }
|
||||
|
||||
if r.FormValue("beneficiaryid") != "" {
|
||||
// Handler form
|
||||
|
||||
searched = true
|
||||
|
||||
requestbeneficiary := &mobilityaccounts.GetAccountRequest{
|
||||
@@ -250,8 +233,6 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
beneficiary = respbeneficiary.Account.ToStorageType()
|
||||
|
||||
if r.Method == "POST" {
|
||||
fmt.Println("herrre")
|
||||
///////////////////////////////////////////
|
||||
departure := r.FormValue("departure")
|
||||
destination := r.FormValue("destination")
|
||||
|
||||
@@ -288,41 +269,20 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
r.ParseForm()
|
||||
|
||||
/////////////////
|
||||
// locTime, errTime := time.LoadLocation("Europe/Paris")
|
||||
// if errTime != nil {
|
||||
// fmt.Println("Loading timezone location Europe/Paris error : ")
|
||||
// fmt.Println("Missing zones in container ? ")
|
||||
// panic(errTime)
|
||||
// }
|
||||
|
||||
// departdate := r.FormValue("departuredate")
|
||||
// departTime := r.FormValue("departuretime")
|
||||
//departuredatetime, _ := time.ParseInLocation("2006-01-02 15:04", fmt.Sprintf("%s %s", departuredate, departuretime), locTime)
|
||||
|
||||
////////////////
|
||||
if r.FormValue("name") == "" {
|
||||
|
||||
fmt.Println("invalid name")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// if r.FormValue("driver") == "" {
|
||||
|
||||
// fmt.Println("invalid name")
|
||||
// w.WriteHeader(http.StatusBadRequest)
|
||||
// return
|
||||
// }
|
||||
if r.FormValue("number") == "" {
|
||||
|
||||
fmt.Println("invalid number of personne")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// planType := map[string]any{
|
||||
// "rrecurrent": r.FormValue("recurrent") == "on",
|
||||
// "pponctuelle": r.FormValue("ponctuelle") == "on",
|
||||
// }
|
||||
|
||||
planDays := map[string]any{
|
||||
"lundi": r.FormValue("lundi") == "on",
|
||||
"mardi": r.FormValue("mardi") == "on",
|
||||
@@ -332,10 +292,9 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
"samedi": r.FormValue("samedi") == "on",
|
||||
"dimanche": r.FormValue("dimanche") == "on",
|
||||
}
|
||||
// var rec bool = r.FormValue("recurrent")
|
||||
// var ponc bool
|
||||
|
||||
groupidd := uuid.NewString()
|
||||
fmt.Println("herrr&e")
|
||||
|
||||
dataMap := map[string]any{
|
||||
"name": r.FormValue("name"),
|
||||
"number": r.FormValue("number"),
|
||||
@@ -348,15 +307,12 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
"enddate": r.FormValue("enddate"),
|
||||
"departtime": r.FormValue("departtime"),
|
||||
"time": r.FormValue("time"),
|
||||
// "ponctdate": r.FormValue("ponctdate"),
|
||||
//"planType": planType,
|
||||
|
||||
"planDays": planDays,
|
||||
"recurrent": r.FormValue("recurrent"),
|
||||
"pontuelle": r.FormValue("ponctuelle"),
|
||||
// "r": rec,
|
||||
// "p": pon,
|
||||
}
|
||||
fmt.Println(dataMap["ponctuelle"])
|
||||
|
||||
data, err := structpb.NewValue(dataMap)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
@@ -378,25 +334,9 @@ func (h *ApplicationHandler) CreateGroup(w http.ResponseWriter, r *http.Request)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
// request_organizatio := &groupsmanagement.AddGroupMemberRequest{
|
||||
// Group: &groupsmanagement.GroupMember{
|
||||
// Id: groupidd,
|
||||
// //Namespace: "parcoursmob_groups_covoiturage",
|
||||
// Data: data.GetStructValue(),
|
||||
// },
|
||||
// }
|
||||
|
||||
// _, err = h.services.GRPC.GroupsManagement.AddGroupMember(context.TODO(), request_organizatio)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// w.WriteHeader(http.StatusInternalServerError)
|
||||
// return
|
||||
// }
|
||||
////////////////////////////////////////////////
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/journeys/groups_covoiturage/create/%s", request_organization.Group.ToStorageType().ID), http.StatusFound)
|
||||
|
||||
//http.Redirect(w, r, fmt.Print("/app/journeys"), http.StatusFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -433,9 +373,7 @@ func (h *ApplicationHandler) DisplayGroupCovoiturage(w http.ResponseWriter, r *h
|
||||
}
|
||||
|
||||
ressp, _ := h.services.GRPC.MobilityAccounts.GetAccountsBatch(context.TODO(), requesst)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
for _, account := range ressp.Accounts {
|
||||
if filterAcc(r, account) {
|
||||
a := account.ToStorageType()
|
||||
@@ -451,9 +389,8 @@ func (h *ApplicationHandler) DisplayGroupCovoiturage(w http.ResponseWriter, r *h
|
||||
|
||||
searched := false
|
||||
|
||||
// if r.Method == "POST" {
|
||||
if r.FormValue("beneficiaryid") != "" {
|
||||
// Handler form
|
||||
|
||||
searched = true
|
||||
|
||||
requestbeneficiary := &mobilityaccounts.GetAccountRequest{
|
||||
@@ -482,6 +419,50 @@ func (h *ApplicationHandler) DisplayGroupCovoiturage(w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if r.FormValue("departure") != "" {
|
||||
var a any
|
||||
json.Unmarshal([]byte(r.FormValue("departure")), &a)
|
||||
|
||||
Depart = a
|
||||
}
|
||||
if r.FormValue("destination") != "" {
|
||||
var a any
|
||||
json.Unmarshal([]byte(r.FormValue("destination")), &a)
|
||||
|
||||
Arrive = a
|
||||
}
|
||||
r.ParseForm()
|
||||
dataMap := map[string]any{
|
||||
|
||||
"depart": Depart,
|
||||
"arrive": Arrive,
|
||||
}
|
||||
|
||||
data, err := structpb.NewValue(dataMap)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
request_organizatio := &groupsmanagement.SubscribeMemberRequest{
|
||||
Group: &groupsmanagement.GroupMember{
|
||||
Memberid: respbeneficiary.Account.Id,
|
||||
Groupid: resp.Group.ToStorageType().ID,
|
||||
Data: data.GetStructValue(),
|
||||
},
|
||||
}
|
||||
|
||||
_, err = h.services.GRPC.GroupsManagement.SubscribeMember(context.TODO(), request_organizatio)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/journeys/groups_covoiturage/create/%s", resp.Group.ToStorageType().ID), http.StatusFound)
|
||||
return
|
||||
}
|
||||
@@ -493,6 +474,5 @@ func (h *ApplicationHandler) DisplayGroupCovoiturage(w http.ResponseWriter, r *h
|
||||
return
|
||||
}
|
||||
|
||||
//h.Renderer.BeneficaireSearch(w, r, accounts, searched, beneficiary, resp.Group.ToStorageType())
|
||||
h.Renderer.DisplayGroupCovoiturage(w, r, resp.Group.ToStorageType().ID, accounts, cacheid, searched, beneficiary, resp.Group.ToStorageType(), accountsBeneficaire)
|
||||
h.Renderer.DisplayGroupCovoiturage(w, r, resp.Group.ToStorageType().ID, Depart, Arrive, accounts, cacheid, searched, beneficiary, resp.Group.ToStorageType(), accountsBeneficaire)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user