diff --git a/src/pages/menuPages/configuration/index.vue b/src/pages/menuPages/configuration/index.vue index ab77019..beec0de 100644 --- a/src/pages/menuPages/configuration/index.vue +++ b/src/pages/menuPages/configuration/index.vue @@ -174,7 +174,7 @@ import SettingValueField from './SettingValueField.vue' import SettingCard from './SettingCard.vue' import { refreshAppModeMenu } from '@/router' import { useUserStore } from '@/store/userStore' -import { setStoreModeFromSettings } from '@/utils/config' +import { applyBannerEnabledFromRows, setBannerEnabledFromSettings, setStoreModeFromSettings } from '@/utils/config' import { EDITABLE_SETTING_GROUPS, SYSTEM_SETTING_GROUPS, @@ -420,7 +420,9 @@ async function initConfig() { (isSystemMode.value ? await getSystemConfiguration() : await getEditableConfiguration()) ?? [] - if (!isSystemMode.value) { + if (isSystemMode.value) { + applyBannerEnabledFromRows(baseData.value) + } else { const storeRow = baseData.value.find((row) => row.key === 'is_store') if (storeRow) { setStoreModeFromSettings(isSwitchOn(storeRow.value)) @@ -531,6 +533,9 @@ async function saveSettingRow(row: Const) { setStoreModeFromSettings(isSwitchOn(value)) refreshMenuAfterStoreChange() } + if (row.key === 'banner_enabled' && isSystemMode.value) { + setBannerEnabledFromSettings(isSwitchOn(value)) + } savedFlashIds.value.add(id) if (saveTimers.has(id)) clearTimeout(saveTimers.get(id)) saveTimers.set( diff --git a/src/pages/menuPages/pricing/hooks/storePriceColumns.tsx b/src/pages/menuPages/pricing/hooks/storePriceColumns.tsx index e179c3c..c0bfb3a 100644 --- a/src/pages/menuPages/pricing/hooks/storePriceColumns.tsx +++ b/src/pages/menuPages/pricing/hooks/storePriceColumns.tsx @@ -4,7 +4,11 @@ import { usePrice } from '@core/utils/usePrice' const SOURCE_LABELS: Record = { zaarbox: 'تابلو Zaarbox', - legacy: 'فید قدیمی' + legacy: 'فید قدیمی', + montzar: 'منتظر', + main_product: 'محصول اصلی', + database_last: 'آخرین قیمت DB', + store: 'فروشگاه' } export const storePriceColumns: BaseTableColumn[] = [ diff --git a/src/pages/menuPages/setting/index.vue b/src/pages/menuPages/setting/index.vue index 597d615..5e4fb15 100644 --- a/src/pages/menuPages/setting/index.vue +++ b/src/pages/menuPages/setting/index.vue @@ -25,6 +25,7 @@ import BasicMenu from '@/components/BasicMenu/index.vue' import { useRouterStore } from '@core/stores/router' import { useUserStore } from '@/store/userStore' import { isDeployAdmin } from '@/utils/deployAdmin' +import { bannerEnabledSetting } from '@/utils/config' import { get } from 'lodash' import type { RouteRecordRaw } from 'vue-router' @@ -36,6 +37,7 @@ const menu = computed(() => { const children = get(item, 'children[0].children', []) as RouteRecordRaw[] return children .filter((child) => !child.meta?.hideMenu) + .filter((child) => child.name !== 'banners' || bannerEnabledSetting.value) .filter( (child) => !child.meta?.deployAdminOnly || isDeployAdmin(userStore.userInfo?.mobile) diff --git a/src/router/routes/setting.ts b/src/router/routes/setting.ts index ab40460..3984765 100644 --- a/src/router/routes/setting.ts +++ b/src/router/routes/setting.ts @@ -1,6 +1,7 @@ import type { RouteRecordRaw } from 'vue-router' import { isDeployAdmin } from '@/utils/deployAdmin' import { useUserStore } from '@/store/userStore' +import { bannerEnabledSetting } from '@/utils/config' const Setting: RouteRecordRaw = { name: 'settings', @@ -67,6 +68,11 @@ const Setting: RouteRecordRaw = { icon: 'vuesax-linear:image', title: 'بنرها', order: 3 + }, + beforeEnter() { + if (!bannerEnabledSetting.value) { + return { name: 'configuration' } + } } }, { diff --git a/src/utils/config.ts b/src/utils/config.ts index 2d1c0e4..301293f 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,3 +1,4 @@ +import { ref } from 'vue' import { setCachedMainMetal } from '@/utils/metalLabels' export function getConfigApp(key: string) { @@ -12,6 +13,9 @@ export function getConfigApp(key: string) { let storeModeFromSettings: boolean | null = null let settingsBootstrapped = false +/** reactive — برای فیلتر منوی «بنرها» در پیکربندی */ +export const bannerEnabledSetting = ref(false) + function isSwitchOn(value: string | undefined | null): boolean { const v = (value ?? '').trim().toLowerCase() return v === 'true' || v === '1' || v === 'yes' @@ -21,6 +25,15 @@ export function setStoreModeFromSettings(value: boolean): void { storeModeFromSettings = value } +export function setBannerEnabledFromSettings(value: boolean): void { + bannerEnabledSetting.value = value +} + +export function applyBannerEnabledFromRows(rows: Array<{ key?: string; value?: string | null }>) { + const row = rows.find((item) => item.key === 'banner_enabled') + setBannerEnabledFromSettings(row ? isSwitchOn(row.value) : false) +} + async function bootstrapSettingsFromApi(): Promise { if (settingsBootstrapped) return @@ -33,11 +46,13 @@ async function bootstrapSettingsFromApi(): Promise { const mainWalletRow = list.find((item) => item.key === 'main_wallet_products') const mainMetalRow = list.find((item) => item.key === 'main_metal') storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false + applyBannerEnabledFromRows(list) setCachedMainMetal(mainMetalRow?.value) const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet') setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value)) } catch { storeModeFromSettings = false + setBannerEnabledFromSettings(false) setCachedMainMetal(null) const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet') setCachedMainWalletProductIds([])