import { cn } from '@/lib/utils'; import { Plus } from 'lucide-react'; interface StatsBoxProps { stats: { totalShares: number; totalInvestment: number; averageCostPerShare: number; currentPrice?: number; currentValue?: number; profitLoss?: number; profitLossPercentage?: number; }; className?: string; onAddPurchase?: () => void; onAddMilestone?: () => void; } export default function StatsBox({ stats, className, onAddPurchase, onAddMilestone }: StatsBoxProps) { const formatCurrency = (amount: number) => { return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(amount); }; const formatCurrencyDetailed = (amount: number) => { return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', minimumFractionDigits: 4, }).format(amount); }; return (
{/* Current Price */} {stats.currentPrice && (
current price
{formatCurrencyDetailed(stats.currentPrice)}
)} {/* Portfolio Stats Grid */}
{/* Total Investment */}
Total Investment
{formatCurrency(stats.totalInvestment)}
{/* Current Value */} {stats.currentValue && (
Current Value
{formatCurrency(stats.currentValue)}
)} {/* Average Cost */}
Avg Cost/Share
{formatCurrencyDetailed(stats.averageCostPerShare)}
{/* Profit/Loss */} {stats.profitLoss !== undefined && (
P&L
= 0 ? "text-green-400" : "text-red-400" )}> {stats.profitLoss >= 0 ? '+' : ''}{formatCurrency(stats.profitLoss)}
)}
{/* Withdrawal Estimates */} {stats.currentValue && (
Annual Withdrawal (Safe)
3% Rule
{formatCurrency(stats.currentValue * 0.03)}
4% Rule
{formatCurrency(stats.currentValue * 0.04)}
)} {/* Action Buttons */}
{/* Add Purchase Button */} {onAddPurchase && ( )} {/* Add Milestone Button */} {onAddMilestone && ( )}
); }