1
1
import { QueryErrorResetBoundary } from '@tanstack/react-query'
2
- import { Suspense , useEffect } from 'react'
2
+ import { Suspense , useEffect , useMemo } from 'react'
3
3
import { ErrorBoundary } from 'react-error-boundary'
4
4
import { Helmet } from 'react-helmet-async'
5
5
import { useNavigate , useSearchParams } from 'react-router-dom'
6
6
import { useHomePageData } from '~apis/main/useHomePageData'
7
+ import useInfiniteNotificationList from '~apis/notification/useInfiniteNotificationList'
7
8
import DogHand from '~assets/dog_hand.svg?react'
8
9
import BellIcon from '~assets/icons/bell_icon.svg?react'
9
10
import ClockIcon from '~assets/icons/clock_icon.svg?react'
@@ -21,16 +22,27 @@ import { useModalStore } from '~stores/modalStore'
21
22
import * as S from './styles'
22
23
23
24
function HomeContent ( ) {
25
+ const {
26
+ data : { pages : notificationListPages } ,
27
+ } = useInfiniteNotificationList ( )
24
28
const { data } = useHomePageData ( )
25
29
const { pushModal } = useModalStore ( )
30
+ const unreadNotificationCount = useMemo ( ( ) => {
31
+ return notificationListPages . reduce ( ( count , page ) => {
32
+ return count + page . data . content . filter ( noti => ! noti . isRead ) . length
33
+ } , 0 )
34
+ } , [ notificationListPages ] )
26
35
27
36
useSubscribe ( )
28
37
29
38
return (
30
39
< >
31
40
< S . Header >
32
41
< Profile $size = { 32 } $src = { data ?. memberProfileImgUrl || '' } />
33
- < BellIcon cursor = 'pointer' onClick = { ( ) => pushModal ( < NotificationModal /> ) } />
42
+ < S . BellIconWrapper >
43
+ < BellIcon cursor = 'pointer' onClick = { ( ) => pushModal ( < NotificationModal /> ) } />
44
+ { unreadNotificationCount ? < S . UnreadCircle /> : null }
45
+ </ S . BellIconWrapper >
34
46
</ S . Header >
35
47
< S . Visual >
36
48
< Typo24 $weight = '700' $textAlign = 'center' >
0 commit comments