Commit e79b8d32 authored by tom's avatar tom

refactor using DataListDisplay

parent 389cbeb4
...@@ -23,8 +23,7 @@ type FilterProps = { ...@@ -23,8 +23,7 @@ type FilterProps = {
type Props = { type Props = {
isError: boolean; isError: boolean;
isLoading: boolean; isLoading: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any items?: Array<unknown>;
items?: Array<any>;
emptyText: string; emptyText: string;
actionBar?: React.ReactNode; actionBar?: React.ReactNode;
content: React.ReactNode; content: React.ReactNode;
......
...@@ -3,7 +3,7 @@ import React from 'react'; ...@@ -3,7 +3,7 @@ import React from 'react';
import useApiQuery from 'lib/api/useApiQuery'; import useApiQuery from 'lib/api/useApiQuery';
import { SECOND } from 'lib/consts'; import { SECOND } from 'lib/consts';
import DataFetchAlert from 'ui/shared/DataFetchAlert'; import DataListDisplay from 'ui/shared/DataListDisplay';
import SkeletonList from 'ui/shared/skeletons/SkeletonList'; import SkeletonList from 'ui/shared/skeletons/SkeletonList';
import SkeletonTable from 'ui/shared/skeletons/SkeletonTable'; import SkeletonTable from 'ui/shared/skeletons/SkeletonTable';
import TxStateList from 'ui/tx/state/TxStateList'; import TxStateList from 'ui/tx/state/TxStateList';
...@@ -26,32 +26,27 @@ const TxState = () => { ...@@ -26,32 +26,27 @@ const TxState = () => {
return txInfo.socketStatus ? <TxSocketAlert status={ txInfo.socketStatus }/> : <TxPendingAlert/>; return txInfo.socketStatus ? <TxSocketAlert status={ txInfo.socketStatus }/> : <TxPendingAlert/>;
} }
if (isError || txInfo.isError) { const skeleton = (
return <DataFetchAlert/>; <>
} <Show below="lg" ssr={ false }>
<Skeleton h={ 4 } borderRadius="full" w="100%"/>
if (isLoading || txInfo.isLoading) { <Skeleton h={ 4 } borderRadius="full" w="100%" mt={ 2 }/>
return ( <Skeleton h={ 4 } borderRadius="full" w="100%" mt={ 2 }/>
<> <Skeleton h={ 4 } borderRadius="full" w="50%" mt={ 2 } mb={ 6 }/>
<Show below="lg" ssr={ false }> <SkeletonList/>
<Skeleton h={ 4 } borderRadius="full" w="100%"/> </Show>
<Skeleton h={ 4 } borderRadius="full" w="100%" mt={ 2 }/> <Hide below="lg" ssr={ false }>
<Skeleton h={ 4 } borderRadius="full" w="100%" mt={ 2 }/> <Skeleton h={ 6 } borderRadius="full" w="90%" mb={ 6 }/>
<Skeleton h={ 4 } borderRadius="full" w="50%" mt={ 2 } mb={ 6 }/> <SkeletonTable columns={ [ '140px', '146px', '33%', '33%', '33%', '150px' ] }/>
<SkeletonList/> </Hide>
</Show> </>
<Hide below="lg" ssr={ false }> );
<Skeleton h={ 6 } borderRadius="full" w="90%" mb={ 6 }/>
<SkeletonTable columns={ [ '28%', '20%', '24px', '20%', '16%', '16%' ] }/>
</Hide>
</>
);
}
return ( const content = data ? (
<> <>
<Text> <Text>
A set of information that represents the current state is updated when a transaction takes place on the network. The below is a summary of those changes A set of information that represents the current state is updated when a transaction takes place on the network.
The below is a summary of those changes.
</Text> </Text>
<Accordion allowMultiple defaultIndex={ [] }> <Accordion allowMultiple defaultIndex={ [] }>
<Hide below="lg" ssr={ false }> <Hide below="lg" ssr={ false }>
...@@ -62,6 +57,17 @@ const TxState = () => { ...@@ -62,6 +57,17 @@ const TxState = () => {
</Show> </Show>
</Accordion> </Accordion>
</> </>
) : null;
return (
<DataListDisplay
isError={ isError }
isLoading={ isLoading }
items={ data }
emptyText="There are no state changes for this transaction."
content={ content }
skeletonProps={{ customSkeleton: skeleton }}
/>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment