feat: replace overview with reports page
This commit is contained in:
parent
e5941e1329
commit
a7d5f21fe8
5 changed files with 12 additions and 200 deletions
|
|
@ -22,19 +22,10 @@ type AddExpenseFormProps struct {
|
|||
ListsWithItems []model.ListWithUncheckedItems
|
||||
PaymentMethods []*model.PaymentMethod
|
||||
DialogID string // which dialog to close on success
|
||||
FromOverview bool // if true, POSTs with ?from=overview; server redirects to expenses page
|
||||
}
|
||||
|
||||
func (p AddExpenseFormProps) formAttrs() templ.Attributes {
|
||||
closeScript := "on htmx:afterOnLoad if event.detail.xhr.status == 200 then call window.tui.dialog.close('" + p.DialogID + "') then reset() me then show #item-selector-section end"
|
||||
if p.FromOverview {
|
||||
return templ.Attributes{
|
||||
"hx-post": "/app/spaces/" + p.Space.ID + "/expenses?from=overview",
|
||||
"hx-target": "body",
|
||||
"hx-swap": "beforeend",
|
||||
"_": closeScript,
|
||||
}
|
||||
}
|
||||
return templ.Attributes{
|
||||
"hx-post": "/app/spaces/" + p.Space.ID + "/expenses",
|
||||
"hx-target": "#expenses-list-wrapper",
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ templ Space(title string, space *model.Space) {
|
|||
@sidebar.MenuButton(sidebar.MenuButtonProps{
|
||||
Href: "/app/spaces/" + space.ID,
|
||||
IsActive: ctxkeys.URLPath(ctx) == "/app/spaces/"+space.ID,
|
||||
Tooltip: "Space Dashboard",
|
||||
Tooltip: "Reports",
|
||||
}) {
|
||||
@icon.House(icon.Props{Class: "size-4"})
|
||||
<span>Overview</span>
|
||||
@icon.ChartPie(icon.Props{Class: "size-4"})
|
||||
<span>Reports</span>
|
||||
}
|
||||
}
|
||||
@sidebar.MenuItem() {
|
||||
|
|
@ -80,16 +80,6 @@ templ Space(title string, space *model.Space) {
|
|||
<span>Budgets</span>
|
||||
}
|
||||
}
|
||||
@sidebar.MenuItem() {
|
||||
@sidebar.MenuButton(sidebar.MenuButtonProps{
|
||||
Href: "/app/spaces/" + space.ID + "/reports",
|
||||
IsActive: ctxkeys.URLPath(ctx) == "/app/spaces/"+space.ID+"/reports",
|
||||
Tooltip: "Reports",
|
||||
}) {
|
||||
@icon.ChartPie(icon.Props{Class: "size-4"})
|
||||
<span>Reports</span>
|
||||
}
|
||||
}
|
||||
@sidebar.MenuItem() {
|
||||
@sidebar.MenuButton(sidebar.MenuButtonProps{
|
||||
Href: "/app/spaces/" + space.ID + "/accounts",
|
||||
|
|
|
|||
|
|
@ -1,119 +0,0 @@
|
|||
package pages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/model"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/badge"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/button"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/dialog"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/ui/components/expense"
|
||||
"git.juancwu.dev/juancwu/budgit/internal/ui/layouts"
|
||||
)
|
||||
|
||||
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">
|
||||
<h1 class="text-2xl font-bold">Welcome to { space.Name }!</h1>
|
||||
@dialog.Dialog(dialog.Props{ID: "add-expense-overview-dialog"}) {
|
||||
@dialog.Trigger() {
|
||||
@button.Button() {
|
||||
Add Expense
|
||||
}
|
||||
}
|
||||
@dialog.Content() {
|
||||
@dialog.Header() {
|
||||
@dialog.Title() {
|
||||
Add Transaction
|
||||
}
|
||||
@dialog.Description() {
|
||||
Add a new expense or top-up to your space.
|
||||
}
|
||||
}
|
||||
@expense.AddExpenseForm(expense.AddExpenseFormProps{
|
||||
Space: space,
|
||||
Tags: tags,
|
||||
ListsWithItems: listsWithItems,
|
||||
DialogID: "add-expense-overview-dialog",
|
||||
FromOverview: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
// Shopping Lists section
|
||||
<div class="border rounded-lg p-4">
|
||||
<h2 class="text-lg font-semibold mb-2">Shopping Lists</h2>
|
||||
if len(lists) > 0 {
|
||||
<ul class="space-y-1">
|
||||
for i, list := range lists {
|
||||
if i < 5 {
|
||||
<li>
|
||||
<a
|
||||
href={ templ.URL("/app/spaces/" + space.ID + "/lists/" + list.ID) }
|
||||
class="block px-3 py-2 rounded-md hover:bg-muted transition-colors text-sm"
|
||||
>
|
||||
{ list.Name }
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
<a
|
||||
href={ templ.URL("/app/spaces/" + space.ID + "/lists") }
|
||||
class="block text-sm text-muted-foreground hover:text-foreground transition-colors mt-2 px-3"
|
||||
>
|
||||
View all shopping lists
|
||||
</a>
|
||||
} else {
|
||||
<p class="text-sm text-muted-foreground">No shopping lists yet.</p>
|
||||
}
|
||||
</div>
|
||||
// Tags section
|
||||
<div class="border rounded-lg p-4">
|
||||
<h2 class="text-lg font-semibold mb-2">Tags</h2>
|
||||
if len(tags) > 0 {
|
||||
<div class="flex flex-wrap gap-2">
|
||||
for _, tag := range tags {
|
||||
@badge.Badge(badge.Props{Variant: badge.VariantSecondary}) {
|
||||
{ tag.Name }
|
||||
}
|
||||
}
|
||||
</div>
|
||||
} else {
|
||||
<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>
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue