Improve export txs filter

pull/234/head
artemkolodko 2 years ago
parent a700739987
commit dc55b36f5a
  1. 17
      src/pages/ExportData/index.tsx

@ -111,9 +111,9 @@ export const ExportData = () => {
offset: 0,
limit: 1,
orderBy: 'number',
orderDirection: 'asc',
orderDirection: 'desc',
filters: [{
type: 'gte',
type: 'lte',
property: 'timestamp',
value: `'${dateFrom}'`
}]
@ -128,16 +128,21 @@ export const ExportData = () => {
}
}
if (dateTo) {
const diff = dayjs().diff(dayjs(dateTo), 'days')
const isCurrentDateOrNext = diff <= 0
const blockToFilter = {
offset: 0,
limit: 1,
orderBy: 'number',
orderDirection: 'desc',
filters: [{
type: 'lt',
filters: [] as any
}
if(!isCurrentDateOrNext) {
blockToFilter.filters.push({
type: 'lte',
property: 'timestamp',
value: `'${dayjs(dateTo).add(1, 'day').format(dateFormat)}'`
}]
})
}
const [blockTo] = await getBlocks([0, blockToFilter]);
if(blockTo) {
@ -202,6 +207,7 @@ export const ExportData = () => {
Export the last {DefaultLimit} {getTxTextType(type)} for <Address address={address} />
{type === 'transaction' && 'starting from'}
</Box>
{!['erc20', 'internal_transaction'].includes(type) &&
<FlexWrapper>
<InputContainer>
<Tip dropProps={{ align: { bottom: "top" }}} content={<TipContent showArrow={true} message={'Select start date'} />}>
@ -223,6 +229,7 @@ export const ExportData = () => {
</Tip>
</InputContainer>
</FlexWrapper>
}
<Box style={{ justifyContent: 'center', alignItems: 'center' }} pad={{ top: 'large', bottom: 'medium' }}>
<Box width={'small'}>
<DownloadButton

Loading…
Cancel
Save