feat: 권한별 메뉴 반영

main
minuk926 3 years ago
parent 5454e36dda
commit 6414cd31af

@ -65,11 +65,12 @@ export const JWTProvider = ({ children }) => {
const response = await axios.get('/api/v1/ctgy/user/info'); const response = await axios.get('/api/v1/ctgy/user/info');
console.log(response); console.log(response);
// TODO : 적용 필요 // TODO : 적용 필요
const { userid, email, name } = response.data; const { userid, email, name, accesstype } = response.data;
dispatch({ dispatch({
type: LOGIN, type: LOGIN,
payload: { payload: {
isLoggedIn: true, isLoggedIn: true,
accesstype,
user: { user: {
id: userid, id: userid,
email, email,
@ -98,6 +99,7 @@ export const JWTProvider = ({ children }) => {
// console.log(response); // console.log(response);
if (response && response.data) { if (response && response.data) {
const { accessToken, refreshToken, user } = response.data; const { accessToken, refreshToken, user } = response.data;
console.log(user);
setLocalStorage(ACCESS_TOKEN_NAME, accessToken); setLocalStorage(ACCESS_TOKEN_NAME, accessToken);
if (refreshToken) setLocalStorage(REFRESH_TOKEN_NAME, refreshToken); if (refreshToken) setLocalStorage(REFRESH_TOKEN_NAME, refreshToken);
@ -109,7 +111,12 @@ export const JWTProvider = ({ children }) => {
type: LOGIN, type: LOGIN,
payload: { payload: {
isLoggedIn: true, isLoggedIn: true,
user accesstype: user.accesstype,
user: {
id: user.userid,
email: user.email,
name: user.name
}
} }
}); });
} }

@ -5,11 +5,19 @@ import { Typography } from '@mui/material';
// project imports // project imports
import NavGroup from './NavGroup'; import NavGroup from './NavGroup';
import menuItem from 'menu-items'; import useAuth from 'hooks/useAuth';
import other from 'menu-items/other';
import admin from 'menu-items/admin';
import dashboard from 'menu-items/dashboard';
// ==============================|| SIDEBAR MENU LIST ||============================== // // ==============================|| SIDEBAR MENU LIST ||============================== //
const MenuList = () => { const MenuList = () => {
const { accesstype } = useAuth();
const menuItem = accesstype === '001' ? { items: [dashboard, admin, other] } : { items: [admin] };
const navItems = menuItem.items.map((item) => { const navItems = menuItem.items.map((item) => {
switch (item.type) { switch (item.type) {
case 'group': case 'group':

@ -9,11 +9,14 @@ import { AppBar, Box, Container, CssBaseline, Toolbar, useMediaQuery } from '@mu
import Breadcrumbs from 'ui-component/extended/Breadcrumbs'; import Breadcrumbs from 'ui-component/extended/Breadcrumbs';
import Header from './Header'; import Header from './Header';
import Sidebar from './Sidebar'; import Sidebar from './Sidebar';
import navigation from 'menu-items'; import other from 'menu-items/other';
import admin from 'menu-items/admin';
import dashboard from 'menu-items/dashboard';
import useConfig from 'hooks/useConfig'; import useConfig from 'hooks/useConfig';
import { drawerWidth } from 'store/constant'; import { drawerWidth } from 'store/constant';
import { openDrawer } from 'store/slices/menu'; import { openDrawer } from 'store/slices/menu';
import { useDispatch, useSelector } from 'store'; import { useDispatch, useSelector } from 'store';
import useAuth from 'hooks/useAuth';
// assets // assets
import { IconChevronRight } from '@tabler/icons'; import { IconChevronRight } from '@tabler/icons';
@ -65,6 +68,8 @@ const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(({
// ==============================|| MAIN LAYOUT ||============================== // // ==============================|| MAIN LAYOUT ||============================== //
const MainLayout = () => { const MainLayout = () => {
const { accesstype } = useAuth();
console.log(`###############`, accesstype);
const theme = useTheme(); const theme = useTheme();
const matchDownMd = useMediaQuery(theme.breakpoints.down('lg')); const matchDownMd = useMediaQuery(theme.breakpoints.down('lg'));
@ -111,13 +116,25 @@ const MainLayout = () => {
{/* breadcrumb */} {/* breadcrumb */}
{container && ( {container && (
<Container maxWidth="lg"> <Container maxWidth="lg">
<Breadcrumbs separator={IconChevronRight} navigation={navigation} icon title rightAlign /> <Breadcrumbs
separator={IconChevronRight}
navigation={accesstype === '001' ? { items: [dashboard, admin, other] } : { items: [admin] }}
icon
title
rightAlign
/>
<Outlet /> <Outlet />
</Container> </Container>
)} )}
{!container && ( {!container && (
<> <>
<Breadcrumbs separator={IconChevronRight} navigation={navigation} icon title rightAlign /> <Breadcrumbs
separator={IconChevronRight}
navigation={accesstype === '001' ? { items: [dashboard, admin, other] } : { items: [admin] }}
icon
title
rightAlign
/>
<Outlet /> <Outlet />
</> </>
)} )}

@ -47,15 +47,15 @@ const icons = {
// ==============================|| OPST MENU ITEMS ||============================== // // ==============================|| OPST MENU ITEMS ||============================== //
const opst = { const admin = {
id: 'opst', id: 'admin',
// title: <FormattedMessage id="opst" />, // title: <FormattedMessage id="admin" />,
type: 'group', type: 'group',
children: [ children: [
{ {
/* 공지 사항 */ /* 공지 사항 */
id: 'opst-1', id: 'admin-1',
title: <FormattedMessage id="opst-1" />, title: <FormattedMessage id="admin-1" />,
type: 'item', type: 'item',
icon: icons.IconClipboardCheck, icon: icons.IconClipboardCheck,
url: '/publicBoard', url: '/publicBoard',
@ -63,23 +63,23 @@ const opst = {
}, },
{ {
/* 주정차 의견 진술 */ /* 주정차 의견 진술 */
id: 'opst-2', id: 'admin-2',
title: <FormattedMessage id="opst-2" />, title: <FormattedMessage id="admin-2" />,
type: 'collapse', type: 'collapse',
icon: icons.IconParking, icon: icons.IconParking,
children: [ children: [
{ {
/* 심의 목록 */ /* 심의 목록 */
id: 'opst-2-1', id: 'admin-2-1',
title: <FormattedMessage id="opst-2-1" />, title: <FormattedMessage id="admin-2-1" />,
type: 'item', type: 'item',
url: '/parking/review', url: '/parking/review',
icon: icons.IconList icon: icons.IconList
}, },
{ {
/* 심의 등록 */ /* 심의 등록 */
id: 'opst-2-2', id: 'admin-2-2',
title: <FormattedMessage id="opst-2-2" />, title: <FormattedMessage id="admin-2-2" />,
type: 'item', type: 'item',
url: '/parking/register', url: '/parking/register',
icon: icons.IconDatabaseImport icon: icons.IconDatabaseImport
@ -88,31 +88,31 @@ const opst = {
}, },
{ {
/* 거주자 의견 진술 */ /* 거주자 의견 진술 */
id: 'opst-3', id: 'admin-3',
title: <FormattedMessage id="opst-3" />, title: <FormattedMessage id="admin-3" />,
type: 'collapse', type: 'collapse',
icon: icons.IconUser, icon: icons.IconUser,
children: [ children: [
{ {
/* 자료 관리 */ /* 자료 관리 */
id: 'opst-3-1', id: 'admin-3-1',
title: <FormattedMessage id="opst-3-1" />, title: <FormattedMessage id="admin-3-1" />,
type: 'item', type: 'item',
url: '/resident/data', url: '/resident/data',
icon: icons.IconDatabase icon: icons.IconDatabase
}, },
{ {
/* 심의 목록 */ /* 심의 목록 */
id: 'opst-3-2', id: 'admin-3-2',
title: <FormattedMessage id="opst-2-1" />, title: <FormattedMessage id="admin-2-1" />,
type: 'item', type: 'item',
url: '/resident/review', url: '/resident/review',
icon: icons.IconList icon: icons.IconList
}, },
{ {
/* 심의 등록 */ /* 심의 등록 */
id: 'opst-3-3', id: 'admin-3-3',
title: <FormattedMessage id="opst-2-2" />, title: <FormattedMessage id="admin-2-2" />,
type: 'item', type: 'item',
url: '/resident/register', url: '/resident/register',
icon: icons.IconDatabaseImport icon: icons.IconDatabaseImport
@ -121,31 +121,31 @@ const opst = {
}, },
{ {
/* 장애인 의견 진술 */ /* 장애인 의견 진술 */
id: 'opst-4', id: 'admin-4',
title: <FormattedMessage id="opst-4" />, title: <FormattedMessage id="admin-4" />,
type: 'collapse', type: 'collapse',
icon: icons.IconDisabled, icon: icons.IconDisabled,
children: [ children: [
{ {
/* 자료 관리 */ /* 자료 관리 */
id: 'opst-4-1', id: 'admin-4-1',
title: <FormattedMessage id="opst-3-1" />, title: <FormattedMessage id="admin-3-1" />,
type: 'item', type: 'item',
url: '/disabled/data', url: '/disabled/data',
icon: icons.IconDatabase icon: icons.IconDatabase
}, },
{ {
/* 심의 목록 */ /* 심의 목록 */
id: 'opst-4-2', id: 'admin-4-2',
title: <FormattedMessage id="opst-2-1" />, title: <FormattedMessage id="admin-2-1" />,
type: 'item', type: 'item',
url: '/disabled/review', url: '/disabled/review',
icon: icons.IconList icon: icons.IconList
}, },
{ {
/* 심의 등록 */ /* 심의 등록 */
id: 'opst-4-3', id: 'admin-4-3',
title: <FormattedMessage id="opst-2-2" />, title: <FormattedMessage id="admin-2-2" />,
type: 'item', type: 'item',
url: '/disabled/register', url: '/disabled/register',
icon: icons.IconDatabaseImport icon: icons.IconDatabaseImport
@ -154,24 +154,24 @@ const opst = {
}, },
{ {
/* 사용자 관리 */ /* 사용자 관리 */
id: 'opst-5', id: 'admin-5',
title: <FormattedMessage id="opst-5" />, title: <FormattedMessage id="admin-5" />,
type: 'item', type: 'item',
url: '/user/management', url: '/user/management',
icon: icons.IconUserCheck icon: icons.IconUserCheck
}, },
// { // {
// /* SMS 관리 */ // /* SMS 관리 */
// id: 'opst-6', // id: 'admin-6',
// title: <FormattedMessage id="opst-6" />, // title: <FormattedMessage id="admin-6" />,
// type: 'item', // type: 'item',
// url: '/sms/management', // url: '/sms/management',
// icon: icons.IconMessage // icon: icons.IconMessage
// }, // },
{ {
/* 게시판 관리 */ /* 게시판 관리 */
id: 'opst-7', id: 'admin-7',
title: <FormattedMessage id="opst-7" />, title: <FormattedMessage id="admin-7" />,
type: 'item', type: 'item',
url: '/board', url: '/board',
icon: icons.IconClipboardList icon: icons.IconClipboardList
@ -179,4 +179,4 @@ const opst = {
] ]
}; };
export default opst; export default admin;

@ -1,11 +1,13 @@
import other from './other'; import other from './other';
import opst from './opst'; import admin from './admin';
import dashboard from './dashboard'; import dashboard from './dashboard';
// ==============================|| MENU ITEMS ||============================== // // ==============================|| MENU ITEMS ||============================== //
const menuItems = { export const adminMenuItems = {
items: [dashboard, opst, other] items: [dashboard, admin, other]
}; };
export default menuItems; export const judgeMenuItems = {
items: [dashboard, admin, other]
};

@ -0,0 +1,108 @@
// third-party
import { FormattedMessage } from 'react-intl';
// assets
import {
IconKey,
IconReceipt2,
IconBug,
IconBellRinging,
IconPhoneCall,
IconQuestionMark,
IconShieldLock,
IconUserCheck,
IconMessage,
IconClipboardList,
IconClipboardCheck,
IconDisabled,
IconUser,
IconParking,
IconDatabase,
IconDatabaseImport,
IconList,
IconFileCertificate
} from '@tabler/icons';
// constant
const icons = {
IconKey,
IconReceipt2,
IconBug,
IconBellRinging,
IconPhoneCall,
IconQuestionMark,
IconShieldLock,
IconUserCheck,
IconMessage,
IconClipboardList,
IconClipboardCheck,
IconUser,
IconDisabled,
IconParking,
IconDatabase,
IconDatabaseImport,
IconList,
IconFileCertificate
};
// ==============================|| OPST MENU ITEMS ||============================== //
const judge = {
id: 'judge',
// title: <FormattedMessage id="admin" />,
type: 'group',
children: [
{
/* 공지 사항 */
id: 'judge-1',
title: <FormattedMessage id="judge-1" />,
type: 'item',
icon: icons.IconClipboardCheck,
url: '/publicBoard',
breadcrumbs: true
},
{
/* 심의대상 목록 */
id: 'judge-2',
title: <FormattedMessage id="judge-2" />,
type: 'collapse',
icon: icons.IconParking,
children: [
{
/* 주정차 심의대상 목록 */
id: 'judge-2-1',
title: <FormattedMessage id="judge-2-1" />,
type: 'item',
url: '/parking/review',
icon: icons.IconList
},
{
/* 거주자 심의대상 목록 */
id: 'judge-2-2',
title: <FormattedMessage id="judge-2-2" />,
type: 'item',
url: '/resident/review',
icon: icons.IconList
},
{
/* 장애인 심의대상 목록 */
id: 'judge-2-3',
title: <FormattedMessage id="judge-2-3" />,
type: 'item',
url: '/disabled/review',
icon: icons.IconList
}
]
},
{
/* 게시판 관리 */
id: 'judge-3',
title: <FormattedMessage id="judge-3" />,
type: 'item',
url: '/board',
icon: icons.IconClipboardList
}
]
};
export default judge;

@ -10,7 +10,7 @@ const SamplePage = Loadable(lazy(() => import('views/sample-page')));
const DashboardDefault = Loadable(lazy(() => import('views/dashboard/Default'))); const DashboardDefault = Loadable(lazy(() => import('views/dashboard/Default')));
const DashboardAnalytics = Loadable(lazy(() => import('views/dashboard/Analytics'))); const DashboardAnalytics = Loadable(lazy(() => import('views/dashboard/Analytics')));
// opst page routing // admin page routing
const PublicBoard = Loadable(lazy(() => import('views/biz/board/PublicBoard'))); const PublicBoard = Loadable(lazy(() => import('views/biz/board/PublicBoard')));
const Board = Loadable(lazy(() => import('views/biz/board/Board'))); const Board = Loadable(lazy(() => import('views/biz/board/Board')));

@ -5,6 +5,7 @@ import { LOGIN, LOGOUT, REGISTER } from './actions';
const initialState = { const initialState = {
isLoggedIn: false, isLoggedIn: false,
accesstype: null,
isInitialized: false, isInitialized: false,
user: null user: null
}; };
@ -19,10 +20,11 @@ const accountReducer = (state = initialState, action) => {
}; };
} }
case LOGIN: { case LOGIN: {
const { user } = action.payload; const { user, accesstype } = action.payload;
return { return {
...state, ...state,
isLoggedIn: true, isLoggedIn: true,
accesstype,
isInitialized: true, isInitialized: true,
user user
}; };
@ -31,6 +33,7 @@ const accountReducer = (state = initialState, action) => {
return { return {
...state, ...state,
isInitialized: true, isInitialized: true,
accesstype: null,
isLoggedIn: false, isLoggedIn: false,
user: null user: null
}; };

@ -1,16 +1,16 @@
{ {
"opst": "Opst", "opst": "Opst",
"opst-1": "Public board", "admin-1": "Public board",
"opst-2": "주정차 의견 진술", "admin-2": "주정차 의견 진술",
"opst-2-1": "심의 목록", "admin-2-1": "심의 목록",
"opst-2-2": "심의 등록", "admin-2-2": "심의 등록",
"opst-3": "거주자 의견 진술", "admin-3": "거주자 의견 진술",
"opst-3-1": "자료 관리", "admin-3-1": "자료 관리",
"opst-4": "장애인 의견 진술", "admin-4": "장애인 의견 진술",
"opst-5": "사용자 관리", "admin-5": "사용자 관리",
"opst-5-2": "심사위원 평가", "admin-5-2": "심사위원 평가",
"opst-6": "SMS 관리", "admin-6": "SMS 관리",
"opst-7": "Board", "admin-7": "Board",
"dashboard": "Dashboard", "dashboard": "Dashboard",
"default": "Default", "default": "Default",

@ -1,16 +1,24 @@
{ {
"opst": "의견 진술 관리", "admin": "의견 진술 관리[관리자]",
"opst-1": "공지 사항", "admin-1": "공지 사항",
"opst-2": "주정차 의견진술", "admin-2": "주정차 의견진술",
"opst-2-1": "심의목록", "admin-2-1": "심의목록",
"opst-2-2": "심의 등록", "admin-2-2": "심의 등록",
"opst-3": "거주자 의견 진술", "admin-3": "거주자 의견 진술",
"opst-3-1": "자료 관리", "admin-3-1": "자료 관리",
"opst-4": "장애인 의견 진술", "admin-4": "장애인 의견 진술",
"opst-5": "사용자 관리", "admin-5": "사용자 관리",
"opst-5-2": "심사위원 평가", "admin-5-2": "심사위원 평가",
"opst-6": "SMS 관리", "admin-6": "SMS 관리",
"opst-7": "게시판 관리", "admin-7": "게시판 관리",
"judge": "의견 진술 관리[심사자]",
"judge-1": "공지 사항",
"judge-2": "심의대상 목록",
"judge-2-1": "주정차 심의대상 목록",
"judge-2-2": "거주자 심의대상 목록",
"judge-2-3": "장애인 심의대상 목록",
"judge-3": "게시판 관리",
"dashboard": "Dashboard", "dashboard": "Dashboard",
"default": "Default", "default": "Default",

Loading…
Cancel
Save