mirror of
https://github.com/System-End/site.git
synced 2026-04-20 00:25:19 +00:00
Merge pull request #1055 from hackclub/slack-form
This commit is contained in:
commit
f2848ff811
2 changed files with 13 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue