Refactor frontend components and contexts for improved structure and functionality
- Removed unnecessary comments and documentation from CardContainer, Header, HistoryCharts, MenuButton, PollutionMap, SideMenu, SummaryCards, and ThemeButton components. - Updated import paths to use aliasing for cleaner code. - Replaced the old context implementations (ConfigContext, DataContext, ThemeContext) with new hooks and context structure for better state management. - Introduced a new axios instance for API calls to streamline requests. - Added new utility functions for date and error parsing. - Updated the main entry point and pages to reflect new context and component structures. - Created new configuration files for development and production environments. - Enhanced data fetching logic with improved error handling and loading states.
This commit is contained in:
@@ -1,36 +1,16 @@
|
||||
import "../css/SideMenu.css";
|
||||
import "@/css/SideMenu.css";
|
||||
import PropTypes from 'prop-types';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faTimes, faHome } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { DataProvider } from '../contexts/DataContext';
|
||||
import { useData } from '../contexts/DataContext';
|
||||
import { DataProvider } from '@/context/DataContext';
|
||||
import { useDataContext } from "@/hooks/useDataContext";
|
||||
|
||||
import { useConfig } from '../contexts/ConfigContext';
|
||||
import { useTheme } from "../contexts/ThemeContext";
|
||||
import { useConfig } from '@/hooks/useConfig.js';
|
||||
import { useTheme } from "@/hooks/useTheme";
|
||||
|
||||
import Card from './Card';
|
||||
|
||||
/** ⚠️ EN PRUEBAS ⚠️
|
||||
* SideMenu.jsx
|
||||
*
|
||||
* Este archivo define el componente SideMenu, que muestra un menú lateral con enlaces de navegación.
|
||||
*
|
||||
* Importaciones:
|
||||
* - "../css/SideMenu.css": Archivo CSS que contiene los estilos para el menú lateral.
|
||||
* - PropTypes: Librería para la validación de tipos de propiedades en componentes de React.
|
||||
* - FontAwesomeIcon, faTimes: Componentes e iconos de FontAwesome para mostrar el icono de cerrar.
|
||||
*
|
||||
* Funcionalidad:
|
||||
* - SideMenu: Componente que renderiza un menú lateral con enlaces de navegación.
|
||||
* - Utiliza la propiedad `isOpen` para determinar si el menú debe estar visible.
|
||||
* - Utiliza la propiedad `onClose` para manejar el evento de cierre del menú.
|
||||
*
|
||||
* PropTypes:
|
||||
* - SideMenu espera una propiedad `isOpen` que es un booleano requerido.
|
||||
* - SideMenu espera una propiedad `onClose` que es una función requerida.
|
||||
* ⚠️ EN PRUEBAS ⚠️ **/
|
||||
|
||||
const SideMenu = ({ isOpen, onClose }) => {
|
||||
const { config, configLoading, configError } = useConfig();
|
||||
|
||||
@@ -54,7 +34,7 @@ const SideMenu = ({ isOpen, onClose }) => {
|
||||
};
|
||||
|
||||
const SideMenuContent = ({ isOpen, onClose }) => {
|
||||
const { data, dataLoading, dataError } = useData();
|
||||
const { data, dataLoading, dataError } = useDataContext();
|
||||
const { theme } = useTheme();
|
||||
|
||||
if (dataLoading) return <p>Cargando datos...</p>;
|
||||
|
||||
Reference in New Issue
Block a user