Add page for showing notifications
This commit is contained in:
parent
c3e8bba822
commit
396cf5c586
6 changed files with 128 additions and 3 deletions
42
sync/notification.go
Normal file
42
sync/notification.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package sync
|
||||
|
||||
import (
|
||||
//"context"
|
||||
//"fmt"
|
||||
"net/http"
|
||||
//"strings"
|
||||
//"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/notification"
|
||||
//"github.com/Gleipnir-Technology/bob"
|
||||
//"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
//"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/db/sql"
|
||||
//"github.com/google/uuid"
|
||||
//"github.com/uber/h3-go/v4"
|
||||
)
|
||||
|
||||
type contentNotificationList struct {
|
||||
Notifications []notification.Notification
|
||||
User User
|
||||
}
|
||||
|
||||
func getNotificationList(w http.ResponseWriter, r *http.Request, u *models.User) {
|
||||
userContent, err := contentForUser(r.Context(), u)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get user", err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
ctx := r.Context()
|
||||
notifications, err := notification.ForUser(ctx, u)
|
||||
if err != nil {
|
||||
respondError(w, "Failed to get notifications", err, http.StatusInternalServerError)
|
||||
}
|
||||
html.RenderOrError(w, "sync/notification-list.html", &contentNotificationList{
|
||||
Notifications: notifications,
|
||||
User: userContent,
|
||||
})
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ func Router() chi.Router {
|
|||
r.Get("/arcgis/oauth/callback", getArcgisOauthCallback)
|
||||
r.Get("/district", getDistrict)
|
||||
|
||||
// Mock endpoints
|
||||
r.Get("/mock", renderMock("mock-root.html"))
|
||||
r.Get("/mock/admin", renderMock("admin.html"))
|
||||
r.Get("/mock/admin/service-request", renderMock("admin-service-request.html"))
|
||||
|
|
@ -46,10 +47,9 @@ func Router() chi.Router {
|
|||
r.Get("/mock/setting/user", renderMock("setting-user.html"))
|
||||
r.Get("/mock/setting/user/add", renderMock("setting-user-add.html"))
|
||||
|
||||
// Utility endpoints
|
||||
r.Get("/oauth/refresh", getOAuthRefresh)
|
||||
|
||||
r.Get("/privacy", getPrivacy)
|
||||
|
||||
r.Get("/qr-code/report/{code}", getQRCodeReport)
|
||||
r.Get("/signin", getSignin)
|
||||
r.Post("/signin", postSignin)
|
||||
|
|
@ -61,6 +61,7 @@ func Router() chi.Router {
|
|||
r.Route("/api", api.AddRoutes)
|
||||
r.Method("GET", "/cell/{cell}", auth.NewEnsureAuth(getCellDetails))
|
||||
r.Method("GET", "/layout-test", auth.NewEnsureAuth(getLayoutTest))
|
||||
r.Method("GET", "/notification", auth.NewEnsureAuth(getNotificationList))
|
||||
r.Method("GET", "/pool", auth.NewEnsureAuth(getPoolList))
|
||||
r.Method("GET", "/pool/upload", auth.NewEnsureAuth(getPoolUpload))
|
||||
r.Method("GET", "/pool/upload/{id}", auth.NewEnsureAuth(getPoolUploadByID))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue