mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
import React from 'react';
|
|
|
|
import type { AddressMetadataTagFormatted } from 'types/client/addressMetadata';
|
|
|
|
import config from 'configs/app';
|
|
import { Image } from '@luxfi/ui/image';
|
|
import { Link } from 'toolkit/next/link';
|
|
import { Skeleton } from '@luxfi/ui/skeleton';
|
|
import { Tooltip } from '@luxfi/ui/tooltip';
|
|
import AppActionButton from 'ui/shared/AppActionButton/AppActionButton';
|
|
import * as DetailedInfo from 'ui/shared/DetailedInfo/DetailedInfo';
|
|
import TextSeparator from 'ui/shared/TextSeparator';
|
|
|
|
interface Props {
|
|
hash: string | undefined;
|
|
id?: string;
|
|
isLoading?: boolean;
|
|
appActionData?: AddressMetadataTagFormatted['meta'];
|
|
source: 'NFT collection' | 'NFT item';
|
|
}
|
|
|
|
const TokenNftMarketplaces = ({ hash, id, isLoading, appActionData, source }: Props) => {
|
|
if (!hash || config.UI.views.nft.marketplaces.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
const items = config.UI.views.nft.marketplaces
|
|
.map((item) => {
|
|
const hrefTemplate = id ? item.instance_url : item.collection_url;
|
|
if (!hrefTemplate) {
|
|
return null;
|
|
}
|
|
const href = hrefTemplate
|
|
.replace('{id}', id || '')
|
|
.replace('{id_lowercase}', id?.toLowerCase() || '')
|
|
.replace('{hash}', hash || '')
|
|
.replace('{hash_lowercase}', hash?.toLowerCase() || '');
|
|
|
|
return {
|
|
href,
|
|
logo_url: item.logo_url,
|
|
name: item.name,
|
|
};
|
|
})
|
|
.filter(Boolean);
|
|
|
|
if (items.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<DetailedInfo.ItemLabel
|
|
hint="Marketplaces trading this NFT"
|
|
isLoading={ isLoading }
|
|
>
|
|
Marketplaces
|
|
</DetailedInfo.ItemLabel>
|
|
<DetailedInfo.ItemValue
|
|
>
|
|
<Skeleton loading={ isLoading } className="flex flex-wrap items-center">
|
|
<div>
|
|
{ items.map((item) => {
|
|
return (
|
|
<Tooltip content={ `View on ${ item.name }` } key={ item.name }>
|
|
<Link href={ item.href } external noIcon>
|
|
<Image
|
|
src={ item.logo_url }
|
|
alt={ `${ item.name } marketplace logo` }
|
|
/>
|
|
</Link>
|
|
</Tooltip>
|
|
);
|
|
}) }
|
|
</div>
|
|
{ appActionData && (
|
|
<>
|
|
<TextSeparator/>
|
|
<AppActionButton data={ appActionData } className="h-[30px]" source={ source }/>
|
|
</>
|
|
) }
|
|
</Skeleton>
|
|
</DetailedInfo.ItemValue>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default React.memo(TokenNftMarketplaces);
|