'use client' import { useRouter } from 'next/navigation' import type { MappedQuote } from '@/lib/stockApi' import { SwipeableRow } from './SwipeableRow' interface StockWatchlistRowProps { stock: MappedQuote & { id: string } onDelete: () => Promise isOpen: boolean onOpenChange: (open: boolean) => void } export function StockWatchlistRow({ stock, onDelete, isOpen, onOpenChange }: StockWatchlistRowProps) { const router = useRouter() const changeColor = stock.priceChange > 0 ? 'text-positive' : stock.priceChange < 0 ? 'text-negative' : 'text-foreground' const changeSign = stock.priceChange > 0 ? '+' : '' return ( router.push(`/symbol-details?symbol=${stock.symbol}`)} isOpen={isOpen} onOpenChange={onOpenChange} >
{/* Header Row */}
{stock.symbol}
${stock.lastPrice.toFixed(2)}
{changeSign}${stock.priceChange.toFixed(2)} ({changeSign}{stock.percentChange.toFixed(2)}%)
{/* Key fields */}
Open {stock.openPrice != null ? `$${stock.openPrice.toFixed(2)}` : '—'}
Prev Close ${stock.previousClose.toFixed(2)}
Volume {stock.volume.toLocaleString()}
) }