import React, { useState } from 'react'; interface WatchListProps { watchlist: string[]; currentSymbol: string; onSelect: (symbol: string) => void; onAdd: (symbol: string) => void; onRemove: (symbol: string) => void; onClose: () => void; priceMap: Record; } const WatchList: React.FC = ({ watchlist, currentSymbol, onSelect, onAdd, onRemove, onClose, priceMap, }) => { const [input, setInput] = useState(''); const handleAdd = () => { const sym = input.trim().toUpperCase(); if (sym && !watchlist.includes(sym)) { onAdd(sym); setInput(''); } }; return (
⭐ 관심 종목
setInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && handleAdd()} placeholder="심볼 추가..." />
{watchlist.map(sym => { const info = priceMap[sym]; const pct = info?.changePct ?? 0; const isActive = sym === currentSymbol; return (
onSelect(sym)} > {sym}
{info && ( <> {info.price.toFixed(2)} = 0 ? 'up' : 'down'}`}> {pct >= 0 ? '+' : ''}{pct.toFixed(2)}% )}
); })}
); }; export default WatchList;