Merge pull request #1055 from hackclub/slack-form

This commit is contained in:
Toby Brown 2024-01-11 07:22:00 +00:00 committed by GitHub
commit f2848ff811
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -17,7 +17,7 @@ import { getCookie, hasCookie } from 'cookies-next'
const JoinForm = ({ sx = {} }) => {
const router = useRouter()
const { status, formProps, useField } = useForm('/api/join/', null, {
clearOnSubmit: 5000,
clearOnSubmit: 60000,
method: 'POST',
initData: hasCookie('continent')
? {
@ -150,6 +150,7 @@ const JoinForm = ({ sx = {} }) => {
? "We'll be in touch soon!"
: 'Check your email for invite!'
}}
disabled={status === 'loading' || status === 'success'}
/>
{status === 'success' && (
<Text

View file

@ -52,9 +52,17 @@ const useForm = (
if (r.ok) {
setStatus('success')
if (callback) callback(r)
setTimeout(() => setStatus('default'), 3500)
if (options.clearOnSubmit)
setTimeout(() => setData({}), options.clearOnSubmit)
if (options.clearOnSubmit) {
setTimeout(() => {
setData({});
setStatus('default');
}, options.clearOnSubmit);
} else {
setTimeout(() => {
setData({});
setStatus('default')
}, 3500)
}
} else {
setStatus('error')
console.error(response)