mirror of
https://github.com/hanzonet/explore.git
synced 2026-10-30 18:16:57 +00:00
* add prefix to API resources * fix pw tests * refactor config * remove unnecessary prefixes in resource names * fixes * update screenshots
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { Box } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
import type { TokensSortingValue } from 'types/api/tokens';
|
|
|
|
import { apos } from 'toolkit/utils/htmlEntities';
|
|
import DataFetchAlert from 'ui/shared/DataFetchAlert';
|
|
import DataListDisplay from 'ui/shared/DataListDisplay';
|
|
import type { QueryWithPagesResult } from 'ui/shared/pagination/useQueryWithPages';
|
|
|
|
import TokensListItem from './TokensListItem';
|
|
import TokensTable from './TokensTable';
|
|
|
|
interface Props {
|
|
query: QueryWithPagesResult<'general:tokens'> | QueryWithPagesResult<'general:tokens_bridged'>;
|
|
onSortChange: (value: TokensSortingValue) => void;
|
|
sort: TokensSortingValue;
|
|
actionBar?: React.ReactNode;
|
|
hasActiveFilters: boolean;
|
|
description?: React.ReactNode;
|
|
tableTop?: number;
|
|
}
|
|
|
|
const Tokens = ({ query, onSortChange, sort, actionBar, description, hasActiveFilters, tableTop }: Props) => {
|
|
|
|
const { isError, isPlaceholderData, data, pagination } = query;
|
|
|
|
if (isError) {
|
|
return <DataFetchAlert/>;
|
|
}
|
|
|
|
const content = data?.items ? (
|
|
<>
|
|
<Box hideFrom="lg">
|
|
{ description }
|
|
{ data.items.map((item, index) => (
|
|
<TokensListItem
|
|
key={ item.address_hash + (isPlaceholderData ? index : '') }
|
|
token={ item }
|
|
index={ index }
|
|
page={ pagination.page }
|
|
isLoading={ isPlaceholderData }
|
|
/>
|
|
)) }
|
|
</Box>
|
|
<Box hideBelow="lg">
|
|
{ description }
|
|
<TokensTable
|
|
items={ data.items }
|
|
page={ pagination.page }
|
|
isLoading={ isPlaceholderData }
|
|
setSorting={ onSortChange }
|
|
sorting={ sort }
|
|
top={ tableTop }
|
|
/>
|
|
</Box>
|
|
</>
|
|
) : null;
|
|
|
|
return (
|
|
<DataListDisplay
|
|
isError={ isError }
|
|
itemsNum={ data?.items.length }
|
|
emptyText="There are no tokens."
|
|
filterProps={{
|
|
emptyFilteredText: `Couldn${ apos }t find token that matches your filter query.`,
|
|
hasActiveFilters,
|
|
}}
|
|
actionBar={ query.pagination.isVisible || hasActiveFilters ? actionBar : null }
|
|
>
|
|
{ content }
|
|
</DataListDisplay>
|
|
);
|
|
};
|
|
|
|
export default Tokens;
|