Files
1a57cb25a0 Async CSV export (#3330)
* add export for address txs

* transfer all export from page to dialog

* remove old route and components

* improve file name and fix loading state of icon button

* basic implementation

* refetch item status

* status indicator for download items

* changes for multichain

* handle too many requests for downloads error

* update button styles and spacing

* fix tests

* disable async export for multichain

* Fix CSV export cancel flow and stabilize context updates

Applied via @cursor push command

* test and review fixes

* design fixes

* refactor file names

---------

Co-authored-by: Hanzo Dev <[email protected]>
2026-03-02 15:51:50 +02:00

60 lines
2.0 KiB
TypeScript

import { chakra, Flex, Text } from '@chakra-ui/react';
import React from 'react';
import type { CsvExportType } from '../../types/client';
import type { ClusterChainConfig } from 'types/multichain';
import shortenString from 'lib/shortenString';
import ChainIcon from 'ui/shared/externalChains/ChainIcon';
import getPrefixByFilter from '../../utils/get-prefix-by-filter';
interface Props {
type: CsvExportType;
params?: Record<string, string>;
chainInfo?: ClusterChainConfig;
recordsLimit: number;
}
const CsvExportDialogDescription = ({ type, params, chainInfo, recordsLimit }: Props) => {
const chainInfoElement = chainInfo ? (
<Flex display="inline-flex" alignItems="center" whiteSpace="pre">
<span> on </span>
<ChainIcon data={ chainInfo } mr={ 1 }/>
<span>{ chainInfo.app_config.chain.name }</span>
</Flex>
) : null;
const limitText = recordsLimit.toLocaleString(undefined, { maximumFractionDigits: 3, notation: 'compact' });
if (type === 'token_holders') {
return (
<Text>
<span>Export holders for token </span>
{ params?.token_name && <chakra.span fontWeight="700">{ params.token_name }</chakra.span> }
{ chainInfoElement }
<span> to CSV file. </span>
<span>Limited to the top { limitText } holders by amount held.</span>
</Text>
);
}
if (type.startsWith('address_')) {
const entityText = type.replace('address_', '').replace('_', ' ');
const entityPrefix = getPrefixByFilter(params?.filter_type, params?.filter_value);
return (
<Text as="div">
<span>Export { entityPrefix ? `${ entityPrefix } ` : '' }{ entityText } for address </span>
{ params?.hash && <chakra.span fontWeight="700">{ shortenString(params.hash) }</chakra.span> }
{ chainInfoElement }
<span> to CSV file. </span>
<span>Limited to the last { limitText } { entityText }.</span>
</Text>
);
}
return null;
};
export default React.memo(CsvExportDialogDescription);