From dc55b36f5a14dc50fc80859b3a7e859861004c84 Mon Sep 17 00:00:00 2001 From: artemkolodko Date: Tue, 25 Oct 2022 08:16:00 +0100 Subject: [PATCH] Improve export txs filter --- src/pages/ExportData/index.tsx | 59 +++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/pages/ExportData/index.tsx b/src/pages/ExportData/index.tsx index df2dada..c42cf57 100644 --- a/src/pages/ExportData/index.tsx +++ b/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,27 +207,29 @@ export const ExportData = () => { Export the last {DefaultLimit} {getTxTextType(type)} for
{type === 'transaction' && 'starting from'} - - - }> - onChangeDateFrom(value)} - /> - - -
to
- - }> - onChangeDateTo(value)} - /> - - -
+ {!['erc20', 'internal_transaction'].includes(type) && + + + }> + onChangeDateFrom(value)} + /> + + +
to
+ + }> + onChangeDateTo(value)} + /> + + +
+ }