-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FE] feat: 에러, 로딩 페이지 구현 및 적용 #155
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e118d10
feat: 버튼 컴포넌트에 아이콘을 선택적으로 추가할 수 있도록 변경
soosoo22 128e794
feat: 에러 페이지를 위한 ErrorSection 컴포넌트 구현
soosoo22 8124d3f
feat: 라우터 설정에서 `errorElement`에 `ErrorPage` 컴포넌트를 추가
soosoo22 5ef1f9c
feat: 버튼 클릭 시 새로고침 및 홈 이동 기능 추가
soosoo22 6d07ef2
feat: LoadingBar 컴포넌트 구현
soosoo22 500d721
feat: 로딩 페이지 추가 및 적용
soosoo22 eaaaf4c
refactor: buttons 배열을 통해 버튼 생성
soosoo22 930b117
refactor: 코드컨벤션에 맞게 코드 수정 및 imageDescription을 버튼 props에 추가
soosoo22 ce59420
refactor: boolean 타입추론 제거
soosoo22 eaa5e2f
design: 에러 컴포넌트 화면 가운데 배치
soosoo22 7adae67
design: 로딩 컴포넌트 화면 가운데 배치
soosoo22 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { ReviewComment } from '@/components'; | |
import { DetailReviewData } from '@/types'; | ||
|
||
import { getDetailedReviewApi } from '../../apis/review'; | ||
import LoadingPage from '../LoadingPage'; | ||
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. 리뷰 상세페이지에 LoadingPage를 적용시켰군요! |
||
|
||
import KeywordSection from './components/KeywordSection'; | ||
import ReviewDescription from './components/ReviewDescription'; | ||
|
@@ -24,8 +25,9 @@ const DetailedReviewPage = () => { | |
useEffect(() => { | ||
const fetchReview = async () => { | ||
try { | ||
const result = await getDetailedReviewApi({ reviewId: Number(id), memberId: Number(memberId) }); | ||
setIsLoading(true); | ||
|
||
const result = await getDetailedReviewApi({ reviewId: Number(id), memberId: Number(memberId) }); | ||
setDetailReview(result); | ||
setErrorMessage(''); | ||
} catch (error) { | ||
|
@@ -38,7 +40,7 @@ const DetailedReviewPage = () => { | |
fetchReview(); | ||
}, [id]); | ||
|
||
if (isLoading) return <div>Loading...</div>; | ||
if (isLoading) return <LoadingPage />; | ||
|
||
if (errorMessage) return <div>Error: {errorMessage}</div>; | ||
if (!detailedReview) return <div>Error: 상세보기 리뷰 데이터를 가져올 수 없어요.</div>; | ||
|
56 changes: 56 additions & 0 deletions
56
frontend/src/pages/ErrorPage/components/ErrorSection/index.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,56 @@ | ||
import AlertTriangle from '@/assets/alertTriangle.svg'; | ||
import HomeIcon from '@/assets/home.svg'; | ||
import ReloadIcon from '@/assets/reload.svg'; | ||
import { Button } from '@/components'; | ||
import { ButtonType } from '@/types/styles'; | ||
|
||
import * as S from './styles'; | ||
|
||
interface ErrorSectionProps { | ||
errorMessage: string; | ||
handleReload: () => void; | ||
handleGoHome: () => void; | ||
} | ||
|
||
const ErrorSection = ({ errorMessage, handleReload, handleGoHome }: ErrorSectionProps) => { | ||
const buttons = [ | ||
{ | ||
buttonType: 'primary' as ButtonType, | ||
text: '새로고침하기', | ||
image: ReloadIcon, | ||
imageDescription: '새로고침 이미지', | ||
onClick: handleReload, | ||
}, | ||
{ | ||
buttonType: 'secondary' as ButtonType, | ||
text: '홈으로 이동하기', | ||
image: HomeIcon, | ||
imageDescription: '홈 이미지', | ||
onClick: handleGoHome, | ||
}, | ||
]; | ||
|
||
return ( | ||
<S.Layout> | ||
<S.ErrorLogoWrapper> | ||
<img src={AlertTriangle} alt="에러 로고" /> | ||
</S.ErrorLogoWrapper> | ||
<S.ErrorMessage>{errorMessage}</S.ErrorMessage> | ||
<S.Container> | ||
{buttons.map((button, index) => ( | ||
<S.ButtonContainer key={index}> | ||
<Button | ||
buttonType={button.buttonType} | ||
text={button.text} | ||
image={button.image} | ||
imageDescription={button.imageDescription} | ||
onClick={button.onClick} | ||
/> | ||
</S.ButtonContainer> | ||
))} | ||
</S.Container> | ||
</S.Layout> | ||
); | ||
}; | ||
|
||
export default ErrorSection; |
45 changes: 45 additions & 0 deletions
45
frontend/src/pages/ErrorPage/components/ErrorSection/styles.ts
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,45 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Layout = styled.div` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 3rem; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const ErrorLogoWrapper = styled.div` | ||
& > img { | ||
width: 15rem; | ||
height: 15rem; | ||
} | ||
`; | ||
|
||
export const ErrorMessage = styled.span` | ||
font-size: 2rem; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
gap: 3.5rem; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const ButtonContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
margin-top: 3rem; | ||
|
||
& > button { | ||
width: 17rem; | ||
height: 5rem; | ||
font-size: 1.4rem; | ||
} | ||
`; |
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,43 @@ | ||
import { useNavigate } from 'react-router'; | ||
|
||
import { Main, PageLayout, SideModal, Sidebar, Topbar } from '@/components'; | ||
import { useSidebar } from '@/hooks'; | ||
|
||
import ErrorSection from './components/ErrorSection'; | ||
|
||
const ERROR_MESSAGE = { | ||
serverUnstable: '서버와의 통신이 불안정합니다.', | ||
}; | ||
|
||
const ErrorPage = () => { | ||
const { isSidebarHidden, isSidebarModalOpen, closeSidebar, openSidebar } = useSidebar(); | ||
const navigate = useNavigate(); | ||
|
||
const handleReload = () => { | ||
navigate(0); | ||
}; | ||
|
||
const handleGoHome = () => { | ||
navigate('/'); // TODO: 홈 페이지 경로가 결정되면 변경 필요 | ||
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. TODO 주석 좋아요! |
||
}; | ||
|
||
return ( | ||
<PageLayout> | ||
{isSidebarModalOpen && ( | ||
<SideModal isSidebarHidden={isSidebarHidden}> | ||
<Sidebar closeSidebar={closeSidebar} /> | ||
</SideModal> | ||
)} | ||
<Topbar openSidebar={openSidebar} /> | ||
<Main> | ||
<ErrorSection | ||
errorMessage={ERROR_MESSAGE.serverUnstable} | ||
handleReload={handleReload} | ||
handleGoHome={handleGoHome} | ||
/> | ||
</Main> | ||
</PageLayout> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
7 changes: 7 additions & 0 deletions
7
frontend/src/pages/LoadingPage/components/LoadingBar/index.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,7 @@ | ||
import * as S from './styles'; | ||
|
||
const LoadingBar = () => { | ||
return <S.LoadingBar />; | ||
}; | ||
|
||
export default LoadingBar; |
41 changes: 41 additions & 0 deletions
41
frontend/src/pages/LoadingPage/components/LoadingBar/styles.ts
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,41 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const LoadingBar = styled.div` | ||
position: relative; | ||
|
||
display: block; | ||
|
||
width: 30rem; | ||
height: 2rem; | ||
|
||
background-color: ${({ theme }) => theme.colors.lightPurple}; | ||
border-radius: 3rem; | ||
|
||
::before { | ||
content: ''; | ||
|
||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
|
||
width: 0%; | ||
height: 100%; | ||
|
||
background: ${({ theme }) => theme.colors.primary}; | ||
border-radius: 3rem; | ||
|
||
animation: moving 1s ease-in-out infinite; | ||
} | ||
|
||
@keyframes moving { | ||
50% { | ||
width: 100%; | ||
} | ||
|
||
100% { | ||
right: 0; | ||
left: unset; | ||
width: 0; | ||
} | ||
} | ||
`; |
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,13 @@ | ||
import LoadingBar from './components/LoadingBar'; | ||
import * as S from './styles'; | ||
|
||
const LoadingPage = () => { | ||
return ( | ||
<S.Container> | ||
<S.Text>Loading ....</S.Text> | ||
<LoadingBar /> | ||
</S.Container> | ||
); | ||
}; | ||
|
||
export default LoadingPage; |
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,21 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Container = styled.div` | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 1.5rem; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
width: 100%; | ||
`; | ||
|
||
export const Text = styled.span` | ||
font-size: ${({ theme }) => theme.fontSize.basic}; | ||
color: ${({ theme }) => theme.colors.primary}; | ||
`; |
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
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.
버튼에 텍스트 뿐 아니라 아이콘까지 추가돼서 이와 같이 코드를 작성하신 것 같아요. 추후에 텍스트, 아이콘 이외의 요소들이 더 들어올 상황이 생길 수도 있을 것 같아요. 이런 경우에 optional로 props를 계속 받기보다는, 공통 버튼 컴포넌트는 Children만을 받아서 그대로 출력해주는 것은 어떨까요?
그렇게 되면 버튼을 사용하는 쪽에서 필요한 요소들을 유연하게 넣을 수 있고, 현재 코드에서의
icon
도 그 종류가 특정될 수 있을 것 같아요.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.
너무 동의합니다!
에프이가 말했던 것처럼 추가적으로 요소들이 더 들어오면 아래 코드처럼 옵셔널로 props를 받는 상황이 많아질텐데.... children을 받는 방법이 더 효율적일 것 같네요! 고마워요~~😊