-
Notifications
You must be signed in to change notification settings - Fork 2
✨Feat: 로딩 스피너 컴포넌트, 로딩화면 구현 #99
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
Open
le2yunji
wants to merge
1
commit into
develop
Choose a base branch
from
feat/loading
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import React from 'react'; | ||
|
|
||
| const LoadingSpinner = () => { | ||
| return ( | ||
| <div className="flex min-h-screen items-center justify-center"> | ||
| <div className="flex flex-col items-center gap-4"> | ||
| {/* 스피너 */} | ||
| <div className="relative h-16 w-16"> | ||
| <div className="absolute h-16 w-16 animate-spin rounded-full border-4 border-gray-200"></div> | ||
| <div className="absolute h-16 w-16 animate-spin rounded-full border-4 border-transparent border-t-orange-500"></div> | ||
| </div> | ||
| {/* 로딩 텍스트 */} | ||
| <p className="text-lg font-medium text-gray-600">로딩중...</p> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default LoadingSpinner; |
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import PostBanner from '@/components/owner/PostBanner'; | |
| import { transformApplicationData } from '@/lib/utils/transformTableData'; | ||
| import { calculatePercentage } from '@/utils/transformNotice'; | ||
| import AlertModal from '@/components/common/modal/AlertModal'; | ||
| import LoadingSpinner from '@/components/common/LoadingSpinner'; | ||
|
|
||
| const NoticeDetail = () => { | ||
| const router = useRouter(); | ||
|
|
@@ -19,7 +20,7 @@ const NoticeDetail = () => { | |
| >(null); | ||
| const [shop, setShop] = useState<(ShopRequest & { id: string }) | null>(null); | ||
| const [applicationList, setApplicationList] = useState<ApplicationItem[]>([]); | ||
| const [_loading, setLoading] = useState(true); | ||
| const [loading, setLoading] = useState(true); | ||
| const [_actionLoading, setActionLoading] = useState<string | null>(null); | ||
|
|
||
| // 에러 모달 상태 | ||
|
|
@@ -50,6 +51,7 @@ const NoticeDetail = () => { | |
| const fetchNotice = async () => { | ||
| try { | ||
| setLoading(true); | ||
| if (loading) return <LoadingSpinner />; | ||
|
Contributor
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. |
||
|
|
||
| // 1. 공고 상세 조회 | ||
| const noticeRes = await notices.getShopNotice( | ||
|
|
@@ -58,6 +60,7 @@ const NoticeDetail = () => { | |
| ); | ||
|
|
||
| const noticeData = noticeRes.item; | ||
|
|
||
| setNotice({ | ||
| id: noticeData.id, | ||
| hourlyPay: noticeData.hourlyPay, | ||
|
|
@@ -166,7 +169,8 @@ const NoticeDetail = () => { | |
| setActionLoading(null); | ||
| } | ||
| }; | ||
|
|
||
| // 로딩 중일 때 | ||
| if (loading) return <LoadingSpinner />; | ||
| if (!notice) return <div className="p-6">공고를 찾을 수 없습니다.</div>; | ||
|
|
||
| return ( | ||
|
|
||
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
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.
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.
useEffect내의 로직에 문제가 있어 페이지가 무한 로딩 상태에 빠질 수 있습니다.shopId가router.query로부터 아직 제공되지 않았을 때initializePage함수가return되면서setLoading(false)가 호출되지 않기 때문입니다. 이로 인해 사용자는 계속 로딩 스피너만 보게 됩니다.router.isReady를 사용하여 라우터가 준비되었는지 확인하고, 준비되었음에도shopId가 없는 경우에만 로딩을 중단하도록 로직을 수정해야 합니다.