diff --git a/internal/handler/space.go b/internal/handler/space.go index 865a691..9b81afb 100644 --- a/internal/handler/space.go +++ b/internal/handler/space.go @@ -115,5 +115,25 @@ func (h *spaceHandler) SpaceOverviewPage(w http.ResponseWriter, r *http.Request) return } - ui.Render(w, r, pages.SpaceOverview(space.Name)) + accounts, err := h.accountService.GetAccountsForSpace(spaceID) + if err != nil { + slog.Error("failed to fetch accounts for space", "error", err, "spaceID", spaceID) + ui.RenderError(w, r, "Failed to load accounts", http.StatusInternalServerError) + return + } + + accountCards := make([]blocks.AccountCardInfo, 0, len(accounts)) + for _, a := range accounts { + accountCards = append(accountCards, blocks.AccountCardInfo{ + ID: a.ID, + Name: a.Name, + Balance: a.Balance, + }) + } + + ui.Render(w, r, pages.SpaceOverview(pages.SpaceOverviewProps{ + SpaceID: space.ID, + SpaceName: space.Name, + Accounts: accountCards, + })) } diff --git a/internal/ui/blocks/account_card.templ b/internal/ui/blocks/account_card.templ new file mode 100644 index 0000000..c9a8ca3 --- /dev/null +++ b/internal/ui/blocks/account_card.templ @@ -0,0 +1,32 @@ +package blocks + +import "github.com/shopspring/decimal" +import "strings" +import "git.juancwu.dev/juancwu/budgit/internal/ui/components/icon" + +type AccountCardInfo struct { + ID string + Name string + Balance decimal.Decimal +} + +templ AccountCard(info AccountCardInfo) { +
+} diff --git a/internal/ui/layouts/app.templ b/internal/ui/layouts/app.templ index 544625b..95c5173 100644 --- a/internal/ui/layouts/app.templ +++ b/internal/ui/layouts/app.templ @@ -3,6 +3,7 @@ package layouts import ( "git.juancwu.dev/juancwu/budgit/internal/ctxkeys" "git.juancwu.dev/juancwu/budgit/internal/model" + "git.juancwu.dev/juancwu/budgit/internal/routeurl" "git.juancwu.dev/juancwu/budgit/internal/ui/blocks" "git.juancwu.dev/juancwu/budgit/internal/ui/components/avatar" "git.juancwu.dev/juancwu/budgit/internal/ui/components/breadcrumb" @@ -11,10 +12,9 @@ import ( "git.juancwu.dev/juancwu/budgit/internal/ui/components/icon" "git.juancwu.dev/juancwu/budgit/internal/ui/components/sidebar" "strings" - "git.juancwu.dev/juancwu/budgit/internal/routeurl" ) -templ App(title string) { +templ App(title string, sidebarContent ...templ.Component) { {{ cfg := ctxkeys.Config(ctx) }} @Base(SEOProps{ Title: title, @@ -41,32 +41,8 @@ templ App(title string) { } } @sidebar.Content() { - @sidebar.Group() { - @sidebar.GroupLabel() { - Overview - } - @sidebar.Menu() { - @sidebar.MenuItem() { - @sidebar.MenuButton(sidebar.MenuButtonProps{ - Href: routeurl.URL("page.app.spaces"), - IsActive: ctxkeys.URLPath(ctx) == routeurl.URL("page.app.spaces"), - Tooltip: "My spaces", - }) { - @icon.User() - My spaces - } - } - @sidebar.MenuItem() { - @sidebar.MenuButton(sidebar.MenuButtonProps{ - Href: routeurl.URL("page.app.shared-with-me"), - IsActive: ctxkeys.URLPath(ctx) == routeurl.URL("page.app.shared-with-me"), - Tooltip: "Shared with me", - }) { - @icon.Users() - Shared with me - } - } - } + for _, content := range sidebarContent { + @content } } @sidebar.Footer() { diff --git a/internal/ui/pages/page_app_spaces_space_overview.templ b/internal/ui/pages/page_app_spaces_space_overview.templ deleted file mode 100644 index 05a9154..0000000 --- a/internal/ui/pages/page_app_spaces_space_overview.templ +++ /dev/null @@ -1,9 +0,0 @@ -package pages - -import "git.juancwu.dev/juancwu/budgit/internal/ui/layouts" - -templ SpaceOverview(spaceName string) { - @layouts.App("Space Overview") { -Space overview
+No accounts yet.
+ } else { +