Update frontend

This commit is contained in:
Urtzi Alfaro
2025-08-23 16:30:45 +02:00
parent a214617815
commit b7eb4888a6
9 changed files with 1188 additions and 11 deletions

View File

@@ -1,8 +1,11 @@
import React from 'react';
import React, { useState } from 'react';
import { useDashboard } from '../../hooks/useDashboard';
import { useOrderSuggestions } from '../../hooks/useOrderSuggestions';
// Import simplified components
// Import enhanced dashboard components
import { EnhancedDashboard } from '../../components/dashboard/EnhancedDashboard';
// Import simplified components for fallback
import TodayRevenue from '../../components/simple/TodayRevenue';
import TodayProduction from '../../components/simple/TodayProduction';
import QuickActions from '../../components/simple/QuickActions';
@@ -27,6 +30,7 @@ const DashboardPage: React.FC<DashboardPageProps> = ({
onNavigateToRecipes,
onNavigateToSales
}) => {
const [useEnhancedView, setUseEnhancedView] = useState(true);
const {
weather,
tenantId,
@@ -78,6 +82,39 @@ const DashboardPage: React.FC<DashboardPageProps> = ({
return 'Buenas noches';
};
// Toggle between enhanced and classic view
const toggleDashboardView = () => {
setUseEnhancedView(!useEnhancedView);
};
// Show enhanced dashboard by default - use debug version for stability
if (useEnhancedView) {
return (
<div>
{/* Dashboard View Toggle */}
<div className="fixed top-4 right-4 z-50 flex space-x-2">
<button
onClick={toggleDashboardView}
className="px-3 py-1 text-xs bg-blue-600 text-white rounded-full hover:bg-blue-700 transition-colors shadow-lg"
title="Cambiar a vista clásica"
>
Vista Clásica
</button>
</div>
<EnhancedDashboard
onNavigateToOrders={onNavigateToOrders}
onNavigateToReports={onNavigateToReports}
onNavigateToProduction={onNavigateToProduction}
onNavigateToInventory={onNavigateToInventory}
onNavigateToRecipes={onNavigateToRecipes}
onNavigateToSales={onNavigateToSales}
/>
</div>
);
}
// Classic dashboard view
if (isLoading) {
return (
<div className="flex items-center justify-center h-64">
@@ -106,6 +143,17 @@ const DashboardPage: React.FC<DashboardPageProps> = ({
return (
<div className="p-4 md:p-6 space-y-6 bg-gray-50 min-h-screen">
{/* Dashboard View Toggle */}
<div className="fixed top-4 right-4 z-50">
<button
onClick={toggleDashboardView}
className="px-3 py-1 text-xs bg-gray-600 text-white rounded-full hover:bg-gray-700 transition-colors shadow-lg"
title="Cambiar a vista mejorada"
>
Vista Mejorada
</button>
</div>
{/* Welcome Header */}
<div className="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between">