From 514448748d6fff0583fdbc0f513b632af7659097 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Tue, 31 Aug 2021 13:20:59 +0300 Subject: [PATCH] feat: enable button save on updating contacts --- src/components/Forms/User/UpdateUserContactsForm.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Forms/User/UpdateUserContactsForm.tsx b/src/components/Forms/User/UpdateUserContactsForm.tsx index 52a0b0f..4fb374c 100644 --- a/src/components/Forms/User/UpdateUserContactsForm.tsx +++ b/src/components/Forms/User/UpdateUserContactsForm.tsx @@ -11,6 +11,7 @@ import { yupResolver } from '@hookform/resolvers/yup'; import UpdateUserContactsSchema from 'validators/UpdateUserContactsSchema'; import useUpdateUserContactsQuery from 'hooks/useUpdateUserContactsQuery'; +import { observer } from 'mobx-react'; type UpdateUserContactsInputType = { phone_number: string | null; @@ -41,7 +42,14 @@ const UpdateUserContactsForm: React.FC = ({ contact const { updateContacts, loading } = useUpdateUserContactsQuery(); const onSubmit: SubmitHandler = data => { - updateContacts(data).finally(() => reset(data)); + updateContacts(data).finally(() => + reset({ + phone_number: data.phone_number ?? '', + twitter_id: data.twitter_id ?? '', + telegram_id: data.telegram_id ?? '', + vk_id: data.vk_id ?? '', + }) + ); }; return ( @@ -106,4 +114,4 @@ const UpdateUserContactsForm: React.FC = ({ contact ); }; -export default UpdateUserContactsForm; +export default observer(UpdateUserContactsForm);