feat: show money accounts in overview page
All checks were successful
Deploy / build-and-deploy (push) Successful in 1m1s

This commit is contained in:
juancwu 2026-02-13 01:11:38 +00:00
commit 364f8dc682
2 changed files with 39 additions and 2 deletions

View file

@ -99,7 +99,14 @@ func (h *SpaceHandler) DashboardPage(w http.ResponseWriter, r *http.Request) {
return
}
ui.Render(w, r, pages.SpaceOverviewPage(space, lists, tags, listsWithItems))
accounts, err := h.accountService.GetAccountsForSpace(spaceID)
if err != nil {
slog.Error("failed to get accounts for space", "error", err, "space_id", spaceID)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
ui.Render(w, r, pages.SpaceOverviewPage(space, lists, tags, listsWithItems, accounts))
}
func (h *SpaceHandler) ListsPage(w http.ResponseWriter, r *http.Request) {

View file

@ -1,6 +1,7 @@
package pages
import (
"fmt"
"git.juancwu.dev/juancwu/budgit/internal/model"
"git.juancwu.dev/juancwu/budgit/internal/ui/components/button"
"git.juancwu.dev/juancwu/budgit/internal/ui/components/dialog"
@ -8,7 +9,7 @@ import (
"git.juancwu.dev/juancwu/budgit/internal/ui/layouts"
)
templ SpaceOverviewPage(space *model.Space, lists []*model.ShoppingList, tags []*model.Tag, listsWithItems []model.ListWithUncheckedItems) {
templ SpaceOverviewPage(space *model.Space, lists []*model.ShoppingList, tags []*model.Tag, listsWithItems []model.ListWithUncheckedItems, accounts []model.MoneyAccountWithBalance) {
@layouts.Space("Overview", space) {
<div class="space-y-4">
<div class="flex justify-between items-center">
@ -80,6 +81,35 @@ templ SpaceOverviewPage(space *model.Space, lists []*model.ShoppingList, tags []
<p class="text-sm text-muted-foreground">No tags yet.</p>
}
</div>
// Money Accounts section
<div class="border rounded-lg p-4">
<h2 class="text-lg font-semibold mb-2">Money Accounts</h2>
if len(accounts) > 0 {
<ul class="space-y-1">
for i, account := range accounts {
if i < 5 {
<li>
<a
href={ templ.URL("/app/spaces/" + space.ID + "/accounts") }
class="block px-3 py-2 rounded-md hover:bg-muted transition-colors text-sm flex justify-between"
>
<span>{ account.Name }</span>
<span class="text-muted-foreground">{ fmt.Sprintf("$%.2f", float64(account.BalanceCents)/100) }</span>
</a>
</li>
}
}
</ul>
<a
href={ templ.URL("/app/spaces/" + space.ID + "/accounts") }
class="block text-sm text-muted-foreground hover:text-foreground transition-colors mt-2 px-3"
>
View all accounts
</a>
} else {
<p class="text-sm text-muted-foreground">No accounts yet.</p>
}
</div>
</div>
</div>
}