diff --git a/apps/meteor/client/views/account/profile/AccountProfileForm.tsx b/apps/meteor/client/views/account/profile/AccountProfileForm.tsx index cb65ce80317e..1a326db4544d 100644 --- a/apps/meteor/client/views/account/profile/AccountProfileForm.tsx +++ b/apps/meteor/client/views/account/profile/AccountProfileForm.tsx @@ -22,7 +22,6 @@ import UserAvatarEditor from '../../../components/avatar/UserAvatarEditor'; import { useUpdateAvatar } from '../../../hooks/useUpdateAvatar'; import { USER_STATUS_TEXT_MAX_LENGTH, BIO_TEXT_MAX_LENGTH } from '../../../lib/constants'; import type { AccountProfileFormValues } from './getProfileInitialValues'; -import { getProfileInitialValues } from './getProfileInitialValues'; import { useAccountProfileSettings } from './useAccountProfileSettings'; const AccountProfileForm = (props: AllHTMLAttributes): ReactElement => { @@ -46,10 +45,8 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle } = useAccountProfileSettings(); const { - register, control, watch, - reset, handleSubmit, formState: { errors }, } = useFormContext(); @@ -97,10 +94,10 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle try { await updateOwnBasicInfo( { - ...(allowRealNameChange ? { realname: name } : {}), - ...(allowEmailChange && user ? getUserEmailAddress(user) !== email && { email } : {}), - ...(canChangeUsername ? { username } : {}), - ...(allowUserStatusMessageChange ? { statusText } : {}), + realname: name, + ...(user ? getUserEmailAddress(user) !== email && { email } : {}), + username, + statusText, statusType, nickname, bio, @@ -110,7 +107,6 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle await updateAvatar(); dispatchToastMessage({ type: 'success', message: t('Profile_saved_successfully') }); - reset(getProfileInitialValues(user)); } catch (error) { dispatchToastMessage({ type: 'error', message: error }); } @@ -147,16 +143,21 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle {t('Name')} - (requireName && name === '' ? t('error-the-field-is-required', { field: t('Name') }) : true), - })} - id={nameId} - error={errors.name?.message} - disabled={!allowRealNameChange} - aria-required='true' - aria-invalid={errors.username ? 'true' : 'false'} - aria-describedby={`${nameId}-error ${nameId}-hint`} + (requireName && name === '' ? t('error-the-field-is-required', { field: t('Name') }) : true) }} + render={({ field }) => ( + + )} /> {errors.name && ( @@ -171,17 +172,25 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle {t('Username')} - validateUsername(username), - })} - id={usernameId} - error={errors.username?.message} - addon={} - aria-required='true' - aria-invalid={errors.username ? 'true' : 'false'} - aria-describedby={`${usernameId}-error ${usernameId}-hint`} + }} + render={({ field }) => ( + } + aria-required='true' + aria-invalid={errors.username ? 'true' : 'false'} + aria-describedby={`${usernameId}-error ${usernameId}-hint`} + /> + )} /> {errors?.username && ( @@ -195,26 +204,31 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle {t('StatusMessage')} - ( - - )} + ( + ( + + )} + /> + } /> - } + )} /> {errors?.statusText && ( @@ -227,21 +241,34 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle {t('Nickname')} - } /> + ( + } /> + )} + /> {t('Bio')} - } - aria-invalid={errors.statusText ? 'true' : 'false'} - aria-describedby={`${bioId}-error`} + ( + } + aria-invalid={errors.statusText ? 'true' : 'false'} + aria-describedby={`${bioId}-error`} + /> + )} /> {errors?.bio && ( @@ -255,18 +282,23 @@ const AccountProfileForm = (props: AllHTMLAttributes): ReactEle {t('Email')} - (validateEmail(email) ? undefined : t('error-invalid-email-address')) }, - })} - flexGrow={1} - error={errors.email?.message} - addon={} - disabled={!allowEmailChange} - aria-required='true' - aria-invalid={errors.email ? 'true' : 'false'} - aria-describedby={`${emailId}-error ${emailId}-hint`} + (validateEmail(email) ? undefined : t('error-invalid-email-address')) } }} + render={({ field }) => ( + } + disabled={!allowEmailChange} + aria-required='true' + aria-invalid={errors.email ? 'true' : 'false'} + aria-describedby={`${emailId}-error ${emailId}-hint`} + /> + )} /> {!isUserVerified && (