From cdeb088a1307aaf69fea872155ab8e356f237aa1 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 8 Nov 2023 03:00:47 +0100 Subject: [PATCH] Show market list --- server/router/handler/index.go | 13 +++++++++++++ server/router/router.go | 2 +- vue/src/components/MarketList.vue | 29 +++++++++++++++++++++++++++++ vue/src/components/NavBar.vue | 15 --------------- vue/src/index.css | 17 ++++++++++++++++- vue/src/views/MarketView.vue | 7 ++++++- 6 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 vue/src/components/MarketList.vue diff --git a/server/router/handler/index.go b/server/router/handler/index.go index 2f641cb..e4acdd3 100644 --- a/server/router/handler/index.go +++ b/server/router/handler/index.go @@ -26,3 +26,16 @@ func HandleIndex(sc context.ServerContext) echo.HandlerFunc { return sc.Render(c, http.StatusOK, "index.html", data) } } + +func HandleMarkets(sc context.ServerContext) echo.HandlerFunc { + return func(c echo.Context) error { + var ( + markets []db.Market + err error + ) + if err = sc.Db.FetchActiveMarkets(&markets); err != nil { + return err + } + return c.JSON(http.StatusOK, markets) + } +} diff --git a/server/router/router.go b/server/router/router.go index 7c05b6f..589b791 100644 --- a/server/router/router.go +++ b/server/router/router.go @@ -24,7 +24,6 @@ func mountMiddleware(e *echo.Echo, sc ServerContext) { } func addFrontendRoutes(e *echo.Echo, sc ServerContext) { - GET(e, sc, "/", handler.HandleIndex) GET(e, sc, "/user", handler.HandleUser, middleware.SessionGuard) @@ -41,6 +40,7 @@ func addFrontendRoutes(e *echo.Echo, sc ServerContext) { } func addBackendRoutes(e *echo.Echo, sc ServerContext) { + GET(e, sc, "/api/markets", handler.HandleMarkets) GET(e, sc, "/api/login", handler.HandleLogin) GET(e, sc, "/api/login/callback", handler.HandleLoginCallback) POST(e, sc, "/api/logout", handler.HandleLogout) diff --git a/vue/src/components/MarketList.vue b/vue/src/components/MarketList.vue new file mode 100644 index 0000000..5808346 --- /dev/null +++ b/vue/src/components/MarketList.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/vue/src/components/NavBar.vue b/vue/src/components/NavBar.vue index b18dc7a..99011f4 100644 --- a/vue/src/components/NavBar.vue +++ b/vue/src/components/NavBar.vue @@ -20,21 +20,6 @@ nav { justify-content: center; } -a { - color: #8787a4; - text-decoration: underline; -} - -a:hover { - color: #ffffff; - background: #8787A4; -} - -a.selected { - color: #ffffff; - background: #8787A4; -} - nav>a { margin: 0 3px; } diff --git a/vue/src/index.css b/vue/src/index.css index 5c08f35..10a15e0 100644 --- a/vue/src/index.css +++ b/vue/src/index.css @@ -11,4 +11,19 @@ button { button:hover { color: #ffffff; background: #8787A4; -} \ No newline at end of file +} + +a { + color: #8787a4; + text-decoration: underline; +} + +a:hover { + color: #ffffff; + background: #8787A4; +} + +a.selected { + color: #ffffff; + background: #8787A4; +} diff --git a/vue/src/views/MarketView.vue b/vue/src/views/MarketView.vue index 24f2893..675f6fc 100644 --- a/vue/src/views/MarketView.vue +++ b/vue/src/views/MarketView.vue @@ -11,6 +11,11 @@ + + + - +