From 5574516716b285b2ada6e7430e90084bff502e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Mon, 24 May 2021 02:52:13 +0200 Subject: [PATCH] Add loading & LinearProgress to Koneksyon component --- components/kont/koneksyon.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/kont/koneksyon.js b/components/kont/koneksyon.js index 951c009..2936184 100644 --- a/components/kont/koneksyon.js +++ b/components/kont/koneksyon.js @@ -9,6 +9,7 @@ import { Input, InputAdornment, InputLabel, + LinearProgress, Snackbar, Typography } from '@material-ui/core' @@ -22,6 +23,7 @@ function Koneksyon() { const [loginError, setError] = useState('') const [credentials, setCredentials] = useState({username: '', password: ''}) const [showPassword, setShowPassword] = useState(false) + const [loading, setLoading] = useState(false) const [open, setOpen] = useState(true) const router = useRouter() @@ -30,13 +32,16 @@ function Koneksyon() { } const handleClick = async () => { + setLoading(true) const response = await signIn('credentials', { redirect: false, ...credentials }) if (response.error) { setError(response.error) + setLoading(false) } else if (response.ok) { + setLoading(false) router.push('/kont') } } @@ -101,7 +106,7 @@ function Koneksyon() { + {loading && } + {loginError && (