feat: disable login/signup buttons when all inputs are not filled

This commit is contained in:
Olaleye Blessing 2022-04-20 00:12:11 +01:00
parent 1b5389e06c
commit 5f64a60b7f
3 changed files with 21 additions and 4 deletions

View File

@ -29,6 +29,9 @@ function Login() {
user.login(userData)
}
// disable submit button is any input has not been filled
const disabledSubmitBtn = Object.values(userData).some((val) => val === '')
if (user.user) {
router.push('/dashboard')
}
@ -69,7 +72,11 @@ function Login() {
/>
</div>
<button type="submit" className="submit-button">
<button
type="submit"
className="submit-button"
disabled={disabledSubmitBtn}
>
Submit
</button>

View File

@ -28,6 +28,9 @@ function Reg() {
context.createAcc(userData)
}
// disable submit button is any input has not been filled
const disabledSubmitBtn = Object.values(userData).some((val) => val === '')
if (context.user) {
router.push('/dashboard')
}
@ -96,7 +99,11 @@ function Reg() {
/>
</div>
<button type="submit" className="submit-button">
<button
type="submit"
className="submit-button"
disabled={disabledSubmitBtn}
>
Submit
</button>

View File

@ -9,8 +9,8 @@ body {
overflow-y: auto;
}
a, a:hover
{
a,
a:hover {
color: inherit;
text-decoration: none;
}
@ -51,3 +51,6 @@ body::-webkit-scrollbar-thumb {
border-radius: 10px;
}
button:disabled {
cursor: not-allowed;
}