пва
This commit is contained in:
@@ -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.
Reference in New Issue
Block a user