fix some bugs 4

This commit is contained in:
2026-07-18 22:22:21 +03:30
parent d5e452d02b
commit a2f3e320d5
8 changed files with 343 additions and 8 deletions
+18 -2
View File
@@ -28,16 +28,20 @@ let settingsBootstrapped = false
/** reactive — برای فیلتر منوی «بنرها» در پیکربندی */
export const bannerEnabledSetting = ref(false)
/** reactive — نمایش UI ته‌حsاب در حسابداری و ... */
/** reactive — نمایش UI ته‌حساب در حسابداری و ... */
export const tahesabEnabledSetting = ref(false)
/** reactive — نمایش UI پرگar در حسابداری و ... */
/** reactive — نمایش UI پرگار در حسابداری و ... */
export const pargarEnabledSetting = ref(false)
/** reactive — دکمه پیامک تکی در لیست مشتریان */
export const customerDirectSmsEnabledSetting = ref(false)
export const accountingProviderSetting = ref<AccountingProvider>('none')
let tahesabEnabledFromSettings: boolean | null = null
let pargarEnabledFromSettings: boolean | null = null
let customerDirectSmsFromSettings: boolean | null = null
let accountingProviderFromSettings: AccountingProvider | null = null
function isSwitchOn(value: string | undefined | null): boolean {
@@ -96,11 +100,21 @@ export function setPargarEnabledFromSettings(value: boolean): void {
pargarEnabledSetting.value = value
}
export function setCustomerDirectSmsEnabledFromSettings(value: boolean): void {
customerDirectSmsFromSettings = value
customerDirectSmsEnabledSetting.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)
}
export function applyCustomerDirectSmsFromRows(rows: Array<{ key?: string; value?: string | null }>) {
const row = rows.find((item) => item.key === 'customer_direct_sms')
setCustomerDirectSmsEnabledFromSettings(row ? isSwitchOn(row.value) : false)
}
async function bootstrapSettingsFromApi(): Promise<void> {
if (settingsBootstrapped) return
@@ -115,12 +129,14 @@ async function bootstrapSettingsFromApi(): Promise<void> {
storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false
applyAccountingProviderFromRows(list)
applyBannerEnabledFromRows(list)
applyCustomerDirectSmsFromRows(list)
setCachedMainMetal(mainMetalRow?.value)
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value))
} catch {
storeModeFromSettings = false
setBannerEnabledFromSettings(false)
setCustomerDirectSmsEnabledFromSettings(false)
applyAccountingProviderFromRows([])
setCachedMainMetal(null)
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')