@@ -4,9 +4,11 @@ import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
44import { BaseBadge } from '@app/components/common/BaseBadge/BaseBadge' ;
55import { NotificationsOverlay } from '@app/components/header/components/notificationsDropdown/NotificationsOverlay/NotificationsOverlay' ;
66import { PaymentNotificationsOverlay } from '@app/components/header/components/notificationsDropdown/PaymentNotificationsOverlay' ;
7+ import ReportNotificationsOverlay from '@app/components/header/components/notificationsDropdown/ReportNotificationsOverlay' ;
78import { notifications as fetchedNotifications , Notification , Message } from '@app/api/notifications.api' ;
89import { useModerationNotifications } from '@app/hooks/useModerationNotifications' ;
910import { usePaymentNotifications } from '@app/hooks/usePaymentNotifications' ;
11+ import { useReportNotifications } from '@app/hooks/useReportNotifications' ;
1012import { HeaderActionWrapper } from '@app/components/header/Header.styles' ;
1113import { BasePopover } from '@app/components/common/BasePopover/BasePopover' ;
1214import { useTranslation } from 'react-i18next' ;
@@ -40,18 +42,28 @@ export const NotificationsDropdown: React.FC = () => {
4042 fetchNotifications : refreshModerationNotifications
4143 } = useModerationNotifications ( ) ;
4244
43- // Filter to only show unread moderation notifications in the dropdown
44- const moderationNotifications = allModerationNotifications . filter ( notification => ! notification . is_read ) ;
45-
4645 const {
4746 notifications : allPaymentNotifications ,
4847 markAsRead : markPaymentAsRead ,
4948 markAllAsRead : markAllPaymentsAsRead ,
5049 fetchNotifications : refreshPaymentNotifications
5150 } = usePaymentNotifications ( ) ;
51+
52+ const {
53+ notifications : allReportNotifications ,
54+ markAsRead : markReportAsRead ,
55+ markAllAsRead : markAllReportsAsRead ,
56+ fetchNotifications : refreshReportNotifications
57+ } = useReportNotifications ( ) ;
58+
59+ // Filter to only show unread moderation notifications in the dropdown
60+ const moderationNotifications = allModerationNotifications . filter ( notification => ! notification . is_read ) ;
5261
5362 // Filter to only show unread notifications in the dropdown
5463 const paymentNotifications = allPaymentNotifications . filter ( notification => ! notification . is_read ) ;
64+
65+ // Filter to only show unread report notifications in the dropdown
66+ const reportNotifications = allReportNotifications . filter ( notification => ! notification . is_read ) ;
5567
5668 // Use ref to track if we've processed these notifications before
5769 const processedModerationIdsRef = useRef < Set < number > > ( new Set ( ) ) ;
@@ -80,17 +92,19 @@ export const NotificationsDropdown: React.FC = () => {
8092 }
8193 } , [ allModerationNotifications ] ) ;
8294
83- // Initialize both notification types
95+ // Initialize all notification types
8496 useEffect ( ( ) => {
8597 refreshModerationNotifications ( { filter : 'unread' } ) ;
8698 refreshPaymentNotifications ( { filter : 'unread' } ) ;
87- } , [ refreshModerationNotifications , refreshPaymentNotifications ] ) ;
99+ refreshReportNotifications ( { filter : 'unread' } ) ;
100+ } , [ refreshModerationNotifications , refreshPaymentNotifications , refreshReportNotifications ] ) ;
88101
89102 // Refresh all notifications, only showing unread ones
90103 const handleRefresh = useCallback ( ( ) => {
91104 refreshModerationNotifications ( { filter : 'unread' } ) ;
92105 refreshPaymentNotifications ( { filter : 'unread' } ) ;
93- } , [ refreshModerationNotifications , refreshPaymentNotifications ] ) ;
106+ refreshReportNotifications ( { filter : 'unread' } ) ;
107+ } , [ refreshModerationNotifications , refreshPaymentNotifications , refreshReportNotifications ] ) ;
94108
95109 // Handle clearing all notifications, including moderation ones
96110 const handleClearAll = useCallback ( ( ) => {
@@ -108,21 +122,29 @@ export const NotificationsDropdown: React.FC = () => {
108122 // Check specifically for unread notifications
109123 const hasUnreadModerationNotifications = moderationNotifications . some ( notification => ! notification . is_read ) ;
110124 const hasUnreadPaymentNotifications = paymentNotifications . some ( notification => ! notification . is_read ) ;
111- const hasUnreadNotifications = hasUnreadModerationNotifications || hasUnreadPaymentNotifications ;
125+ const hasUnreadReportNotifications = reportNotifications . some ( notification => ! notification . is_read ) ;
126+ const hasUnreadNotifications = hasUnreadModerationNotifications || hasUnreadPaymentNotifications || hasUnreadReportNotifications ;
112127
113128 // Count unread notifications
114129 const unreadModerationCount = moderationNotifications . filter ( notification => ! notification . is_read ) . length ;
115130 const unreadPaymentCount = paymentNotifications . filter ( notification => ! notification . is_read ) . length ;
116- const totalUnreadCount = unreadModerationCount + unreadPaymentCount ;
131+ const unreadReportCount = reportNotifications . filter ( notification => ! notification . is_read ) . length ;
132+ const totalUnreadCount = unreadModerationCount + unreadPaymentCount + unreadReportCount ;
117133
118134 // Handle clearing all payment notifications
119135 const handleClearAllPayments = useCallback ( ( ) => {
120136 return markAllPaymentsAsRead ( ) ;
121137 } , [ markAllPaymentsAsRead ] ) ;
122138
139+ // Handle clearing all report notifications
140+ const handleClearAllReports = useCallback ( ( ) => {
141+ return markAllReportsAsRead ( ) ;
142+ } , [ markAllReportsAsRead ] ) ;
143+
123144 // Get translated tab names
124145 const moderationLabel = t ( 'moderation.notifications.title' , 'Moderation' ) ;
125146 const paymentsLabel = t ( 'payment.notifications.title' , 'Payments' ) ;
147+ const reportsLabel = t ( 'report.notifications.title' , 'Reports' ) ;
126148
127149 // Custom tab style to ensure content overflow is handled correctly
128150 const tabContentStyle = {
@@ -186,6 +208,30 @@ export const NotificationsDropdown: React.FC = () => {
186208 </ div >
187209 ) ,
188210 } ,
211+ {
212+ key : '3' ,
213+ label : (
214+ < span >
215+ { reportsLabel }
216+ { unreadReportCount > 0 && (
217+ < BaseBadge count = { unreadReportCount } size = "small" style = { { marginLeft : '5px' } } />
218+ ) }
219+ </ span >
220+ ) ,
221+ children : (
222+ < div style = { tabContentStyle } >
223+ < ReportNotificationsOverlay
224+ notifications = { reportNotifications }
225+ markAsRead = { markReportAsRead }
226+ markAllAsRead = { handleClearAllReports }
227+ onRefresh = { ( ) => {
228+ refreshReportNotifications ( { filter : 'unread' } ) ;
229+ return Promise . resolve ( ) ;
230+ } }
231+ />
232+ </ div >
233+ ) ,
234+ } ,
189235 ] ;
190236
191237 return (
0 commit comments