add the logic to store adresse

This commit is contained in:
soukainna 2022-11-10 17:24:36 +01:00
parent 941a7ccc5e
commit 814a20c7e2
1 changed files with 13 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package application
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"sort" "sort"
@ -16,6 +17,8 @@ import (
"google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/structpb"
) )
var Addres any
type BeneficiariesGroupForm struct { type BeneficiariesGroupForm struct {
FirstName string `json:"first_name" validate:"required"` FirstName string `json:"first_name" validate:"required"`
LastName string `json:"last_name" validate:"required"` LastName string `json:"last_name" validate:"required"`
@ -61,6 +64,12 @@ func (h *ApplicationHandler) Groups(w http.ResponseWriter, r *http.Request) {
func (h *ApplicationHandler) CreateGroupModule(w http.ResponseWriter, r *http.Request) { func (h *ApplicationHandler) CreateGroupModule(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" { if r.Method == "POST" {
if r.PostFormValue("address") != "" {
var a any
json.Unmarshal([]byte(r.PostFormValue("address")), &a)
Addres = a
}
r.ParseForm() r.ParseForm()
if r.FormValue("name") == "" { if r.FormValue("name") == "" {
@ -79,8 +88,10 @@ func (h *ApplicationHandler) CreateGroupModule(w http.ResponseWriter, r *http.Re
groupid := uuid.NewString() groupid := uuid.NewString()
dataMap := map[string]any{ dataMap := map[string]any{
"name": r.FormValue("name"), "name": r.FormValue("name"),
"type": r.FormValue("type"), "type": r.FormValue("type"),
"description": r.FormValue("description"),
"address": Addres,
} }
data, err := structpb.NewValue(dataMap) data, err := structpb.NewValue(dataMap)
@ -149,7 +160,6 @@ func (h *ApplicationHandler) DisplayGroupModule(w http.ResponseWriter, r *http.R
// if err != nil { // if err != nil {
// return err // return err
// } // }
for _, account := range ressp.Accounts { for _, account := range ressp.Accounts {
if filterAcccount(r, account) { if filterAcccount(r, account) {
a := account.ToStorageType() a := account.ToStorageType()