diff --git a/src/app/(service)/(my)/notification/page.tsx b/src/app/(service)/(my)/notification/page.tsx index aa396981..7c1c3f30 100644 --- a/src/app/(service)/(my)/notification/page.tsx +++ b/src/app/(service)/(my)/notification/page.tsx @@ -2,6 +2,7 @@ import { useState } from 'react'; +import { MemberNotificationResponse } from '@/api/openapi'; import type { GetMemberNotificationsTopicTypeEnum } from '@/api/openapi/api/notification-api'; import NotificationList from '@/components/lists/notification-list'; import Button from '@/components/ui/button'; @@ -61,6 +62,14 @@ export default function NotificationPage() { readNotifications(ids); }; + const handleNotificationClick = ( + notification: MemberNotificationResponse, + ) => { + if (!notification.isRead) { + readNotifications([notification.id]); + } + }; + return (
{/* Header */} @@ -83,7 +92,7 @@ export default function NotificationPage() {
- + {/* Pagination */}
diff --git a/src/components/lists/notification-list.tsx b/src/components/lists/notification-list.tsx index 5670b155..dcc54a2a 100644 --- a/src/components/lists/notification-list.tsx +++ b/src/components/lists/notification-list.tsx @@ -25,17 +25,20 @@ const getBadgeColor = ( interface NotificationListProps { notifications?: MemberNotificationResponse[]; + onNotificationClick?: (notification: MemberNotificationResponse) => void; } export default function NotificationList({ notifications, + onNotificationClick, }: NotificationListProps) { return (
    {notifications?.map((notification) => (
  • onNotificationClick?.(notification)} >
    - - {format(notification.createdAt, 'yyyy.MM.dd HH:mm')} - +
    + + {format(notification.createdAt, 'yyyy.MM.dd HH:mm')} + +
  • ))}
diff --git a/src/components/modals/notification-dropdown.tsx b/src/components/modals/notification-dropdown.tsx index 53245faa..33fc3ddc 100644 --- a/src/components/modals/notification-dropdown.tsx +++ b/src/components/modals/notification-dropdown.tsx @@ -3,11 +3,12 @@ import { DotIcon } from 'lucide-react'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; +import { MemberNotificationResponse } from '@/api/openapi'; import NotificationList from '@/components/lists/notification-list'; import { useGetNotifications, - useHasNewNotification, + useReadNotifications, } from '@/hooks/queries/notification-api'; import NotiIcon from 'public/icons/notifications_none.svg'; import { @@ -30,9 +31,16 @@ export default function NotificationDropdown() { size: 5, hasRead: false, }); - const { data: newData } = useHasNewNotification(); - const isRead = newData?.isRead; + const { mutate: readNotifications } = useReadNotifications(); + + const handleNotificationClick = ( + notification: MemberNotificationResponse, + ) => { + if (!notification.isRead) { + readNotifications([notification.id]); + } + }; const notifications = mode === 'all' @@ -48,8 +56,8 @@ export default function NotificationDropdown() {
- {!isRead && ( - + {totalUnreadCount !== undefined && totalUnreadCount > 0 && ( + )}
@@ -87,7 +95,10 @@ export default function NotificationDropdown() {

) : ( - + )}