Skip to content

Commit

Permalink
fix verified email checkmark behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Oct 18, 2024
1 parent 3eefec5 commit d268288
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/myProfile/MyProfileEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const MyProfileEmail = ({ profileQuery }: Props) => {
onSubmit={ formApi.handleSubmit(onFormSubmit) }
>
<MyProfileFieldsName/>
<MyProfileFieldsEmail isReadOnly={ !config.services.reCaptchaV3.siteKey }/>
<MyProfileFieldsEmail isReadOnly={ !config.services.reCaptchaV3.siteKey } defaultValue={ profileQuery.data?.email || undefined }/>
{ config.services.reCaptchaV3.siteKey && (
<GoogleReCaptchaProvider reCaptchaKey={ config.services.reCaptchaV3.siteKey }>
<FormFieldReCaptcha/>
Expand Down
6 changes: 4 additions & 2 deletions ui/myProfile/fields/MyProfileFieldsEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder';

interface Props {
isReadOnly?: boolean;
defaultValue: string | undefined;
}

const MyProfileFieldsEmail = ({ isReadOnly }: Props) => {
const MyProfileFieldsEmail = ({ isReadOnly, defaultValue }: Props) => {
const { control } = useFormContext<FormFields>();
const { field, fieldState, formState } = useController<FormFields, 'email'>({
control,
Expand All @@ -21,6 +22,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => {
});

const isDisabled = formState.isSubmitting;
const isVerified = defaultValue && field.value === defaultValue;

return (
<FormControl variant="floating" isDisabled={ isDisabled } isRequired size="md">
Expand All @@ -34,7 +36,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => {
autoComplete="off"
/>
<InputPlaceholder text="Email" error={ fieldState.error }/>
{ !formState.dirtyFields.email && (
{ isVerified && (
<InputRightElement h="100%">
<IconSvg name="certified" boxSize={ 5 } color="green.500"/>
</InputRightElement>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d268288

Please sign in to comment.