Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/components/NftCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
MoreVertical,
RefreshCcw,
SendIcon,
Tag,
UserRoundPlus,
} from 'lucide-react';
import { useEffect, useState } from 'react';
Expand Down Expand Up @@ -100,6 +101,7 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
const { addError } = useErrors();

const [thumbnail, setThumbnail] = useState<string | null>(null);
const [activeOfferCount, setActiveOfferCount] = useState<number | null>(null);
const [transferOpen, setTransferOpen] = useState(false);
const [assignOpen, setAssignOpen] = useState(false);
const [addUrlOpen, setAddUrlOpen] = useState(false);
Expand Down Expand Up @@ -169,6 +171,26 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
};
}, [nft.launcher_id]);

useEffect(() => {
let cancelled = false;
commands
.getOffersForAsset({ asset_id: nft.launcher_id })
.then((response) => {
if (!cancelled) {
const count = response.offers.filter(
(o) => o.status === 'active' || o.status === 'pending',
).length;
setActiveOfferCount(count);
}
})
.catch(() => {
// non-blocking — silently ignore errors
});
return () => {
cancelled = true;
};
}, [nft.launcher_id]);

const toggleVisibility = () => {
commands
.updateNft({ nft_id: nft.launcher_id, visible: !nft.visible })
Expand Down Expand Up @@ -343,6 +365,26 @@ export function NftCard({ nft, updateNfts, selectionState }: NftCardProps) {
/>
)}

{activeOfferCount !== null && activeOfferCount > 0 && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<div className='absolute top-2 left-2 flex items-center gap-1 rounded-full bg-amber-500/90 px-1.5 py-0.5 text-xs font-medium text-white shadow-sm'>
<Tag className='h-3 w-3' aria-hidden='true' />
{activeOfferCount > 1 && <span>{activeOfferCount}</span>}
</div>
</TooltipTrigger>
<TooltipContent side='bottom'>
<p>
{activeOfferCount === 1
? t`1 active offer`
: t`${activeOfferCount} active offers`}
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
)}

{nft.special_use_type === 'theme' && (
<div className='absolute bottom-0 left-0 right-0 bg-primary/70 text-primary-foreground text-xs font-medium py-1 px-2 text-center border-t border-border'>
<Trans>Theme</Trans>
Expand Down
Loading