import { useState } from 'react'; import { Link } from 'react-router-dom'; import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { MapPin, Store, Bookmark, MoreVertical, Flag } from 'lucide-react'; import { useAuthor } from '@/hooks/useAuthor'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { genUserName } from '@/lib/genUserName'; import { ZapButton } from '@/components/ZapButton'; import { TrustBadge } from '@/components/TrustBadge'; import { AddToCollectionDialog } from '@/components/AddToCollectionDialog'; import { ReportDialog } from '@/components/ReportDialog'; import type { SkateSpot } from '@/lib/types'; import { SPOT_TYPE_LABELS, ACCESS_TYPE_INFO } from '@/lib/types'; import { cn } from '@/lib/utils'; interface SpotCardProps { spot: SkateSpot; } export function SpotCard({ spot }: SpotCardProps) { const author = useAuthor(spot.pubkey); const { user } = useCurrentUser(); const metadata = author.data?.metadata; const displayName = metadata?.name ?? genUserName(spot.pubkey); const [showCollectionDialog, setShowCollectionDialog] = useState(false); const [showReportDialog, setShowReportDialog] = useState(false); // Determine if this is a shop or a spot const isShop = spot.types.includes('shop'); const isOwner = user?.pubkey === spot.pubkey; const route = isShop ? `/shop/${spot.pubkey}/${spot.identifier}` : `/spot/${spot.pubkey}/${spot.identifier}`; return ( {/* Image */} {spot.images[0] ? ( ) : ( {isShop ? ( ) : ( )} )} {/* Shop badge or Type badges overlay */} {isShop ? ( 🏪 SKATE SHOP ) : ( <> {spot.accessType && ( {ACCESS_TYPE_INFO[spot.accessType].emoji} {ACCESS_TYPE_INFO[spot.accessType].label.split(' - ')[0]} )} {spot.types.length > 0 && ( {spot.types.slice(0, 2).map((type) => ( {SPOT_TYPE_LABELS[type] || type} ))} )} > )} {spot.title} {spot.location && ( {isShop ? ( ) : ( )} {spot.location} )} {spot.description && ( {spot.description} )} {displayName.slice(0, 2).toUpperCase()} {displayName} {/* Trust Badge */} e.preventDefault()}> {user && !isShop && ( { e.preventDefault(); e.stopPropagation(); setShowCollectionDialog(true); }} > )} {/* More options menu */} e.stopPropagation()} > {!isOwner && ( { e.preventDefault(); e.stopPropagation(); setShowReportDialog(true); }} className="text-red-500 focus:text-red-500" > Report )} {/* Collection Dialog */} {!isShop && ( )} {/* Report Dialog */} ); } export function SpotCardSkeleton() { return ( ); }
{isShop ? ( ) : ( )} {spot.location}
{spot.description}