mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
notifications: for nodes
This commit is contained in:
parent
14bf5be65f
commit
d9544e917b
13 changed files with 156 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
|||
import { FC, useEffect } from 'react';
|
||||
import { FC, useCallback, useEffect } from 'react';
|
||||
|
||||
import classNames from 'classnames';
|
||||
|
||||
|
@ -6,7 +6,9 @@ import { Button } from '~/components/input/Button';
|
|||
import { InputRow } from '~/components/input/InputRow';
|
||||
import { LoaderScreen } from '~/components/input/LoaderScreen';
|
||||
import { NotificationComment } from '~/components/notifications/NotificationComment';
|
||||
import { NotificationNode } from '~/components/notifications/NotificationNode';
|
||||
import { useNotificationsList } from '~/hooks/notifications/useNotificationsList';
|
||||
import { NotificationItem, NotificationType } from '~/types/notifications';
|
||||
import { useNotifications } from '~/utils/providers/NotificationProvider';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
@ -22,6 +24,17 @@ const NotificationList: FC<NotificationListProps> = () => {
|
|||
return () => markAsRead();
|
||||
}, []);
|
||||
|
||||
const renderItem = useCallback((item: NotificationItem) => {
|
||||
switch (item.type) {
|
||||
case NotificationType.Comment:
|
||||
return <NotificationComment item={item} />;
|
||||
case NotificationType.Node:
|
||||
return <NotificationNode item={item} />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (isLoading) {
|
||||
return <LoaderScreen align="top" />;
|
||||
}
|
||||
|
@ -46,7 +59,7 @@ const NotificationList: FC<NotificationListProps> = () => {
|
|||
<div className={styles.items}>
|
||||
{items?.map((item) => (
|
||||
<div className={styles.item} key={item.created_at}>
|
||||
<NotificationComment item={item} />
|
||||
{renderItem(item)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
@ -47,8 +47,9 @@
|
|||
|
||||
.item {
|
||||
@include row_shadow;
|
||||
padding-right: $gap;
|
||||
padding: $gap / 2 $gap $gap / 2 $gap / 2;
|
||||
transition: background-color 0.25s;
|
||||
min-width: 0;
|
||||
|
||||
&:hover {
|
||||
background-color: $content_bg_lighter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue