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');
console.log(response);
// TODO : 적용 필요
const { userid, email, name } = response.data;
const { userid, email, name, accesstype } = response.data;
dispatch({
type: LOGIN,
payload: {
isLoggedIn: true,
accesstype,
user: {
id: userid,
email,
@ -98,6 +99,7 @@ export const JWTProvider = ({ children }) => {
// console.log(response);
if (response && response.data) {
const { accessToken, refreshToken, user } = response.data;
console.log(user);
setLocalStorage(ACCESS_TOKEN_NAME, accessToken);
if (refreshToken) setLocalStorage(REFRESH_TOKEN_NAME, refreshToken);
@ -109,7 +111,12 @@ export const JWTProvider = ({ children }) => {
type: LOGIN,
payload: {
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
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 ||============================== //
const MenuList = () => {
const { accesstype } = useAuth();
const menuItem = accesstype === '001' ? { items: [dashboard, admin, other] } : { items: [admin] };
const navItems = menuItem.items.map((item) => {
switch (item.type) {
case 'group':

@ -9,11 +9,14 @@ import { AppBar, Box, Container, CssBaseline, Toolbar, useMediaQuery } from '@mu
import Breadcrumbs from 'ui-component/extended/Breadcrumbs';
import Header from './Header';
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 { drawerWidth } from 'store/constant';
import { openDrawer } from 'store/slices/menu';
import { useDispatch, useSelector } from 'store';
import useAuth from 'hooks/useAuth';
// assets
import { IconChevronRight } from '@tabler/icons';
@ -65,6 +68,8 @@ const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(({
// ==============================|| MAIN LAYOUT ||============================== //
const MainLayout = () => {
const { accesstype } = useAuth();
console.log(`###############`, accesstype);
const theme = useTheme();
const matchDownMd = useMediaQuery(theme.breakpoints.down('lg'));
@ -111,13 +116,25 @@ const MainLayout = () => {
{/* breadcrumb */}
{container && (
<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 />
</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 />
</>
)}

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

@ -1,11 +1,13 @@
import other from './other';
import opst from './opst';
import admin from './admin';
import dashboard from './dashboard';
// ==============================|| MENU ITEMS ||============================== //
const menuItems = {
items: [dashboard, opst, other]
export const adminMenuItems = {
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 DashboardAnalytics = Loadable(lazy(() => import('views/dashboard/Analytics')));
// opst page routing
// admin page routing
const PublicBoard = Loadable(lazy(() => import('views/biz/board/PublicBoard')));
const Board = Loadable(lazy(() => import('views/biz/board/Board')));

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

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

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

Loading…
Cancel
Save