This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b561cd
commit 64c1741
Showing
3 changed files
with
51 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,32 @@ | ||
import { Button, Center, Heading, VStack } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
import { errors } from 'lib/constants'; | ||
import Head from 'next/head'; | ||
import Link from 'next/link'; | ||
import React from 'react'; | ||
import { ArrowLeftCircle } from 'react-feather'; | ||
|
||
export default function Error({ code }) { | ||
const errors = { | ||
'400': 'Bad Request', | ||
'401': 'Unauthorized', | ||
'402': 'Payment Required', | ||
'403': 'Forbidden', | ||
'404': 'Not Found', | ||
'405': 'Method Not Allowed', | ||
'406': 'Not Acceptable', | ||
'407': 'Proxy Authentication Required', | ||
'408': 'Request Timeout', | ||
'409': 'Conflict', | ||
'410': 'Gone', | ||
'411': 'Length Required', | ||
'412': 'Precondition Required', | ||
'413': 'Request Entry Too Large', | ||
'414': 'Request-URI Too Long', | ||
'415': 'Unsupported Media Type', | ||
'416': 'Requested Range Not Satisfiable', | ||
'417': 'Expectation Failed', | ||
'418': 'I\'m a teapot', | ||
'429': 'Too Many Requests', | ||
'500': 'Internal Server Error', | ||
'501': 'Not Implemented', | ||
'502': 'Bad Gateway', | ||
'503': 'Service Unavailable', | ||
'504': 'Gateway Timeout', | ||
'505': 'HTTP Version Not Supported' | ||
}; | ||
this.title = `${code} ${errors[String(code)]}` | ||
export default function Error({ title }) { | ||
return ( | ||
<Center h='100vh'> | ||
<VStack> | ||
<Heading>{code} {errors[String(code)]}</Heading> | ||
<Link href='/dash' passHref> | ||
<Button justifyContent='flex-start' colorScheme='purple' leftIcon={<ArrowLeftCircle/>}>Go back</Button> | ||
</Link> | ||
</VStack> | ||
</Center> | ||
<> | ||
<Head> | ||
<title>{title}</title> | ||
<meta property='og:title' content={title}/> | ||
<meta property='theme-color' content='#FC8181'/> | ||
</Head> | ||
<Center h='100vh'> | ||
<VStack> | ||
<Heading>{title}</Heading> | ||
<Link href='/dash' passHref> | ||
<Button justifyContent='flex-start' colorScheme='purple' leftIcon={<ArrowLeftCircle/>}>Go back</Button> | ||
</Link> | ||
</VStack> | ||
</Center> | ||
</> | ||
); | ||
} | ||
|
||
Error.getInitialProps = ({ res, err }) => { | ||
const code = res ? res.statusCode : err ? err.statusCode : 404; | ||
return { code }; | ||
const title = `${code} ${errors[String(code)]}`; | ||
return { title }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters