Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display error message when CurrentMember request fails on network error #201

Open
spaenleh opened this issue Mar 2, 2023 · 0 comments
Open

Comments

@spaenleh
Copy link
Member

spaenleh commented Mar 2, 2023

import { Refresh } from '@mui/icons-material';
import {
  Alert,
  AlertTitle,
  IconButton,
  Stack,
  Tooltip,
  Typography,
} from '@mui/material';
import { Box } from '@mui/material';

import { FAILURE_MESSAGES } from '@graasp/translations';

import { useMessagesTranslation, usePlayerTranslation } from '@/config/i18n';

const NetworkErrorAlert = () => {
  const { t: messagesTranslations } = useMessagesTranslation();
  const { t } = usePlayerTranslation();
  return (
    <Box
      display="flex"
      height="100vh"
      width="100%"
      justifyContent="center"
      margin="auto"
      alignItems="center"
    >
      <Alert severity="error">
        <AlertTitle>
          {messagesTranslations(FAILURE_MESSAGES.UNEXPECTED_ERROR)}
        </AlertTitle>
        <Stack direction="column" alignItems="center">
          <Typography>
            {t(
              'There seems to be a problem joining the server. Please try again later',
            )}
          </Typography>
          <Tooltip title="Reload">
            <span>
              <IconButton onClick={() => window.location.reload()}>
                <Refresh />
              </IconButton>
            </span>
          </Tooltip>
        </Stack>
      </Alert>
    </Box>
  );
};
export default NetworkErrorAlert;

And in App.tsx

  if (
    isError &&
    (currentMemberError as { code: string }).code === 'ERR_NETWORK'
  ) {
    return <NetworkErrorAlert />;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant