Skip to content

Commit cf8ed00

Browse files
committed
✨Feat: UnreadCircle
1 parent 64fe8f0 commit cf8ed00

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/pages/HomePage/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { QueryErrorResetBoundary } from '@tanstack/react-query'
2-
import { Suspense, useEffect } from 'react'
2+
import { Suspense, useEffect, useMemo } from 'react'
33
import { ErrorBoundary } from 'react-error-boundary'
44
import { Helmet } from 'react-helmet-async'
55
import { useNavigate, useSearchParams } from 'react-router-dom'
66
import { useHomePageData } from '~apis/main/useHomePageData'
7+
import useInfiniteNotificationList from '~apis/notification/useInfiniteNotificationList'
78
import DogHand from '~assets/dog_hand.svg?react'
89
import BellIcon from '~assets/icons/bell_icon.svg?react'
910
import ClockIcon from '~assets/icons/clock_icon.svg?react'
@@ -21,16 +22,27 @@ import { useModalStore } from '~stores/modalStore'
2122
import * as S from './styles'
2223

2324
function HomeContent() {
25+
const {
26+
data: { pages: notificationListPages },
27+
} = useInfiniteNotificationList()
2428
const { data } = useHomePageData()
2529
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])
2635

2736
useSubscribe()
2837

2938
return (
3039
<>
3140
<S.Header>
3241
<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>
3446
</S.Header>
3547
<S.Visual>
3648
<Typo24 $weight='700' $textAlign='center'>

src/pages/HomePage/styles.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,14 @@ export const WalkDistance = styled.div`
4949
align-items: center;
5050
justify-content: space-between;
5151
`
52+
export const BellIconWrapper = styled.div`
53+
position: relative;
54+
`
55+
export const UnreadCircle = styled.span`
56+
position: absolute;
57+
width: 4px;
58+
height: 4px;
59+
background-color: ${({ theme }) => theme.colors.brand.sub};
60+
top: 0;
61+
right: 0;
62+
`

0 commit comments

Comments
 (0)