Skip to content

Commit 5edfd92

Browse files
committed
feat: SomethingWentWrong 페이지 구현
- SomethingWentWrong 컴포넌트로 대체하여 오류 발생 시 사용자 경험을 개선함 - 새로운 오류 이미지(SomethingWentWrong.png)를 추가하고, 스타일링을 위한 SomethingWentWrong.styles.ts 파일을 생성함 - 오류 메시지 및 재시도 버튼을 포함한 레이아웃을 구성하여 사용자에게 명확한 피드백을 제공함
1 parent 6389e6a commit 5edfd92

File tree

5 files changed

+134
-13
lines changed

5 files changed

+134
-13
lines changed
9.57 KB
Loading

apps/web/src/components/ErrorPage/NotFound.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import styled from '@emotion/styled';
2+
3+
const Container = styled.div`
4+
width: 100%;
5+
height: 100%;
6+
max-width: ${({ theme }) => theme.breakpoints.mobile};
7+
margin: 0 auto;
8+
display: flex;
9+
flex-direction: column;
10+
align-items: center;
11+
padding: 0 20px;
12+
`;
13+
14+
const IconWrapper = styled.div`
15+
margin-top: 220px;
16+
width: 128px;
17+
height: 128px;
18+
display: flex;
19+
justify-content: center;
20+
align-items: center;
21+
`;
22+
23+
const ErrorImage = styled.img`
24+
width: 100%;
25+
height: 100%;
26+
object-fit: contain;
27+
`;
28+
29+
const ContentWrapper = styled.div`
30+
margin-top: 40px;
31+
width: 100%;
32+
text-align: center;
33+
`;
34+
35+
const Title = styled.h1`
36+
${({ theme }) => theme.typography.title.display1};
37+
color: ${({ theme }) => theme.palette.common.white};
38+
margin-bottom: 8px;
39+
`;
40+
41+
const Description = styled.p`
42+
${({ theme }) => theme.typography.body.body1};
43+
color: ${({ theme }) => theme.palette.gray['gray-5']};
44+
white-space: pre-line;
45+
text-align: center;
46+
`;
47+
48+
const ErrorText = styled.p`
49+
${({ theme }) => theme.typography.body.caption};
50+
color: ${({ theme }) => theme.palette.gray['gray-5']};
51+
margin-top: 8px;
52+
`;
53+
54+
const ButtonWrapper = styled.div`
55+
position: fixed;
56+
bottom: 40px;
57+
left: 20px;
58+
right: 20px;
59+
padding: 0px 20px;
60+
max-width: ${({ theme }) => theme.breakpoints.mobile};
61+
margin: 0 auto;
62+
`;
63+
64+
const StyledButton = styled.button`
65+
width: 100%;
66+
height: 52px;
67+
background-color: ${({ theme }) => theme.palette.main.pink[50]};
68+
border: none;
69+
border-radius: 10px;
70+
color: ${({ theme }) => theme.palette.common.white};
71+
${({ theme }) => theme.typography.title.subhead1};
72+
cursor: pointer;
73+
74+
&:hover {
75+
background-color: ${({ theme }) => theme.palette.main.pink[40]};
76+
}
77+
78+
&:active {
79+
background-color: ${({ theme }) => theme.palette.main.pink[40]};
80+
}
81+
`;
82+
83+
export {
84+
Container,
85+
IconWrapper,
86+
ErrorImage,
87+
ContentWrapper,
88+
Title,
89+
Description,
90+
ErrorText,
91+
ButtonWrapper,
92+
StyledButton,
93+
};

apps/web/src/components/ErrorPage/SomethingWentWrong.tsx

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import Layout from '@/components/Layout';
2+
import { useTheme } from '@emotion/react';
3+
import SomethingWentWrongIcon from '@/assets/images/SomethingWentWrong.png';
4+
import * as S from './SomethingWentWrong.styles';
5+
import { useNavigate } from 'react-router-dom';
6+
17
interface SomethingWentWrongProps {
28
onRetry?: () => void;
39
status?: string;
@@ -9,13 +15,41 @@ const SomethingWentWrong = ({
915
status,
1016
errorMessage,
1117
}: SomethingWentWrongProps) => {
18+
const theme = useTheme();
19+
const navigate = useNavigate();
20+
1221
return (
13-
<div>
14-
<h1>Something went wrong!</h1>
15-
{status && <div>{status}</div>}
16-
{errorMessage && <div>{errorMessage}</div>}
17-
{onRetry && <button onClick={onRetry}>Retry</button>}
18-
</div>
22+
<Layout
23+
layoutStyle={{
24+
backgroundColor: theme.palette.gray['gray-10'],
25+
}}
26+
>
27+
<S.Container>
28+
<S.IconWrapper>
29+
<S.ErrorImage
30+
src={SomethingWentWrongIcon}
31+
alt="오류가 발생했습니다"
32+
/>
33+
</S.IconWrapper>
34+
<S.ContentWrapper>
35+
<S.Title>오류가 발생하였습니다.</S.Title>
36+
<S.Description>
37+
문제를 해결하기 위해 열심히 노력하고 있어요.
38+
{'\n'}잠시 후 다시 시도해 주세요!
39+
</S.Description>
40+
{status && <S.ErrorText>{status}</S.ErrorText>}
41+
{errorMessage && <S.ErrorText>{errorMessage}</S.ErrorText>}
42+
</S.ContentWrapper>
43+
<S.ButtonWrapper>
44+
{onRetry && (
45+
<S.StyledButton onClick={onRetry}>다시 시도하기</S.StyledButton>
46+
)}
47+
<S.StyledButton onClick={() => navigate('/')}>
48+
홈으로 이동
49+
</S.StyledButton>
50+
</S.ButtonWrapper>
51+
</S.Container>
52+
</Layout>
1953
);
2054
};
2155

apps/web/src/routes/RouteProvider.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from 'react-router-dom';
77
import { PATH } from '@/constants/path';
88

9-
import NotFound from '@/components/ErrorPage/NotFound';
109
import SomethingWentWrong from '@/components/ErrorPage/SomethingWentWrong';
1110
import APIErrorBoundary from '@/components/ErrorBoundary/APIErrorBoundary';
1211
import UnknownErrorBoundary from '@/components/ErrorBoundary/UnKnownErrorBoudary';
@@ -56,7 +55,7 @@ const router = createBrowserRouter([
5655
...createAuthRouter('PUBLIC', []),
5756
{
5857
path: '*',
59-
element: <NotFound />,
58+
element: <SomethingWentWrong />,
6059
},
6160
],
6261
},

0 commit comments

Comments
 (0)