-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/#265 추가기능 알림 기능 #273
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
Merged
The head ref may contain hidden characters: "feature/#265_\uCD94\uAC00\uAE30\uB2A5-\uC54C\uB9BC-\uAE30\uB2A5"
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
52ae362
✨ 알림 기능 구현
solprime 0d76847
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime d036e13
✨ 알림 클릭으로 이동 후 알림창 닫기
solprime 5259d42
🔥 이전 코드 제거
solprime 552cc20
🐛 이벤트 전파 방지
solprime 39e8c43
Merge branch 'develop' into feature/#265_추가기능-알림-기능
solprime 6c0dd1b
Merge branch 'develop' into feature/#265_추가기능-알림-기능
junghwaYang f25c5e2
⚡️ 메뉴에 내 위키 추가
solprime eab8783
💄 로그아웃 텍스트 색상 변경
solprime 4acca52
💄 메뉴에서 border 삭제
solprime 8eb0d5b
🐛 알림 아이콘 한 번 더 누르면 닫히도록 수정
solprime 5561803
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime 0e05930
Merge branch 'feature/#265_추가기능-알림-기능' of https://github.com/codeitFE…
solprime 1e2e361
Merge branch 'develop' of https://github.com/codeitFE11-part3-team7/w…
solprime f1119f2
Merge branch 'feature/#265_추가기능-알림-기능' of https://github.com/codeitFE…
solprime d1c714e
💄 스타일 수정
solprime 51ce027
🐛 버튼 안에 버튼 제거
solprime f08f912
💄 6시간 전 알림까지 파란불 띄우기
solprime f18101e
🐛 pc 드롭다운 오류 해결
solprime 3812221
💄 헤더 다크모드 그림자
solprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,28 +1,46 @@ | ||
| import Image from 'next/image'; | ||
| import { useRef, useState } from 'react'; | ||
| import NotificationWrapper from '@/components/Notification/NotificationWrapper'; | ||
| import useOutsideClick from '@/hooks/useOutsideClick'; | ||
|
|
||
| interface AlarmProps { | ||
| isLoggedIn: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * 알림 컴포넌트 | ||
| * @param isLoggedIn 로그인 여부 판별 | ||
| */ | ||
|
|
||
| export default function Alarm({ isLoggedIn }: AlarmProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const handleAlarmOpen = () => setIsOpen(!isOpen); | ||
| const handleAlarmClose = () => setIsOpen(false); | ||
| const alarmRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| useOutsideClick(alarmRef, () => setIsOpen(false)); | ||
|
|
||
| if (!isLoggedIn) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <button> | ||
| <Image | ||
| src="/icon/icon-alarm.svg" | ||
| className="mo:hidden" | ||
| alt="알림 아이콘" | ||
| width={32} | ||
| height={32} | ||
| /> | ||
| </button> | ||
| <div ref={alarmRef}> | ||
| <div | ||
| role="button" | ||
| tabIndex={0} | ||
| onClick={handleAlarmOpen} | ||
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' || e.key === ' ') handleAlarmOpen(); | ||
| }} | ||
| > | ||
| <Image | ||
| src="/icon/icon-alarm.svg" | ||
| className="mo:hidden" | ||
| alt="알림 아이콘" | ||
| width={32} | ||
| height={32} | ||
| /> | ||
| </div> | ||
|
|
||
| {isOpen && ( | ||
| <NotificationWrapper isOpen={isOpen} onClose={handleAlarmClose} /> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,76 @@ | ||
| import Image from 'next/image'; | ||
| import NotificationContents from './NotificationContents'; | ||
| import { NotificationProps } from '../Notification/NotificationWrapper'; | ||
| import instance from '@/lib/axios-client'; | ||
| import { useSnackbar } from 'context/SnackBarContext'; | ||
|
|
||
| interface NotificationBoxProps { | ||
| onClose: () => void; | ||
| content: NotificationProps | undefined; | ||
| setNotification: (notification: NotificationProps) => void; | ||
| } | ||
|
|
||
| export default function NotificationBox({ | ||
| onClose, | ||
| content, | ||
| setNotification, | ||
| }: NotificationBoxProps) { | ||
| const { showSnackbar } = useSnackbar(); | ||
| const handleNotiContent = async (id: number) => { | ||
| try { | ||
| await instance.delete(`/notifications/${id}`); | ||
|
|
||
| if (content?.list) { | ||
| const updatedList = content.list.filter( | ||
| (notification) => notification.id !== id | ||
| ); | ||
|
|
||
| setNotification({ | ||
| totalCount: updatedList.length, | ||
| list: updatedList, | ||
| }); | ||
| } | ||
| } catch (error) { | ||
| showSnackbar('오류가 발생했습니다', 'fail'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="alarmDownFadein absolute right-0 z-20 mt-[8px] flex max-h-[293px] w-[368px] flex-col gap-[16px] rounded-custom bg-gray-200 px-[20px] py-[24px] shadow-custom dark:shadow-custom-dark mo:top-[30px] mo:w-[250px]"> | ||
| <div className="flex items-center justify-between"> | ||
| <div className="text-20b">알림 {content?.totalCount}개</div> | ||
| <button onClick={onClose}> | ||
| <Image | ||
| src="/icon/icon-close.svg" | ||
| alt="닫기 버튼" | ||
| width={24} | ||
| height={24} | ||
| className="brightness-0" | ||
| /> | ||
| </button> | ||
| </div> | ||
| <div | ||
| className={`flex flex-col gap-[8px] overflow-y-auto [&::-webkit-scrollbar]:hidden`} | ||
| style={{ | ||
| scrollbarWidth: 'none', | ||
| msOverflowStyle: 'none', | ||
| }} | ||
| > | ||
| {content?.list && content.list.length > 0 ? ( | ||
| content.list.map((notification) => ( | ||
| <NotificationContents | ||
| key={notification.id} | ||
| createdAt={notification.createdAt} | ||
| handleNotiContent={() => handleNotiContent(notification.id)} | ||
| onClose={onClose} | ||
| /> | ||
| )) | ||
| ) : ( | ||
| <div className="flex h-[100px] items-center justify-center text-14 text-gray-400"> | ||
| 최근 알림이 없습니다 | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.