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

Fixing mobile error page #82

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2,132 changes: 572 additions & 1,560 deletions client/package-lock.json

Large diffs are not rendered by default.

Binary file added client/public/gifs/error/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/gifs/error/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/gifs/error/3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/gifs/error/4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/gifs/error/5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 0 additions & 22 deletions client/public/images/sad-smile.svg

This file was deleted.

14 changes: 12 additions & 2 deletions client/src/components/layouts/StartLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ import { center, columnCenter } from '../../styles/flex';
export interface Props extends BoxProps {
header?: boolean;
backBtn?: boolean;
boxProps?: BoxProps;
}

const StartLayout: React.FC<Props> = ({ children, sx, header = true, backBtn = false }) => (
<Box sx={{ minHeight: '100vh', ...center, ...sx }}>
const StartLayout: React.FC<Props> = ({
children,
sx,
header = true,
backBtn = false,
boxProps,
...rest
}) => (
<Box sx={{ minHeight: '100vh', ...center, ...sx }} {...rest}>
<Box
{...boxProps}
sx={{
height: '300px',
justifyContent: 'flex-start',
gap: '20px',
...columnCenter,
...boxProps?.sx,
}}
>
{header && <Header disableBackBtn={!backBtn} />}
Expand Down
47 changes: 35 additions & 12 deletions client/src/pages/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Stack, Typography } from '@mui/material';
import HomeLayout, { Props as HomeLayoutProps } from '../components/layouts/HomeLayout';
import StartLayout, { Props as StartLayoutProps } from '../components/layouts/StartLayout';
import Button from '../components/UI/buttons/Button';
import Routes from '../services/Router/Routes';
import { LayoutProps } from '../types/utils/LayoutProps';
import ApiError from '../services/Api/ApiError';
import sadSmile from '/images/sad-smile.svg';
import { center } from '../styles/flex';
import usePublicFolder from '../hooks/usePublicFolder';
import getRandom from '../utils/getRandom';

type ErrorDetails = {
title: string;
Expand All @@ -23,6 +24,9 @@ type Props = LayoutProps & {

const ErrorPage: React.FC<Props> = (props) => {
const { layout, error, errorDetails, actions, onGoHome, ...rest } = props;
const randomNum = useMemo(() => getRandom(1, 5), []);
const gifSrc = usePublicFolder(`gifs/error/${randomNum}.gif`);

let status;
let message;
let title;
Expand All @@ -42,19 +46,34 @@ const ErrorPage: React.FC<Props> = (props) => {
}

const content = (
<Stack spacing={2} alignItems="center">
<Stack direction="row" justifyContent="center" alignItems="center" spacing={8}>
<img src={sadSmile} alt="sad smile" css={{ height: '200px', width: 'auto' }} />
<Typography fontWeight={400} variant="h2" color="error">
<Stack spacing={4} paddingInline={4} justifyContent="center" alignItems="center">
<img src={gifSrc} alt={title} css={{ maxWidth: 600, width: '100%', height: 'auto' }} />
<Stack
justifyContent="center"
alignItems="center"
spacing={3}
sx={{
wordBreak: 'break-word',
wordWrap: 'normal',
}}
>
<Typography
textAlign="center"
fontWeight={400}
variant="h3"
color={(theme) => theme.palette.error.main}
maxWidth={1200}
>
{title}
</Typography>
</Stack>

<Typography variant="h6">{message}</Typography>

<Stack direction="row" spacing={3} alignItems="center">
{actions}
<Typography textAlign="center" variant="h5" maxWidth={900}>
{message}
</Typography>
</Stack>
{actions}

<Stack>
<Button
to={layout === 'home' ? Routes.HOME : Routes.START}
onClick={onGoHome}
Expand All @@ -78,7 +97,11 @@ const ErrorPage: React.FC<Props> = (props) => {
}

return (
<StartLayout header={false} {...(rest as StartLayoutProps)}>
<StartLayout
boxProps={{ sx: { maxWidth: '100%', height: 'unset' } }}
header={false}
{...(rest as StartLayoutProps)}
>
{content}
</StartLayout>
);
Expand Down