Commit d7075bc8 authored by isstuev's avatar isstuev

token transfer notice

parent 17e3dce6
...@@ -22,11 +22,11 @@ import DataFetchAlert from 'ui/shared/DataFetchAlert'; ...@@ -22,11 +22,11 @@ import DataFetchAlert from 'ui/shared/DataFetchAlert';
import Pagination from 'ui/shared/Pagination'; import Pagination from 'ui/shared/Pagination';
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 SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import { TOKEN_TYPE, flattenTotal } from 'ui/shared/TokenTransfer/helpers'; import { TOKEN_TYPE, flattenTotal } from 'ui/shared/TokenTransfer/helpers';
import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter'; import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter';
import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList'; import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList';
import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable'; import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable';
import TxsNewItemNotice from 'ui/txs/TxsNewItemNotice';
type Filters = { type Filters = {
type: Array<TokenType>; type: Array<TokenType>;
...@@ -185,7 +185,12 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD ...@@ -185,7 +185,12 @@ const AddressTokenTransfers = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLD
/> />
</Hide> </Hide>
<Show below="lg"> <Show below="lg">
<TxsNewItemNotice url={ window.location.href } num={ newItemsCount } alert={ socketAlert }/> <SocketNewItemsNotice
url={ window.location.href }
num={ newItemsCount }
alert={ socketAlert }
type="token_transfer"
/>
<TokenTransferList <TokenTransferList
data={ items } data={ items }
baseAddress={ currentAddress } baseAddress={ currentAddress }
......
...@@ -5,7 +5,7 @@ import useApiQuery from 'lib/api/useApiQuery'; ...@@ -5,7 +5,7 @@ import useApiQuery from 'lib/api/useApiQuery';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import useNewTxsSocket from 'lib/hooks/useNewTxsSocket'; import useNewTxsSocket from 'lib/hooks/useNewTxsSocket';
import link from 'lib/link/link'; import link from 'lib/link/link';
import TxsNewItemNotice from 'ui/txs/TxsNewItemNotice'; import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import LatestTxsItem from './LatestTxsItem'; import LatestTxsItem from './LatestTxsItem';
import LatestTxsItemSkeleton from './LatestTxsItemSkeleton'; import LatestTxsItemSkeleton from './LatestTxsItemSkeleton';
...@@ -36,7 +36,7 @@ const LatestTransactions = () => { ...@@ -36,7 +36,7 @@ const LatestTransactions = () => {
const txsUrl = link('txs'); const txsUrl = link('txs');
content = ( content = (
<> <>
<TxsNewItemNotice borderBottomRadius={ 0 } url={ link('txs') } num={ num } alert={ socketAlert }/> <SocketNewItemsNotice borderBottomRadius={ 0 } url={ link('txs') } num={ num } alert={ socketAlert }/>
<Box mb={{ base: 3, lg: 4 }}> <Box mb={{ base: 3, lg: 4 }}>
{ data.slice(0, txsCount).map((tx => <LatestTxsItem key={ tx.hash } tx={ tx }/>)) } { data.slice(0, txsCount).map((tx => <LatestTxsItem key={ tx.hash } tx={ tx }/>)) }
</Box> </Box>
......
...@@ -4,7 +4,7 @@ import React from 'react'; ...@@ -4,7 +4,7 @@ import React from 'react';
import { ROUTES } from 'lib/link/routes'; import { ROUTES } from 'lib/link/routes';
import TestApp from 'playwright/TestApp'; import TestApp from 'playwright/TestApp';
import TxsNewItemNotice from './TxsNewItemNotice'; import SocketNewItemsNotice from './SocketNewItemsNotice';
const hooksConfig = { const hooksConfig = {
router: { router: {
...@@ -16,7 +16,7 @@ const hooksConfig = { ...@@ -16,7 +16,7 @@ const hooksConfig = {
test('2 new items in validated txs list +@dark-mode', async({ mount }) => { test('2 new items in validated txs list +@dark-mode', async({ mount }) => {
const component = await mount( const component = await mount(
<TestApp> <TestApp>
<TxsNewItemNotice url="/" num={ 2 }/> <SocketNewItemsNotice url="/" num={ 2 }/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
); );
...@@ -27,7 +27,7 @@ test('2 new items in validated txs list +@dark-mode', async({ mount }) => { ...@@ -27,7 +27,7 @@ test('2 new items in validated txs list +@dark-mode', async({ mount }) => {
test('connection loss', async({ mount }) => { test('connection loss', async({ mount }) => {
const component = await mount( const component = await mount(
<TestApp> <TestApp>
<TxsNewItemNotice url="/" alert="Connection is lost. Please reload the page."/> <SocketNewItemsNotice url="/" alert="Connection is lost. Please reload the page."/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
); );
...@@ -38,7 +38,7 @@ test('connection loss', async({ mount }) => { ...@@ -38,7 +38,7 @@ test('connection loss', async({ mount }) => {
test('fetching', async({ mount }) => { test('fetching', async({ mount }) => {
const component = await mount( const component = await mount(
<TestApp> <TestApp>
<TxsNewItemNotice url="/"/> <SocketNewItemsNotice url="/"/>
</TestApp>, </TestApp>,
{ hooksConfig }, { hooksConfig },
); );
......
...@@ -7,6 +7,7 @@ interface InjectedProps { ...@@ -7,6 +7,7 @@ interface InjectedProps {
} }
interface Props { interface Props {
type?: 'transaction' | 'token_transfer';
children?: (props: InjectedProps) => JSX.Element; children?: (props: InjectedProps) => JSX.Element;
className?: string; className?: string;
url: string; url: string;
...@@ -14,7 +15,7 @@ interface Props { ...@@ -14,7 +15,7 @@ interface Props {
num?: number; num?: number;
} }
const TxsNewItemNotice = ({ children, className, url, num, alert }: Props) => { const SocketNewItemsNotice = ({ children, className, url, num, alert, type = 'transaction' }: Props) => {
const theme = useTheme(); const theme = useTheme();
const alertContent = (() => { const alertContent = (() => {
...@@ -22,13 +23,15 @@ const TxsNewItemNotice = ({ children, className, url, num, alert }: Props) => { ...@@ -22,13 +23,15 @@ const TxsNewItemNotice = ({ children, className, url, num, alert }: Props) => {
return alert; return alert;
} }
const name = type === 'token_transfer' ? 'token transfer' : 'transaction';
if (!num) { if (!num) {
return 'scanning new transactions...'; return `scanning new ${ name }s...`;
} }
return ( return (
<> <>
<Link href={ url }>{ num } more transaction{ num > 1 ? 's' : '' }</Link> <Link href={ url }>{ num } more { name }{ num > 1 ? 's' : '' }</Link>
<Text whiteSpace="pre"> ha{ num > 1 ? 've' : 's' } come in</Text> <Text whiteSpace="pre"> ha{ num > 1 ? 've' : 's' } come in</Text>
</> </>
); );
...@@ -52,4 +55,4 @@ const TxsNewItemNotice = ({ children, className, url, num, alert }: Props) => { ...@@ -52,4 +55,4 @@ const TxsNewItemNotice = ({ children, className, url, num, alert }: Props) => {
return children ? children({ content }) : content; return children ? children({ content }) : content;
}; };
export default chakra(TxsNewItemNotice); export default chakra(SocketNewItemsNotice);
...@@ -3,9 +3,9 @@ import React from 'react'; ...@@ -3,9 +3,9 @@ import React from 'react';
import type { TokenTransfer } from 'types/api/tokenTransfer'; import type { TokenTransfer } from 'types/api/tokenTransfer';
import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import { default as Thead } from 'ui/shared/TheadSticky'; import { default as Thead } from 'ui/shared/TheadSticky';
import TokenTransferTableItem from 'ui/shared/TokenTransfer/TokenTransferTableItem'; import TokenTransferTableItem from 'ui/shared/TokenTransfer/TokenTransferTableItem';
import TxsNewItemNotice from 'ui/txs/TxsNewItemNotice';
interface Props { interface Props {
data: Array<TokenTransfer>; data: Array<TokenTransfer>;
...@@ -47,7 +47,14 @@ const TokenTransferTable = ({ ...@@ -47,7 +47,14 @@ const TokenTransferTable = ({
{ showSocketInfo && ( { showSocketInfo && (
<Tr> <Tr>
<Td colSpan={ 10 } p={ 0 }> <Td colSpan={ 10 } p={ 0 }>
<TxsNewItemNotice borderRadius={ 0 } pl="10px" url={ window.location.href } alert={ socketInfoAlert } num={ socketInfoNum }/> <SocketNewItemsNotice
borderRadius={ 0 }
pl="10px"
url={ window.location.href }
alert={ socketInfoAlert }
num={ socketInfoNum }
type="token_transfer"
/>
</Td> </Td>
</Tr> </Tr>
) } ) }
......
...@@ -9,10 +9,10 @@ import DataFetchAlert from 'ui/shared/DataFetchAlert'; ...@@ -9,10 +9,10 @@ import DataFetchAlert from 'ui/shared/DataFetchAlert';
import type { Props as PaginationProps } from 'ui/shared/Pagination'; import type { Props as PaginationProps } from 'ui/shared/Pagination';
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 SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import TxsHeaderMobile from './TxsHeaderMobile'; import TxsHeaderMobile from './TxsHeaderMobile';
import TxsListItem from './TxsListItem'; import TxsListItem from './TxsListItem';
import TxsNewItemNotice from './TxsNewItemNotice';
import TxsTable from './TxsTable'; import TxsTable from './TxsTable';
import useTxsSort from './useTxsSort'; import useTxsSort from './useTxsSort';
...@@ -75,9 +75,9 @@ const TxsContent = ({ ...@@ -75,9 +75,9 @@ const TxsContent = ({
<Show below="lg" ssr={ false }> <Show below="lg" ssr={ false }>
<Box> <Box>
{ showSocketInfo && ( { showSocketInfo && (
<TxsNewItemNotice url={ window.location.href } num={ socketInfoNum } alert={ socketInfoAlert }> <SocketNewItemsNotice url={ window.location.href } num={ socketInfoNum } alert={ socketInfoAlert }>
{ ({ content }) => <Box>{ content }</Box> } { ({ content }) => <Box>{ content }</Box> }
</TxsNewItemNotice> </SocketNewItemsNotice>
) } ) }
{ txs.map(tx => ( { txs.map(tx => (
<TxsListItem <TxsListItem
......
...@@ -7,9 +7,9 @@ import type { Sort } from 'types/client/txs-sort'; ...@@ -7,9 +7,9 @@ import type { Sort } from 'types/client/txs-sort';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import rightArrowIcon from 'icons/arrows/east.svg'; import rightArrowIcon from 'icons/arrows/east.svg';
import SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import TheadSticky from 'ui/shared/TheadSticky'; import TheadSticky from 'ui/shared/TheadSticky';
import TxsNewItemNotice from './TxsNewItemNotice';
import TxsTableItem from './TxsTableItem'; import TxsTableItem from './TxsTableItem';
type Props = { type Props = {
...@@ -67,9 +67,9 @@ const TxsTable = ({ ...@@ -67,9 +67,9 @@ const TxsTable = ({
</TheadSticky> </TheadSticky>
<Tbody> <Tbody>
{ showSocketInfo && ( { showSocketInfo && (
<TxsNewItemNotice borderRadius={ 0 } url={ window.location.href } alert={ socketInfoAlert } num={ socketInfoNum }> <SocketNewItemsNotice borderRadius={ 0 } url={ window.location.href } alert={ socketInfoAlert } num={ socketInfoNum }>
{ ({ content }) => <Tr><Td colSpan={ 10 } p={ 0 }>{ content }</Td></Tr> } { ({ content }) => <Tr><Td colSpan={ 10 } p={ 0 }>{ content }</Td></Tr> }
</TxsNewItemNotice> </SocketNewItemsNotice>
) } ) }
<AnimatePresence initial={ false }> <AnimatePresence initial={ false }>
{ txs.map((item) => ( { txs.map((item) => (
......
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