-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
알림 컴포넌트 구현 #51
알림 컴포넌트 구현 #51
Changes from 4 commits
4702827
7105c3d
65887d4
9703a24
94a2f1b
97d5222
72470e7
bb2c128
094810a
5df506b
8cffe47
c8eaf93
b91449c
f06af43
7228844
115bdd3
ada2c8a
6fcaf59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use client' | ||
|
||
import { cls } from '@/utils' | ||
import { XMarkIcon } from '@heroicons/react/24/solid' | ||
import Button from '../Button/Button' | ||
import { NOTIFICATION_MSG } from './constants' | ||
|
||
export interface NotificationProps { | ||
type: 'follow' | 'comment' | 'space' | ||
userName: string | ||
spaceName?: string | ||
isRead?: boolean | ||
isAccept?: boolean | ||
onAccept?: (e?: React.MouseEvent<HTMLButtonElement>) => void | ||
onClose?: (e?: React.MouseEvent<HTMLButtonElement>) => void | ||
} | ||
|
||
const Notification = ({ | ||
type, | ||
userName, | ||
spaceName, | ||
isRead = false, | ||
isAccept = false, | ||
onAccept, | ||
onClose, | ||
}: NotificationProps) => { | ||
return ( | ||
<div | ||
className={cls( | ||
'rounded-md border border-slate3 p-3', | ||
isRead ? 'bg-bgColor' : 'bg-emerald05', | ||
)}> | ||
<div className="flex w-full items-start justify-between text-sm font-medium text-gray9"> | ||
{type === 'follow' && ( | ||
<div> | ||
<span className="font-bold">{userName}</span> | ||
{NOTIFICATION_MSG.FOLLOW} | ||
</div> | ||
)} | ||
{type === 'comment' && ( | ||
<div> | ||
<span className="font-bold">{userName}</span> | ||
{NOTIFICATION_MSG.USER} | ||
<span className="font-bold">{spaceName}</span> | ||
{NOTIFICATION_MSG.COMMENT} | ||
</div> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type이 follow와 comment일때는 각각 팔로우 신청한 사람의 프로필 페이지, 댓글이 달린 해당 스페이스 댓글페이지로 라우팅시키는건 어떠신가요..! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다! 😀 |
||
{type === 'space' && ( | ||
<div className="flex w-full flex-col gap-6"> | ||
<div className="flex items-start justify-between"> | ||
<div> | ||
<span className="font-bold">{userName}</span> | ||
{NOTIFICATION_MSG.USER} | ||
<span className="font-bold">{spaceName}</span> | ||
{NOTIFICATION_MSG.SPACE} | ||
</div> | ||
<Button onClick={onClose}> | ||
<XMarkIcon className="h-5 w-5 p-0.5 text-slate6" /> | ||
</Button> | ||
</div> | ||
<div className="flex justify-end"> | ||
{isAccept ? ( | ||
<div className="text-sm font-semibold text-slate6"> | ||
{NOTIFICATION_MSG.APPROVE} | ||
</div> | ||
) : ( | ||
<Button | ||
className="button button-emerald px-2.5 py-1.5" | ||
onClick={onAccept}> | ||
{NOTIFICATION_MSG.APPROVE_BUTTON} | ||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
)} | ||
{type !== 'space' && 'comment' && ( | ||
<Button onClick={onClose}> | ||
<XMarkIcon className="h-5 w-5 p-0.5 text-slate6" /> | ||
</Button> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 별건 아니지만 레이아웃을 수정하면 x 버튼을 타입별로 나누지 않을 수 있을 것 같아요..!! 💡 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다! 😀 |
||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Notification |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const NOTIFICATION_MSG = { | ||
APPROVE_BUTTON: '수락', | ||
APPROVE: '수락 완료', | ||
USER: ' 님이 ', | ||
FOLLOW: ' 님이 팔로우했습니다.', | ||
COMMENT: ' 스페이스에 댓글을 남겼습니다.', | ||
SPACE: ' 스페이스에 초대했습니다.', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
알림을 눌렀을 때 읽음 처리와 페이지 이동을 해줘야 하는데 이 부분이 빠진 것 같습니다! 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영했습니다! 😀