add error page

This commit is contained in:
renzynx 2022-12-26 15:09:39 +07:00
parent 8396aeb8d0
commit 226bf55065
1 changed files with 31 additions and 0 deletions

31
web/src/pages/_error.tsx Normal file
View File

@ -0,0 +1,31 @@
import { ROUTES } from '@lib/constants';
import { Button, Center, Stack, Text } from '@mantine/core';
import Head from 'next/head';
import Router from 'next/router';
export default function Error({ statusCode, oauthError }: any) {
return (
<>
<Head>
<title>Error ({statusCode})</title>
</Head>
<Center sx={{ height: '100vh', width: '100vw' }}>
<Stack justify="center" align="center" spacing="lg">
<Text size="xl" align="center">
{statusCode
? `An error ${statusCode} occurred on server`
: 'An error occurred on client'}
</Text>
<Button onClick={() => Router.push(ROUTES.HOME)}>Go back</Button>
</Stack>
</Center>
</>
);
}
export function getInitialProps({ res, err }: any) {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
return { pageProps: { statusCode } };
}