'use client' import Link from 'next/link' import { useSearchParams } from 'next/navigation' import { ArrowLeft, ChevronDown, RefreshCw, BellPlus } from 'lucide-react' import { Suspense, useState, useEffect } from 'react' import { SentimentalityBar } from '@/components/widgets/SentimentalityBar' import { getLiveQuote, formatMarketValue, type MappedQuote } from '@/lib/stockApi' import { StockChart } from '@/components/stock-chart/stock-chart' import { NewsHeadlines } from '@/components/widgets/NewsHeadlines' import { AlertsModal } from '@/components/widgets/AlertsModal' import type { TimeRange } from '@/components/stock-chart/types' function SymbolDetailsContent() { const searchParams = useSearchParams() const symbol = (searchParams.get('symbol') || 'AAPL').toUpperCase() const [chartExpanded, setChartExpanded] = useState(true) const [headlinesExpanded, setHeadlinesExpanded] = useState(true) const [selectedRange, setSelectedRange] = useState('1D') const [quote, setQuote] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [refreshTick, setRefreshTick] = useState(0) const [avgSentiment, setAvgSentiment] = useState(null) const [alertsModalOpen, setAlertsModalOpen] = useState(false) useEffect(() => { setLoading(true) setError(null) getLiveQuote(symbol) .then(setQuote) .catch((err) => setError(err.message)) .finally(() => setLoading(false)) }, [symbol, refreshTick]) return (
{/* Header */}

{symbol}

{/* Loading / Error states */} {loading && (
Loading {symbol}...
)} {!loading && error && (
{error}
)} {!loading && !error && quote && (
{/* Stock Summary Card */}
{/* Card header row with refresh button */}
{quote.symbol}
${quote.lastPrice.toFixed(2)}
0 ? 'text-positive' : quote.priceChange < 0 ? 'text-negative' : 'text-foreground' }>
{quote.priceChange > 0 ? '+' : ''}${quote.priceChange.toFixed(2)}
({quote.priceChange > 0 ? '+' : ''}{quote.percentChange.toFixed(2)}%)
{/* Key Metrics */}
Open
{formatMarketValue(quote.openPrice, quote.marketOpen, (v) => `$${v.toFixed(2)}`)}
Prev Close
${quote.previousClose.toFixed(2)}
Volume
{formatMarketValue(quote.volume, quote.marketOpen, (v) => v.toLocaleString())}
{/* Sentimentality Bar - average of headline sentiments */}
{/* Chart Section - Collapsible */}
{chartExpanded && (
{/* Range selector */}
{(['1D', '5D', '1M', '3M', '6M', 'YTD', '1Y', '3Y'] as TimeRange[]).map((r) => ( ))}
{/* Chart */}
Show more
)}
{/* Headlines Section - Collapsible */}
{headlinesExpanded && (
)}
)}
) } export default function SymbolDetails() { return (
Loading...
}>
) }