Implement single account transaction-list

This commit is contained in:
2021-12-02 21:44:35 +00:00
parent f2e8721aa8
commit 871b11bbcc
7 changed files with 56 additions and 48 deletions

View File

@ -8,7 +8,7 @@ import (
"github.com/google/uuid"
)
type AccountData struct {
type AccountsData struct {
Accounts []postgres.GetAccountsWithBalanceRow
}
@ -26,9 +26,42 @@ func (h *Handler) accounts(c *gin.Context) {
return
}
d := AccountData{
d := AccountsData{
Accounts: accounts,
}
c.HTML(http.StatusOK, "accounts.html", d)
}
type AccountData struct {
Account *postgres.Account
Transactions []postgres.Transaction
}
func (h *Handler) account(c *gin.Context) {
accountID := c.Param("accountid")
accountUUID, err := uuid.Parse(accountID)
if err != nil {
c.Redirect(http.StatusTemporaryRedirect, "/login")
return
}
account, err := h.Service.DB.GetAccount(c.Request.Context(), accountUUID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
return
}
transactions, err := h.Service.DB.GetTransactionsForAccount(c.Request.Context(), accountUUID)
if err != nil {
c.AbortWithError(http.StatusNotFound, err)
return
}
d := AccountData{
Account: &account,
Transactions: transactions,
}
c.HTML(http.StatusOK, "budget.html", d)
}