From 5571d29b83f1021e0a9712c1ee1a797561fc572d Mon Sep 17 00:00:00 2001 From: rafael Date: Thu, 20 Nov 2025 18:45:17 -0400 Subject: [PATCH] Add scheduled requests feature with navigation, forms, and table components Introduced a new 'Solicitudes Programadas' section with full CRUD functionality using localStorage for persistence. Added navigation to toggle between dashboard and scheduled views. Updated the header, sidebar, and main content to support dynamic titles and active views. Included components for viewing and managing scheduled requests (form and table). Enhanced styles for the new section. --- src/App.js | 30 +++-- src/components/Layout/Header.js | 8 +- src/components/Layout/Sidebar.js | 27 +++-- src/components/Scheduled/ScheduledForm.js | 135 +++++++++++++++++++++ src/components/Scheduled/ScheduledPage.js | 130 ++++++++++++++++++++ src/components/Scheduled/ScheduledTable.js | 84 +++++++++++++ 6 files changed, 392 insertions(+), 22 deletions(-) create mode 100644 src/components/Scheduled/ScheduledForm.js create mode 100644 src/components/Scheduled/ScheduledPage.js create mode 100644 src/components/Scheduled/ScheduledTable.js diff --git a/src/App.js b/src/App.js index cba1eaf..f51dcc8 100644 --- a/src/App.js +++ b/src/App.js @@ -4,27 +4,41 @@ import { Sidebar, Header } from './components/Layout'; import { DashboardCards } from './components/Dashboard'; import RequestTable from './components/Requests/RequestTable'; import RequestForm from './components/Requests/RequestForm'; +import ScheduledPage from './components/Scheduled/ScheduledPage'; function App() { const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); + const [activeView, setActiveView] = useState('dashboard'); // 'dashboard' | 'scheduled' const handleToggleMobileMenu = () => setIsMobileMenuOpen(!isMobileMenuOpen); + const handleNavigate = (key) => { + setActiveView(key); + setIsMobileMenuOpen(false); + }; + + const headerTitle = activeView === 'scheduled' ? 'Solicitudes Programadas' : 'Dashboard'; return (
-
-
- -
- - -
-
+
+ {activeView === 'scheduled' ? ( + + ) : ( +
+ +
+ + +
+
+ )}
); diff --git a/src/components/Layout/Header.js b/src/components/Layout/Header.js index 1125410..bdc002f 100644 --- a/src/components/Layout/Header.js +++ b/src/components/Layout/Header.js @@ -1,7 +1,7 @@ import React from 'react'; import '../../styles/components.css'; -const Header = () => { +const Header = ({ title = 'Dashboard' }) => { const handleLogout = () => { try { localStorage.setItem('auth', 'false'); @@ -10,11 +10,13 @@ const Header = () => { window.location.reload(); }; + const iconClass = title === 'Solicitudes Programadas' ? 'fas fa-calendar-alt' : 'fas fa-tachometer-alt'; + return (
- - Dashboard + + {title}
diff --git a/src/components/Layout/Sidebar.js b/src/components/Layout/Sidebar.js index d9f46c7..475cb4b 100644 --- a/src/components/Layout/Sidebar.js +++ b/src/components/Layout/Sidebar.js @@ -1,16 +1,21 @@ import React from 'react'; import '../../styles/components.css'; -const Sidebar = ({ isMobileMenuOpen, onToggleMobileMenu }) => { +const Sidebar = ({ isMobileMenuOpen, onToggleMobileMenu, activeView = 'dashboard', onNavigate }) => { const navItems = [ - { icon: 'fas fa-tachometer-alt', label: 'Dashboard', active: true, badge: null }, - { icon: 'fas fa-list', label: 'Solicitudes Programadas', active: false, badge: '12' }, - { icon: 'fas fa-plus-circle', label: 'Crear Solicitud', active: false, badge: null }, - { icon: 'fas fa-history', label: 'Historial', active: false, badge: null }, - { icon: 'fas fa-cog', label: 'Configuración', active: false, badge: null }, - { icon: 'fas fa-question-circle', label: 'Ayuda', active: false, badge: null } + { key: 'dashboard', icon: 'fas fa-tachometer-alt', label: 'Dashboard', badge: null }, + { key: 'scheduled', icon: 'fas fa-list', label: 'Solicitudes Programadas', badge: null }, + { key: 'create', icon: 'fas fa-plus-circle', label: 'Crear Solicitud', badge: null }, + { key: 'history', icon: 'fas fa-history', label: 'Historial', badge: null }, + { key: 'settings', icon: 'fas fa-cog', label: 'Configuración', badge: null }, + { key: 'help', icon: 'fas fa-question-circle', label: 'Ayuda', badge: null } ]; + const handleClick = (e, key) => { + e.preventDefault(); + onNavigate?.(key); + }; + return ( <> + )} +
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + {item.scheduleType === 'cron' ? ( +
+ + +
+ ) : ( +
+ + +
+ )} + +
+ +