Skip to content

Commit

Permalink
web: disable signup button while submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorganca committed Jul 13, 2023
1 parent e6eee07 commit 787d965
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/app/download/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { useState } from 'react'

export default function Signup() {
const [email, setEmail] = useState('')
const [submitting, setSubmitting] = useState(false)
const [success, setSuccess] = useState(false)

return (
<form
onSubmit={async e => {
e.preventDefault()

setSubmitting(true)

await fetch('/api/signup', {
method: 'POST',
headers: {
Expand All @@ -19,6 +22,7 @@ export default function Signup() {
body: JSON.stringify({ email }),
})

setSubmitting(false)
setSuccess(true)
setEmail('')

Expand All @@ -38,7 +42,8 @@ export default function Signup() {
<input
type='submit'
value='Get updates'
className='bg-black text-white rounded-lg px-4 py-2 focus:outline-none cursor-pointer'
disabled={submitting}
className='bg-black text-white disabled:text-neutral-200 disabled:bg-neutral-700 rounded-lg px-4 py-2 focus:outline-none cursor-pointer'
/>
{success && <p className='text-center text-sm'>You&apos;re signed up for updates</p>}
</form>
Expand Down

0 comments on commit 787d965

Please sign in to comment.