Commit 7207fc98 authored by isstuev's avatar isstuev

csv export logs

parent 0c8394f3
......@@ -479,6 +479,9 @@ export const RESOURCES = {
csv_export_token_transfers: {
path: '/token-transfers-csv',
},
csv_export_logs: {
path: '/logs-csv',
},
};
export type ResourceName = keyof typeof RESOURCES;
......
export type CsvExportType = 'transactions' | 'internal-transactions' | 'token-transfers';
export type CsvExportType = 'transactions' | 'internal-transactions' | 'token-transfers' | 'logs';
......@@ -10,11 +10,13 @@ import DataListDisplay from 'ui/shared/DataListDisplay';
import LogItem from 'ui/shared/logs/LogItem';
import Pagination from 'ui/shared/Pagination';
import AddressCsvExportLink from './AddressCsvExportLink';
const AddressLogs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivElement>}) => {
const router = useRouter();
const hash = getQueryParamString(router.query.hash);
const { data, isPlaceholderData, isError, pagination, isPaginationVisible } = useQueryWithPages({
const { data, isPlaceholderData, isError, pagination } = useQueryWithPages({
resourceName: 'address_logs',
pathParams: { hash },
scrollRef,
......@@ -28,11 +30,12 @@ const AddressLogs = ({ scrollRef }: {scrollRef?: React.RefObject<HTMLDivElement>
},
});
const actionBar = isPaginationVisible ? (
<ActionBar mt={ -6 } showShadow>
<Pagination ml="auto" { ...pagination }/>
const actionBar = (
<ActionBar mt={ -6 } showShadow justifyContent={{ base: 'space-between', lg: 'end' }}>
<AddressCsvExportLink address={ hash } isLoading={ pagination.isLoading } type="logs"/>
<Pagination ml={{ base: 0, lg: 8 }} { ...pagination }/>
</ActionBar>
) : null;
);
const content = data?.items ? data.items.map((item, index) => <LogItem key={ index } { ...item } type="address" isLoading={ isPlaceholderData }/>) : null;
......
......@@ -39,6 +39,11 @@ const EXPORT_TYPES: Record<CsvExportType, ExportTypeEntity> = {
resource: 'csv_export_token_transfers',
fileNameTemplate: 'token_transfers',
},
logs: {
text: 'logs',
resource: 'csv_export_logs',
fileNameTemplate: 'logs',
},
};
const isCorrectExportType = (type: string): type is CsvExportType => Object.keys(EXPORT_TYPES).includes(type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment