27 lines
505 B
Go
27 lines
505 B
Go
package http
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.javil.eu/jacob1123/budgeteer"
|
|
"git.javil.eu/jacob1123/budgeteer/postgres"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (h *Handler) dashboard(c *gin.Context) {
|
|
userID := c.MustGet("token").(budgeteer.Token).GetID()
|
|
budgets, err := h.Service.DB.GetBudgetsForUser(c.Request.Context(), userID)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
d := DashboardData{
|
|
Budgets: budgets,
|
|
}
|
|
c.HTML(http.StatusOK, "dashboard.html", d)
|
|
}
|
|
|
|
type DashboardData struct {
|
|
Budgets []postgres.Budget
|
|
}
|