added notif 2
This commit is contained in:
+46
-2
@@ -1,7 +1,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { setCachedMainMetal } from '@/utils/metalLabels'
|
||||
|
||||
export type AccountingProvider = 'none' | 'pargar' | 'tahesab'
|
||||
export type AccountingProvider = 'none' | 'pargar' | 'tahesab' | 'zarin'
|
||||
|
||||
export function getConfigApp(key: string) {
|
||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
||||
@@ -34,6 +34,9 @@ export const trackingSystemsEnabledSetting = ref(false)
|
||||
/** reactive — نمایش UI تهحساب در حسابداری و ... */
|
||||
export const tahesabEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — نمایش UI زرین در حسابداری و ... */
|
||||
export const zarinEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — نمایش UI پرگار در حسابداری و ... */
|
||||
export const pargarEnabledSetting = ref(false)
|
||||
|
||||
@@ -43,12 +46,19 @@ export const customerDirectSmsEnabledSetting = ref(false)
|
||||
/** reactive — منو و UI سفارش شرطی (ادمین + کنترلهای مشتری) */
|
||||
export const conditionalOrderEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — منو و UI هشدار قیمت */
|
||||
export const priceTriggerEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — منو و زنگوله اعلان داخل اپ */
|
||||
export const appNotificationEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — منبع قیمت فعال (montzar / zaarbox / main_product) */
|
||||
export const priceProviderSetting = ref('')
|
||||
|
||||
export const accountingProviderSetting = ref<AccountingProvider>('none')
|
||||
|
||||
let tahesabEnabledFromSettings: boolean | null = null
|
||||
let zarinEnabledFromSettings: boolean | null = null
|
||||
let pargarEnabledFromSettings: boolean | null = null
|
||||
let customerDirectSmsFromSettings: boolean | null = null
|
||||
let accountingProviderFromSettings: AccountingProvider | null = null
|
||||
@@ -60,7 +70,7 @@ function isSwitchOn(value: string | undefined | null): boolean {
|
||||
|
||||
function normalizeAccountingProvider(value: string | undefined | null): AccountingProvider {
|
||||
const v = (value ?? '').trim().toLowerCase()
|
||||
if (v === 'pargar' || v === 'tahesab') return v
|
||||
if (v === 'pargar' || v === 'tahesab' || v === 'zarin') return v
|
||||
return 'none'
|
||||
}
|
||||
|
||||
@@ -88,6 +98,7 @@ export function applyAccountingProviderFromRows(
|
||||
accountingProviderFromSettings = provider
|
||||
accountingProviderSetting.value = provider
|
||||
setTahesabEnabledFromSettings(provider === 'tahesab')
|
||||
setZarinEnabledFromSettings(provider === 'zarin')
|
||||
setPargarEnabledFromSettings(provider === 'pargar')
|
||||
}
|
||||
|
||||
@@ -108,6 +119,11 @@ export function setTahesabEnabledFromSettings(value: boolean): void {
|
||||
tahesabEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setZarinEnabledFromSettings(value: boolean): void {
|
||||
zarinEnabledFromSettings = value
|
||||
zarinEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setPargarEnabledFromSettings(value: boolean): void {
|
||||
pargarEnabledFromSettings = value
|
||||
pargarEnabledSetting.value = value
|
||||
@@ -122,6 +138,14 @@ export function setConditionalOrderEnabledFromSettings(value: boolean): void {
|
||||
conditionalOrderEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setPriceTriggerEnabledFromSettings(value: boolean): void {
|
||||
priceTriggerEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setAppNotificationEnabledFromSettings(value: boolean): void {
|
||||
appNotificationEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setPriceProviderFromSettings(value?: string | null): void {
|
||||
priceProviderSetting.value = (value ?? '').trim().toLowerCase()
|
||||
}
|
||||
@@ -150,6 +174,20 @@ export function applyConditionalOrderEnabledFromRows(
|
||||
setConditionalOrderEnabledFromSettings(row ? isSwitchOn(row.value) : false)
|
||||
}
|
||||
|
||||
export function applyPriceTriggerEnabledFromRows(
|
||||
rows: Array<{ key?: string; value?: string | null }>
|
||||
) {
|
||||
const row = rows.find((item) => item.key === 'has_page_price_trigger')
|
||||
setPriceTriggerEnabledFromSettings(row ? isSwitchOn(row.value) : false)
|
||||
}
|
||||
|
||||
export function applyAppNotificationEnabledFromRows(
|
||||
rows: Array<{ key?: string; value?: string | null }>
|
||||
) {
|
||||
const row = rows.find((item) => item.key === 'has_page_notification')
|
||||
setAppNotificationEnabledFromSettings(row ? isSwitchOn(row.value) : false)
|
||||
}
|
||||
|
||||
export function applyPriceProviderFromRows(
|
||||
rows: Array<{ key?: string; value?: string | null }>
|
||||
) {
|
||||
@@ -176,6 +214,8 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
applyTrackingSystemsEnabledFromRows(list)
|
||||
applyCustomerDirectSmsFromRows(list)
|
||||
applyConditionalOrderEnabledFromRows(list)
|
||||
applyPriceTriggerEnabledFromRows(list)
|
||||
applyAppNotificationEnabledFromRows(list)
|
||||
applyPriceProviderFromRows(list)
|
||||
setCachedMainMetal(mainMetalRow?.value)
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
@@ -207,6 +247,10 @@ export function isTahesabEnabled(): boolean {
|
||||
return tahesabEnabledFromSettings === true
|
||||
}
|
||||
|
||||
export function isZarinEnabled(): boolean {
|
||||
return zarinEnabledFromSettings === true
|
||||
}
|
||||
|
||||
export function isPargarEnabled(): boolean {
|
||||
return pargarEnabledFromSettings === true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user