From 7ea58a985c1348baa4b83f09572743f7cf40b8b5 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Mon, 31 Aug 2026 16:49:47 +0200 Subject: [PATCH] fix: 2 fixes --- src/components/SecuritySetupCards.tsx | 2 +- src/pages/ProfilePage.tsx | 3 ++- src/pages/auth/LoginPage.tsx | 3 ++- src/pages/dashboard/plugin/StoreListing.tsx | 22 +++++++++++++++++---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/components/SecuritySetupCards.tsx b/src/components/SecuritySetupCards.tsx index 69d13c4..fec4031 100644 --- a/src/components/SecuritySetupCards.tsx +++ b/src/components/SecuritySetupCards.tsx @@ -132,7 +132,7 @@ export const SecuritySetupCards: React.FC = ({ setPasskeyError(null); const startRes = await api.post('/user/passkey/register/start'); - const options = startRes.data; + const options = startRes.data?.publicKey || startRes.data; const credential = await startRegistration({ optionsJSON: options }); diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 6bb4e55..1c13e6d 100644 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -379,7 +379,8 @@ const ProfilePage = () => { setPasskeyRegistering(true); try { const startRes = await api.post('/user/passkey/register/start'); - const credential = await startRegistration({ optionsJSON: startRes.data }); + const options = startRes.data?.publicKey || startRes.data; + const credential = await startRegistration({ optionsJSON: options }); const finishRes = await api.post('/user/passkey/register/finish', { name: newPasskeyName.trim() || 'My Passkey', credential, diff --git a/src/pages/auth/LoginPage.tsx b/src/pages/auth/LoginPage.tsx index c12065f..4c7204f 100644 --- a/src/pages/auth/LoginPage.tsx +++ b/src/pages/auth/LoginPage.tsx @@ -137,8 +137,9 @@ const LoginPage = () => { email: form.email.trim() || undefined, }); + const options = startRes.data?.options?.publicKey || startRes.data?.options || startRes.data?.publicKey || startRes.data; const credential = await startAuthentication({ - optionsJSON: startRes.data.options, + optionsJSON: options, }); const finishRes = await api.post('/auth/passkey/login/finish', { diff --git a/src/pages/dashboard/plugin/StoreListing.tsx b/src/pages/dashboard/plugin/StoreListing.tsx index 0ee48f6..14a61b3 100644 --- a/src/pages/dashboard/plugin/StoreListing.tsx +++ b/src/pages/dashboard/plugin/StoreListing.tsx @@ -146,10 +146,24 @@ const StoreListing = ({ plugin, onSaved }: Props) => { const [saveError, setSaveError] = useState(null); const [name, setName] = useState(plugin.name); const [descriptions, setDescriptions] = useState>(() => { - const parsed = JSON.parse(plugin.translated_descriptions || '{}'); - // Ensure default locale always exists - if (!parsed[DEFAULT_LOCALE]) parsed[DEFAULT_LOCALE] = parsed['en'] ?? ''; - return parsed; + let parsed: Record = {}; + try { parsed = JSON.parse(plugin.translated_descriptions || '{}'); } catch { /* ignore */ } + + // Normalize: if a value is a nested object (old format), extract its 'description' string. + const flat: Record = {}; + for (const [k, v] of Object.entries(parsed)) { + if (typeof v === 'string') { + flat[k] = v; + } else if (v && typeof v === 'object' && 'description' in v) { + flat[k] = String((v as Record).description ?? ''); + } + } + + // Ensure the default locale always exists. + if (!flat[DEFAULT_LOCALE]) { + flat[DEFAULT_LOCALE] = flat['en-GB'] ?? flat['en'] ?? ''; + } + return flat; }); const [activeLocale, setActiveLocale] = useState(DEFAULT_LOCALE); const [category, setCategory] = useState(plugin.category);