diff --git a/src/app/setupRouter.ts b/src/app/setupRouter.ts index 108ce5a..8438964 100644 --- a/src/app/setupRouter.ts +++ b/src/app/setupRouter.ts @@ -99,6 +99,34 @@ export function setupRouterGuards() { } } + if ( + getToken() && + (to.name === 'piggy' || + to.name === 'fund' || + to.name === 'fund_info' || + to.name === 'fund_add') + ) { + const { useSettingsStore } = await import('@/store/settingsStore') + const settingsStore = useSettingsStore() + if (!settingsStore.loaded) { + await settingsStore.fetchSettings() + } + if (!settingsStore.isSettingTruthy('enable_product_funds')) { + return next({ name: (from.name as string) || 'home' }) + } + } + + if (to.name === 'earnMoney' && getToken()) { + const { useSettingsStore } = await import('@/store/settingsStore') + const settingsStore = useSettingsStore() + if (!settingsStore.loaded) { + await settingsStore.fetchSettings() + } + if (!settingsStore.isSettingTruthy('has_page_earn_money')) { + return next({ name: (from.name as string) || 'user' }) + } + } + if (isFirst) { isFirst = false diff --git a/src/layouts/desktop/DesktopSidebar.vue b/src/layouts/desktop/DesktopSidebar.vue index d1fa6b4..14ded3c 100644 --- a/src/layouts/desktop/DesktopSidebar.vue +++ b/src/layouts/desktop/DesktopSidebar.vue @@ -50,6 +50,7 @@ import { useTrackingSystemsFeature } from '@/composables/useTrackingSystemsFeatu import { useSettingsStore } from '@/store/settingsStore' import { getPrimaryNavItems, getSecondaryNavItems } from '../config/navigation' import { useAppNavigation } from '../composables/useAppNavigation' +import { featureSettingForRoute } from '@/utils/superAdminMenuGates' import DesktopNavItem from './DesktopNavItem.vue' import AppCreditLink from '@/components/AppCreditLink.vue' @@ -58,7 +59,13 @@ const authenticated = computed(() => isToken()) const navLogo = logoFull const { trackingSystemsEnabled } = useTrackingSystemsFeature() const settingsStore = useSettingsStore() -const primaryItems = computed(() => getPrimaryNavItems(authenticated.value)) +const primaryItems = computed(() => + getPrimaryNavItems(authenticated.value).filter((item) => { + const featureKey = featureSettingForRoute(item.routeName) + if (featureKey) return settingsStore.isSettingTruthy(featureKey) + return true + }), +) /** «لیست دریافتیها» فقط در موبایل نمایش داده میشود */ const DESKTOP_HIDDEN_NAV_IDS = ['list'] const secondaryItems = computed(() => @@ -66,12 +73,8 @@ const secondaryItems = computed(() => includeRecoverySites: trackingSystemsEnabled.value, }).filter((item) => { if (DESKTOP_HIDDEN_NAV_IDS.includes(item.id)) return false - if (item.id === 'notifyTrigger') { - return settingsStore.isSettingTruthy('has_page_price_trigger') - } - if (item.id === 'giftCard') { - return settingsStore.isSettingTruthy('has_page_gift_card') - } + const featureKey = featureSettingForRoute(item.routeName) + if (featureKey) return settingsStore.isSettingTruthy(featureKey) return true }), ) diff --git a/src/layouts/mobile/MobileOverflowMenu.vue b/src/layouts/mobile/MobileOverflowMenu.vue index 1734193..d54d66d 100644 --- a/src/layouts/mobile/MobileOverflowMenu.vue +++ b/src/layouts/mobile/MobileOverflowMenu.vue @@ -34,18 +34,7 @@ >