import { useGameStore } from '@/store'; import { formatMoney, formatNumber, formatPercent } from '@ai-tycoon/shared'; import { DollarSign, Server, Brain, Users, TrendingUp, TrendingDown, Minus, Cpu, Zap, Shield, } from 'lucide-react'; import { XAxis, YAxis, Tooltip, ResponsiveContainer, Area, AreaChart } from 'recharts'; import { TutorialHint } from '@/components/game/TutorialHint'; export function DashboardPage() { const money = useGameStore((s) => s.economy.money); const revenuePerTick = useGameStore((s) => s.economy.revenuePerTick); const expensesPerTick = useGameStore((s) => s.economy.expensesPerTick); const totalFlops = useGameStore((s) => s.infrastructure.totalFlops); const dataCenters = useGameStore((s) => s.infrastructure.dataCenters); const trainedModels = useGameStore((s) => s.models.trainedModels); const activeTraining = useGameStore((s) => s.models.activeTraining); const subscribers = useGameStore((s) => s.market.consumers.totalSubscribers); const reputation = useGameStore((s) => s.reputation.score); const inferenceUtil = useGameStore((s) => s.compute.inferenceUtilization); const financialHistory = useGameStore((s) => s.economy.financialHistory); const era = useGameStore((s) => s.meta.currentEra); const netIncome = revenuePerTick - expensesPerTick; return (

Dashboard

{dataCenters.length === 0 && ( Welcome to AI Tycoon! Start by building a data center in the Infrastructure tab, then order racks to begin training your first AI model. )} {dataCenters.length > 0 && trainedModels.length === 0 && !activeTraining && ( You have compute available! Head to the Models tab to allocate compute for training and start your first model. )} {trainedModels.length > 0 && !trainedModels.some(m => m.isDeployed) && ( Your model is trained! Deploy it from the Models tab to start serving customers and earning revenue. )}
= 0 ? '+' : ''}${formatMoney(netIncome)}/s`} trend={netIncome > 0 ? 'up' : netIncome < 0 ? 'down' : 'neutral'} color="text-green-400" />

Revenue Over Time

{financialHistory.length > 1 ? ( [formatMoney(value), 'Revenue']} /> ) : (
No data yet — start earning revenue
)}

System Status

0.9 ? 'bg-danger' : inferenceUtil > 0.7 ? 'bg-warning' : 'bg-success'} /> 70 ? 'bg-success' : reputation > 40 ? 'bg-warning' : 'bg-danger'} />

Subscribers Over Time

{(useGameStore.getState().market.subscriberHistory?.length ?? 0) > 1 ? ( [formatNumber(value), 'Subscribers']} /> ) : (
No subscriber data yet
)}

Reputation Over Time

{(useGameStore.getState().reputation.reputationHistory?.length ?? 0) > 1 ? ( [`${value}/100`, 'Reputation']} /> ) : (
No reputation data yet
)}
{dataCenters.length === 0 && (

Get Started

Build your first data center to start training AI models.

)}
); } function StatCard({ icon: Icon, label, value, subValue, trend, color, }: { icon: typeof DollarSign; label: string; value: string; subValue?: string; trend?: 'up' | 'down' | 'neutral'; color?: string; }) { return (
{label}
{value}
{subValue && (
{trend === 'up' && } {trend === 'down' && } {trend === 'neutral' && } {subValue}
)}
); } function StatusRow({ icon: Icon, label, value, bar, barColor, }: { icon: typeof Cpu; label: string; value: string; bar: number; barColor: string; }) { return (
{label}
{value}
); }