fix(admin): merge SuperAdmin settings over local can_edit locks
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+7
-8
@@ -332,21 +332,20 @@ async function bootstrapSettingsFromApi(): Promise<void> {
|
||||
|
||||
try {
|
||||
const { getConfiguration } = await import('@/api/configuration')
|
||||
const { fetchSuperAdminProgramSettings } = await import('@/api/superadminSettings')
|
||||
const { fetchSuperAdminProgramSettings, isLockedCanEdit } = await import('@/api/superadminSettings')
|
||||
const { parseMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
|
||||
const [localRows, saRows] = await Promise.all([
|
||||
getConfiguration().catch(() => []),
|
||||
fetchSuperAdminProgramSettings(),
|
||||
])
|
||||
const localRows = await getConfiguration().catch(() => [])
|
||||
const saRows = await fetchSuperAdminProgramSettings()
|
||||
const local = Array.isArray(localRows) ? localRows : []
|
||||
const merged = [...local]
|
||||
for (const item of saRows) {
|
||||
const editable = local.filter((row) => !isLockedCanEdit(row?.can_edit))
|
||||
const merged = [...saRows] as typeof local
|
||||
for (const item of editable) {
|
||||
if (!item?.key) continue
|
||||
const index = merged.findIndex((row) => row.key === item.key)
|
||||
if (index >= 0) {
|
||||
merged[index] = { ...merged[index], ...item }
|
||||
} else {
|
||||
merged.push(item as (typeof merged)[number])
|
||||
merged.push(item)
|
||||
}
|
||||
}
|
||||
const list = merged
|
||||
|
||||
Reference in New Issue
Block a user