import React, { useState, useMemo } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { ChevronDown, ChevronUp, Plus, Search, TrendingUp, TrendingDown, Trash2, PieChart as PieIcon, BarChart3, Info } from 'lucide-react'; import { AreaChart, Area, XAxis, YAxis, Tooltip, ResponsiveContainer, ReferenceLine } from 'recharts'; import InvestmentCommittee from './InvestmentCommittee'; export default function HoldingsList({ allocation, prices, onAddClick, onAssetClick, onRemoveAsset }) { const [expandedId, setExpandedId] = useState(null); const [searchTerm, setSearchTerm] = useState(''); const filteredAllocation = useMemo(() => { return allocation.filter(asset => asset.ticker.toLowerCase().includes(searchTerm.toLowerCase()) || asset.name.toLowerCase().includes(searchTerm.toLowerCase()) ); }, [allocation, searchTerm]); const toggleExpand = (ticker) => { setExpandedId(expandedId === ticker ? null : ticker); }; return (
| Asset | Price | Shares | Value | Avg Cost | Gain/Loss | Return | Alloc | |
|---|---|---|---|---|---|---|---|---|
|
No holdings found matching your search. |
||||||||
{asset.name}
{priceData?.percent !== undefined && !isNaN(priceData.percent) && (${currentPrice.toFixed(2)}
{asset.shares}
${marketValue.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
${(asset.avgCost || 0).toFixed(2)}
{isPositive ? '+' : ''}${Math.abs(gainLoss).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
Real-time market tracking for {asset.ticker}
Volatility
Moderate
Buy Price
${(asset.avgCost || 0).toFixed(2)}
Hold Since
{new Date(asset.dateBought).toLocaleDateString()}