fix: remove balance from dashboard
This commit is contained in:
parent
e97e154b76
commit
ee64d5e456
2 changed files with 8 additions and 25 deletions
|
|
@ -32,17 +32,7 @@ func (h *dashboardHandler) DashboardPage(w http.ResponseWriter, r *http.Request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalBalance int
|
ui.Render(w, r, pages.Dashboard(spaces))
|
||||||
for _, space := range spaces {
|
|
||||||
balance, err := h.expenseService.GetBalanceForSpace(space.ID)
|
|
||||||
if err != nil {
|
|
||||||
slog.Error("failed to get balance for space", "error", err, "space_id", space.ID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
totalBalance += balance
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.Render(w, r, pages.Dashboard(spaces, totalBalance))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *dashboardHandler) CreateSpace(w http.ResponseWriter, r *http.Request) {
|
func (h *dashboardHandler) CreateSpace(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package pages
|
package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"git.juancwu.dev/juancwu/budgit/internal/model"
|
"git.juancwu.dev/juancwu/budgit/internal/model"
|
||||||
"git.juancwu.dev/juancwu/budgit/internal/ui/layouts"
|
"git.juancwu.dev/juancwu/budgit/internal/ui/layouts"
|
||||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/button"
|
"git.juancwu.dev/juancwu/budgit/internal/ui/components/button"
|
||||||
|
|
@ -13,7 +12,7 @@ import (
|
||||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/label"
|
"git.juancwu.dev/juancwu/budgit/internal/ui/components/label"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ Dashboard(spaces []*model.Space, totalBalance int) {
|
templ Dashboard(spaces []*model.Space) {
|
||||||
@layouts.App("Dashboard") {
|
@layouts.App("Dashboard") {
|
||||||
<div class="container max-w-7xl px-6 py-8">
|
<div class="container max-w-7xl px-6 py-8">
|
||||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
|
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
|
||||||
|
|
@ -23,20 +22,15 @@ templ Dashboard(spaces []*model.Space, totalBalance int) {
|
||||||
Welcome back! Here's an overview of your spaces.
|
Welcome back! Here's an overview of your spaces.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-card border rounded-lg p-4 shadow-sm min-w-[200px]">
|
|
||||||
<p class="text-sm font-medium text-muted-foreground">Total Balance</p>
|
|
||||||
<p class={ "text-2xl font-bold", templ.KV("text-destructive", totalBalance < 0) }>
|
|
||||||
{ fmt.Sprintf("$%.2f", float64(totalBalance)/100.0) }
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
for _, space := range spaces {
|
for _, space := range spaces {
|
||||||
<a href={ templ.SafeURL("/app/spaces/" + space.ID) } class="block hover:no-underline group">
|
<a href={ templ.SafeURL("/app/spaces/" + space.ID) } class="block hover:no-underline group">
|
||||||
@card.Card(card.Props{Class: "h-full transition-colors group-hover:border-primary"}) {
|
@card.Card(card.Props{Class: "h-full transition-colors group-hover:border-primary"}) {
|
||||||
@card.Header() {
|
@card.Header() {
|
||||||
@card.Title() { { space.Name } }
|
@card.Title() {
|
||||||
|
{ space.Name }
|
||||||
|
}
|
||||||
@card.Description() {
|
@card.Description() {
|
||||||
Manage expenses and shopping lists in this space.
|
Manage expenses and shopping lists in this space.
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +41,6 @@ templ Dashboard(spaces []*model.Space, totalBalance int) {
|
||||||
}
|
}
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option to create a new space
|
// Option to create a new space
|
||||||
@dialog.Dialog(dialog.Props{ID: "create-space-dialog"}) {
|
@dialog.Dialog(dialog.Props{ID: "create-space-dialog"}) {
|
||||||
@dialog.Trigger() {
|
@dialog.Trigger() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue