Hay que agregar la metrica active users: import React, { useEffect } from 'react';…
- User
Hay que agregar la metrica active users: import React, { useEffect } from 'react'; import { useGlobalContext } from '../context/GlobalContext'; import MainLayout from '../layouts/MainLayout'; import styles from '../styles/Home.module.css';
const Home = () => { const { fetchStats, stats, fetchAlerts, alerts, fetchOrders, error, storesError, productsError } = useGlobalContext();
useEffect(() => { if (typeof fetchStats === 'function') { fetchStats(); } if (typeof fetchAlerts === 'function') { fetchAlerts(); } if (typeof fetchOrders === 'function') { fetchOrders(); } }, [fetchStats, fetchAlerts, fetchOrders]);
const renderErrorMessage = () => { if (error || storesError || productsError) { return ( Errores {error && {error}} {storesError && Error al cargar las tiendas: {storesError}} {productsError && No se pudieron obtener todos los productos.} ); } return null; };
return ( Asistente de Negocio {renderErrorMessage()} Nuevos Usuarios Hoy {stats?.newUsersToday || 0} Nuevas Tiendas Hoy {stats?.newStoresToday || 0} Nuevos Trabajadores Hoy {stats?.newWorkersToday || 0} Nuevos Productos Hoy {stats?.newProductsToday || 0} Tareas Pendientes {stats?.pendingTasks || 0}
{alerts?.length > 0 && ( <div className={styles.alerts}> <h2>Alertas</h2> {alerts.map((alert, index) => ( <div key={index} className={styles.alert}> {alert.message} </div> ))} </div> )} </div> </MainLayout>); };
export default Home;
- Assistant