Skip to content

Commit

Permalink
404 페이지를 제작한다. (SWYP-team-2th#120)
Browse files Browse the repository at this point in the history
* 404 페이지를 제작한다.

* title 변경

* 404 navigate 로직 작성

* 리다이렉트 로직 수정
  • Loading branch information
YOOJS1205 committed Mar 2, 2025
1 parent 31b32a8 commit 6bddeea
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function App() {
if (myInfo && isMyInfoSuccess) {
navigate(`/user/${myInfo.id}`, { replace: true });
}
}, [navigate, myInfo, isMyInfoSuccess]);
}, [myInfo, isMyInfoSuccess, accessToken]);

return (
<div className="w-full max-w-[480px] mx-auto my-0 h-[100dvh] flex items-center justify-center">
Expand Down
Binary file added src/assets/images/not-found.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions src/pages/NotFound/NotFoundPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useNavigate } from 'react-router-dom';
import useGetMyInfo from '@/api/useGetMyInfo';
import Logo from '@/assets/icons/logo.svg?react';
import NotFoundImage from '@/assets/images/not-found.png';
import { Button } from '@/components/common/Button/Button';
import { Header } from '@/components/common/Header/Header';
import Icon from '@/components/common/Icon';
import { getAccessToken } from '@/components/login/Auth/token';

export default function NotFoundPage() {
const navigate = useNavigate();
const accessToken = getAccessToken();

const { data: myInfo } = useGetMyInfo({
enabled: !!accessToken,
});

const handleClickBackButton = () => {
navigate(-1);
};

const handleClickGoToHomeButton = () => {
if (myInfo?.id) {
navigate(`/user/${myInfo.id}`);
} else {
navigate('/onboarding');
}
};

return (
<div className="relative w-full h-[100dvh]">
<Header
leftNode={
<Icon
name="ArrowLeft"
size="medium"
onClick={handleClickBackButton}
/>
}
centerNode={<Logo style={{ width: 70 }} />}
rightNode={<Icon name="UserOutline" size="medium" />}
/>
<div className="flex gap-[55px] w-full flex-col items-center justify-center absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2">
<img src={NotFoundImage} alt="not-found" width={200} height={200} />
<div className="flex flex-col gap-2 justify-center items-center">
<p className="text-h3">앗! 잘못된 주소예요!🥲</p>
<p className="text-title-x-small">
선택한 페이지가 없거나 삭제되었어요.
</p>
</div>
</div>
<Button
buttonType="primary"
size="large"
variant="solid"
className="fixed bottom-16 left-1/2 -translate-x-1/2"
onClick={handleClickGoToHomeButton}
>
홈으로 가기
</Button>
</div>
);
}
5 changes: 5 additions & 0 deletions src/routes/routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DefaultLayout from '@/components/common/Layout/DefaultLayout';
import SubLayout from '@/components/common/Layout/SubLayout';
import OAuthPage from '@/pages/Login/OAuthPage';
import MyPage from '@/pages/my/MyPage';
import NotFoundPage from '@/pages/NotFound/NotFoundPage';
import OnBoardingPage from '@/pages/OnBoarding/OnBoardingPage';
import SettingsPage from '@/pages/settings/SettingsPage';
import VoteCommentDetailPage from '@/pages/Vote/VoteCommentDetailPage';
Expand Down Expand Up @@ -45,6 +46,10 @@ export const router = createBrowserRouter([
path: '/settings',
element: <SettingsPage />,
},
{
path: '*',
element: <NotFoundPage />,
},
],
},
]);

0 comments on commit 6bddeea

Please sign in to comment.