This commit is contained in:
Kirill
2026-05-22 23:44:48 +05:00
parent bb78782b39
commit 7e5ed9cefa
3 changed files with 6 additions and 1 deletions
@@ -19,6 +19,7 @@ import {
unlinkOAuthFx,
type AuthMethod,
} from '@/shared/model/auth'
import { getErrorMessage } from '@/shared/lib/get-error-message'
const METHOD_LABELS: Record<string, string> = { password: 'Пароль', vk: 'ВКонтакте', yandex: 'Яндекс' }
@@ -95,7 +96,7 @@ export function AuthMethodsSection() {
return url
},
onSuccess: (url) => setVerificationUrl(url),
onError: (err) => setEmailChangeError(err?.message || 'Не удалось сменить email'),
onError: (err) => setEmailChangeError(getErrorMessage(err, 'Не удалось сменить email')),
})
if (!user) return null
@@ -1,4 +1,8 @@
export function getErrorMessage(error: unknown, fallback = 'Произошла ошибка'): string {
if (error && typeof error === 'object' && 'response' in error) {
const axiosErr = error as { response?: { data?: { error?: string } } }
if (axiosErr.response?.data?.error) return axiosErr.response.data.error
}
if (error instanceof Error && error.message) return error.message
return fallback
}
Binary file not shown.