diff --git a/internal/handler/space.go b/internal/handler/space.go index 66bce3c..a40c178 100644 --- a/internal/handler/space.go +++ b/internal/handler/space.go @@ -401,18 +401,14 @@ func (h *SpaceHandler) CreateExpense(w http.ResponseWriter, r *http.Request) { newTag, err := h.tagService.CreateTag(spaceID, tagName, nil) if err != nil { slog.Error("failed to create new tag from expense form", "error", err, "tag_name", tagName) - // Continue processing other tags? Or fail? - // Let's continue, maybe the tag was invalid or duplicate race condition. - // If duplicate race condition, we could try fetching it again, but for now simple log. continue } finalTagIDs = append(finalTagIDs, newTag.ID) - existingTagsMap[tagName] = newTag.ID // Update map in case repeated in this request (though processedTags handles that) + existingTagsMap[tagName] = newTag.ID } processedTags[tagName] = true } - // --- DTO Creation & Service Call --- dto := service.CreateExpenseDTO{ SpaceID: spaceID, UserID: user.ID, @@ -434,8 +430,6 @@ func (h *SpaceHandler) CreateExpense(w http.ResponseWriter, r *http.Request) { balance, err := h.expenseService.GetBalanceForSpace(spaceID) if err != nil { slog.Error("failed to get balance", "error", err, "space_id", spaceID) - // Fallback: return just the item if balance fails, but ideally we want both. - // For now we will just log and continue, potentially showing stale balance. } ui.Render(w, r, pages.ExpenseCreatedResponse(newExpense, balance)) diff --git a/internal/ui/components/expense/expense.templ b/internal/ui/components/expense/expense.templ index ea84858..f47f7ec 100644 --- a/internal/ui/components/expense/expense.templ +++ b/internal/ui/components/expense/expense.templ @@ -86,10 +86,12 @@ templ BalanceCard(spaceID string, balance int, oob bool) {

Current Balance

diff --git a/internal/ui/pages/app_space_expenses.templ b/internal/ui/pages/app_space_expenses.templ index 66133bb..81137ce 100644 --- a/internal/ui/pages/app_space_expenses.templ +++ b/internal/ui/pages/app_space_expenses.templ @@ -14,7 +14,7 @@ templ SpaceExpensesPage(space *model.Space, expenses []*model.Expense, balance i

Expenses

- @dialog.Dialog(dialog.Props{ ID: "add-expense-dialog" }) { + @dialog.Dialog(dialog.Props{ID: "add-expense-dialog"}) { @dialog.Trigger() { @button.Button() { Add Expense @@ -22,7 +22,9 @@ templ SpaceExpensesPage(space *model.Space, expenses []*model.Expense, balance i } @dialog.Content() { @dialog.Header() { - @dialog.Title() { Add Transaction } + @dialog.Title() { + Add Transaction + } @dialog.Description() { Add a new expense or top-up to your space. } @@ -31,10 +33,8 @@ templ SpaceExpensesPage(space *model.Space, expenses []*model.Expense, balance i } }
- // Balance Card @expense.BalanceCard(space.ID, balance, false) - // List of expenses