|
| 1 | +import { Anchor, Center, Stack, Text, Title } from '@mantine/core' |
| 2 | +import { FC, useMemo } from 'react' |
| 3 | +import { useTranslation } from 'react-i18next' |
| 4 | +import { Link, useLocation, useNavigate } from 'react-router' |
| 5 | +import { LogoHeader } from '@Components/LogoHeader' |
| 6 | +import { usePageTitle } from '@Hooks/usePageTitle' |
| 7 | +import misc from '@Styles/Misc.module.css' |
| 8 | + |
| 9 | +// Email validation regex |
| 10 | +const isValidEmail = (email: string): boolean => { |
| 11 | + return typeof email === 'string' && email.trim().length > 0 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim()) |
| 12 | +} |
| 13 | + |
| 14 | +const EmailConfirmationPending: FC = () => { |
| 15 | + const location = useLocation() |
| 16 | + const emailFromState = location.state?.email || '' |
| 17 | + |
| 18 | + const email = useMemo(() => (isValidEmail(emailFromState) ? emailFromState.trim() : ''), [emailFromState]) |
| 19 | + |
| 20 | + const { t } = useTranslation() |
| 21 | + const navigate = useNavigate() |
| 22 | + |
| 23 | + usePageTitle(t('account.title.verify_email')) |
| 24 | + |
| 25 | + return ( |
| 26 | + <Center h="100vh"> |
| 27 | + <Stack align="center" justify="center"> |
| 28 | + <LogoHeader onClick={() => navigate('/')} /> |
| 29 | + <Stack gap="xs" align="center" justify="center"> |
| 30 | + <Title order={3} fw={600} ta="center"> |
| 31 | + {t('account.content.verify_email.title')} |
| 32 | + </Title> |
| 33 | + <Text size="md" fw={500} ta="center"> |
| 34 | + {t('account.content.verify_email.message')} |
| 35 | + </Text> |
| 36 | + <Text size="md" fw={600} c="brand" ta="center"> |
| 37 | + {email || 'email@example.com'} |
| 38 | + </Text> |
| 39 | + <Text size="sm" c="dimmed" ta="center"> |
| 40 | + {t('account.content.verify_email.check_spam')} |
| 41 | + </Text> |
| 42 | + <Anchor fz="xs" className={misc.alignSelfEnd} component={Link} to="/account/login"> |
| 43 | + {t('account.anchor.login')} |
| 44 | + </Anchor> |
| 45 | + </Stack> |
| 46 | + </Stack> |
| 47 | + </Center> |
| 48 | + ) |
| 49 | +} |
| 50 | + |
| 51 | +export default EmailConfirmationPending |
0 commit comments