feat(notificaciones): configuración de notificaciones por rol

- Nueva tabla tenant notification_role_preferences para guardar (email_type, role, enabled).
- Migración 051 aplicada a todos los tenants.
- Backend expone endpoint /notificaciones con matriz de preferencias por rol.
- Filtrado por rol en documento_subido, weekly_update, subscription_expiring,
  alertas_nuevas y recordatorio_proximo.
- Frontend rediseñado como tabla notificación × rol con toggles inmediatos.
This commit is contained in:
Horux Dev
2026-06-17 00:04:37 +00:00
parent 8a1fbceb38
commit b217342a96
8 changed files with 380 additions and 192 deletions

View File

@@ -0,0 +1,37 @@
CREATE TABLE IF NOT EXISTS notification_role_preferences (
id SERIAL PRIMARY KEY,
email_type VARCHAR(50) NOT NULL,
role VARCHAR(20) NOT NULL,
enabled BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
UNIQUE (email_type, role)
);
INSERT INTO notification_role_preferences (email_type, role, enabled)
VALUES
('documento_subido','owner',true),
('documento_subido','supervisor',true),
('documento_subido','auxiliar',true),
('documento_subido','cliente',true),
('weekly_update','owner',true),
('weekly_update','supervisor',true),
('weekly_update','auxiliar',true),
('weekly_update','cliente',true),
('subscription_expiring','owner',true),
('subscription_expiring','supervisor',true),
('subscription_expiring','auxiliar',true),
('subscription_expiring','cliente',true),
('recordatorio_fiscal','owner',true),
('recordatorio_fiscal','supervisor',true),
('recordatorio_fiscal','auxiliar',true),
('recordatorio_fiscal','cliente',true),
('alertas_nuevas','owner',true),
('alertas_nuevas','supervisor',true),
('alertas_nuevas','auxiliar',true),
('alertas_nuevas','cliente',true),
('recordatorio_proximo','owner',true),
('recordatorio_proximo','supervisor',true),
('recordatorio_proximo','auxiliar',true),
('recordatorio_proximo','cliente',true)
ON CONFLICT (email_type, role) DO NOTHING;