package handlers import ( "net/http" apidomain "git.jamestombleson.com/jtom38/newsbot-api/domain" "git.jamestombleson.com/jtom38/newsbot-portal/internal/models" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/articles" "github.com/labstack/echo/v4" ) func (h *Handler) ArticlesList(c echo.Context) error { err := HasValidScope(c, apidomain.ScopeArticleRead) if err != nil { return RenderError(c, err) } resp, err := h.api.Articles.List(GetJwtToken(c), 0) if err != nil { return RenderError(c, err) } vm := models.ListArticlesViewModel{} for _, article := range resp.Payload { source, err := h.api.Sources.GetById(GetJwtToken(c), article.SourceID) if err != nil { return RenderError(c, err) } item := models.ListArticleSourceModel{ Article: article, Source: source.Payload[0], } vm.Items = append(vm.Items, item) } return Render(c, http.StatusOK, articles.ListArticlesTable(vm)) }