Skip to content

Commit

Permalink
feat: add error page
Browse files Browse the repository at this point in the history
  • Loading branch information
pooriaset committed May 6, 2024
1 parent 5eee205 commit 21faa14
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
Binary file added public/assets/images/unplugged.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/app/[locale]/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use client';

import { Header } from '@/components/Header';
import { Box, Button, Container, Stack, Typography } from '@mui/material';
import { useTranslations } from 'next-intl';
import Image from 'next/image';
import { FC, useEffect } from 'react';

export interface ErrorProps {
error: Error & { digest?: string };
reset: () => void;
}

const Error: FC<ErrorProps> = ({ error, reset }) => {
const t = useTranslations();

useEffect(() => {
console.error(error);
}, [error]);

return (
<>
<Header />

<Container
maxWidth="xs"
sx={{
px: 2,
mt: 6,
}}
>
<Stack
spacing={2}
alignItems="center"
sx={{
userSelect: 'none',
}}
>
<Image
width={200}
height={200}
src="/assets/images/unplugged.png"
alt="Error!"
style={{
opacity: 0.68,
}}
/>
<Typography variant="h5" component="h1">
{t('pages.error.message')}
</Typography>
<Button fullWidth variant="contained" size="large" onClick={reset}>
{t('pages.error.buttons.reset')}
</Button>
</Stack>
</Container>
</>
);
};

export default Error;
8 changes: 4 additions & 4 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { AppBar, Container } from '@mui/material';
import { FC, Suspense } from 'react';
import DesktopView from '../App/DesktopView';
import MobileView from '../App/MobileView';
import { DesktopHeader } from './components';
import { DesktopHeader, MobileHeader } from './components';
import TopBanner, {
TopBannerProps,
} from '@/app/[locale]/(main)/components/TopBanner/TopBanner';

export interface HeaderProps {
topBanner: TopBannerProps['data'];
topBanner?: TopBannerProps['data'];
}
const Header: FC<HeaderProps> = ({ topBanner }) => {
return (
Expand All @@ -26,14 +26,14 @@ const Header: FC<HeaderProps> = ({ topBanner }) => {
backgroundColor: '#ffffff',
}}
>
<TopBanner data={topBanner} />
{topBanner && <TopBanner data={topBanner} />}
<Container maxWidth="xl">
<DesktopView>
<DesktopHeader />
</DesktopView>
<MobileView>
<Suspense>
<MobileView />
<MobileHeader />
</Suspense>
</MobileView>
</Container>
Expand Down
8 changes: 7 additions & 1 deletion src/data/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@
},
"sendAgainText": "to send again",
"seconds": "s"
},
"error": {
"message": "Oops, Something went wrong!",
"buttons": {
"reset": "ُTry again!"
}
}
},
"fields": {
"size": "Size"
}
}
}
8 changes: 7 additions & 1 deletion src/data/i18n/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,15 @@
},
"sendAgainText": "تا ارسال مجدد",
"seconds": "ثانیه"
},
"error": {
"message": "متاسفانه خطایی رخ داده است.",
"buttons": {
"reset": "تلاش دوباره!"
}
}
},
"fields": {
"size": "سایز"
}
}
}

0 comments on commit 21faa14

Please sign in to comment.