"use client"; type TrackForecast = { actual: number; forecast: number; variance: number; variance_percent?: number; unit: string; }; type UnifiedForecast = { revenue: TrackForecast; partnerships: { actual_count: number; target_count: number; variance: number; unit: string }; ma: { deals_in_progress: number; pipeline_target: number; variance: number; unit: string }; expansion: { markets_launched: number; markets_planned: number; variance: number; unit: string }; }; function TrackRow({ label, labelAr, actual, target, variance, unit }: { label: string; labelAr: string; actual: number; target: number; variance: number; unit: string; }) { const pct = target > 0 ? Math.round((actual / target) * 100) : 0; const color = pct >= 90 ? "text-emerald-500" : pct >= 70 ? "text-yellow-500" : "text-red-500"; return (
{pct}%
{labelAr} {label}
= 90 ? "bg-emerald-500" : pct >= 70 ? "bg-yellow-500" : "bg-red-500"}`} style={{ width: `${Math.min(100, pct)}%` }} />
الانحراف: {variance} {unit} الفعلي: {actual.toLocaleString()} | الهدف: {target.toLocaleString()} {unit}
); } export function ActualVsForecastDashboard({ data }: { data?: UnifiedForecast }) { const d = data || { revenue: { actual: 0, forecast: 0, variance: 0, variance_percent: 0, unit: "SAR" }, partnerships: { actual_count: 0, target_count: 0, variance: 0, unit: "partners" }, ma: { deals_in_progress: 0, pipeline_target: 0, variance: 0, unit: "deals" }, expansion: { markets_launched: 0, markets_planned: 0, variance: 0, unit: "markets" }, }; return (

الفعلي مقابل التوقعات | Actual vs Forecast

); }