From 08b2760721b79c48302a9134bf60e3b5b99c465b Mon Sep 17 00:00:00 2001 From: checktheroads Date: Mon, 25 Jan 2021 22:47:13 -0700 Subject: [PATCH] remove custom error page, closes #109 --- hyperglass/ui/pages/_error.tsx | 89 ---------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 hyperglass/ui/pages/_error.tsx diff --git a/hyperglass/ui/pages/_error.tsx b/hyperglass/ui/pages/_error.tsx deleted file mode 100644 index b48035d7..00000000 --- a/hyperglass/ui/pages/_error.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { useMemo } from 'react'; -import { useRouter } from 'next/router'; -import { - Flex, - Text, - theme, - Button, - Heading, - ThemeProvider, - ChakraProvider, - useColorModeValue, -} from '@chakra-ui/react'; -import { inRange } from 'lodash'; - -import type { NextPage, NextPageContext } from 'next'; - -interface TError { - status: string; - code: number; -} - -const ErrorContent: React.FC = (props: TError) => { - const { status, code } = props; - const router = useRouter(); - - const bg = useColorModeValue('white', 'black'); - const color = useColorModeValue('black', 'white'); - const error400 = useColorModeValue('error.500', 'error.300'); - const error500 = useColorModeValue('danger.500', 'danger.300'); - const errorColor = { 400: error400, 500: error500 }; - const colorScheme = { 400: 'error', 500: 'danger' }; - - const baseCode = useMemo(() => { - return inRange(code, 400, 500) ? 400 : inRange(code, 500, 600) ? 500 : 400; - }, [code]); - - function handleClick(): void { - router.push('/'); - } - - return ( - - - - - {status} - - {code === 404 && {` isn't a thing...`}} - - - - - ); -}; - -const ErrorPage: NextPage = (props: TError) => { - const { status, code } = props; - return ( - - - - - - ); -}; - -ErrorPage.getInitialProps = (ctx: NextPageContext): TError => { - const { res, err } = ctx; - const code = res ? res.statusCode : err ? err.statusCode ?? 500 : 404; - const status = err ? err.message : 'Error'; - return { status, code }; -}; - -export default ErrorPage;