import { useState } from 'react'; import { Link } from 'react-router-dom'; import { Package, Plus, ExternalLink } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { MarkSoldDialog } from '@/components/MarkSoldDialog'; import { useMarketplaceItems } from '@/hooks/useMarketplace'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import type { MarketplaceItem } from '@/lib/types'; function MyListingRow({ item }: { item: MarketplaceItem }) { const [openSold, setOpenSold] = useState(false); const listing = { pubkey: item.pubkey, identifier: item.identifier }; const soldOut = item.status === 'sold'; const price = item.price ? `${Number(item.price.amount).toLocaleString()} ${item.price.currency}` : item.priceType === 'trade' ? 'Trade' : 'Free'; return ( <> {item.images[0] ? ( ) : (
)}

{item.title}

{price} {item.location ? ` · ${item.location}` : ''}

{soldOut ? 'Sold' : 'Active'} {!soldOut && ( )}
); } /** * Marketplace → Selling tab: the seller's own listings, with a one-tap * "mark sold" (which also records the trade for reputation). */ export function SellerDashboard() { const { user } = useCurrentUser(); const { data: items, isLoading } = useMarketplaceItems(200); const mine = (items ?? []).filter((i) => i.pubkey === user?.pubkey); const active = mine.filter((i) => i.status !== 'sold'); const sold = mine.filter((i) => i.status === 'sold'); return (

Your listings {mine.length > 0 && ( {active.length} active )}

{isLoading ? (

Loading your listings…

) : mine.length === 0 ? (

You have no listings yet.

) : (
{active.map((item) => ( ))} {sold.length > 0 && ( <>

Sold

{sold.map((item) => ( ))} )}
)}
); }