Skip to content

Commit

Permalink
feat: add try again if not token on email verify
Browse files Browse the repository at this point in the history
  • Loading branch information
Qolzam committed May 30, 2024
1 parent b379be1 commit 321fdf3
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions src/pages/EmailVerifyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSelector } from 'redux/store';
import { authorizeSelector } from 'redux/reducers/authorize/authorizeSelector';
import { PATH_AUTH } from 'routes/paths';
import { Link as RouterLink } from 'react-router-dom';
import { Map } from 'immutable';

// material
import { Box, Button, Container, Typography } from '@mui/material';
Expand All @@ -23,34 +24,41 @@ export default function EmailVerifyPage() {
const navigate = useNavigate();
const { enqueueSnackbar } = useSnackbar();
const { verifyRegisterCode } = useAuth();
const user = useSelector(selectUserFromRegisterToken);
const user = useSelector((state: Map<string, any>) => selectUserFromRegisterToken(state));

return (
<AuthWrapper>
<Container sx={{ p: 5 }}>
<Box sx={{ maxWidth: 480, mx: 'auto' }}>
<Typography variant="h3" paragraph>
Please check your email!
</Typography>
<Typography sx={{ color: 'text.secondary' }}>
We have emailed a 6-digit confirmation code to <strong>{user.email}</strong>, please enter the
code in below box to verify your email.
</Typography>
<Box sx={{ mt: 5, mb: 3 }}>
<VerifyCodeForm
verify={verifyRegisterCode}
onSuccess={() => {
enqueueSnackbar('Verify success', { variant: 'success' });
navigate(PATH_AUTH.login);
}}
onError={(error) => {
enqueueSnackbar(error.message, { variant: 'error' });
}}
/>
{user && user.email ? (
<Box sx={{ maxWidth: 480, mx: 'auto' }}>
<Typography variant="h3" paragraph>
Please check your email!
</Typography>
<Typography sx={{ color: 'text.secondary' }}>
We have emailed a 6-digit confirmation code to <strong>{user.email}</strong>, please enter
the code in below box to verify your email.
</Typography>
<Box sx={{ mt: 5, mb: 3 }}>
<VerifyCodeForm
verify={verifyRegisterCode}
onSuccess={() => {
enqueueSnackbar('Verify success', { variant: 'success' });
navigate(PATH_AUTH.login);
}}
onError={(error) => {
enqueueSnackbar(error.message, { variant: 'error' });
}}
/>
</Box>
<Button fullWidth component={RouterLink} to={PATH_AUTH.register} sx={{ mb: 3 }}>
{t('emailVerification.back')}
</Button>
</Box>
) : (
<Box sx={{ maxWidth: 480, mx: 'auto' }}>
<Typography sx={{ color: 'text.secondary' }}>Try again!</Typography>
</Box>
<Button fullWidth component={RouterLink} to={PATH_AUTH.register} sx={{ mb: 3 }}>
{t('emailVerification.back')}
</Button>
</Box>
)}
</Container>
</AuthWrapper>
);
Expand Down

0 comments on commit 321fdf3

Please sign in to comment.