Commit d2682889 authored by tom's avatar tom

fix verified email checkmark behaviour

parent 3eefec5d
...@@ -81,7 +81,7 @@ const MyProfileEmail = ({ profileQuery }: Props) => { ...@@ -81,7 +81,7 @@ const MyProfileEmail = ({ profileQuery }: Props) => {
onSubmit={ formApi.handleSubmit(onFormSubmit) } onSubmit={ formApi.handleSubmit(onFormSubmit) }
> >
<MyProfileFieldsName/> <MyProfileFieldsName/>
<MyProfileFieldsEmail isReadOnly={ !config.services.reCaptchaV3.siteKey }/> <MyProfileFieldsEmail isReadOnly={ !config.services.reCaptchaV3.siteKey } defaultValue={ profileQuery.data?.email || undefined }/>
{ config.services.reCaptchaV3.siteKey && ( { config.services.reCaptchaV3.siteKey && (
<GoogleReCaptchaProvider reCaptchaKey={ config.services.reCaptchaV3.siteKey }> <GoogleReCaptchaProvider reCaptchaKey={ config.services.reCaptchaV3.siteKey }>
<FormFieldReCaptcha/> <FormFieldReCaptcha/>
......
...@@ -10,9 +10,10 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder'; ...@@ -10,9 +10,10 @@ import InputPlaceholder from 'ui/shared/InputPlaceholder';
interface Props { interface Props {
isReadOnly?: boolean; isReadOnly?: boolean;
defaultValue: string | undefined;
} }
const MyProfileFieldsEmail = ({ isReadOnly }: Props) => { const MyProfileFieldsEmail = ({ isReadOnly, defaultValue }: Props) => {
const { control } = useFormContext<FormFields>(); const { control } = useFormContext<FormFields>();
const { field, fieldState, formState } = useController<FormFields, 'email'>({ const { field, fieldState, formState } = useController<FormFields, 'email'>({
control, control,
...@@ -21,6 +22,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => { ...@@ -21,6 +22,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => {
}); });
const isDisabled = formState.isSubmitting; const isDisabled = formState.isSubmitting;
const isVerified = defaultValue && field.value === defaultValue;
return ( return (
<FormControl variant="floating" isDisabled={ isDisabled } isRequired size="md"> <FormControl variant="floating" isDisabled={ isDisabled } isRequired size="md">
...@@ -34,7 +36,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => { ...@@ -34,7 +36,7 @@ const MyProfileFieldsEmail = ({ isReadOnly }: Props) => {
autoComplete="off" autoComplete="off"
/> />
<InputPlaceholder text="Email" error={ fieldState.error }/> <InputPlaceholder text="Email" error={ fieldState.error }/>
{ !formState.dirtyFields.email && ( { isVerified && (
<InputRightElement h="100%"> <InputRightElement h="100%">
<IconSvg name="certified" boxSize={ 5 } color="green.500"/> <IconSvg name="certified" boxSize={ 5 } color="green.500"/>
</InputRightElement> </InputRightElement>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment