Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions pages/users/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function Login() {
// TODO
// eslint-disable-next-line no-unused-vars
const router = useRouter();
const [formMessage, setFormMessage] = useState('');
const [successOpen, setSuccessOpen] = useState(false);
const [errorOpen, setErrorOpen] = useState(false);

Expand All @@ -69,10 +68,8 @@ function Login() {
};

const handleSubmit = async (values, setSubmitting) => {
setFormMessage('');

if (await login(values.email, values.password)) {
setFormMessage('Success: Logging in. Please wait.');
setSuccessOpen(true);
// router.push('/dashboard');
//
// TODO: Nextjs doesn't support Server side redirects
Expand Down Expand Up @@ -123,7 +120,7 @@ function Login() {
id="form"
>
{({
submitForm, isSubmitting, values,
isSubmitting, values,
}) => (
<Form className={classes.form}>
<Grid container spacing={2}>
Expand Down Expand Up @@ -156,22 +153,15 @@ function Login() {
variant="contained"
color="primary"
className={classes.submit}
onClick={submitForm}
disabled={isSubmitting}
type="submit"
>
Login
</Button>
</Form>
)}
</Formik>

{formMessage
&& (
<Typography>
{formMessage}
</Typography>
)}

<Link href="/users/signup">
<Typography className={classes.login}>
Don&#39;t have an account? Sign up now!
Expand All @@ -180,8 +170,20 @@ function Login() {

</Container>
</Paper>
<SnackAlert open={successOpen} onClose={handleSnackClose} severity="success" message="Success: Logging in. Please wait." />
<SnackAlert open={errorOpen} onClose={handleSnackClose} severity="error" message="Error: Email or password is invalid" />
<SnackAlert
open={successOpen}
onClose={handleSnackClose}
severity="success"
message="Success: Logging in. Please wait."
id="success-message"
/>
<SnackAlert
open={errorOpen}
onClose={handleSnackClose}
severity="error"
message="Error: Email or password is invalid"
id="error-message"
/>
</Grid>
);
}
Expand Down
4 changes: 2 additions & 2 deletions pages/users/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function Signup() {
validateOnChange={false}
id="form"
>
{({ values, submitForm, isSubmitting }) => (
{({ values, isSubmitting }) => (
<Form className={classes.form}>
<Grid container spacing={2}>
<Grid item xs={12}>
Expand Down Expand Up @@ -169,8 +169,8 @@ function Signup() {
variant="contained"
color="primary"
className={classes.submit}
onClick={submitForm}
disabled={isSubmitting}
type="submit"
>
Sign Up
</Button>
Expand Down