feat(explorer): try again for tx details (#3195)

This commit is contained in:
Art 2023-03-15 09:24:42 +01:00 committed by GitHub
parent f407110e95
commit 67e602ebb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { Button } from '@vegaprotocol/ui-toolkit';
import { StatusMessage } from '../status-message'; import { StatusMessage } from '../status-message';
interface RenderFetchedProps { interface RenderFetchedProps {
@ -7,6 +8,7 @@ interface RenderFetchedProps {
loading: boolean | undefined; loading: boolean | undefined;
className?: string; className?: string;
errorMessage?: string; errorMessage?: string;
refetch?: () => void;
} }
export const RenderFetched = ({ export const RenderFetched = ({
@ -15,6 +17,7 @@ export const RenderFetched = ({
children, children,
className, className,
errorMessage = t('Error retrieving data'), errorMessage = t('Error retrieving data'),
refetch,
}: RenderFetchedProps) => { }: RenderFetchedProps) => {
if (loading) { if (loading) {
return ( return (
@ -23,7 +26,20 @@ export const RenderFetched = ({
} }
if (error) { if (error) {
return <StatusMessage className={className}>{errorMessage}</StatusMessage>; return (
<>
<StatusMessage className={className}>{errorMessage}</StatusMessage>
{refetch && (
<Button
onClick={() => {
refetch();
}}
>
{t('Try again')}
</Button>
)}
</>
);
} }
return children; return children;

View File

@ -22,6 +22,7 @@ const Tx = () => {
const { const {
state: { data, loading, error }, state: { data, loading, error },
refetch,
} = useFetch<BlockExplorerTransaction>( } = useFetch<BlockExplorerTransaction>(
`${DATA_SOURCES.blockExplorerUrl}/transactions/${toNonHex(hash)}` `${DATA_SOURCES.blockExplorerUrl}/transactions/${toNonHex(hash)}`
); );
@ -56,6 +57,7 @@ const Tx = () => {
error={error} error={error}
loading={loading} loading={loading}
errorMessage={errorMessage} errorMessage={errorMessage}
refetch={refetch}
> >
<TxDetails <TxDetails
className="mb-28" className="mb-28"