유저 권한레벨 처리

This commit is contained in:
2025-03-26 15:28:26 +09:00
parent cddd8e6333
commit 894eb17fd8
5 changed files with 118 additions and 87 deletions

View File

@@ -9,9 +9,8 @@ import { useEffect, useState } from 'react';
import Button from '../button/Button';
import { useLocation } from 'react-router-dom';
import { AuthInfo } from '../../../apis';
import { authType } from '../../../assets/data';
import { menuConfig } from '../../../assets/data/menuConfig';
import { getMenuConfig } from '../../../utils';
import { adminAuthLevel } from '../../../assets/data/types';
const Navi = () => {
const token = sessionStorage.getItem('token');
@@ -71,54 +70,16 @@ const Navi = () => {
}
};
// const menu = [
// {
// title: '운영자 관리',
// link: '/usermanage',
// access: userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === authType.adminSearchRead || auth.id === authType.adminLogSearchRead || auth.id === authType.authoritySettingRead || auth.id === authType.caliumRequestRead),
// submenu: [
// { title: '운영자 조회', link: '/usermanage/adminview', id: authType.adminSearchRead },
// { title: '사용 이력 조회', link: '/usermanage/logview', id: authType.adminLogSearchRead },
// { title: '권한 설정', link: '/usermanage/authsetting', id: authType.authoritySettingRead },
// { title: '칼리움 요청', link: '/usermanage/caliumrequest', id: authType.caliumRequestRead },
// ],
// },
// {
// title: '지표 관리',
// link: '/indexmanage',
// access: userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === authType.userIndicatorsRead || auth.id === authType.economicIndicatorsRead),
// submenu: [
// { title: '유저 지표', link: '/indexmanage/userindex', id: authType.userIndicatorsRead },
// { title: '경제 지표', link: '/indexmanage/economicindex', id: authType.economicIndicatorsRead },
// ],
// },
// {
// title: '운영 정보 관리',
// link: '/datamanage',
// access: userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === authType.userSearchRead || auth.id === authType.contentSearchRead || auth.id === authType.gameLogRead || auth.id === authType.cryptoRead),
// submenu: [
// { title: '유저 조회', link: '/datamanage/userview', id: authType.userIndicatorsRead },
// { title: '컨텐츠 조회', link: '/datamanage/contentsview', id: authType.contentSearchRead },
// { title: '게임 로그 조회', link: '/datamanage/gamelogview', id: authType.gameLogRead },
// { title: '크립토 조회', link: '/datamanage/cryptview', id: authType.cryptoRead },
// ],
// },
// {
// title: '운영 서비스 관리',
// link: '/servicemanage',
// access: userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === authType.inGameRead || auth.id === authType.whiteListRead || auth.id === authType.mailRead
// || auth.id === authType.blackListRead || auth.id === authType.reportRead || auth.id === authType.itemRead || auth.id === authType.eventRead ),
// submenu: [
// { title: '인게임 메시지', link: '/servicemanage/board', id: authType.inGameRead },
// // { title: '화이트리스트', link: '/servicemanage/whitelist', id: authType.whiteListRead },
// { title: '우편', link: '/servicemanage/mail', id: authType.mailRead },
// { title: '이용자 제재', link: '/servicemanage/userblock', id: authType.blackListRead },
// { title: '신고내역', link: '/servicemanage/reportlist', id: authType.reportRead },
// // { title: '아이템 복구 및 삭제', link: '/servicemanage/items', id: authType.itemRead },
// { title: '보상 이벤트 관리', link: '/servicemanage/event', id: authType.eventRead },
// ],
// },
// ];
const isClickable = (submenu) => {
switch (userInfo.auth_level_type) {
case adminAuthLevel.DEVELOPER:
case adminAuthLevel.READER:
case adminAuthLevel.MASTER:
return true;
default:
return submenu.authLevel === adminAuthLevel.NONE && userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === submenu.id);
}
}
return (
<>
@@ -133,14 +94,14 @@ const Navi = () => {
</TopMenu>
)}
<SubMenu>
{item.submenu &&
{item.submenu && userInfo &&
item.submenu.map((submenu, idx) => {
return (
<SubMenuItem key={idx} $isclickable={userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === submenu.id) ? 'true' : 'false'}>
<SubMenuItem key={idx} $isclickable={isClickable(submenu) ? 'true' : 'false'}>
<NavLink
to={userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === submenu.id) ? submenu.link : location.pathname}
to={isClickable(submenu) ? submenu.link : location.pathname}
onClick={e => {
userInfo.auth_list && userInfo.auth_list.some(auth => auth.id === submenu.id) ? handleLink(e) : handleModalClose();
isClickable(submenu) ? handleLink(e) : handleModalClose();
}}>
{submenu.title}
</NavLink>

View File

@@ -29,7 +29,9 @@ const Profile = () => {
const fetchData = async () => {
const token = sessionStorage.getItem('token');
setInfoData(await AuthInfo(token));
await AuthInfo(token).then(data => {
setInfoData(data);
});
};
useEffect(() => {