..
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAppBridge } from '@/hooks';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useStore } from '@/shared/model/store';
|
||||
import { showAlert } from '../show-alert';
|
||||
|
||||
export const FooterNavigation = ({
|
||||
setMenuOn,
|
||||
@@ -16,11 +18,26 @@ export const FooterNavigation = ({
|
||||
}: FooterProps) => {
|
||||
const { navigate } = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const menuGrantsByKey = useStore.getState().UserStore.menuGrantsByKey;
|
||||
|
||||
const [isFooterOn, setIsFooterOn] = useState<boolean>(true);
|
||||
|
||||
const onClickToNavigate = (path?: string) => {
|
||||
if(!!path){
|
||||
navigate(path);
|
||||
const checkGrant = (menuId?: number) => {
|
||||
const myGrants = menuGrantsByKey['' + menuId];
|
||||
if(myGrants?.includes('R') || menuId === -1){
|
||||
return true
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const onClickToNavigate = (menuId?: number, path?: string) => {
|
||||
if(menuId && checkGrant(menuId)){
|
||||
if(!!path){
|
||||
navigate(path);
|
||||
}
|
||||
}
|
||||
else{
|
||||
showAlert('권한이 없습니다.');
|
||||
}
|
||||
};
|
||||
const onClickToOpenMenu = () => {
|
||||
@@ -33,6 +50,7 @@ export const FooterNavigation = ({
|
||||
activeIcon: IMAGE_ROOT + '/home-active.svg',
|
||||
inactiveIcon: IMAGE_ROOT + '/home.svg',
|
||||
path: PATHS.home,
|
||||
menuId: -1,
|
||||
activeKey: FooterItemActiveKey.Home,
|
||||
title: t('footer.home')
|
||||
},
|
||||
@@ -40,6 +58,7 @@ export const FooterNavigation = ({
|
||||
activeIcon: IMAGE_ROOT + '/chart-active.svg',
|
||||
inactiveIcon: IMAGE_ROOT + '/chart.svg',
|
||||
path: PATHS.transaction.allTransaction.list,
|
||||
menuId: 31,
|
||||
activeKey: FooterItemActiveKey.Transaction,
|
||||
title: t('footer.transaction')
|
||||
},
|
||||
@@ -47,6 +66,7 @@ export const FooterNavigation = ({
|
||||
activeIcon: IMAGE_ROOT + '/money-active.svg',
|
||||
inactiveIcon: IMAGE_ROOT + '/money.svg',
|
||||
path: PATHS.settlement.list,
|
||||
menuId: 36,
|
||||
activeKey: FooterItemActiveKey.Settlement,
|
||||
title: t('footer.settlement')
|
||||
},
|
||||
@@ -54,6 +74,7 @@ export const FooterNavigation = ({
|
||||
activeIcon: IMAGE_ROOT + '/users-active.svg',
|
||||
inactiveIcon: IMAGE_ROOT + '/users.svg',
|
||||
path: PATHS.account.user.manage,
|
||||
menuId: 45,
|
||||
activeKey: FooterItemActiveKey.Account,
|
||||
title: t('footer.account')
|
||||
},
|
||||
@@ -76,7 +97,7 @@ export const FooterNavigation = ({
|
||||
data-inactive-icon={ buttonItems[i]?.inactiveIcon }
|
||||
onClick={ () => {
|
||||
if(!!buttonItems[i]?.path){
|
||||
onClickToNavigate(buttonItems[i]?.path);
|
||||
onClickToNavigate(buttonItems[i]?.menuId, buttonItems[i]?.path);
|
||||
}
|
||||
else{
|
||||
onClickToOpenMenu();
|
||||
|
||||
Reference in New Issue
Block a user