feat: added notification system with toasts #160

This commit is contained in:
2024-09-11 15:04:40 +02:00
parent b7cda2db35
commit 0e186940cc
5 changed files with 62 additions and 3 deletions

28
service/index_and_404.go Normal file
View File

@@ -0,0 +1,28 @@
package service
import (
"database/sql"
"me-fit/template"
"me-fit/utils"
"net/http"
"github.com/a-h/templ"
)
func HandleIndexAnd404(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
user := utils.GetUserFromSession(db, r)
var comp templ.Component = nil
userComp := UserInfoComp(user)
if r.URL.Path != "/" {
comp = template.Layout(template.NotFound(), userComp)
w.WriteHeader(http.StatusNotFound)
} else {
comp = template.Layout(template.Index(), userComp)
}
comp.Render(r.Context(), w)
}
}