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 { #sub_btn:hover {
background: #333; background: #000;
transition: all .5s transition: all .1s
}
#sub_btn:disabled {
background: #ccc;
transition: all .1s
} }
footer p { footer p {

View File

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