From 084f6e3930ceb576698999ffa3e1f120b8cc75d5 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 15 May 2026 22:00:54 -0500 Subject: [PATCH] up --- migrations/migrate.go | 1 + resources/views/layouts/portal.html | 77 +++++++++++++++++++++++++-- resources/views/partials/header.html | 75 -------------------------- rest/controllers/portal_controller.go | 39 ++++++++++++++ rest/routes/portal.go | 5 ++ 5 files changed, 118 insertions(+), 79 deletions(-) diff --git a/migrations/migrate.go b/migrations/migrate.go index 992cf29..ee51a28 100755 --- a/migrations/migrate.go +++ b/migrations/migrate.go @@ -813,6 +813,7 @@ func SeedPortalClientes() { {"Facturas", "GestiΓ³n de facturas y pagos por cliente", "/app/facturas"}, {"Portal Usuarios", "Usuarios con acceso al portal de clientes", "/app/portal-usuarios"}, {"Tickets", "Tickets de soporte abiertos por clientes del portal", "/app/tickets"}, + {"Config. Notificaciones", "Configurar canales de notificaciΓ³n por evento", "/app/notif-config"}, } var insertados []models.Submodules diff --git a/resources/views/layouts/portal.html b/resources/views/layouts/portal.html index 7a6e2db..2437d40 100644 --- a/resources/views/layouts/portal.html +++ b/resources/views/layouts/portal.html @@ -20,15 +20,84 @@ -
+
- U + U Portal de Clientes - -
+ +
+ +
+ + +
+
+ Notificaciones + +
+
+ + +
+
+
+ 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 @@
- - -
- -
- - -
- - -
- - - - -
- - - - -
-
-
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) }