site/components/stickers/request-form.js
Lachlan Campbell 56dd418d0d HC-55 Add Stickers page (#6)
* Begin sticker page

* Add formatted countries

* Remove unused imports

* Use fetch again

* Small edits

* Fix typo

* Continue polishing

* Fix address autocomplete

* Add stickers to page

* Add hero image

* Add link to homepage

* fix person

* console log

* fix typo

* h

* fix detection

* fix again i think

* more fix

* fix again lol

* edge case

* fix equals

* fix and improve :) :) " :):):)

* add zip code

Co-authored-by: Matthew Stanciu <mattbstanciu@gmail.com>
2020-11-09 13:05:16 -05:00

85 lines
2.4 KiB
JavaScript

import { Grid, Card, Label, Input, Select } from 'theme-ui'
import useForm from '../../lib/use-form'
import { countries } from '../../lib/countries'
import Submit from '../submit'
const RequestForm = () => {
const { status, formProps, useField } = useForm('/api/stickers')
return (
<Grid
as="form"
columns={2}
gap={3}
{...formProps}
sx={{
label: { gridColumn: ['span 2', 'auto'] },
button: { gridColumn: 'span 2', maxWidth: '75%', mx: 'auto' },
'input, select': { bg: 'dark' }
}}
>
<Label>
Full name
<Input {...useField('name')} placeholder="Fiona Hackworth" required />
</Label>
<Label>
Email address (for tracking)
<Input
{...useField('email')}
placeholder="fiona@hackclub.com"
required
/>
</Label>
<Label>
Address (first line)
<Input
{...useField('addressFirst')}
placeholder="8605 Santa Monica Blvd"
autoComplete="address-line1"
required
/>
</Label>
<Label>
Address (second line) (optional)
<Input
{...useField('addressSecond')}
autoComplete="address-line2"
placeholder="#86294"
/>
</Label>
<Label sx={{ gridColumn: 'span 1 !important' }}>
City
<Input {...useField('city')} placeholder="West Hollywood" required />
</Label>
<Label sx={{ gridColumn: 'span 1 !important' }}>
State/Province
<Input {...useField('state')} placeholder="CA" required />
</Label>
<Label sx={{ gridColumn: 'span 1 !important' }}>
Zip Code
<Input {...useField('zipCode')} placeholder="90069" />
</Label>
<Label sx={{ gridColumn: 'span 1 !important' }}>
Country
<Select {...useField('country')} defaultValue="Choose a country">
<option value="" selected disabled>
Choose a country
</option>
{Object.entries(countries).map(country => (
<option value={country.slice(1)}>{country.slice(1)}</option>
))}
</Select>
</Label>
<Submit
status={status}
labels={{
default: 'Request stickers',
error: 'Something went wrong',
success: 'Coming your way!'
}}
/>
</Grid>
)
}
export default RequestForm