fix: Notification is shown to the user when api for login is not successfull (#361)

This commit is contained in:
pal-sig 2021-11-17 17:00:14 +05:30 committed by GitHub
parent 36e95332bc
commit 865e487fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { Button, Input, Typography } from 'antd'; import { Button, Input, notification, Typography } from 'antd';
import signup from 'api/user/signup'; import signup from 'api/user/signup';
import ROUTES from 'constants/routes'; import ROUTES from 'constants/routes';
import history from 'lib/history'; import history from 'lib/history';
@ -18,6 +18,8 @@ import {
} from './styles'; } from './styles';
const Signup = ({ loggedIn }: SignupProps): JSX.Element => { const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
const [notificationsInstance, Element] = notification.useNotification();
const [state, setState] = useState({ submitted: false }); const [state, setState] = useState({ submitted: false });
const [formState, setFormState] = useState({ const [formState, setFormState] = useState({
firstName: { value: '' }, firstName: { value: '' },
@ -61,17 +63,22 @@ const Signup = ({ loggedIn }: SignupProps): JSX.Element => {
loggedIn(); loggedIn();
history.push(ROUTES.APPLICATION); history.push(ROUTES.APPLICATION);
} else { } else {
// @TODO throw a error notification here notificationsInstance.error({
message: 'Something went wrong',
});
} }
} catch (error) { } catch (error) {
console.error(error); notificationsInstance.error({
// @TODO throw a error notification here message: 'Something went wrong',
});
} }
})(); })();
}; };
return ( return (
<div> <div>
{Element}
<Container direction="vertical"> <Container direction="vertical">
<Title>Create your account</Title> <Title>Create your account</Title>
<Typography> <Typography>