import type { MessageDescriptor } from '@lingui/core'; import { Trans, msg } from '@lingui/macro'; import { useLingui } from '@lingui/react'; import { motion } from 'framer-motion'; import { ChevronLeft } from 'lucide-react'; import { Link, useNavigate } from 'react-router'; import backgroundPattern from '@documenso/assets/images/background-pattern.png'; import { formatDocumentsPath } from '@documenso/lib/utils/teams'; import { cn } from '@documenso/ui/lib/utils'; import { Button } from '@documenso/ui/primitives/button'; import { useOptionalCurrentTeam } from '~/providers/team'; export type GenericErrorLayoutProps = { children?: React.ReactNode; errorCode?: number; }; export const ErrorLayoutCodes: Record< number, { subHeading: MessageDescriptor; heading: MessageDescriptor; message: MessageDescriptor } > = { 404: { subHeading: msg`404 Page not found`, heading: msg`Oops! Something went wrong.`, message: msg`The page you are looking for was moved, removed, renamed or might never have existed.`, }, 500: { subHeading: msg`500 Internal Server Error`, heading: msg`Oops! Something went wrong.`, message: msg`An unexpected error occurred.`, }, }; export const GenericErrorLayout = ({ children, errorCode }: GenericErrorLayoutProps) => { const navigate = useNavigate(); const { _ } = useLingui(); const team = useOptionalCurrentTeam(); const { subHeading, heading, message } = ErrorLayoutCodes[errorCode || 404] ?? ErrorLayoutCodes[404]; return (
{_(subHeading)}
{_(message)}