import React, { useState, useEffect } from 'react';
import { db } from '../../firebase/config';
import { ref, onValue, push, set } from 'firebase/database';
import { TrendingUp, Users, ShoppingBag, AlertCircle, UtensilsCrossed, DollarSign, ShieldCheck, User, Utensils } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
export default function DashboardOverview({ setActiveTab }) {
const navigate = useNavigate();
const [stats, setStats] = useState({ ventasHoy: 0, mesasActivas: 0, stockBajo: 0 });
useEffect(() => {
// Aquí iría la escucha de Firebase para stats en tiempo real
setStats({
ventasHoy: 12500,
mesasActivas: 4,
stockBajo: 2
});
}, []);
const cards = [
{ title: 'Ventas de Hoy', value: `$${stats.ventasHoy.toLocaleString()}`, icon: , bg: 'rgba(32, 201, 151, 0.1)' },
{ title: 'Mesas Activas', value: stats.mesasActivas, icon: , bg: 'rgba(50, 173, 230, 0.1)' },
{ title: 'Órdenes', value: '45', icon: , bg: 'rgba(255, 90, 95, 0.1)' },
{ title: 'Stock Bajo', value: stats.stockBajo, icon: , bg: 'rgba(245, 166, 35, 0.1)' }
];
const seedData = async () => {
if (!window.confirm('¿Deseas cargar toda la información de ejemplo en el sistema? Esto agregará productos, insumos, usuarios y mesas.')) return;
try {
// 1. Sembrar Menú (8 Productos + 5 Especialidades)
const menuRef = ref(db, 'menu');
const menuExamples = [
{ name: 'Hamburgesa Clásica', price: 12.50, category: 'Fuertes', image: '/images/burger.png', active: true },
{ name: 'Pasta Pomodoro', price: 10.00, category: 'Pasta', image: '/images/pasta.png', active: true },
{ name: 'Tacos de Pollo', price: 9.00, category: 'Entradas', image: '/images/tacos.png', active: true },
{ name: 'Pizza Margherita', price: 14.00, category: 'Pizzas', image: '/images/pizza.png', active: true },
{ name: 'Ensalada César', price: 8.50, category: 'Entradas', image: 'https://images.unsplash.com/photo-1550304943-4f24f54ddde9?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Sopa de Tomate', price: 7.00, category: 'Entradas', image: 'https://images.unsplash.com/photo-1547592166-23ac45744acd?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Sandwich Gourmet', price: 11.00, category: 'Fuertes', image: 'https://images.unsplash.com/photo-1528735602780-2552fd46c7af?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Chocolate Muffin', price: 4.50, category: 'Postres', image: 'https://images.unsplash.com/photo-1582231222779-1adb0b322f84?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Ribeye Premium', price: 35.00, category: 'Especialidades', image: '/images/steak.png', active: true },
{ name: 'Risotto de Trufa', price: 28.00, category: 'Especialidades', image: '/images/risotto.png', active: true },
{ name: 'Salmón Glaseado', price: 26.00, category: 'Especialidades', image: 'https://images.unsplash.com/photo-1467003909585-2f8a72700288?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Pato a la Naranja', price: 32.00, category: 'Especialidades', image: 'https://images.unsplash.com/photo-1626082927389-6cd097cdc6ec?auto=format&fit=crop&q=80&w=1000', active: true },
{ name: 'Langosta Thermidor', price: 45.00, category: 'Especialidades', image: 'https://images.unsplash.com/photo-1553243599-c052f82958d2?auto=format&fit=crop&q=80&w=1000', active: true }
];
for (const item of menuExamples) { await set(push(menuRef), item); }
// 2. Sembrar Inventario
const invRef = ref(db, 'inventory');
const invExamples = [
{ name: 'Harina de Trigo', quantity: 100, unit: 'Kg', minStock: 20 },
{ name: 'Tomate Cherry', quantity: 15, unit: 'Kg', minStock: 5 },
{ name: 'Queso Mozzarella', quantity: 40, unit: 'Kg', minStock: 10 },
{ name: 'Carne de Res Premium', quantity: 25, unit: 'Kg', minStock: 8 },
{ name: 'Limones', quantity: 200, unit: 'Und', minStock: 50 },
{ name: 'Papas', quantity: 120, unit: 'Kg', minStock: 30 },
{ name: 'Cebolla', quantity: 30, unit: 'Kg', minStock: 10 }
];
for (const item of invExamples) { await set(push(invRef), item); }
// 3. Sembrar Mesas
const tableRef = ref(db, 'config/tables');
for (let i = 1; i <= 12; i++) {
await set(push(tableRef), { number: i, capacity: i > 6 ? 6 : 4, status: 'available', x: 0, y: 0 });
}
// 4. Sembrar Usuarios
const usersRef = ref(db, 'users');
const users = [
{ name: 'Juan Pérez', role: 'Mesero', shift: 'Mañana', pin: '1234' },
{ name: 'Ana García', role: 'Cocinero', shift: 'Tarde', pin: '5678' },
{ name: 'Carlos López', role: 'Cajero', shift: 'Completo', pin: '9999' }
];
for (const u of users) { await set(push(usersRef), u); }
alert('¡Sistema poblado con datos de ejemplo con éxito! Ya puedes ver los insumos y los platillos. Ve al menú correspondiente para confirmarlo.');
} catch (err) {
console.error(err);
alert('Hubo un error al intentar subir los datos. Verifica la conexión de red o la consola.');
}
};
return (
Resumen General
Cargar Datos de Ejemplo
{cards.map((card, i) => (
{card.icon}
{card.title}
{card.value}
))}
Accesos Rápidos
{[
{ label: 'Administrador', icon:
, action: () => setActiveTab && setActiveTab('overview'), color: 'var(--primary)', bg: 'rgba(255,90,95,0.1)' },
{ label: 'Caja', icon:
, action: () => setActiveTab && setActiveTab('cash'), color: 'var(--success)', bg: 'rgba(32, 201, 151, 0.1)' },
{ label: 'Mesero / POS', icon:
, action: () => navigate('/pos'), color: 'var(--info)', bg: 'rgba(50, 173, 230, 0.1)' },
{ label: 'Cocina', icon:
, action: () => window.open('/kitchen', '_blank'), color: 'var(--warning)', bg: 'rgba(245, 166, 35, 0.1)' },
{ label: 'Carta Digital', icon:
, action: () => window.open('/menu', '_blank'), color: '#a855f7', bg: 'rgba(168, 85, 247, 0.1)' }
].map((btn, idx) => (
e.currentTarget.style.transform = 'translateY(-5px)'} onMouseOut={e => e.currentTarget.style.transform = 'translateY(0)'}>
{btn.icon}
{btn.label}
))}
Misión del Sistema
Este sistema está diseñado para gestionar de manera integral un restaurante moderno.
Desde la recepción del cliente en la Carta Digital , pasando por la toma de pedidos en el
POS de Meseros , hasta la preparación coordinada en la Pantalla de Cocina .
);
}