Extract getImportantData to own file
This commit is contained in:
@ -10,11 +10,12 @@ import (
|
||||
)
|
||||
|
||||
type BudgetData struct {
|
||||
Budget *postgres.Budget
|
||||
AlwaysNeededData
|
||||
Transactions []postgres.GetTransactionsForBudgetRow
|
||||
}
|
||||
|
||||
func (h *Handler) budget(c *gin.Context) {
|
||||
base := c.MustGet("data").(AlwaysNeededData)
|
||||
budgetID := c.Param("budgetid")
|
||||
budgetUUID, err := uuid.Parse(budgetID)
|
||||
if err != nil {
|
||||
@ -22,12 +23,6 @@ func (h *Handler) budget(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
budget, err := h.Service.DB.GetBudget(context.Background(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
}
|
||||
|
||||
transactions, err := h.Service.DB.GetTransactionsForBudget(context.Background(), budgetUUID)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
@ -35,8 +30,8 @@ func (h *Handler) budget(c *gin.Context) {
|
||||
}
|
||||
|
||||
d := BudgetData{
|
||||
Budget: &budget,
|
||||
Transactions: transactions,
|
||||
base,
|
||||
transactions,
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "budget.html", d)
|
||||
|
Reference in New Issue
Block a user