Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add field validation to resolve the Update Profile Issue #8809

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
4 changes: 0 additions & 4 deletions src/Components/Form/FormFields/PhoneNumberFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ export default function PhoneNumberFormField(props: Props) {
}
}, [setValue]);

useEffect(() => {
setValue(field.value || "+91");
}, []);

return (
<FormField
field={{
Expand Down
9 changes: 8 additions & 1 deletion src/Components/Users/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default function UserProfile() {
isChecking: false,
isUpdateAvailable: false,
});
const [dirty, setDirty] = useState<boolean>(false);

const authUser = useAuthUser();

Expand Down Expand Up @@ -172,6 +173,7 @@ export default function UserProfile() {
type: "set_form",
form: formData,
});
setDirty(false);
},
});

Expand Down Expand Up @@ -324,6 +326,7 @@ export default function UserProfile() {
type: "set_form",
form: { ...states.form, [event.name]: event.value },
});
setDirty(true);
};

const getDate = (value: any) =>
Expand Down Expand Up @@ -788,7 +791,11 @@ export default function UserProfile() {
</div>
</div>
<div className="bg-secondary-50 px-4 py-3 text-right sm:px-6">
<Submit onClick={handleSubmit} label={t("update")} />
<Submit
onClick={handleSubmit}
label={t("update")}
disabled={!dirty}
/>
</div>
</div>
</form>
Expand Down
Loading