Skip to content

Commit

Permalink
fix: notification array
Browse files Browse the repository at this point in the history
  • Loading branch information
Regikon committed Dec 21, 2024
1 parent 948344a commit a30a06f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
42 changes: 22 additions & 20 deletions src/application/components/notification_list/notification_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,30 @@ export class NotificationList extends Component {
const unreadNotifications = (this.props.notifications as Notification[]).filter(
(notification) => !notification.isRead,
);
const renderedNotifications = unreadNotifications.map((notification) => {
return (
<div
className="notification-list__notification"
onHover={() => {
const notificationManager = userStore.getData().notificationManager;
if (notificationManager) {
notificationManager.setNotificationRead(notification.id);
}
}}
>
<div className="notification-list__notification-text">
{notification.notificationText}
</div>
<div className="notification-list__createdAt">
{new Date(notification.createdAt).toLocaleDateString('ru-RU')}
</div>
</div>
);
});
return (
<div className={`${this.props.elementClass} notification-list`}>
{unreadNotifications.map((notification) => {
return (
<div
className="notification-list__notification"
onHover={() => {
const notificationManager = userStore.getData().notificationManager;
if (notificationManager) {
notificationManager.setNotificationRead(notification.id);
}
}}
>
<div className="notification-list__notification-text">
{notification.notificationText}
</div>
<div className="notification-list__createdAt">
{new Date(notification.createdAt).toLocaleDateString('ru-RU')}
</div>
</div>
);
}) && (
{...renderedNotifications}
{renderedNotifications.length === 0 && (
<div key="empty" className="notification-list__empty">
Новых уведомлений нет
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/application/stores/user_store/user_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function userStoreReducer(state: UserData, action: Action) {
const payload = action.payload as LoginActionPayload;
let manager: NotificationManager;
if (payload.userType === UserType.Employer) {
const manager = new NotificationManager(backendStore.getData().notificationsUrl.toString());
manager = new NotificationManager(backendStore.getData().notificationsUrl.toString());
manager.establishConnection();
}
return {
Expand Down

0 comments on commit a30a06f

Please sign in to comment.