Skip to content

Commit

Permalink
feat: MyAccount 페이지 로그아웃 기능 구현 및 로그인 했을 경우에만 접근 가능하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyoeunkh committed Jul 4, 2024
1 parent ce87806 commit 8f54222
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/MyAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
/* @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { Navigate, useNavigate } from 'react-router-dom';

import { Button } from '@/components/common/Button';
import { Container } from '@/components/common/Layout/Container';
import { useAuth } from '@/hooks/useAuth';

export default function MyAccountPage() {
const { authToken, setAuthToken } = useAuth();
const navigate = useNavigate();
if (!authToken) {
return <Navigate to="/login" replace={true} />;
}
const HandleLogout = () => {
sessionStorage.clear();
setAuthToken(null);
navigate('/', { replace: true });
};
return (
<MyAccountWrapper>
<Container flexDirection="column" justifyContent="center" alignItems="center" maxWidth="1024px">
<Title>userID님 안녕하세요!</Title>
<Title>{authToken.id} 안녕하세요!</Title>
<Button
themetype="darkGray"
size="large"
onClick={HandleLogout}
css={css`
width: 20%;
margin-top: 30px;
Expand Down

0 comments on commit 8f54222

Please sign in to comment.