base commit
This commit is contained in:
@@ -18,6 +18,13 @@ import {
|
||||
updateProfileFx,
|
||||
verifyEmailChangeFx,
|
||||
} from '@/shared/model/auth'
|
||||
import type { AxiosError } from 'axios'
|
||||
|
||||
function getApiErrorMessage(error: unknown): string | null {
|
||||
const e = error as AxiosError<{ error?: string }>
|
||||
const msg = e?.response?.data?.error
|
||||
return msg ? String(msg) : null
|
||||
}
|
||||
|
||||
export function MePage() {
|
||||
const user = useUnit($user)
|
||||
@@ -45,16 +52,9 @@ export function MePage() {
|
||||
mode: 'onChange',
|
||||
})
|
||||
|
||||
const passwordErrorMsg =
|
||||
(errorPassword as any)?.response?.data?.error ? String((errorPassword as any).response.data.error) : null
|
||||
const emailErrorMsg =
|
||||
(errorEmailReq as any)?.response?.data?.error
|
||||
? String((errorEmailReq as any).response.data.error)
|
||||
: (errorEmailVerify as any)?.response?.data?.error
|
||||
? String((errorEmailVerify as any).response.data.error)
|
||||
: null
|
||||
const profileErrorMsg =
|
||||
(errorProfile as any)?.response?.data?.error ? String((errorProfile as any).response.data.error) : null
|
||||
const passwordErrorMsg = getApiErrorMessage(errorPassword)
|
||||
const emailErrorMsg = getApiErrorMessage(errorEmailReq) ?? getApiErrorMessage(errorEmailVerify)
|
||||
const profileErrorMsg = getApiErrorMessage(errorProfile)
|
||||
|
||||
if (!user) {
|
||||
return <Alert severity="info">Нужно войти. Перейдите на страницу «Вход».</Alert>
|
||||
@@ -175,4 +175,3 @@ export function MePage() {
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user