From fa276eb7f3505f81910fc08ff6f007202b17247c Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 22 May 2026 15:10:20 +0500 Subject: [PATCH] fix(settings): use $updateProfileError and changePasswordFx per spec --- .../src/pages/me/ui/sections/AuthMethodsSection.tsx | 12 +++++++++--- client/src/pages/me/ui/sections/ProfileSection.tsx | 9 ++++++++- client/src/shared/model/auth.ts | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/client/src/pages/me/ui/sections/AuthMethodsSection.tsx b/client/src/pages/me/ui/sections/AuthMethodsSection.tsx index 4bdda00..4c36f4f 100644 --- a/client/src/pages/me/ui/sections/AuthMethodsSection.tsx +++ b/client/src/pages/me/ui/sections/AuthMethodsSection.tsx @@ -8,8 +8,14 @@ import Typography from '@mui/material/Typography' import { useMutation } from '@tanstack/react-query' import { useUnit } from 'effector-react' import { useForm } from 'react-hook-form' -import { apiClient } from '@/shared/api/client' -import { $user, fetchAuthMethodsFx, setPasswordFx, unlinkOAuthFx, type AuthMethod } from '@/shared/model/auth' +import { + $user, + changePasswordFx, + fetchAuthMethodsFx, + setPasswordFx, + unlinkOAuthFx, + type AuthMethod, +} from '@/shared/model/auth' const METHOD_LABELS: Record = { password: 'Пароль', vk: 'ВКонтакте', yandex: 'Яндекс' } @@ -56,7 +62,7 @@ export function AuthMethodsSection() { const changePasswordMutation = useMutation({ mutationFn: async (params: { oldPassword: string; newPassword: string }) => { - await apiClient.post('me/change-password', params) + await changePasswordFx(params) }, onSuccess: () => { setShowChangePassword(false) diff --git a/client/src/pages/me/ui/sections/ProfileSection.tsx b/client/src/pages/me/ui/sections/ProfileSection.tsx index 11ff3f1..01db0d8 100644 --- a/client/src/pages/me/ui/sections/ProfileSection.tsx +++ b/client/src/pages/me/ui/sections/ProfileSection.tsx @@ -1,3 +1,4 @@ +import Alert from '@mui/material/Alert' import Box from '@mui/material/Box' import Button from '@mui/material/Button' import Stack from '@mui/material/Stack' @@ -5,11 +6,12 @@ import TextField from '@mui/material/TextField' import Typography from '@mui/material/Typography' import { useUnit } from 'effector-react' import { useForm } from 'react-hook-form' -import { $user, updateProfileFx } from '@/shared/model/auth' +import { $user, $updateProfileError, updateProfileFx } from '@/shared/model/auth' export function ProfileSection() { const user = useUnit($user) const pendingProfile = useUnit(updateProfileFx.pending) + const updateProfileError = useUnit($updateProfileError) const profileForm = useForm<{ displayName: string }>({ defaultValues: { displayName: user?.displayName ? String(user.displayName) : '' }, @@ -28,6 +30,11 @@ export function ProfileSection() { slotProps={{ htmlInput: { maxLength: 40 } }} {...profileForm.register('displayName')} /> + {updateProfileError && ( + + {updateProfileError} + + )}