This commit is contained in:
focp212@naver.com
2025-11-05 14:25:47 +09:00
parent 696d578e23
commit a61f0bc2ff
5 changed files with 57 additions and 24 deletions

View File

@@ -6,16 +6,8 @@ import { IMAGE_ROOT } from '@/shared/constants/common';
import { UserFavorite } from '@/entities/user/model/types';
import { useStore } from '@/shared/model/store';
import { useTranslation } from 'react-i18next';
import { showAlert } from '@/widgets/show-alert';
/*
const items: Array<UserFavorite> = [
{img: IMAGE_ROOT + '/ico_menu_01.svg', title: '지급대행'},
{img: IMAGE_ROOT + '/ico_menu_02.svg', title: '거래내역조회'},
{img: IMAGE_ROOT + '/ico_menu_03.svg', title: '정산달력'},
{img: IMAGE_ROOT + '/ico_menu_02.svg', title: '거래내역조회'},
{img: IMAGE_ROOT + '/ico_menu_03.svg', title: '정산달력'}
];
*/
export interface FavoriteWrapperProps {
usingType: 'home' | 'menu',
editMode?: boolean,
@@ -33,11 +25,12 @@ export const FavoriteWrapper = ({
}: FavoriteWrapperProps) => {
const { navigate } = useNavigate();
const { i18n, t } = useTranslation();
const menuGrantsByKey = useStore.getState().UserStore.menuGrantsByKey;
const [favoriteItems, setFavoriteItems] = useState<Array<UserFavorite>>([]);
const itemAdd: UserFavorite = {
menuId: 0,
menuId: -1,
menuName: t('favorite.edit'),
menuNameEng: t('favorite.edit'),
iconFilePath: IMAGE_ROOT + '/ico_menu_plus.svg',
@@ -49,14 +42,26 @@ export const FavoriteWrapper = ({
setEditMode(true);
}
};
const checkGrant = (menuId?: number) => {
const myGrants = menuGrantsByKey['' + menuId];
if(myGrants?.includes('R') || menuId === -1){
return true
}
return false;
};
const onClickToNavigate = (path?: string) => {
if(!!path){
navigate(path);
if(setMenuOn){
setMenuOn(false);
const onClickToNavigate = (menuId?: number, path?: string) => {
if(menuId && checkGrant(menuId)){
if(!!path){
navigate(path);
if(setMenuOn){
setMenuOn(false);
}
}
}
else{
showAlert('권한이 없습니다.');
}
};
const getFavoriteList = () => {
@@ -75,7 +80,7 @@ export const FavoriteWrapper = ({
<SwiperSlide key={ `favorite-slide-key-${i}` }>
<div
className="swiper-item"
onClick={ () => !editMode && onClickToNavigate(favoriteItems[i]?.programPath) }
onClick={ () => !editMode && onClickToNavigate(favoriteItems[i]?.menuId, favoriteItems[i]?.programPath) }
>
<div className="swiper-icon coin-icon">
<img