Disable button during reg.

This commit is contained in:
Thomas E Lackey 2023-09-13 16:37:49 -05:00
parent 026c8f448f
commit afb0e0abd9
2 changed files with 12 additions and 3 deletions

View File

@ -115,8 +115,13 @@ input {
}
#sub_btn:hover {
background: #333;
transition: all .5s
background: #000;
transition: all .1s
}
#sub_btn:disabled {
background: #ccc;
transition: all .1s
}
footer p {

View File

@ -9,8 +9,10 @@ export default function SignUpPage() {
const [apiKey, setApiKey] = useState("");
const [message, setMessage] = useState("");
const [error, setError] = useState("");
const [buttonDisabled, setButtonDisabled] = useState(false);
let handleSubmit = async (e) => {
setButtonDisabled(true);
setApiKey("");
setMessage("");
setError("");
@ -41,6 +43,8 @@ export default function SignUpPage() {
}
} catch (err) {
setError("An error occurred.");
} finally {
setButtonDisabled(false);
}
};
@ -80,7 +84,7 @@ export default function SignUpPage() {
rel="noopener noreferrer">terms of service</a></span>.
</p>
<p>
<button id="sub_btn" type="submit">Register</button>
<button id="sub_btn" type="submit" disabled={buttonDisabled}>Register</button>
</p>
</form>
<div className="error">{error ? <p>{error}</p> : null}</div>