diff --git a/src/components/common/Notification/Notification.tsx b/src/components/common/Notification/Notification.tsx index 10a9143d..3e4df79c 100644 --- a/src/components/common/Notification/Notification.tsx +++ b/src/components/common/Notification/Notification.tsx @@ -4,10 +4,14 @@ import { cls } from '@/utils' import { XMarkIcon } from '@heroicons/react/24/solid' import Button from '../Button/Button' import { NOTIFICATION_MSG } from './constants' +import useNotification from './hooks/useNotification' export interface NotificationProps { + notificationId: number type: 'follow' | 'comment' | 'space' + userId: number userName: string + spaceId?: number spaceName?: string isRead?: boolean isAccept?: boolean @@ -16,14 +20,20 @@ export interface NotificationProps { } const Notification = ({ + notificationId, type, + userId, userName, + spaceId, spaceName, isRead = false, isAccept = false, onAccept, onClose, }: NotificationProps) => { + const { handleClickUser, handleClickComment, handleClickSpace } = + useNotification() + return (
{type === 'follow' && (
- {userName} + + handleClickUser({ notificationId, userId, isRead }) + } + className="cursor-pointer font-bold"> + {userName} + {NOTIFICATION_MSG.FOLLOW}
)} {type === 'comment' && (
- {userName} + + handleClickUser({ notificationId, userId, isRead }) + } + className="cursor-pointer font-bold"> + {userName} + {NOTIFICATION_MSG.USER} - {spaceName} - {NOTIFICATION_MSG.COMMENT} + + handleClickSpace({ notificationId, spaceId: spaceId!, isRead }) + } + className="cursor-pointer font-bold"> + {spaceName} + + {NOTIFICATION_MSG.SPACE} + + handleClickComment({ + notificationId, + spaceId: spaceId!, + isRead, + }) + } + className="cursor-pointer font-bold"> + {NOTIFICATION_MSG.COMMENT} + + {NOTIFICATION_MSG.COMMENT_LEAVE}
)} {type === 'space' && (
- {userName} + + handleClickUser({ notificationId, userId, isRead }) + } + className="cursor-pointer font-bold"> + {userName} + {NOTIFICATION_MSG.USER} - {spaceName} - {NOTIFICATION_MSG.SPACE} + + handleClickSpace({ + notificationId, + spaceId: spaceId!, + isRead, + }) + } + className="cursor-pointer font-bold"> + {spaceName} + + {NOTIFICATION_MSG.SPACE_INVITE}