fix withdraw and desposit ui
This commit is contained in:
+26
-6
@@ -8,6 +8,7 @@ export function getConfigApp(key: string) {
|
||||
}
|
||||
|
||||
let storeModeFromSettings: boolean | null = null
|
||||
let settingsBootstrapped = false
|
||||
|
||||
function isSwitchOn(value: string | undefined | null): boolean {
|
||||
const v = (value ?? '').trim().toLowerCase()
|
||||
@@ -18,20 +19,39 @@ export function setStoreModeFromSettings(value: boolean): void {
|
||||
storeModeFromSettings = value
|
||||
}
|
||||
|
||||
/** is_store فقط از API تنظیمات (get_settings) خوانده میشود — نه از get_user */
|
||||
export async function initStoreModeFromSettings(): Promise<boolean> {
|
||||
if (storeModeFromSettings !== null) return storeModeFromSettings
|
||||
async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
if (settingsBootstrapped) return
|
||||
|
||||
try {
|
||||
const { getConfiguration } = await import('@/api/configuration')
|
||||
const { parseMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
const rows = await getConfiguration()
|
||||
const row = Array.isArray(rows) ? rows.find((item) => item.key === 'is_store') : null
|
||||
storeModeFromSettings = row ? isSwitchOn(row.value) : false
|
||||
const list = Array.isArray(rows) ? rows : []
|
||||
const isStoreRow = list.find((item) => item.key === 'is_store')
|
||||
const mainWalletRow = list.find((item) => item.key === 'main_wallet_products')
|
||||
storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value))
|
||||
} catch {
|
||||
storeModeFromSettings = false
|
||||
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
setCachedMainWalletProductIds([])
|
||||
} finally {
|
||||
settingsBootstrapped = true
|
||||
}
|
||||
}
|
||||
|
||||
return storeModeFromSettings
|
||||
/** is_store و main_wallet_products از API تنظیمات — نه از get_user */
|
||||
export async function initStoreModeFromSettings(): Promise<boolean> {
|
||||
if (storeModeFromSettings !== null) return storeModeFromSettings
|
||||
|
||||
await bootstrapSettingsFromApi()
|
||||
|
||||
return storeModeFromSettings === true
|
||||
}
|
||||
|
||||
export async function initWalletSettingsFromApi(): Promise<void> {
|
||||
await bootstrapSettingsFromApi()
|
||||
}
|
||||
|
||||
export function isStoreApp(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user