mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import React from 'react';
|
|
|
|
import useApiQuery from 'lib/api/useApiQuery';
|
|
import { layerLabels } from 'lib/rollups/utils';
|
|
import { L2_WITHDRAWAL_ITEM } from 'stubs/L2';
|
|
import { generateListStub } from 'stubs/utils';
|
|
import { Skeleton } from '@luxfi/ui/skeleton';
|
|
import { rightLineArrow, nbsp } from 'toolkit/utils/htmlEntities';
|
|
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 OptimisticL2WithdrawalsListItem from 'ui/withdrawals/optimisticL2/OptimisticL2WithdrawalsListItem';
|
|
import OptimisticL2WithdrawalsTable from 'ui/withdrawals/optimisticL2/OptimisticL2WithdrawalsTable';
|
|
|
|
const OptimisticL2Withdrawals = () => {
|
|
const { data, isError, isPlaceholderData, pagination } = useQueryWithPages({
|
|
resourceName: 'general:optimistic_l2_withdrawals',
|
|
options: {
|
|
placeholderData: generateListStub<'general:optimistic_l2_withdrawals'>(
|
|
L2_WITHDRAWAL_ITEM,
|
|
50,
|
|
{
|
|
next_page_params: {
|
|
items_count: 50,
|
|
nonce: '',
|
|
},
|
|
},
|
|
),
|
|
},
|
|
});
|
|
|
|
const countersQuery = useApiQuery('general:optimistic_l2_withdrawals_count', {
|
|
queryOptions: {
|
|
placeholderData: 23700,
|
|
},
|
|
});
|
|
|
|
const content = data?.items ? (
|
|
<>
|
|
<div className="lg:hidden">
|
|
{ data.items.map(((item, index) => (
|
|
<OptimisticL2WithdrawalsListItem
|
|
key={ String(item.msg_nonce_version) + item.msg_nonce + (isPlaceholderData ? index : '') }
|
|
item={ item }
|
|
isLoading={ isPlaceholderData }
|
|
/>
|
|
))) }
|
|
</div>
|
|
<div className="hidden lg:block">
|
|
<OptimisticL2WithdrawalsTable items={ data.items } top={ pagination.isVisible ? ACTION_BAR_HEIGHT_DESKTOP : 0 } isLoading={ isPlaceholderData }/>
|
|
</div>
|
|
</>
|
|
) : null;
|
|
|
|
const text = (() => {
|
|
if (countersQuery.isError) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Skeleton
|
|
loading={ countersQuery.isPlaceholderData }
|
|
display="inline-block"
|
|
>
|
|
A total of { countersQuery.data?.toLocaleString() } withdrawals found
|
|
</Skeleton>
|
|
);
|
|
})();
|
|
|
|
const actionBar = <StickyPaginationWithText text={ text } pagination={ pagination }/>;
|
|
|
|
return (
|
|
<>
|
|
<PageTitle title={ `Withdrawals (${ layerLabels.current }${ nbsp }${ rightLineArrow }${ nbsp }${ layerLabels.parent })` } withTextAd/>
|
|
<DataListDisplay
|
|
isError={ isError }
|
|
itemsNum={ data?.items?.length }
|
|
emptyText="There are no withdrawals."
|
|
actionBar={ actionBar }
|
|
>
|
|
{ content }
|
|
</DataListDisplay>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default OptimisticL2Withdrawals;
|