import Typography from '@mui/material/Typography'; import FormControlLabel from '@mui/material/FormControlLabel'; import Checkbox from '@mui/material/Checkbox'; import Button from '@mui/material/Button'; import Box from '@mui/material/Box'; import {useTranslation, Trans} from 'next-i18next'; import {useMemo, useState} from 'react'; import pageUtils from '../../../lib/pageUtils'; import CommonConfirm from '../../../layouts/ConfirmLayout'; import {useUpdateMeMutation} from '../../../generated/graphql'; import useSettings from '../../../hooks/useSettings'; import moment from 'moment'; import {useSession} from 'next-auth/react'; import {TextField, useMediaQuery} from '@mui/material'; import {useTheme} from '@mui/styles'; const Confirm = () => { const {t} = useTranslation(); const settings = useSettings(); const [updateMe] = useUpdateMeMutation(); const session = useSession(); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const sessionNames = session?.data?.token?.name?.split(' ') || ['', '']; const [firstname, setFirstname] = useState(sessionNames[0]); const [lastname, setLastname] = useState(sessionNames[1]); const [newsletterConsent, setNewsletterConsent] = useState(false); const [tosConsent, setTosConsent] = useState(false); const canConfirm = useMemo( () => firstname?.length > 1 && lastname?.length > 1 && tosConsent, [firstname, lastname, tosConsent] ); const onSubmit = async () => { const tosAcceptationDate = tosConsent ? moment().toISOString() : null; await updateMe({ variables: { userUpdate: { newsletterConsent, tosAcceptationDate, firstName: firstname, lastName: lastname, }, }, }); window.location.href = '/dashboard'; }; return ( {t('signup.create')} {t('confirm.google.title')} setFirstname(e.target.value)} fullWidth /> setLastname(e.target.value)} fullWidth /> setNewsletterConsent(checked) } /> } label={t('signup.newsletter.consent')} /> , 'data-privacy-link': ( ), }} /> } control={ setTosConsent(e.target.checked)} /> } /> ); }; export default Confirm; export const getServerSideProps = pageUtils.getServerSideProps();