Skip to content

Commit

Permalink
added snackbar to singin page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebbben committed Oct 1, 2024
1 parent 6322071 commit a715fac
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions app/pages/auth/signIn/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { signIn, useSession } from "next-auth/react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { normalizeEmail } from "./../../../components/Login/authUtil";
import SnackbarAlert from "@/app/components/feedback/snackbarAlert";


export default function SignInPage() {
Expand All @@ -17,6 +18,8 @@ export default function SignInPage() {
const [response, setResponse] = useState("")
const [error, setError] = useState(false)
const [loading, setLoading] = useState(false)
const [snackbarOpen, setSnackbarOpen] = useState(false);
const [severity, setSeverity] = useState("")

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

if (email == "") {
setError(true)
setSeverity("error")
setResponse("Please fill in your email")
setLoading(false);
setSnackbarOpen(true);
return
}

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

if (response.error == null) {
setError(false)
setSeverity("success")
setResponse(`Email sent to ${normalizedEmail}`);
setLoading(false);
setSnackbarOpen(true);
} else {
setError(true);
setSeverity("error")
setResponse(response.error);
setLoading(false);
setSnackbarOpen(true);
}
}

Expand Down Expand Up @@ -120,12 +129,16 @@ export default function SignInPage() {
Register new user
</Typography>
</Link>
</Grid>

<Grid item container>
<Typography variant="subtitle1" >
</Grid>
<Grid item>
<Typography variant="caption">
{response != "" ? (
response
<SnackbarAlert
open={snackbarOpen}
setOpen={setSnackbarOpen}
response={response}
severity={severity}
/>
) : (
<Skeleton
animation={false}
Expand Down

0 comments on commit a715fac

Please sign in to comment.