Bug(UI): Signup onclick loading (#541)

* bug(UI): on click loader is added

* bug(UI): on click loader is added
This commit is contained in:
pal-sig 2021-12-24 11:42:25 +05:30 committed by GitHub
parent d825fc2f30
commit 7f5b0c15c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,13 +20,11 @@ import {
const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
const [notificationsInstance, Element] = notification.useNotification();
const [state, setState] = useState({ submitted: false });
const [loading, setLoading] = useState(false);
const [formState, setFormState] = useState({
firstName: { value: '' },
companyName: { value: '' },
email: { value: '' },
password: { value: '', valid: true },
emailOptIn: { value: true },
});
const updateForm = (
@ -50,7 +48,7 @@ const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
(async (): Promise<void> => {
try {
e.preventDefault();
setState((state) => ({ ...state, submitted: true }));
setLoading(true);
const payload = {
first_name: formState.firstName,
email: formState.email,
@ -69,10 +67,12 @@ const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
message: 'Something went wrong',
});
}
setLoading(false);
} catch (error) {
notificationsInstance.error({
message: 'Something went wrong',
});
setLoading(false);
}
})();
};
@ -121,7 +121,8 @@ const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
type="primary"
htmlType="submit"
data-attr="signup"
disabled={state.submitted && !formState.password}
loading={loading}
disabled={loading || !formState.email.value}
>
Get Started
</Button>