import { ExclamationTriangleIcon } from '@heroicons/react/24/outline' import { isRouteErrorResponse, useRouteError } from '@remix-run/react' import { useState } from 'react' import { cn } from '~/utils/cn' import Code from './Code' import Dialog from './Dialog' type Properties = { readonly type?: 'full' | 'embedded'; } export function ErrorPopup({ type = 'full' }: Properties) { // eslint-disable-next-line react/hook-use-state const open = useState(true) const error = useRouteError() const routing = isRouteErrorResponse(error) const message = (error instanceof Error ? error.message : 'An unexpected error occurred') return ( {() => ( <>
{routing ? error.status : 'Error'}
{routing ? ( error.statusText ) : ( {message} )} )}
) }