Skip to content
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

Feat/#97 admin page #98

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import MyPageAccount from './pages/MyPage/MyPageAccount';
import Complete from './pages/Education/Complete';
import NotFound from './pages/Error/NotFound';
import EmailVerification from './pages/Join/EmailVerification';
import AdminPage from './pages/Admin/AdminPage';
function App() {
return (
<ThemeProvider theme={Theme}>
<GlobalStyle />
<Header />
<Routes>
<Route path='/' element={<Main />} />
<Route path='/admin' element={<AdminPage />} />
<Route path='/education' element={<EducationSelect />} />
<Route path='/education/basic' element={<Game type='basic' />} />
<Route path='/education/advanced' element={<Game type='advanced' />} />
Expand Down
22 changes: 22 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Header = () => {
const loginState = JSON.parse(sessionStorage.getItem('loginState'));
const location = useLocation();
const [nowPath, setNowPath] = useState('');
const [isAdmin, setIsAdmin] = useState(false);

const onClickLogout = (data) => {
if (confirm('로그아웃 하시겠습니까?')) {
Expand All @@ -34,6 +35,7 @@ const Header = () => {
if (loginState) {
GetUserInfo((res) => {
setUserName(res.data.user.nickname);
console.log(res);
});
}
}, []);
Expand All @@ -43,7 +45,14 @@ const Header = () => {
console.log(nowPath);
}, [location]);

useEffect(() => {
GetUserInfo((res) => {
if (res.data.user.role === 'ADMIN') setIsAdmin(true);
});
}, []);

return (
// 관리자 아이디로 로그인 했을시 헤더에 따로 띄우기
<>
{nowPath === '/' ||
nowPath === '/education' ||
Expand All @@ -60,6 +69,9 @@ const Header = () => {
<Learning onClick={() => navigate('/education')}>학습하기</Learning>
{loginState ? (
<SignBox>
{isAdmin && (
<GoAdmin onClick={() => navigate('/admin')}>admin</GoAdmin>
)}
<UserPageBtn onClick={() => navigate('/mypage/education')}>
{userName} 님 환영합니다!
</UserPageBtn>
Expand Down Expand Up @@ -100,6 +112,7 @@ const SignBox = styled.div`
margin-left: auto;
margin-right: 67px;
display: flex;
//justify-content: center;
`;
const SignBtn = styled.button`
height: 27px;
Expand Down Expand Up @@ -132,3 +145,12 @@ const LogoIcon = styled.img`
margin-left: 30px;
cursor: pointer;
`;

const GoAdmin = styled.button`
width: 50px;
background: gold;
font-size: 15px;
font-weight: 700;
color: ${({ theme }) => theme.colors.RED};
padding-right: 20px;
`;
15 changes: 15 additions & 0 deletions src/pages/Admin/AdminPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from 'styled-components';

const AdminPage = () => {
return (
<>
<AdminPageBox>여기는 어드민 페이지 입니다. . . .</AdminPageBox>
</>
);
};

export default AdminPage;

const AdminPageBox = styled.div`
width: 100%;
`;