mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
notification clicking
This commit is contained in:
parent
9b0c3dd1fb
commit
83c9900af1
4 changed files with 18 additions and 9 deletions
|
@ -40,9 +40,11 @@ const HeaderUnconnected: FC<IProps> = memo(
|
||||||
|
|
||||||
<Filler />
|
<Filler />
|
||||||
|
|
||||||
|
{is_user && (
|
||||||
<div className={style.plugs}>
|
<div className={style.plugs}>
|
||||||
<Notifications />
|
<Notifications />
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{is_user && (
|
{is_user && (
|
||||||
<UserButton user={user} onLogout={authLogout} onProfileClick={onProfileClick} />
|
<UserButton user={user} onLogout={authLogout} onProfileClick={onProfileClick} />
|
||||||
|
|
|
@ -20,6 +20,7 @@ const NotificationBubble: FC<IProps> = ({ notifications }) => {
|
||||||
.map(notification =>
|
.map(notification =>
|
||||||
createElement(NOTIFICATION_RENDERERS[notification.type], {
|
createElement(NOTIFICATION_RENDERERS[notification.type], {
|
||||||
notification,
|
notification,
|
||||||
|
onClick: console.log,
|
||||||
key: notification.content.id,
|
key: notification.content.id,
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
import styles from '~/components/notifications/NotificationBubble/styles.scss';
|
import styles from '~/components/notifications/NotificationBubble/styles.scss';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { IMessageNotification } from '~/redux/types';
|
import { IMessageNotification, INotification } from '~/redux/types';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
notification: IMessageNotification;
|
notification: IMessageNotification;
|
||||||
|
onClick: (notification: INotification) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NotificationMessage: FC<IProps> = ({
|
const NotificationMessage: FC<IProps> = ({
|
||||||
|
notification,
|
||||||
notification: {
|
notification: {
|
||||||
content: { text, from },
|
content: { text, from },
|
||||||
},
|
},
|
||||||
|
onClick,
|
||||||
}) => {
|
}) => {
|
||||||
|
const onMouseDown = useCallback(() => onClick(notification), [onClick, notification]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.item}>
|
<div className={styles.item} onMouseDown={onMouseDown}>
|
||||||
<div className={styles.item_head}>
|
<div className={styles.item_head}>
|
||||||
<Icon icon="message" />
|
<Icon icon="message" />
|
||||||
<div className={styles.item_title}>Сообщение от ~{from.username}:</div>
|
<div className={styles.item_title}>Сообщение от ~{from.username}:</div>
|
||||||
|
|
|
@ -171,18 +171,19 @@ export const NOTIFICATION_TYPES = {
|
||||||
export type IMessageNotification = {
|
export type IMessageNotification = {
|
||||||
type: typeof NOTIFICATION_TYPES['message'];
|
type: typeof NOTIFICATION_TYPES['message'];
|
||||||
content: Partial<IMessage>;
|
content: Partial<IMessage>;
|
||||||
|
created_at: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ICommentNotification = {
|
export type ICommentNotification = {
|
||||||
type: typeof NOTIFICATION_TYPES['comment'];
|
type: typeof NOTIFICATION_TYPES['comment'];
|
||||||
content: Partial<IComment>;
|
content: Partial<IComment>;
|
||||||
|
created_at: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type INodeNotification = {
|
export type INodeNotification = {
|
||||||
type: typeof NOTIFICATION_TYPES['node'];
|
type: typeof NOTIFICATION_TYPES['node'];
|
||||||
content: Partial<INode>;
|
content: Partial<INode>;
|
||||||
};
|
|
||||||
|
|
||||||
export type INotification = (IMessageNotification | ICommentNotification) & {
|
|
||||||
created_at: string;
|
created_at: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type INotification = IMessageNotification | ICommentNotification;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue