Commit c69977d8 authored by tom's avatar tom

change tx text

parent b26c8962
import { Hide, Show, Text } from '@chakra-ui/react'; import { Hide, Show, Text, Flex, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { TokenTransferResponse } from 'types/api/tokenTransfer'; import type { TokenTransferResponse } from 'types/api/tokenTransfer';
...@@ -7,6 +7,7 @@ import type { QueryKeys } from 'types/client/queries'; ...@@ -7,6 +7,7 @@ import type { QueryKeys } from 'types/client/queries';
import useQueryWithPages from 'lib/hooks/useQueryWithPages'; import useQueryWithPages from 'lib/hooks/useQueryWithPages';
import ActionBar from 'ui/shared/ActionBar'; import ActionBar from 'ui/shared/ActionBar';
import DataFetchAlert from 'ui/shared/DataFetchAlert'; import DataFetchAlert from 'ui/shared/DataFetchAlert';
import HashStringShorten from 'ui/shared/HashStringShorten';
import Pagination from 'ui/shared/Pagination'; import Pagination from 'ui/shared/Pagination';
import SkeletonTable from 'ui/shared/SkeletonTable'; import SkeletonTable from 'ui/shared/SkeletonTable';
import { flattenTotal } from 'ui/shared/TokenTransfer/helpers'; import { flattenTotal } from 'ui/shared/TokenTransfer/helpers';
...@@ -22,9 +23,10 @@ interface Props { ...@@ -22,9 +23,10 @@ interface Props {
queryIds?: Array<string>; queryIds?: Array<string>;
baseAddress?: string; baseAddress?: string;
showTxInfo?: boolean; showTxInfo?: boolean;
txHash?: string;
} }
const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryIds, path, baseAddress, showTxInfo = true }: Props) => { const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryIds, path, baseAddress, showTxInfo = true, txHash }: Props) => {
const { isError, isLoading, data, pagination } = useQueryWithPages<TokenTransferResponse>({ const { isError, isLoading, data, pagination } = useQueryWithPages<TokenTransferResponse>({
apiPath: path, apiPath: path,
queryName, queryName,
...@@ -37,13 +39,14 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI ...@@ -37,13 +39,14 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI
return ( return (
<> <>
<Hide below="lg"> <Hide below="lg">
{ txHash !== undefined && <Skeleton mb={ 6 } h={ 6 } w="340px"/> }
<SkeletonTable columns={ showTxInfo ? <SkeletonTable columns={ showTxInfo ?
[ '44px', '185px', '160px', '25%', '25%', '25%', '25%' ] : [ '44px', '185px', '160px', '25%', '25%', '25%', '25%' ] :
[ '185px', '25%', '25%', '25%', '25%' ] } [ '185px', '25%', '25%', '25%', '25%' ] }
/> />
</Hide> </Hide>
<Show below="lg"> <Show below="lg">
<TokenTransferSkeletonMobile showTxInfo={ showTxInfo }/> <TokenTransferSkeletonMobile showTxInfo={ showTxInfo } txHash={ txHash }/>
</Show> </Show>
</> </>
); );
...@@ -70,9 +73,17 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI ...@@ -70,9 +73,17 @@ const TokenTransfer = ({ isLoading: isLoadingProp, isDisabled, queryName, queryI
); );
})(); })();
const isPaginatorHidden = pagination.page === 1 && !pagination.hasNextPage;
return ( return (
<> <>
{ pagination.page === 1 && !pagination.hasNextPage ? null : ( { txHash && (data?.items.length || 0 > 0) && (
<Flex mb={ isPaginatorHidden ? 6 : 0 } w="100%">
<Text as="span" fontWeight={ 600 } whiteSpace="pre">Token transfers for by txn hash: </Text>
<HashStringShorten hash={ txHash }/>
</Flex>
) }
{ isPaginatorHidden ? null : (
<ActionBar> <ActionBar>
<Pagination ml="auto" { ...pagination }/> <Pagination ml="auto" { ...pagination }/>
</ActionBar> </ActionBar>
......
import { Skeleton, SkeletonCircle, Flex, Box, useColorModeValue } from '@chakra-ui/react'; import { Skeleton, SkeletonCircle, Flex, Box, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
const TokenTransferSkeletonMobile = ({ showTxInfo }: { showTxInfo?: boolean }) => { const TokenTransferSkeletonMobile = ({ showTxInfo, txHash }: { showTxInfo?: boolean; txHash?: string }) => {
const borderColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200'); const borderColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200');
return ( return (
<Box> <>
{ Array.from(Array(2)).map((item, index) => ( { txHash !== undefined && <Skeleton mb={ 6 } h={ 6 } w="100%"/> }
<Flex <Box>
key={ index } { Array.from(Array(2)).map((item, index) => (
rowGap={ 3 } <Flex
flexDirection="column" key={ index }
paddingY={ 6 } rowGap={ 3 }
borderTopWidth="1px" flexDirection="column"
borderColor={ borderColor } paddingY={ 6 }
_last={{ borderTopWidth="1px"
borderBottomWidth: '1px', borderColor={ borderColor }
}} _last={{
> borderBottomWidth: '1px',
<Flex h={ 6 }> }}
<SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/> >
<Skeleton w="100px" mr={ 2 }/> <Flex h={ 6 }>
<Skeleton w="50px"/> <SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/>
{ showTxInfo && <Skeleton w="24px" ml="auto"/> } <Skeleton w="100px" mr={ 2 }/>
</Flex> <Skeleton w="50px"/>
<Flex h={ 6 } columnGap={ 2 }> { showTxInfo && <Skeleton w="24px" ml="auto"/> }
<Skeleton w="70px"/> </Flex>
<Skeleton w="24px"/>
<Skeleton w="90px"/>
</Flex>
{ showTxInfo && (
<Flex h={ 6 } columnGap={ 2 }> <Flex h={ 6 } columnGap={ 2 }>
<Skeleton w="70px" flexShrink={ 0 }/> <Skeleton w="70px"/>
<Skeleton w="100%"/> <Skeleton w="24px"/>
<Skeleton w="90px"/>
</Flex>
{ showTxInfo && (
<Flex h={ 6 } columnGap={ 2 }>
<Skeleton w="70px" flexShrink={ 0 }/>
<Skeleton w="100%"/>
</Flex>
) }
<Flex h={ 6 }>
<SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/>
<Skeleton flexGrow={ 1 } mr={ 3 }/>
<Skeleton w="50px" mr={ 3 }/>
<SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/>
<Skeleton flexGrow={ 1 } mr={ 3 }/>
</Flex>
<Flex h={ 6 } columnGap={ 2 }>
<Skeleton w="45px"/>
<Skeleton w="90px"/>
</Flex> </Flex>
) }
<Flex h={ 6 }>
<SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/>
<Skeleton flexGrow={ 1 } mr={ 3 }/>
<Skeleton w="50px" mr={ 3 }/>
<SkeletonCircle size="6" mr={ 2 } flexShrink={ 0 }/>
<Skeleton flexGrow={ 1 } mr={ 3 }/>
</Flex>
<Flex h={ 6 } columnGap={ 2 }>
<Skeleton w="45px"/>
<Skeleton w="90px"/>
</Flex> </Flex>
</Flex> )) }
)) } </Box>
</Box> </>
); );
}; };
......
import { Text } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { QueryKeys } from 'types/client/queries'; import { QueryKeys } from 'types/client/queries';
...@@ -24,17 +23,15 @@ const TxTokenTransfer = () => { ...@@ -24,17 +23,15 @@ const TxTokenTransfer = () => {
const path = `/node-api/transactions/${ data?.hash }/token-transfers`; const path = `/node-api/transactions/${ data?.hash }/token-transfers`;
return ( return (
<> <TokenTransfer
<Text mb={ 6 }>Token transfers for transaction { data?.hash }</Text> isLoading={ isLoading }
<TokenTransfer isDisabled={ !data?.status || !data?.hash }
isLoading={ isLoading } path={ path }
isDisabled={ !data?.status || !data?.hash } queryName={ QueryKeys.txTokenTransfers }
path={ path } queryIds={ data?.hash ? [ data.hash ] : undefined }
queryName={ QueryKeys.txTokenTransfers } showTxInfo={ false }
queryIds={ data?.hash ? [ data.hash ] : undefined } txHash={ data?.hash || '' }
showTxInfo={ false } />
/>
</>
); );
}; };
......
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