-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from bankidz/dev
돈길 계약하기 웹뷰 렌더링 오류 수정1트
- Loading branch information
Showing
12 changed files
with
186 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/components/blocks/home/notification/NotificationItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import styled from 'styled-components'; | ||
import { INotification } from '@lib/apis/notification/notificationDTO'; | ||
import { ReactComponent as AlertDongil } from '@assets/icons/alertDongil.svg'; | ||
import { ReactComponent as AlertNotice } from '@assets/icons/alertNotice.svg'; | ||
import { ReactComponent as AlertLevel } from '@assets/icons/alertLevel.svg'; | ||
import { ReactComponent as AlertFamily } from '@assets/icons/alertFamily.svg'; | ||
import getTimeForToday from '@lib/utils/getTimeForToday'; | ||
|
||
const icon = { | ||
CHALLENGE: <AlertDongil />, | ||
NOTICE: <AlertNotice />, | ||
LEVEL: <AlertLevel />, | ||
FAMILY: <AlertFamily />, | ||
}; | ||
const category = { | ||
CHALLENGE: '돈길', | ||
NOTICE: '공지', | ||
LEVEL: '레벨', | ||
FAMILY: '가족', | ||
}; | ||
|
||
export interface NotificationItemProps { | ||
notification: INotification; | ||
isRead: boolean; | ||
handleListItemClick: () => void; | ||
} | ||
|
||
const NotificationItem = ({ | ||
notification, | ||
isRead, | ||
handleListItemClick, | ||
}: NotificationItemProps) => { | ||
const { id, notificationCategory, createdAt, title, message } = notification; | ||
return ( | ||
<Wrapper key={id} isRead={isRead} onClick={handleListItemClick}> | ||
{icon[notificationCategory]} | ||
<div> | ||
<div className="sub"> | ||
<p>{category[notificationCategory]}</p> | ||
<p>{getTimeForToday(createdAt)}</p> | ||
</div> | ||
<div className="main"> | ||
<p>{title}</p> | ||
<p>{message}</p> | ||
</div> | ||
</div> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default NotificationItem; | ||
|
||
const Wrapper = styled.div<{ isRead: boolean }>` | ||
display: grid; | ||
grid-template-columns: 48px auto; | ||
grid-gap: 16px; | ||
padding: 16px 18px 20px 18px; | ||
background-color: ${({ isRead, theme }) => | ||
isRead ? 'none' : theme.palette.main.yellow100}; | ||
cursor: pointer; | ||
.sub { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 8px; | ||
& > p:first-child { | ||
${({ theme }) => theme.typo.text.T_12_EB} | ||
color: ${({ theme }) => theme.palette.greyScale.grey500}; | ||
} | ||
& > p:last-child { | ||
${({ theme }) => theme.typo.text.Alarm_T_12_R} | ||
color: ${({ theme }) => theme.palette.greyScale.grey500}; | ||
} | ||
} | ||
.main { | ||
${({ theme }) => theme.typo.text.Alarm_T_14_R} | ||
line-height: 150%; | ||
color: ${({ theme }) => theme.palette.greyScale.black}; | ||
} | ||
svg { | ||
margin: auto 0px; | ||
} | ||
`; |
63 changes: 63 additions & 0 deletions
63
src/components/blocks/home/notification/NotificationList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useCallback, useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import NotificationItem, { NotificationItemProps } from './NotificationItem'; | ||
import { INotification } from '@lib/apis/notification/notificationDTO'; | ||
import notificationAPI from '@lib/apis/notification/notificationAPI'; | ||
|
||
interface NotificationListProps { | ||
notifications: INotification[]; | ||
} | ||
|
||
const NotificationList = ({ notifications }: NotificationListProps) => { | ||
return ( | ||
<> | ||
{notifications.map((notification) => ( | ||
<NotificationListHeadless | ||
notification={notification} | ||
key={notification.id} | ||
> | ||
{({ notification, handleListItemClick, isRead }) => ( | ||
<NotificationItem | ||
notification={notification} | ||
handleListItemClick={handleListItemClick} | ||
isRead={isRead} | ||
/> | ||
)} | ||
</NotificationListHeadless> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default NotificationList; | ||
|
||
interface NotificationListHeadlessProps { | ||
notification: INotification; | ||
children: (args: NotificationItemProps) => JSX.Element; | ||
} | ||
|
||
const NotificationListHeadless = ({ | ||
notification, | ||
children, | ||
}: NotificationListHeadlessProps) => { | ||
const { isRead, id, linkUrl } = notification; | ||
const [isReadClient, setIsReadClient] = useState<boolean>(isRead); | ||
const navigate = useNavigate(); | ||
|
||
const onNotificationItemClick = useCallback( | ||
async (id: number, url: string) => { | ||
if (!isReadClient) { | ||
await notificationAPI.patchNotificationIsRead(id); | ||
setIsReadClient(true); | ||
} | ||
url && navigate(url); | ||
}, | ||
[isReadClient], | ||
); | ||
|
||
return children({ | ||
notification: notification, | ||
handleListItemClick: () => onNotificationItemClick(id, linkUrl), | ||
isRead: isReadClient, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters