Files
LingvAI/components/CustomError.tsx

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-03-16 23:58:12 +01:00
import { FC } from "react";
2021-03-18 14:18:29 +01:00
import { Stack, HStack, Heading, Text, Icon, useColorModeValue } from "@chakra-ui/react";
2021-03-16 23:58:12 +01:00
import { FaSadTear } from "react-icons/fa";
2021-03-18 14:18:29 +01:00
import Layout from "./Layout";
2021-03-16 23:58:12 +01:00
const statusTexts: {
[key: string]: string
} = {
400: "Bad Request",
404: "This page could not be found",
405: "Method Not Allowed",
500: "Internal Server Error",
fallback: "An unexpected error has occurred"
};
type Props = {
statusCode: number
};
const CustomError: FC<Props> = ({ statusCode }) => (
2021-03-18 14:18:29 +01:00
<Layout customTitle={`${statusCode} - ${statusTexts?.[statusCode] ?? statusTexts.fallback}`}>
<Stack
color={useColorModeValue("lingva.900", "lingva.100")}
direction={["column", null, "row"]}
justify="center"
align="center"
spacing={4}
w="full"
>
<HStack align="center" spacing={5}>
<Heading as="h1" size="3xl">
{statusCode}
</Heading>
<Icon as={FaSadTear} boxSize={10} />
</HStack>
<Text as="h2" fontSize="xl">
{statusTexts?.[statusCode] ?? statusTexts.fallback}
</Text>
</Stack>
</Layout>
2021-03-16 23:58:12 +01:00
);
export default CustomError;