import { useParams, Link } from 'react-router-dom';
import { ArrowLeft, Building2, TrendingUp, TrendingDown, Minus, AlertTriangle, Info, Calendar, Activity } from 'lucide-react';
import { NIFTY_50_STOCKS } from '../types';
import { sampleRecommendations, getStockHistory } from '../data/recommendations';
import { DecisionBadge, ConfidenceBadge, RiskBadge } from '../components/StockCard';
export default function StockDetail() {
const { symbol } = useParams<{ symbol: string }>();
const stock = NIFTY_50_STOCKS.find(s => s.symbol === symbol);
const latestRecommendation = sampleRecommendations[0];
const analysis = latestRecommendation?.analysis[symbol || ''];
const history = symbol ? getStockHistory(symbol) : [];
if (!stock) {
return (
Stock Not Found
The stock "{symbol}" was not found in Nifty 50.
View All Stocks
);
}
const decisionIcon = {
BUY: TrendingUp,
SELL: TrendingDown,
HOLD: Minus,
};
const decisionColor = {
BUY: 'from-green-500 to-green-600',
SELL: 'from-red-500 to-red-600',
HOLD: 'from-amber-500 to-amber-600',
};
const DecisionIcon = analysis?.decision ? decisionIcon[analysis.decision] : Activity;
const bgGradient = analysis?.decision ? decisionColor[analysis.decision] : 'from-gray-500 to-gray-600';
return (
{/* Back Button */}
{/* Stock Header */}
{stock.symbol}
{analysis?.decision && (
{analysis.decision}
)}
{stock.company_name}
{stock.sector || 'N/A'}
Latest Analysis
{latestRecommendation?.date ? new Date(latestRecommendation.date).toLocaleDateString('en-IN', {
month: 'short',
day: 'numeric',
year: 'numeric',
}) : 'N/A'}
{/* Analysis Details */}
{analysis ? (
Decision
Confidence
Risk Level
) : (
No analysis available for this stock yet.
)}
{/* Quick Stats Grid */}
{history.length}
Total Analyses
{history.filter(h => h.decision === 'BUY').length}
Buy Signals
{history.filter(h => h.decision === 'HOLD').length}
Hold Signals
{history.filter(h => h.decision === 'SELL').length}
Sell Signals
{/* Analysis History */}
Recommendation History
{history.length > 0 ? (
{history.map((entry, idx) => (
{new Date(entry.date).toLocaleDateString('en-IN', {
weekday: 'short',
month: 'short',
day: 'numeric',
year: 'numeric',
})}
))}
) : (
No History Yet
Recommendation history will appear here as we analyze this stock daily.
)}
{/* Top Pick / Avoid Status */}
{latestRecommendation && (
<>
{latestRecommendation.top_picks.some(p => p.symbol === symbol) && (
Top Pick
{latestRecommendation.top_picks.find(p => p.symbol === symbol)?.reason}
)}
{latestRecommendation.stocks_to_avoid.some(s => s.symbol === symbol) && (
Stock to Avoid
{latestRecommendation.stocks_to_avoid.find(s => s.symbol === symbol)?.reason}
)}
>
)}
{/* Disclaimer */}
Disclaimer: This AI-generated recommendation is for educational purposes only.
It should not be considered as financial advice. Always do your own research and consult with
a qualified financial advisor before making investment decisions.
);
}