fix: expense edits does not update balance card
This commit is contained in:
parent
99a002c607
commit
948aa092ed
2 changed files with 17 additions and 2 deletions
|
|
@ -684,7 +684,12 @@ func (h *SpaceHandler) UpdateExpense(w http.ResponseWriter, r *http.Request) {
|
||||||
Tags: tagsMap[updatedExpense.ID],
|
Tags: tagsMap[updatedExpense.ID],
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Render(w, r, pages.ExpenseListItem(spaceID, expWithTags))
|
balance, err := h.expenseService.GetBalanceForSpace(spaceID)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("failed to get balance after update", "error", err, "space_id", spaceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.Render(w, r, pages.ExpenseUpdatedResponse(spaceID, expWithTags, balance))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *SpaceHandler) DeleteExpense(w http.ResponseWriter, r *http.Request) {
|
func (h *SpaceHandler) DeleteExpense(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
@ -701,7 +706,12 @@ func (h *SpaceHandler) DeleteExpense(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
balance, err := h.expenseService.GetBalanceForSpace(spaceID)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("failed to get balance after delete", "error", err, "space_id", spaceID)
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.Render(w, r, expense.BalanceCard(spaceID, balance, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *SpaceHandler) CreateInvite(w http.ResponseWriter, r *http.Request) {
|
func (h *SpaceHandler) CreateInvite(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
||||||
|
|
@ -149,3 +149,8 @@ templ ExpenseCreatedResponse(spaceID string, newExpense *model.ExpenseWithTags,
|
||||||
@ExpenseListItem(spaceID, newExpense)
|
@ExpenseListItem(spaceID, newExpense)
|
||||||
@expense.BalanceCard(newExpense.SpaceID, balance, true)
|
@expense.BalanceCard(newExpense.SpaceID, balance, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templ ExpenseUpdatedResponse(spaceID string, exp *model.ExpenseWithTags, balance int) {
|
||||||
|
@ExpenseListItem(spaceID, exp)
|
||||||
|
@expense.BalanceCard(exp.SpaceID, balance, true)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue