import pageUtils from '../../lib/pageUtils'; import Layout from '../../layouts/EventCreation'; import { Button, CardActions, Checkbox, FormControlLabel, Paper, Stack, TextField, } from '@mui/material'; import useEventCreationStore from '../../stores/useEventCreationStore'; import {useTranslation} from 'next-i18next'; import {useSession} from 'next-auth/react'; import {useMemo} from 'react'; import {isValidEmail} from '../../lib/formValidation'; import NextLink from 'next/link'; import Logo from '../../components/Logo'; interface Props { announcement?: string; } const NewEvent = (props: Props) => { const {t} = useTranslation(); const session = useSession(); const isAuthenticated = session.status === 'authenticated'; const event = useEventCreationStore(s => s.event); const setField = useEventCreationStore(s => s.setField); const canSubmit = useMemo(() => { const nameIsOk = event.name?.length > 0; const emailIsOk = event.email?.length > 0 && isValidEmail(event.email); return isAuthenticated ? nameIsOk : nameIsOk && emailIsOk; }, [event, , isAuthenticated]); return ( setField('name', e.target.value)} id="NewEventName" name="name" /> {!isAuthenticated && ( <> setField('email', e.target.value)} name="email" type="email" id="NewEventEmail" /> setField('newsletter', e.target.checked)} /> } /> )} {!isAuthenticated && ( )} ); }; export const getServerSideProps = pageUtils.getServerSideProps(); export default NewEvent;