mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import React from 'react';
|
|
|
|
import type { NFTTokenType } from 'types/api/token';
|
|
|
|
import { useMultichainContext } from 'lib/contexts/multichain';
|
|
import useIsMobile from 'lib/hooks/useIsMobile';
|
|
import ActionBar from 'ui/shared/ActionBar';
|
|
import DataListDisplay from 'ui/shared/DataListDisplay';
|
|
import Pagination from 'ui/shared/pagination/Pagination';
|
|
import type { QueryWithPagesResult } from 'ui/shared/pagination/useQueryWithPages';
|
|
|
|
import AddressNftTypeFilter from './AddressNftTypeFilter';
|
|
import NFTItem from './NFTItem';
|
|
|
|
type Props = {
|
|
tokensQuery: QueryWithPagesResult<'general:address_nfts'>;
|
|
tokenTypes: Array<NFTTokenType> | undefined;
|
|
onTokenTypesChange: (value: Array<NFTTokenType>) => void;
|
|
};
|
|
|
|
const AddressNFTs = ({ tokensQuery, tokenTypes, onTokenTypesChange }: Props) => {
|
|
const isMobile = useIsMobile();
|
|
const multichainContext = useMultichainContext();
|
|
|
|
const { isError, isPlaceholderData, data, pagination } = tokensQuery;
|
|
|
|
const hasActiveFilters = Boolean(tokenTypes?.length);
|
|
|
|
const actionBar = isMobile && pagination.isVisible && (
|
|
<ActionBar className="-mt-6">
|
|
<AddressNftTypeFilter value={ tokenTypes } onChange={ onTokenTypesChange }/>
|
|
<Pagination className="ml-auto" { ...pagination }/>
|
|
</ActionBar>
|
|
);
|
|
|
|
const content = data?.items ? (
|
|
<div className="grid w-full gap-x-3 lg:gap-x-6 gap-y-3 lg:gap-y-6"
|
|
|
|
>
|
|
{ data.items.map((item, index) => {
|
|
const key = item.token.address_hash + '_' + (item.id && !isPlaceholderData ? `id_${ item.id }` : `index_${ index }`);
|
|
|
|
return (
|
|
<NFTItem
|
|
key={ key }
|
|
{ ...item }
|
|
isLoading={ isPlaceholderData }
|
|
withTokenLink
|
|
chain={ multichainContext?.chain }
|
|
/>
|
|
);
|
|
}) }
|
|
</div>
|
|
) : null;
|
|
|
|
return (
|
|
<DataListDisplay
|
|
isError={ isError }
|
|
itemsNum={ data?.items?.length }
|
|
emptyText="There are no tokens of selected type."
|
|
actionBar={ actionBar }
|
|
hasActiveFilters={ hasActiveFilters }
|
|
emptyStateProps={{
|
|
term: 'token',
|
|
}}
|
|
>
|
|
{ content }
|
|
</DataListDisplay>
|
|
);
|
|
};
|
|
|
|
export default AddressNFTs;
|