Loading and error states for blocks home route
This commit is contained in:
parent
47e078a502
commit
061388938c
12
apps/explorer/src/app/components/status-message/index.tsx
Normal file
12
apps/explorer/src/app/components/status-message/index.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import classnames from 'classnames';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface StatusMessageProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatusMessage = ({ children, className }: StatusMessageProps) => {
|
||||||
|
const classes = classnames('font-alpha', 'text-h4', 'mb-28', className);
|
||||||
|
return <h3 className={classes}>{children}</h3>;
|
||||||
|
};
|
@ -2,12 +2,13 @@ import { DATA_SOURCES } from '../../../config';
|
|||||||
import useFetch from '../../../hooks/use-fetch';
|
import useFetch from '../../../hooks/use-fetch';
|
||||||
import { TendermintBlockchainResponse } from '../tendermint-blockchain-response';
|
import { TendermintBlockchainResponse } from '../tendermint-blockchain-response';
|
||||||
import { RouteTitle } from '../../../components/route-title';
|
import { RouteTitle } from '../../../components/route-title';
|
||||||
|
import { StatusMessage } from '../../../components/status-message';
|
||||||
import { BlocksData, BlocksRefetch } from '../../../components/blocks';
|
import { BlocksData, BlocksRefetch } from '../../../components/blocks';
|
||||||
import { JumpToBlock } from '../../../components/jump-to-block';
|
import { JumpToBlock } from '../../../components/jump-to-block';
|
||||||
|
|
||||||
const Blocks = () => {
|
const Blocks = () => {
|
||||||
const {
|
const {
|
||||||
state: { data },
|
state: { data, error, loading },
|
||||||
refetch,
|
refetch,
|
||||||
} = useFetch<TendermintBlockchainResponse>(
|
} = useFetch<TendermintBlockchainResponse>(
|
||||||
`${DATA_SOURCES.tendermintUrl}/blockchain`
|
`${DATA_SOURCES.tendermintUrl}/blockchain`
|
||||||
@ -16,8 +17,14 @@ const Blocks = () => {
|
|||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<RouteTitle>Blocks</RouteTitle>
|
<RouteTitle>Blocks</RouteTitle>
|
||||||
|
{loading && <StatusMessage>Loading...</StatusMessage>}
|
||||||
|
{error && <StatusMessage>Error: {error}</StatusMessage>}
|
||||||
|
{data && (
|
||||||
|
<>
|
||||||
<BlocksRefetch refetch={refetch} />
|
<BlocksRefetch refetch={refetch} />
|
||||||
<BlocksData data={data} className="mb-28" />
|
<BlocksData data={data} className="mb-28" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<JumpToBlock />
|
<JumpToBlock />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user