-
Notifications
You must be signed in to change notification settings - Fork 192
/
Copy pathform.js
78 lines (70 loc) · 1.87 KB
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import Icon from '@hackclub/icons'
import { useRef, useState } from 'react'
import { Box, Label, Input, Button, Text } from 'theme-ui'
const Form = () => {
const [submitted, setSubmitted] = useState(false)
const formRef = useRef(null)
const handleSubmit = async e => {
e.preventDefault()
await fetch(
'https://airtable-forms-proxy.hackclub.dev/api/appEzv7w2IBMoxxHe/Hackathon%20Grant%20Waitlist',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
Email: e.target.email.value
})
}
)
formRef.current.reset()
setSubmitted(true)
}
return (
<Box
sx={{ textAlign: 'center', maxWidth: '24rem', mx: 'auto' }}
as="form"
ref={formRef}
onSubmit={handleSubmit}
>
<Label htmlFor="email" sx={{ color: 'smoke', fontSize: 18 }}>
Your email
<Input
id="email"
name="email"
type="email"
sx={{
bg: 'darkless',
my: 0,
mt: 1,
mb: 2
}}
required
/>
</Label>
{submitted ? (
<Text color="smoke" sx={{ display: 'block', mt: 3 }}>
<Box color="green">
<Icon glyph="checkmark" />
</Box>
Thanks! We'll send you an email in the coming weeks when applications
have opened.
</Text>
) : (
<>
<Button variant="outline">Get notified</Button>
<Text
variant="caption"
sx={{ color: 'muted', fontSize: 16, display: 'block', mt: 3 }}
>
We'll send you an email when grant applications are open— no spam or
unexpected marketing emails.
</Text>
</>
)}
</Box>
)
}
export default Form