메뉴 권한 및 ui 수정
This commit is contained in:
@@ -5,6 +5,7 @@ import { RefObject, useEffect, useState } from 'react';
|
||||
import { MenuItem } from '../model/types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { MenuItems } from '@/entities/common/model/constant';
|
||||
import { showAlert } from '@/widgets/show-alert';
|
||||
|
||||
export interface MenuCategoryProps {
|
||||
menuId?: number;
|
||||
@@ -33,15 +34,30 @@ export const MenuCategory = ({
|
||||
}: MenuCategoryProps) => {
|
||||
const { navigate } = useNavigate();
|
||||
const { i18n } = useTranslation();
|
||||
const menuGrantsByKey = useStore.getState().UserStore.menuGrantsByKey;
|
||||
|
||||
const [favoriteItems, setFavoriteItems] = useState<Array<UserFavorite>>([]);
|
||||
const [menuIds, setMenuIds] = useState<Array<number | undefined>>([]);
|
||||
|
||||
const onClickToNavigate = (path?: string, menuId?: number) => {
|
||||
if(!!path && !!setMenuOn && !editMode){
|
||||
setMenuOn(false);
|
||||
navigate(path);
|
||||
const checkGrant = (menuId?: number) => {
|
||||
const myGrants = menuGrantsByKey['' + menuId];
|
||||
if(myGrants?.includes('R')){
|
||||
return true
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const onClickToNavigate = (menuId?: number, path?: string) => {
|
||||
if(menuId && checkGrant(menuId)){
|
||||
if(!!path && !!setMenuOn && !editMode){
|
||||
setMenuOn(false);
|
||||
navigate(path);
|
||||
}
|
||||
}
|
||||
else{
|
||||
showAlert('권한이 없습니다.');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const favoriteSetting = (
|
||||
@@ -121,7 +137,7 @@ export const MenuCategory = ({
|
||||
rs.push(
|
||||
<li
|
||||
key={ `menu-item-key-${menuId}-${i}` }
|
||||
onClick={ () => onClickToNavigate(subMenu[i]?.programPath) }
|
||||
onClick={ () => onClickToNavigate(subMenu[i]?.menuId, subMenu[i]?.programPath) }
|
||||
>
|
||||
<span>{ displayName }</span>
|
||||
<div className="check_box_scrap">
|
||||
@@ -151,7 +167,7 @@ export const MenuCategory = ({
|
||||
rs.push(
|
||||
<li
|
||||
key={ `menu-item-key-${i}` }
|
||||
onClick={ () => onClickToNavigate(subMenu[i]?.programPath) }
|
||||
onClick={ () => onClickToNavigate(subMenu[i]?.menuId, subMenu[i]?.programPath) }
|
||||
>{ displayName }</li>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user