This commit is contained in:
Toby Brown 2024-01-07 14:56:51 +00:00
parent 562440f726
commit dfa384dc16
2 changed files with 18 additions and 2 deletions

View file

@ -13,9 +13,22 @@ import { useRouter } from 'next/router'
import useForm from '../../lib/use-form'
import Submit from '../submit'
import { getCookie, hasCookie } from 'cookies-next'
import { useEffect, useState } from 'react'
const JoinForm = ({ sx = {} }) => {
const router = useRouter()
const [event, setEvent] = useState(null)
useEffect(() => {
if (!router.isReady) {
setEvent(null)
console.log('not ready yet!')
} else {
setEvent(router.query.event)
console.log('Hello from the client!', name)
}
}, [])
const { status, formProps, useField } = useForm('/api/join/', null, {
clearOnSubmit: 5000,
method: 'POST',
@ -23,7 +36,7 @@ const JoinForm = ({ sx = {} }) => {
? {
continent: getCookie('continent'),
reason: router.query.reason,
event: router.query.event
event: event
}
: { reason: router.query.reason, event: router.query.event }
})

View file

@ -55,6 +55,9 @@ export default async function handler(req, res) {
})
}
console.log("Hello from the server!", data.event)
console.log("Hello from the server!", data)
const airtablePromise = joinTable.create({
'Full Name': data.name,
'Email Address': data.email,
@ -62,7 +65,7 @@ export default async function handler(req, res) {
Reason: data.reason,
Invited: !waitlist,
Club: data.club ? data.club : '',
Event: data.event ? data.event : '',
'Event': data.event ? data.event : '',
IP: req.headers['x-forwarded-for'] || req.socket.remoteAddress
})