diff --git a/cmd/web-app/handlers/api_geo.go b/cmd/web-app/handlers/api_geo.go
new file mode 100644
index 0000000..7efefdb
--- /dev/null
+++ b/cmd/web-app/handlers/api_geo.go
@@ -0,0 +1,52 @@
+package handlers
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "strings"
+
+ "geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
+ "github.com/jmoiron/sqlx"
+ "geeks-accelerator/oss/saas-starter-kit/internal/geonames"
+ "gopkg.in/DataDog/dd-trace-go.v1/contrib/go-redis/redis"
+)
+
+// Check provides support for orchestration geo endpoints.
+type Geo struct {
+ MasterDB *sqlx.DB
+ Redis *redis.Client
+}
+
+// RegionsAutocomplete...
+func (h *Geo) RegionsAutocomplete(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {
+
+ var filters []string
+ var args []interface{}
+
+ if qv := r.URL.Query().Get("postal_code"); qv != "" {
+ filters = append(filters,"postal_code like ?")
+ args = append(args, qv+"%")
+ }
+
+ if qv := r.URL.Query().Get("query"); qv != "" {
+ filters = append(filters,"(state_name like ? or state_code like ?)")
+ args = append(args, qv+"%", qv+"%")
+ }
+
+ where := strings.Join(filters, " AND ")
+
+ res, err := geonames.FindGeonameRegions(ctx, h.MasterDB, where, args)
+ if err != nil {
+ fmt.Printf("%+v", err)
+ return web.RespondJsonError(ctx, w, err)
+ }
+
+ var list []string
+ for _, c := range res {
+ list = append(list, c.Name)
+ }
+
+ return web.RespondJson(ctx, w, list, http.StatusOK)
+}
+
diff --git a/cmd/web-app/handlers/routes.go b/cmd/web-app/handlers/routes.go
index 3c9876e..17d8237 100644
--- a/cmd/web-app/handlers/routes.go
+++ b/cmd/web-app/handlers/routes.go
@@ -68,6 +68,14 @@ func APP(shutdown chan os.Signal, log *log.Logger, env webcontext.Env, staticDir
app.Handle("POST", "/signup", s.Step1)
app.Handle("GET", "/signup", s.Step1)
+ // Register geo
+ g := Geo{
+ MasterDB: masterDB,
+ Redis: redis,
+ }
+ // These routes are not authenticated
+ app.Handle("GET", "/geo/regions/autocomplete", g.RegionsAutocomplete)
+
// Register root
r := Root{
MasterDB: masterDB,
diff --git a/cmd/web-app/handlers/signup.go b/cmd/web-app/handlers/signup.go
index 802ff83..7dd078f 100644
--- a/cmd/web-app/handlers/signup.go
+++ b/cmd/web-app/handlers/signup.go
@@ -2,6 +2,7 @@ package handlers
import (
"context"
+ "geeks-accelerator/oss/saas-starter-kit/internal/geonames"
"net/http"
"time"
@@ -80,6 +81,14 @@ func (h *Signup) Step1(ctx context.Context, w http.ResponseWriter, r *http.Reque
// Redirect the user to the dashboard.
http.Redirect(w, r, "/", http.StatusFound)
+ return nil
+ }
+
+ data["geonameCountries"] = geonames.ValidGeonameCountries
+
+ data["countries"], err = geonames.FindCountries(ctx, h.MasterDB, "name", "")
+ if err != nil {
+ return err
}
return nil
diff --git a/cmd/web-app/templates/content/signup-step1.tmpl b/cmd/web-app/templates/content/signup-step1.tmpl
index 2f05cc4..ce2df6c 100644
--- a/cmd/web-app/templates/content/signup-step1.tmpl
+++ b/cmd/web-app/templates/content/signup-step1.tmpl
@@ -35,17 +35,21 @@
@@ -103,13 +107,71 @@
{{end}}
{{define "js"}}
+
+
diff --git a/cmd/web-app/templates/content/user-login.tmpl b/cmd/web-app/templates/content/user-login.tmpl
index fa8546f..ecfe5ac 100644
--- a/cmd/web-app/templates/content/user-login.tmpl
+++ b/cmd/web-app/templates/content/user-login.tmpl
@@ -31,8 +31,8 @@