Implement single account transaction-list
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user