Commit 23362254 authored by isstuev's avatar isstuev

better types

parent c5d5c4d0
...@@ -109,8 +109,7 @@ const AddressBlocksValidated = ({ scrollRef }: Props) => { ...@@ -109,8 +109,7 @@ const AddressBlocksValidated = ({ scrollRef }: Props) => {
isError={ query.isError } isError={ query.isError }
isLoading={ query.isLoading } isLoading={ query.isLoading }
items={ query.data?.items } items={ query.data?.items }
isLongSkeleton skeletonProps={{ isLongSkeleton: true, skeletonDesktopColumns: [ '17%', '17%', '16%', '25%', '25%' ] }}
skeletonDesktopColumns={ [ '17%', '17%', '16%', '25%', '25%' ] }
emptyText="There are no validated blocks for this address." emptyText="There are no validated blocks for this address."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -68,11 +68,9 @@ const AddressInternalTxs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivE ...@@ -68,11 +68,9 @@ const AddressInternalTxs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivE
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
isLongSkeleton skeletonProps={{ isLongSkeleton: true, skeletonDesktopColumns: [ '15%', '15%', '10%', '20%', '20%', '20%' ] }}
skeletonDesktopColumns={ [ '15%', '15%', '10%', '20%', '20%', '20%' ] } filterProps={{ emptyFilteredText: `Couldn${ apos }t find any transaction that matches your query.`, hasActiveFilters: Boolean(filterValue) }}
emptyText="There are no internal transactions for this address." emptyText="There are no internal transactions for this address."
emptyFilteredText={ `Couldn${ apos }t find any transaction that matches your query.` }
hasActiveFilters={ Boolean(filterValue) }
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -37,7 +37,7 @@ const AddressLogs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivElement> ...@@ -37,7 +37,7 @@ const AddressLogs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivElement>
emptyText="There are no logs for this address." emptyText="There are no logs for this address."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
customSkeleton={ skeleton } skeletonProps={{ customSkeleton: skeleton }}
/> />
); );
}; };
......
...@@ -247,11 +247,15 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD ...@@ -247,11 +247,15 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
isLongSkeleton skeletonProps={{
skeletonDesktopColumns={ [ '44px', '185px', '160px', '25%', '25%', '25%', '25%' ] } isLongSkeleton: true,
skeletonDesktopColumns: [ '44px', '185px', '160px', '25%', '25%', '25%', '25%' ],
}}
emptyText="There are no token transfers." emptyText="There are no token transfers."
emptyFilteredText={ `Couldn${ apos }t find any token transfer that matches your query.` } filterProps={{
hasActiveFilters={ Boolean(numActiveFilters) } emptyFilteredText: `Couldn${ apos }t find any token transfer that matches your query.`,
hasActiveFilters: Boolean(numActiveFilters),
}}
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -63,7 +63,7 @@ const AddressCoinBalanceHistory = ({ query }: Props) => { ...@@ -63,7 +63,7 @@ const AddressCoinBalanceHistory = ({ query }: Props) => {
isError={ query.isError } isError={ query.isError }
isLoading={ query.isLoading } isLoading={ query.isLoading }
items={ query.data?.items } items={ query.data?.items }
skeletonDesktopColumns={ [ '25%', '25%', '25%', '25%', '120px' ] } skeletonProps={{ skeletonDesktopColumns: [ '25%', '25%', '25%', '25%', '120px' ] }}
emptyText="There is no coin balance history for this address." emptyText="There is no coin balance history for this address."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -64,7 +64,7 @@ const TokensWithIds = ({ tokensQuery }: Props) => { ...@@ -64,7 +64,7 @@ const TokensWithIds = ({ tokensQuery }: Props) => {
emptyText="There are no tokens of selected type." emptyText="There are no tokens of selected type."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
customSkeleton={ skeleton } skeletonProps={{ customSkeleton: skeleton }}
/> />
); );
}; };
......
...@@ -42,8 +42,10 @@ const TokensWithoutIds = ({ tokensQuery }: Props) => { ...@@ -42,8 +42,10 @@ const TokensWithoutIds = ({ tokensQuery }: Props) => {
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
isLongSkeleton skeletonProps={{
skeletonDesktopColumns={ [ '30%', '30%', '10%', '20%', '10%' ] } isLongSkeleton: true,
skeletonDesktopColumns: [ '30%', '30%', '10%', '20%', '10%' ],
}}
emptyText="There are no tokens of selected type." emptyText="There are no tokens of selected type."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -97,7 +97,7 @@ const BlocksContent = ({ type, query }: Props) => { ...@@ -97,7 +97,7 @@ const BlocksContent = ({ type, query }: Props) => {
isError={ query.isError } isError={ query.isError }
isLoading={ query.isLoading } isLoading={ query.isLoading }
items={ query.data?.items } items={ query.data?.items }
skeletonDesktopColumns={ [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] } skeletonProps={{ skeletonDesktopColumns: [ '125px', '120px', '21%', '64px', '35%', '22%', '22%' ] }}
emptyText="There are no blocks." emptyText="There are no blocks."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -56,7 +56,7 @@ const Accounts = () => { ...@@ -56,7 +56,7 @@ const Accounts = () => {
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
skeletonDesktopColumns={ [ '64px', '30%', '20%', '20%', '15%', '15%' ] } skeletonProps={{ skeletonDesktopColumns: [ '64px', '30%', '20%', '20%', '15%', '15%' ] }}
emptyText="There are no accounts." emptyText="There are no accounts."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -120,10 +120,12 @@ const VerifiedContracts = () => { ...@@ -120,10 +120,12 @@ const VerifiedContracts = () => {
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
skeletonDesktopColumns={ [ '50%', '130px', '130px', '50%', '80px', '110px' ] } skeletonProps={{ skeletonDesktopColumns: [ '50%', '130px', '130px', '50%', '80px', '110px' ] }}
emptyText="There are no verified contracts." emptyText="There are no verified contracts."
emptyFilteredText={ `Couldn${ apos }t find any contract that matches your query.` } filterProps={{
hasActiveFilters={ Boolean(searchTerm || type) } emptyFilteredText: `Couldn${ apos }t find any contract that matches your query.`,
hasActiveFilters: Boolean(searchTerm || type),
}}
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -7,20 +7,29 @@ import DataFetchAlert from './DataFetchAlert'; ...@@ -7,20 +7,29 @@ import DataFetchAlert from './DataFetchAlert';
import SkeletonList from './skeletons/SkeletonList'; import SkeletonList from './skeletons/SkeletonList';
import SkeletonTable from './skeletons/SkeletonTable'; import SkeletonTable from './skeletons/SkeletonTable';
type SkeletonProps =
{ customSkeleton: React.ReactNode } |
{
skeletonDesktopColumns: Array<string>;
isLongSkeleton?: boolean;
}
type FilterProps = {
hasActiveFilters: boolean;
emptyFilteredText: string;
};
type Props = { type Props = {
isError: boolean; isError: boolean;
isLoading: boolean; isLoading: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
items?: Array<any>; items?: Array<any>;
emptyText: string; emptyText: string;
skeletonDesktopColumns?: Array<string>;
isLongSkeleton?: boolean;
actionBar?: React.ReactNode; actionBar?: React.ReactNode;
content: React.ReactNode; content: React.ReactNode;
customSkeleton?: React.ReactNode;
className?: string; className?: string;
hasActiveFilters?: boolean; skeletonProps: SkeletonProps;
emptyFilteredText?: string; filterProps?: FilterProps;
} }
const DataListDisplay = (props: Props) => { const DataListDisplay = (props: Props) => {
...@@ -33,13 +42,14 @@ const DataListDisplay = (props: Props) => { ...@@ -33,13 +42,14 @@ const DataListDisplay = (props: Props) => {
return ( return (
<> <>
{ props.actionBar } { props.actionBar }
{ props.customSkeleton || ( { 'customSkeleton' in props.skeletonProps && props.skeletonProps.customSkeleton }
{ 'skeletonDesktopColumns' in props.skeletonProps && (
<> <>
<SkeletonList display={{ base: 'block', lg: 'none' }}/> <SkeletonList display={{ base: 'block', lg: 'none' }}/>
<SkeletonTable <SkeletonTable
display={{ base: 'none', lg: 'block' }} display={{ base: 'none', lg: 'block' }}
columns={ props.skeletonDesktopColumns || [] } columns={ props.skeletonProps.skeletonDesktopColumns || [] }
isLong={ props.isLongSkeleton } isLong={ props.skeletonProps.isLongSkeleton }
/> />
</> </>
) } ) }
...@@ -47,11 +57,11 @@ const DataListDisplay = (props: Props) => { ...@@ -47,11 +57,11 @@ const DataListDisplay = (props: Props) => {
); );
} }
if (props.hasActiveFilters && !props.items?.length) { if (props.filterProps?.hasActiveFilters && !props.items?.length) {
return ( return (
<> <>
{ props.actionBar } { props.actionBar }
<EmptySearchResult text={ props.emptyFilteredText }/> <EmptySearchResult text={ props.filterProps.emptyFilteredText }/>
</> </>
); );
} }
......
...@@ -48,7 +48,7 @@ const TokenHoldersContent = ({ holdersQuery, tokenQuery }: Props) => { ...@@ -48,7 +48,7 @@ const TokenHoldersContent = ({ holdersQuery, tokenQuery }: Props) => {
isError={ holdersQuery.isError || tokenQuery.isError } isError={ holdersQuery.isError || tokenQuery.isError }
isLoading={ holdersQuery.isLoading || tokenQuery.isLoading } isLoading={ holdersQuery.isLoading || tokenQuery.isLoading }
items={ holdersQuery.data?.items } items={ holdersQuery.data?.items }
skeletonDesktopColumns={ [ '100%', '300px', '175px' ] } skeletonProps={{ skeletonDesktopColumns: [ '100%', '300px', '175px' ] }}
emptyText="There are no holders for this token." emptyText="There are no holders for this token."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -64,7 +64,7 @@ const TokenInventory = ({ inventoryQuery }: Props) => { ...@@ -64,7 +64,7 @@ const TokenInventory = ({ inventoryQuery }: Props) => {
emptyText="There are no tokens." emptyText="There are no tokens."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
customSkeleton={ skeleton } skeletonProps={{ customSkeleton: skeleton }}
/> />
); );
}; };
......
...@@ -100,8 +100,10 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => { ...@@ -100,8 +100,10 @@ const TokenTransfer = ({ transfersQuery, tokenId }: Props) => {
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
isLongSkeleton skeletonProps={{
skeletonDesktopColumns={ [ '45%', '15%', '36px', '15%', '25%' ] } isLongSkeleton: true,
skeletonDesktopColumns: [ '45%', '15%', '36px', '15%', '25%' ],
}}
emptyText="There are no token transfers." emptyText="There are no token transfers."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
...@@ -94,10 +94,12 @@ const Tokens = () => { ...@@ -94,10 +94,12 @@ const Tokens = () => {
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
skeletonDesktopColumns={ [ '25px', '33%', '33%', '33%', '110px' ] } skeletonProps={{ skeletonDesktopColumns: [ '25px', '33%', '33%', '33%', '110px' ] }}
emptyText="There are no tokens." emptyText="There are no tokens."
emptyFilteredText={ `Couldn${ apos }t find token that matches your filter query.` } filterProps={{
hasActiveFilters={ Boolean(debouncedFilter || type) } emptyFilteredText: `Couldn${ apos }t find token that matches your filter query.`,
hasActiveFilters: Boolean(debouncedFilter || type),
}}
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -120,10 +120,12 @@ const TxInternals = () => { ...@@ -120,10 +120,12 @@ const TxInternals = () => {
isError={ isError || txInfo.isError } isError={ isError || txInfo.isError }
isLoading={ isLoading || txInfo.isLoading } isLoading={ isLoading || txInfo.isLoading }
items={ data?.items } items={ data?.items }
skeletonDesktopColumns={ [ '28%', '20%', '24px', '20%', '16%', '16%' ] } skeletonProps={{ skeletonDesktopColumns: [ '28%', '20%', '24px', '20%', '16%', '16%' ] }}
emptyText="There are no internal transactions for this transaction." emptyText="There are no internal transactions for this transaction."
// emptyFilteredText={ `Couldn${ apos }t find any transaction that matches your query.` } // filterProps={{
// hasActiveFilters={ Boolean(filters.length || searchTerm) } // emptyFilteredText: `Couldn${ apos }t find any transaction that matches your query.`.
// hasActiveFilters: Boolean(filters.length || searchTerm),
// }}
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -84,11 +84,15 @@ const TxTokenTransfer = () => { ...@@ -84,11 +84,15 @@ const TxTokenTransfer = () => {
isError={ txsInfo.isError || tokenTransferQuery.isError } isError={ txsInfo.isError || tokenTransferQuery.isError }
isLoading={ txsInfo.isLoading || tokenTransferQuery.isLoading } isLoading={ txsInfo.isLoading || tokenTransferQuery.isLoading }
items={ tokenTransferQuery.data?.items } items={ tokenTransferQuery.data?.items }
isLongSkeleton skeletonProps={{
skeletonDesktopColumns={ [ '185px', '25%', '25%', '25%', '25%' ] } isLongSkeleton: true,
skeletonDesktopColumns: [ '185px', '25%', '25%', '25%', '25%' ],
}}
emptyText="There are no token transfers." emptyText="There are no token transfers."
emptyFilteredText={ `Couldn${ apos }t find any token transfer that matches your query.` } filterProps={{
hasActiveFilters={ Boolean(numActiveFilters) } emptyFilteredText: `Couldn${ apos }t find any token transfer that matches your query.`,
hasActiveFilters: Boolean(numActiveFilters),
}}
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
/> />
......
...@@ -107,11 +107,12 @@ const TxsContent = ({ ...@@ -107,11 +107,12 @@ const TxsContent = ({
isError={ isError } isError={ isError }
isLoading={ isLoading } isLoading={ isLoading }
items={ data?.items } items={ data?.items }
isLongSkeleton={ hasLongSkeleton } skeletonProps={{
skeletonDesktopColumns={ showBlockInfo ? isLongSkeleton: hasLongSkeleton,
[ '32px', '22%', '160px', '20%', '18%', '292px', '20%', '20%' ] : skeletonDesktopColumns: showBlockInfo ?
[ '32px', '22%', '160px', '20%', '292px', '20%', '20%' ] [ '32px', '22%', '160px', '20%', '18%', '292px', '20%', '20%' ] :
} [ '32px', '22%', '160px', '20%', '292px', '20%', '20%' ],
}}
emptyText="There are no transactions." emptyText="There are no transactions."
content={ content } content={ content }
actionBar={ actionBar } actionBar={ actionBar }
......
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