mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import React from 'react';
|
|
|
|
import useApiQuery from 'lib/api/useApiQuery';
|
|
import { generateListStub } from 'stubs/utils';
|
|
import { ZKSYNC_L2_TXN_BATCHES_ITEM } from 'stubs/zkSyncL2';
|
|
import { Skeleton } from '@luxfi/ui/skeleton';
|
|
import { ACTION_BAR_HEIGHT_DESKTOP } from 'ui/shared/ActionBar';
|
|
import DataListDisplay from 'ui/shared/DataListDisplay';
|
|
import PageTitle from 'ui/shared/Page/PageTitle';
|
|
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
|
|
import StickyPaginationWithText from 'ui/shared/StickyPaginationWithText';
|
|
import ZkSyncTxnBatchesListItem from 'ui/txnBatches/zkSyncL2/ZkSyncTxnBatchesListItem';
|
|
import ZkSyncTxnBatchesTable from 'ui/txnBatches/zkSyncL2/ZkSyncTxnBatchesTable';
|
|
|
|
const ZkSyncL2TxnBatches = () => {
|
|
const { data, isError, isPlaceholderData, pagination } = useQueryWithPages({
|
|
resourceName: 'general:zksync_l2_txn_batches',
|
|
options: {
|
|
placeholderData: generateListStub<'general:zksync_l2_txn_batches'>(
|
|
ZKSYNC_L2_TXN_BATCHES_ITEM,
|
|
50,
|
|
{
|
|
next_page_params: {
|
|
items_count: 50,
|
|
number: 9045200,
|
|
},
|
|
},
|
|
),
|
|
},
|
|
});
|
|
|
|
const countersQuery = useApiQuery('general:zksync_l2_txn_batches_count', {
|
|
queryOptions: {
|
|
placeholderData: 5231746,
|
|
},
|
|
});
|
|
|
|
const content = data?.items ? (
|
|
<>
|
|
<div className="lg:hidden">
|
|
{ data.items.map(((item, index) => (
|
|
<ZkSyncTxnBatchesListItem
|
|
key={ item.number + (isPlaceholderData ? String(index) : '') }
|
|
item={ item }
|
|
isLoading={ isPlaceholderData }
|
|
/>
|
|
))) }
|
|
</div>
|
|
<div className="hidden lg:block">
|
|
<ZkSyncTxnBatchesTable items={ data.items } top={ pagination.isVisible ? ACTION_BAR_HEIGHT_DESKTOP : 0 } isLoading={ isPlaceholderData }/>
|
|
</div>
|
|
</>
|
|
) : null;
|
|
|
|
const text = (() => {
|
|
if (countersQuery.isError || isError || !data?.items.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Skeleton loading={ countersQuery.isPlaceholderData || isPlaceholderData } display="flex" className="flex-wrap">
|
|
Txn batch
|
|
<span className="whitespace-pre font-semibold"> #{ data.items[0].number } </span>to
|
|
<span className="whitespace-pre font-semibold"> #{ data.items[data.items.length - 1].number } </span>
|
|
(total of { countersQuery.data?.toLocaleString() } batches)
|
|
</Skeleton>
|
|
);
|
|
})();
|
|
|
|
const actionBar = <StickyPaginationWithText text={ text } pagination={ pagination }/>;
|
|
|
|
return (
|
|
<>
|
|
<PageTitle title="Txn batches" withTextAd/>
|
|
<DataListDisplay
|
|
isError={ isError }
|
|
itemsNum={ data?.items.length }
|
|
emptyText="There are no txn batches."
|
|
actionBar={ actionBar }
|
|
>
|
|
{ content }
|
|
</DataListDisplay>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ZkSyncL2TxnBatches;
|