-
Notifications
You must be signed in to change notification settings - Fork 1
[25.03.10 / TASK-121] Feature - 공지사항 기능 구현 #23
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d10f7ae
feat: 공지사항 제작
six-standard 495434f
refactor: 공지사항 반응형 지원
six-standard b152e84
refactor: 클라이언트 전용 처리
six-standard a672797
refactor: 안정성 강화
six-standard bb0e6a3
refactor: esc close 처리
six-standard e201492
modiy: 브랜치 동기화
six-standard 7068c29
refactor: prose 적용
six-standard 8794055
refactor: 놓친 부분 반영
six-standard f62c912
refactor: 코드 리팩
six-standard e3f4efd
refactor: 주석 제거
six-standard 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 +1,4 @@ | ||
| export * from './dashboard.request'; | ||
| export * from './instance.request'; | ||
| export * from './notice.request'; | ||
| export * from './user.request'; |
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,6 @@ | ||
| import { PATHS } from '@/constants'; | ||
| import { NotiListDto } from '@/types'; | ||
| import { instance } from './instance.request'; | ||
|
|
||
| export const notiList = async () => | ||
| await instance<null, NotiListDto>(PATHS.NOTIS); | ||
Jihyun3478 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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,46 @@ | ||
| 'use client'; | ||
|
|
||
| import { useEffect } from 'react'; | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { notiList } from '@/apis'; | ||
| import { PATHS } from '@/constants'; | ||
| import { useModal } from '@/hooks/useModal'; | ||
| import { Icon } from '@/components'; | ||
|
|
||
| export const Modal = () => { | ||
| const { close } = useModal(); | ||
| const { data } = useQuery({ queryKey: [PATHS.NOTIS], queryFn: notiList }); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| useEffect(() => { | ||
| const handleClose = (e: KeyboardEvent) => e.key === 'Escape' && close(); | ||
|
|
||
| window.addEventListener('keydown', handleClose); | ||
| return () => window.removeEventListener('keydown', handleClose); | ||
| }, [close]); | ||
|
|
||
| return ( | ||
| <div className="w-[800px] h-[500px] max-MBI:w-[450px] max-MBI:h-[200px] overflow-auto flex flex-col gap-3 p-10 max-MBI:p-7 rounded-md bg-BG-SUB"> | ||
| <div className="flex items-center justify-between"> | ||
| <h2 className="text-TEXT-MAIN items-cenetr gap-3 text-T3 max-MBI:text-T4"> | ||
| 공지사항 | ||
| </h2> | ||
| <Icon name="Close" onClick={close} className="cursor-pointer" /> | ||
| </div> | ||
|
|
||
| {data?.posts?.map(({ content, created_at, id, title }) => ( | ||
| <div key={id} className="flex flex-col gap-2"> | ||
| <div className="flex items-center gap-3"> | ||
| <h3 className="text-TEXT-MAIN text-T4 max-MBI:text-T5">{title}</h3> | ||
| <h4 className="text-TEXT-ALT text-T5 max-MBI:text-ST5"> | ||
| {created_at.split('T')[0]} | ||
| </h4> | ||
| </div> | ||
| <div | ||
| className="text-TEXT-MAIN text-I4 prose" | ||
| dangerouslySetInnerHTML={{ __html: content }} | ||
| /> | ||
| </div> | ||
| ))} | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| 'use client'; | ||
|
|
||
| import { useEffect, useState } from 'react'; | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { notiList } from '@/apis'; | ||
| import { PATHS } from '@/constants'; | ||
| import { useModal } from '@/hooks/useModal'; | ||
| import { Modal } from './Modal'; | ||
|
|
||
| const DAY_IN_MS = 1000 * 60 * 60 * 24; | ||
| const TTL = DAY_IN_MS * 2; | ||
| const RECENT_POST_THRESHOLD_DAYS = 4; | ||
| const NOTIFICATION_STORAGE_KEY = 'noti_expiry'; | ||
|
|
||
| export const Notice = () => { | ||
| const { data } = useQuery({ queryKey: [PATHS.NOTIS], queryFn: notiList }); | ||
| const [show, setShow] = useState(false); | ||
| const { open } = useModal(); | ||
|
|
||
| useEffect(() => { | ||
| try { | ||
| const lastUpdated = new Date( | ||
| data?.posts[0].created_at?.split('T')[0] as string, | ||
| ).getTime(); | ||
|
|
||
| const daysSinceUpdate = Math.ceil( | ||
| (new Date().getTime() - lastUpdated) / DAY_IN_MS, | ||
| ); | ||
|
|
||
| if (daysSinceUpdate <= RECENT_POST_THRESHOLD_DAYS) { | ||
| const expiry = localStorage.getItem(NOTIFICATION_STORAGE_KEY); | ||
| if (!expiry || parseInt(expiry, 10) < new Date().getTime()) { | ||
| setShow(true); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| console.error('알림 날짜 처리 중 오류 발생:', error); | ||
| } | ||
| }, [data]); | ||
|
|
||
| return ( | ||
| <> | ||
| <div | ||
| className={`transition-all shrink-0 duration-300 flex items-center justify-center gap-2 w-full overflow-hidden bg-BORDER-SUB ${show ? 'h-[50px]' : 'h-[0px]'}`} | ||
| > | ||
| <h1 className="text-TEXT-MAIN text-ST4 max-MBI:text-ST5"> | ||
| 📣 새로운 업데이트를 확인해보세요! | ||
| </h1> | ||
| <button | ||
| className="text-PRIMARY-MAIN hover:text-PRIMARY-SUB text-ST4 transition-all duration-300 max-MBI:text-ST5" | ||
| onClick={() => { | ||
| setShow(false); | ||
| localStorage.setItem( | ||
| 'noti_expiry', | ||
| JSON.stringify(new Date().getTime() + TTL), | ||
| ); | ||
|
|
||
| open(<Modal />); | ||
| }} | ||
| > | ||
| 확인하기 | ||
| </button> | ||
| </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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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.