- U
+ U
Portal de Clientes
-
-
+
+
+
+
+
+
+
+
+ Notificaciones
+
+
+
+
+ Sin notificaciones
+
+
+
+
+
+
+
+
+
+
+
+
{{ if .portalUser }}{{ .portalUser.Nombre }}{{ end }}
diff --git a/resources/views/partials/header.html b/resources/views/partials/header.html
index ffa77bc..6733770 100755
--- a/resources/views/partials/header.html
+++ b/resources/views/partials/header.html
@@ -155,78 +155,3 @@
-
-
-
-
-
-
-
-
-
Panel de control
-
-
-
-
-
-
diff --git a/rest/controllers/portal_controller.go b/rest/controllers/portal_controller.go
index 0a3f852..3c3473d 100644
--- a/rest/controllers/portal_controller.go
+++ b/rest/controllers/portal_controller.go
@@ -335,3 +335,42 @@ func PortalDownloadFactura(c *fiber.Ctx) error {
c.Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, f.OriginalName))
return c.SendFile(clean)
}
+
+// βββ Notificaciones in-app del portal user ββββββββββββββββββββββββββββββββββββ
+
+func PortalGetNotifs(c *fiber.Ctx) error {
+ u := middlewares.PortalUserFromLocals(c)
+ if u == nil {
+ return c.Status(401).JSON(fiber.Map{"error": "no autenticado"})
+ }
+ soloNoLeidas := c.Query("no_leidas") == "1"
+ items, err := models.GetSistemaNotifs("portal_user", u.ID, soloNoLeidas)
+ if err != nil {
+ return c.Status(500).JSON(fiber.Map{"error": err.Error()})
+ }
+ count := models.CountUnreadNotifs("portal_user", u.ID)
+ return c.JSON(fiber.Map{"items": items, "unread": count})
+}
+
+func PortalMarcarNotifLeida(c *fiber.Ctx) error {
+ u := middlewares.PortalUserFromLocals(c)
+ if u == nil {
+ return c.Status(401).JSON(fiber.Map{"error": "no autenticado"})
+ }
+ id, _ := c.ParamsInt("id")
+ if err := models.MarcarNotifLeida(uint(id)); err != nil {
+ return c.Status(500).JSON(fiber.Map{"error": err.Error()})
+ }
+ return c.JSON(fiber.Map{"ok": true})
+}
+
+func PortalMarcarTodasLeidas(c *fiber.Ctx) error {
+ u := middlewares.PortalUserFromLocals(c)
+ if u == nil {
+ return c.Status(401).JSON(fiber.Map{"error": "no autenticado"})
+ }
+ if err := models.MarcarTodasLeidas("portal_user", u.ID); err != nil {
+ return c.Status(500).JSON(fiber.Map{"error": err.Error()})
+ }
+ return c.JSON(fiber.Map{"ok": true})
+}
diff --git a/rest/routes/portal.go b/rest/routes/portal.go
index 81829dc..4f4afac 100644
--- a/rest/routes/portal.go
+++ b/rest/routes/portal.go
@@ -29,4 +29,9 @@ func PortalRoutes(app fiber.Router) {
// Descargas
portal.Get("/entregables/:id/download", controllers.PortalDownloadEntregable)
portal.Get("/facturas/:id/download", controllers.PortalDownloadFactura)
+
+ // Notificaciones in-app del portal user
+ portal.Get("/mis-notifs", controllers.PortalGetNotifs)
+ portal.Put("/mis-notifs/:id/leida", controllers.PortalMarcarNotifLeida)
+ portal.Post("/mis-notifs/marcar-todas", controllers.PortalMarcarTodasLeidas)
}