feat: agregar funcionalidad para marcar notificaciones como leídas y mejorar el diseño del pie de notificaciones

This commit is contained in:
2026-08-22 12:39:08 -03:00
parent 33743f12b9
commit f00e258819
2 changed files with 67 additions and 9 deletions
@@ -21,6 +21,7 @@ import {
} from "@core/Models/SystemNotifications.model"; } from "@core/Models/SystemNotifications.model";
import { import {
findSystemNotifications, findSystemNotifications,
setStateNotificationByUser,
updateSystemNotification, updateSystemNotification,
} from "@core/app/user/profile/notifications/Notifications.Service"; } from "@core/app/user/profile/notifications/Notifications.Service";
import { import {
@@ -214,6 +215,29 @@ export default function Header(): React.ReactElement {
goTo(NOTIFICATIONS_ROUTE); goTo(NOTIFICATIONS_ROUTE);
}; };
const markNotificationsAsRead = async () => {
if (!SessionInfo.userId || headerState.notificationsCount === 0) {
return;
}
try {
await setStateNotificationByUser({
state: true,
sessionUser: SessionInfo.userId,
});
setNotifications((currentNotifications) =>
currentNotifications.map((notification) => ({
...notification,
readed: true,
}))
);
headerState.setNotificationsCount(0);
} catch (error) {
console.error("Error marking notifications as read", error);
}
};
const openNotification = async (notification: ISystemNotification) => { const openNotification = async (notification: ISystemNotification) => {
setNotificationsOpen(false); setNotificationsOpen(false);
@@ -392,6 +416,15 @@ export default function Header(): React.ReactElement {
))} ))}
</div> </div>
<div className={style.notificationsFooterActions}>
<button
type="button"
className={style.notificationsFooter}
onClick={markNotificationsAsRead}
disabled={headerState.notificationsCount === 0}
>
Marcar como leídas
</button>
<button <button
type="button" type="button"
className={style.notificationsFooter} className={style.notificationsFooter}
@@ -400,6 +433,7 @@ export default function Header(): React.ReactElement {
Ver todas las notificaciones Ver todas las notificaciones
</button> </button>
</div> </div>
</div>
)} )}
</div> </div>
)} )}
@@ -185,11 +185,16 @@
font-weight: 600; font-weight: 600;
} }
.notificationsFooterActions {
display: flex;
border-top: 1px solid var(--gray-lighter);
background: var(--white);
}
.notificationsFooter { .notificationsFooter {
width: 100%; width: 100%;
padding: 14px 18px; padding: 14px 18px;
border: 0; border: 0;
border-top: 1px solid var(--gray-lighter);
background: var(--white); background: var(--white);
color: var(--wine-dark); color: var(--wine-dark);
cursor: pointer; cursor: pointer;
@@ -198,11 +203,21 @@
transition: background-color 0.18s ease, color 0.18s ease; transition: background-color 0.18s ease, color 0.18s ease;
} }
.notificationsFooter:hover { .notificationsFooter + .notificationsFooter {
border-left: 1px solid var(--gray-lighter);
}
.notificationsFooter:hover:not(:disabled) {
background: var(--wine-lighterX2); background: var(--wine-lighterX2);
color: var(--wine-darkest); color: var(--wine-darkest);
} }
.notificationsFooter:disabled {
color: var(--gray-dark);
cursor: default;
opacity: 0.65;
}
@media (max-width: 600px) { @media (max-width: 600px) {
.header { .header {
padding-left: 18px; padding-left: 18px;
@@ -212,4 +227,13 @@
.notificationsMenu { .notificationsMenu {
right: -48px; right: -48px;
} }
.notificationsFooterActions {
flex-direction: column;
}
.notificationsFooter + .notificationsFooter {
border-left: 0;
border-top: 1px solid var(--gray-lighter);
}
} }