Add customers gold credit menu with request and active tabs.
Gate the submenu on enable_gold_credit and wire settings UI for SuperAdmin and tenant credit options. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-3
@@ -64,6 +64,9 @@ export const groupSmsEnabledSetting = ref(false)
|
||||
/** reactive — زیرمنوی قیمت ویژه مشتری */
|
||||
export const customerSpecialPricingEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — زیرمنوی اعتبار طلایی در مشتریان */
|
||||
export const goldCreditEnabledSetting = ref(false)
|
||||
|
||||
/** reactive — منو و زنگوله اعلان داخل اپ */
|
||||
export const appNotificationEnabledSetting = ref(true)
|
||||
|
||||
@@ -87,8 +90,11 @@ let pargarEnabledFromSettings: boolean | null = null
|
||||
let customerDirectSmsFromSettings: boolean | null = null
|
||||
let accountingProviderFromSettings: AccountingProvider | null = null
|
||||
|
||||
function isSwitchOn(value: string | undefined | null): boolean {
|
||||
const v = (value ?? '').trim().toLowerCase()
|
||||
function isSwitchOn(value: string | number | boolean | undefined | null): boolean {
|
||||
if (value === true || value === 1) return true
|
||||
const v = String(value ?? '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
return v === 'true' || v === '1' || v === 'yes' || v === 'activate'
|
||||
}
|
||||
|
||||
@@ -166,6 +172,10 @@ export function setCustomerSpecialPricingEnabledFromSettings(value: boolean): vo
|
||||
customerSpecialPricingEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setGoldCreditEnabledFromSettings(value: boolean): void {
|
||||
goldCreditEnabledSetting.value = value
|
||||
}
|
||||
|
||||
export function setConditionalOrderEnabledFromSettings(value: boolean): void {
|
||||
conditionalOrderEnabledSetting.value = value
|
||||
}
|
||||
@@ -283,13 +293,20 @@ export function applyCustomerSpecialPricingFromRows(
|
||||
if (row) setCustomerSpecialPricingEnabledFromSettings(isSwitchOn(row.value))
|
||||
}
|
||||
|
||||
export function applyGoldCreditEnabledFromRows(
|
||||
rows: Array<{ key?: string; value?: string | null }>
|
||||
) {
|
||||
const row = rows.find((item) => item.key === 'enable_gold_credit')
|
||||
if (row) setGoldCreditEnabledFromSettings(isSwitchOn(row.value))
|
||||
}
|
||||
|
||||
/** بعد از همگامسازی سوپرادمین — bootstrap بعدی دوباره از API میخواند */
|
||||
export function invalidateSettingsBootstrap(): void {
|
||||
settingsBootstrapped = false
|
||||
}
|
||||
|
||||
/**
|
||||
* اعمال مستقیم ۱۴ دسترسی سوپرادمین روی فلگهای منو/UI
|
||||
* اعمال مستقیم ۱۵ دسترسی سوپرادمین روی فلگهای منو/UI
|
||||
* (پاسخ refresh-superadmin.items یا ردیفهای get_settings).
|
||||
*/
|
||||
export function applySuperAdminAccessFlagsFromItems(
|
||||
@@ -301,6 +318,7 @@ export function applySuperAdminAccessFlagsFromItems(
|
||||
applyCustomerDirectSmsFromRows(rows)
|
||||
applyGroupSmsFromRows(rows)
|
||||
applyCustomerSpecialPricingFromRows(rows)
|
||||
applyGoldCreditEnabledFromRows(rows)
|
||||
applyConditionalOrderEnabledFromRows(rows)
|
||||
applyAutomationEnabledFromRows(rows)
|
||||
applyProductFundsEnabledFromRows(rows)
|
||||
@@ -386,6 +404,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
applyCustomerDirectSmsFromRows(list)
|
||||
applyGroupSmsFromRows(list)
|
||||
applyCustomerSpecialPricingFromRows(list)
|
||||
applyGoldCreditEnabledFromRows(list)
|
||||
applyConditionalOrderEnabledFromRows(list)
|
||||
applyAutomationEnabledFromRows(list)
|
||||
applyProductFundsEnabledFromRows(list)
|
||||
|
||||
Reference in New Issue
Block a user