- Moved components to a new layout directory for better organization. - Updated App component to include GroupView and adjust routing. - Removed unused components (App.jsx, Card.jsx, CardContainer.jsx, Header.jsx, MenuButton.jsx, SideMenu.jsx, ThemeButton.jsx). - Introduced LoadingIcon component for loading states. - Updated PollutionMap, SummaryCards, and HistoryCharts components to accept groupId as a prop. - Modified API endpoint configurations in settings.prod.json for better clarity and consistency. - Enhanced chart options in historyChartConfig for improved visual representation. - Updated favicon and logo images.
85 lines
2.8 KiB
JavaScript
85 lines
2.8 KiB
JavaScript
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 '@/context/DataContext';
|
|
import { useDataContext } from "@/hooks/useDataContext";
|
|
|
|
import { useConfig } from '@/hooks/useConfig.js';
|
|
import { useTheme } from "@/hooks/useTheme";
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import Card from './Card';
|
|
|
|
const SideMenu = ({ isOpen, onClose }) => {
|
|
const { config, configLoading, configError } = useConfig();
|
|
|
|
if (configLoading) return <p>Cargando configuración...</p>;
|
|
if (configError) return <p>Error al cargar configuración: {configError}</p>;
|
|
if (!config) return <p>Configuración no disponible.</p>;
|
|
|
|
const BASE = config.appConfig.endpoints.DATA_URL;
|
|
const ENDPOINT = config.appConfig.endpoints.GET_GROUPS;
|
|
|
|
const reqConfig = {
|
|
baseUrl: `${BASE}${ENDPOINT}`,
|
|
params: {}
|
|
}
|
|
|
|
return (
|
|
<DataProvider config={reqConfig}>
|
|
<SideMenuContent isOpen={isOpen} onClose={onClose} />
|
|
</DataProvider>
|
|
);
|
|
};
|
|
|
|
const SideMenuContent = ({ isOpen, onClose }) => {
|
|
const { data, dataLoading, dataError } = useDataContext();
|
|
const { theme } = useTheme();
|
|
|
|
if (dataLoading) return <p>Cargando datos...</p>;
|
|
if (dataError) return <p>Error al cargar datos: {dataError}</p>;
|
|
if (!data) return <p>Datos no disponibles.</p>;
|
|
|
|
return (
|
|
<div className={`side-menu ${isOpen ? 'open' : ''} ${theme}`}>
|
|
<button className="home-btn" onClick={() => window.location.href = '/'}>
|
|
<FontAwesomeIcon icon={faHome} />
|
|
</button>
|
|
<button className="close-btn" onClick={onClose}>
|
|
<FontAwesomeIcon icon={faTimes} />
|
|
</button>
|
|
<hr className="separation w-100"></hr>
|
|
<div className="d-flex flex-column gap-3 mt-5">
|
|
{data.map(group => {
|
|
return (
|
|
<Link to={`/groups/${group.groupId}`} key={group.groupId} style={{ textDecoration: 'none' }}>
|
|
<Card
|
|
title={group.groupName}
|
|
status={`ID: ${group.groupId}`}
|
|
styleMode={"override"}
|
|
className={"col-12"}
|
|
>
|
|
{[]}
|
|
</Card>
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
SideMenu.propTypes = {
|
|
isOpen: PropTypes.bool.isRequired,
|
|
onClose: PropTypes.func.isRequired
|
|
}
|
|
|
|
SideMenuContent.propTypes = {
|
|
isOpen: PropTypes.bool.isRequired,
|
|
onClose: PropTypes.func.isRequired
|
|
}
|
|
|
|
export default SideMenu; |