fix: normalize Khanegi UI config on save for userTheme schema

Prevent re-saving invalid navigation.type/header.variant/products routes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-10 12:34:06 +03:30
co-authored by Cursor
parent c7947fc668
commit 8d0b65f087
2 changed files with 46 additions and 2 deletions
+8 -2
View File
@@ -7,6 +7,7 @@ import api from '@/api/http'
import {
cloneKhanegiAppSnapshot,
createDefaultKhanegiUiConfig,
normalizeKhanegiUiConfigForClient,
} from '@/config/defaultKhanegiUiConfig'
import {
applyKhanegiPreset,
@@ -201,10 +202,15 @@ function buildSavePayload() {
if (selectedPreset.value === 'custom') {
markCustomAndSyncSchemes(config)
}
const payload = JSON.parse(JSON.stringify(config)) as typeof config
const payload = normalizeKhanegiUiConfigForClient(
JSON.parse(JSON.stringify(config)) as typeof config,
)
// Never drop or rewrite an existing factory snapshot on normal save
if (config.defaultSnapshot) {
payload.defaultSnapshot = JSON.parse(JSON.stringify(config.defaultSnapshot))
payload.defaultSnapshot = normalizeKhanegiUiConfigForClient({
app: JSON.parse(JSON.stringify(config.defaultSnapshot.app)),
pages: JSON.parse(JSON.stringify(config.defaultSnapshot.pages || {})),
}) as typeof payload.defaultSnapshot
}
return payload
}