import React, { useState } from 'react';
import { useDemoStore } from '../../mock/store';
import { StatCard, Button, Badge, MaturityBadge } from '../../shared/ui';
import { formatCurrency } from '../../shared/utils/formatters';
import {
TrendingUp,
AlertTriangle,
AlertCircle,
Clock,
CheckCircle2,
ArrowRight,
Utensils,
Car,
ShoppingBag,
Users,
Truck,
DollarSign,
Package,
Layers,
} from 'lucide-react';
import {
AreaChart,
Area,
XAxis,
YAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
} from 'recharts';
import { useNavigate } from 'react-router-dom';
const REVENUE_DATA_TODAY = [
{ time: '10:00', revenue: 14200, orders: 4 },
{ time: '12:00', revenue: 38400, orders: 12 },
{ time: '14:00', revenue: 76000, orders: 24 },
{ time: '16:00', revenue: 104500, orders: 32 },
{ time: '18:00', revenue: 149000, orders: 45 },
{ time: '20:00', revenue: 184500, orders: 58 },
];
const REVENUE_DATA_WEEK = [
{ time: 'Пн', revenue: 142000, orders: 48 },
{ time: 'Вт', revenue: 156000, orders: 52 },
{ time: 'Ср', revenue: 168000, orders: 56 },
{ time: 'Чт', revenue: 174000, orders: 59 },
{ time: 'Пт', revenue: 245000, orders: 84 },
{ time: 'Сб', revenue: 290000, orders: 98 },
{ time: 'Вс', revenue: 260000, orders: 89 },
];
export const DynamicDashboard: React.FC = () => {
const {
getActiveProfile,
getActiveCapabilities,
activeLocation,
setIsQuickActionsOpen,
kdsTickets,
deliveries,
workOrders,
} = useDemoStore();
const profile = getActiveProfile();
const capabilities = getActiveCapabilities();
const navigate = useNavigate();
const [chartPeriod, setChartPeriod] = useState<'today' | 'week'>('today');
// Dynamic KPIs based on Profile
const renderKpis = () => {
switch (profile.id) {
case 'car_wash':
return (
w.status === 'in_progress').length || 4} авто`}
change={{ value: '+2', trend: 'up' }}
subtitle="2 бокса на въезде"
icon={}
/>
}
/>
}
/>
}
/>
);
case 'auto_service':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'restaurant_delivery_only':
return (
}
/>
d.status === 'in_transit').length + 3} курьера`}
change={{ value: '+2', trend: 'up' }}
subtitle="3 на авто, 2 самокат"
icon={}
/>
}
/>
}
/>
);
case 'fitness':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'clinic':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'coworking':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'logistics':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'retail':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'beauty_services':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'wholesale_b2b':
return (
}
/>
}
/>
}
/>
}
/>
);
case 'restaurant_hall_delivery':
default:
return (
}
/>
}
/>
}
/>
}
/>
}
/>
);
}
};
return (
{/* Top Welcome Bar */}
Операционный центр • {profile.companyName}
{profile.category}
Локация: {activeLocation} • Контур реального времени синхронизирован
{/* 1. ЧТО ПРОИСХОДИТ? — KPI МЕТРИКИ */}
{renderKpis()}
{/* 2. БОЛЬШОЙ ГРАФИК ВЫРУЧКИ И ЧЕКОВ */}
Динамика выручки и среднего чека
Почасовая разбивка с кассовых узлов и онлайн-заказов
`${val / 1000}k`} />
[formatCurrency(Number(value)), 'Выручка']}
contentStyle={{
backgroundColor: '#F8F6F0',
borderColor: '#D8D5CB',
borderRadius: 8,
fontSize: 12,
}}
/>
{/* 3. ЧТО ТРЕБУЕТ ВНИМАНИЯ? (Alerts with direct actions) */}
Требует внимания управляющего
3 критических инцидента
Лосось охлажденный: осталось 2.4 кг (порог 6 кг). Хватит на ~2.5 часа работы кухни.
Задержка на кухне (KDS)
Заказ #104 на Стол 4 находится в работе уже 18 минут при норме 12 минут.
Наличные у курьера
Курьер Алексей Смирнов держит 24 500 ₽ наличными после 7 доставок.
{/* 4. СОСТОЯНИЕ БИЗНЕСА СЕЙЧАС (Live Pulse Grid) */}
{capabilities.dining && (
Зал и столы
82% занято
Открытых чеков:
11 столов
Среднее время посадки:
48 минут
)}
{capabilities.kds && (
Кухня (KDS)
{kdsTickets.length} в работе
Суши-цех:
4 блюда
Горячий цех:
2 блюда
)}
{capabilities.delivery && (
Доставка & Курьеры
3 в пути
Среднее время доставки:
34 мин
Курьеров на линии:
4 сотрудника
)}
Финансы & Кассы
Смены открыты
Наличные в кассе:
42 800 ₽
Безнал / Эквайринг:
141 700 ₽
);
};