From d71582f11f14e8aaf43959ec805b5303ae0527c5 Mon Sep 17 00:00:00 2001 From: MyungJiwoo <1206jiwoo@gmail.com> Date: Tue, 24 Sep 2024 06:00:57 +0900 Subject: [PATCH] =?UTF-8?q?#72=20feat:=20404=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 17 +- src/pages/ErrorPage.tsx | 293 +++++++++++++++++++++++++++++++++ src/styles/ErrorPageStyled.tsx | 39 +++++ 3 files changed, 347 insertions(+), 2 deletions(-) create mode 100644 src/pages/ErrorPage.tsx create mode 100644 src/styles/ErrorPageStyled.tsx diff --git a/src/App.tsx b/src/App.tsx index b1ce7bc..fb12b10 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,7 @@ import ChallengeCommunityPage from './pages/ChallengeCommunityPage'; import CreateChallengePage from './pages/CreateChallengePage'; import ChallengeDetailPage from './pages/ChallengeDetailPage'; import TutorialPage from './pages/TutorialPage'; +import ErrorPage from './pages/ErrorPage'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; @@ -60,10 +61,22 @@ const router = (isLoggedIn: boolean) => createBrowserRouter( createRoutesFromElements( - {/* 로그인 상관없이 접근 가능한 라우터 */} - {/* 이전에는 /login 라우터를 따로 두고, 기본 라우터에 접속시 조건문으로 이동할 페이지를 계산. 하지만 로그인 보호 라우터 적용하면서 /login 라우터를 기본 라우터로 변경함. */} + {/* 기본 라우터를 로그인 페이지로 변경 */} } /> + {/* + ) : ( + + ) + } + /> */} + + {/* 로그인 상관없이 접근 가능한 라우터. 보호되지 않는 라우터 */} } /> + } /> {/* 보호된 경로들에 ProtectedRoute 적용 */} { + const navigate = useNavigate(); + + return ( + + {/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */} + + 404 ERROR + + + 죄송합니다. 페이지를 찾을 수 없습니다. +
+ 존재하지 않는 주소를 입력하셨거나, +
+ 요청하신 페이지의 주소가 변경, 삭제되어 찾을 수 없습니다. +
+ + navigate('/')}>홈으로 +
+ ); +}; + +export default ErrorPage; diff --git a/src/styles/ErrorPageStyled.tsx b/src/styles/ErrorPageStyled.tsx new file mode 100644 index 0000000..e6971fd --- /dev/null +++ b/src/styles/ErrorPageStyled.tsx @@ -0,0 +1,39 @@ +import { styled } from 'styled-components'; +import theme from './Theme/Theme'; + +export const Layout = styled.div` + width: 100vw; + min-width: 100vw; + height: 100vh; + + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +`; + +export const Title = styled.p` + margin-top: 3rem; + font-size: 2rem; + font-weight: ${theme.font.weight.bold}; + color: ${theme.color.text}; + line-height: 1.3rem; +`; + +export const Content = styled.p` + margin-top: 2rem; + color: ${theme.color.gray}; + line-height: 1.5rem; + text-align: center; +`; + +export const HomeLink = styled(Content)` + cursor: pointer; + color: ${theme.color.lightGray}; + transition: color 200ms ease-in-out; + border-bottom: 1px solid ${theme.color.white}; + &:hover { + color: ${theme.color.gray}; + border-bottom: 1px solid ${theme.color.lightGray}; + } +`;