mirror of
https://github.com/System-End/site.git
synced 2026-04-20 00:25:19 +00:00
are they an adult?
This commit is contained in:
parent
13e2579901
commit
f7729544b4
1 changed files with 18 additions and 3 deletions
|
|
@ -13,6 +13,7 @@ import { useRouter } from 'next/router'
|
|||
import useForm from '../../lib/use-form'
|
||||
import Submit from '../submit'
|
||||
import { getCookie, hasCookie } from 'cookies-next'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const JoinForm = ({ sx = {} }) => {
|
||||
const router = useRouter()
|
||||
|
|
@ -45,6 +46,20 @@ const JoinForm = ({ sx = {} }) => {
|
|||
const months = createNums(1, 12)
|
||||
const days = createNums(1, 31)
|
||||
|
||||
const month = useField('birthday').value
|
||||
const day = useField('day').value
|
||||
const year = useField('year').value
|
||||
|
||||
const birthday = new Date(year, month - 1, day)
|
||||
|
||||
const age = new Date().getFullYear() - birthday.getFullYear()
|
||||
|
||||
const isPersonAdult = age >= 18
|
||||
|
||||
useEffect(() => {
|
||||
console.log(isPersonAdult)
|
||||
})
|
||||
|
||||
return (
|
||||
<Card sx={{ maxWidth: 'narrow', mx: 'auto', label: { mb: 3 }, ...sx }}>
|
||||
<form {...formProps}>
|
||||
|
|
@ -94,7 +109,7 @@ const JoinForm = ({ sx = {} }) => {
|
|||
<Label>
|
||||
Birthday
|
||||
<Select
|
||||
{...useField('continent')}
|
||||
{...useField('month')}
|
||||
required
|
||||
sx={{ color: useField('continent').value === '' ? 'muted' : '' }}
|
||||
>
|
||||
|
|
@ -111,7 +126,7 @@ const JoinForm = ({ sx = {} }) => {
|
|||
<Label>
|
||||
|
||||
<Select
|
||||
{...useField('continent')}
|
||||
{...useField('day')}
|
||||
required
|
||||
sx={{ color: useField('continent').value === '' ? 'muted' : '' }}
|
||||
>
|
||||
|
|
@ -128,7 +143,7 @@ const JoinForm = ({ sx = {} }) => {
|
|||
<Label>
|
||||
|
||||
<Select
|
||||
{...useField('continent')}
|
||||
{...useField('year')}
|
||||
required
|
||||
sx={{ color: useField('continent').value === '' ? 'muted' : '' }}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue