import React from 'react' import { ZodError, ZodIssue } from 'zod' import { JSONValue } from 'superjson/dist/types' import { JSONPrimitive, ParsedActionReturnData, } from '@interval/sdk/dist/ioSchema' import { TransactionResultStatus } from '@prisma/client' import KeyValueTable from '~/components/KeyValueTable' import RenderValue from '~/components/RenderValue' import { pluralize } from '~/utils/text' import { IORenderInstruction } from '~/components/RenderIOCall' import IconExternalLink from '~/icons/compiled/ExternalLink' import useCopyToClipboard from '~/utils/useCopyToClipboard' import { notify } from '~/components/NotificationCenter' import ObjectViewer from '~/components/ObjectViewer' export default function ResultRenderer({ status, result, shareLink, }: { status: TransactionResultStatus | null result: JSONValue shareLink?: string }) { const { onCopyClick } = useCopyToClipboard() if (result == null) return null return (
An unknown error occurred.
} const { error, message, cause } = errorResult if (error === 'ZodError') { try { const deserialized = JSON.parse(message) if (Array.isArray(deserialized)) { return ({error ?? 'Error'} :{message}
{cause && (Caused by:
{cause}
Please check your host logs for more information.
Label: {component.label ?? No label}
)}This {component ? 'field' : 'action'} contains the following{' '} {pluralize(error.issues.length, 'error')}:
Please correct your action code and try again.