Split budget and dashboard routes into own files
This commit is contained in:
34
http/dashboard.go
Normal file
34
http/dashboard.go
Normal file
@ -0,0 +1,34 @@
|
||||
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) {
|
||||
token, err := h.verifyLogin(c)
|
||||
if err != nil {
|
||||
c.Redirect(http.StatusTemporaryRedirect, "/login")
|
||||
return
|
||||
}
|
||||
|
||||
userID := token.GetID()
|
||||
budgets, err := h.Service.BudgetsForUser(userID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
d := DashboardData{
|
||||
Token: token,
|
||||
Budgets: budgets,
|
||||
}
|
||||
c.HTML(http.StatusOK, "dashboard", d)
|
||||
}
|
||||
|
||||
type DashboardData struct {
|
||||
Token budgeteer.Token
|
||||
Budgets []postgres.Budget
|
||||
}
|
Reference in New Issue
Block a user