Skip to content

Commit a715fac

Browse files
committed
added snackbar to singin page
1 parent 6322071 commit a715fac

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

app/pages/auth/signIn/page.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { signIn, useSession } from "next-auth/react";
99
import Link from "next/link";
1010
import { useRouter } from "next/navigation";
1111
import { normalizeEmail } from "./../../../components/Login/authUtil";
12+
import SnackbarAlert from "@/app/components/feedback/snackbarAlert";
1213

1314

1415
export default function SignInPage() {
@@ -17,6 +18,8 @@ export default function SignInPage() {
1718
const [response, setResponse] = useState("")
1819
const [error, setError] = useState(false)
1920
const [loading, setLoading] = useState(false)
21+
const [snackbarOpen, setSnackbarOpen] = useState(false);
22+
const [severity, setSeverity] = useState("")
2023

2124
const session = useSession()
2225
const router = useRouter()
@@ -31,8 +34,10 @@ export default function SignInPage() {
3134

3235
if (email == "") {
3336
setError(true)
37+
setSeverity("error")
3438
setResponse("Please fill in your email")
3539
setLoading(false);
40+
setSnackbarOpen(true);
3641
return
3742
}
3843

@@ -45,12 +50,16 @@ export default function SignInPage() {
4550

4651
if (response.error == null) {
4752
setError(false)
53+
setSeverity("success")
4854
setResponse(`Email sent to ${normalizedEmail}`);
4955
setLoading(false);
56+
setSnackbarOpen(true);
5057
} else {
5158
setError(true);
59+
setSeverity("error")
5260
setResponse(response.error);
5361
setLoading(false);
62+
setSnackbarOpen(true);
5463
}
5564
}
5665

@@ -120,12 +129,16 @@ export default function SignInPage() {
120129
Register new user
121130
</Typography>
122131
</Link>
123-
</Grid>
124-
125-
<Grid item container>
126-
<Typography variant="subtitle1" >
132+
</Grid>
133+
<Grid item>
134+
<Typography variant="caption">
127135
{response != "" ? (
128-
response
136+
<SnackbarAlert
137+
open={snackbarOpen}
138+
setOpen={setSnackbarOpen}
139+
response={response}
140+
severity={severity}
141+
/>
129142
) : (
130143
<Skeleton
131144
animation={false}

0 commit comments

Comments
 (0)