2026-01-16 20:55:40 +00:00
|
|
|
|
import { renderDashboard } from './DashboardPage.js';
|
|
|
|
|
|
import { renderTestPage } from './test.js';
|
2026-01-23 18:53:02 +00:00
|
|
|
|
import { renderFacturasPage } from './Facturas.js';
|
2026-02-02 16:58:52 +00:00
|
|
|
|
import { renderCreateInvoicePage } from './CreateInvoicePage.js';
|
2026-01-16 20:55:40 +00:00
|
|
|
|
|
2026-01-16 20:22:14 +00:00
|
|
|
|
// Registry of all pages available in the application
|
|
|
|
|
|
export const pagesRegistry = [
|
|
|
|
|
|
{
|
|
|
|
|
|
route: 'dashboard',
|
|
|
|
|
|
name: 'Dashboard',
|
|
|
|
|
|
icon: '🏠',
|
2026-01-16 20:55:40 +00:00
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: true,
|
|
|
|
|
|
render: renderDashboard
|
2026-01-16 20:22:14 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
route: 'test',
|
|
|
|
|
|
name: 'Test Page',
|
|
|
|
|
|
icon: '🧪',
|
2026-01-16 20:55:40 +00:00
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: true,
|
|
|
|
|
|
render: renderTestPage
|
2026-01-16 20:22:14 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
route: 'invoices',
|
|
|
|
|
|
name: 'Facturas',
|
|
|
|
|
|
icon: '📄',
|
2026-01-16 20:55:40 +00:00
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: true,
|
2026-01-23 18:53:02 +00:00
|
|
|
|
render: renderFacturasPage
|
2026-01-16 20:22:14 +00:00
|
|
|
|
},
|
2026-02-02 16:58:52 +00:00
|
|
|
|
{
|
|
|
|
|
|
route: 'create-invoice',
|
|
|
|
|
|
name: 'Nueva Factura',
|
|
|
|
|
|
icon: '➕',
|
|
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: false, // No mostrar en sidebar
|
|
|
|
|
|
render: renderCreateInvoicePage
|
|
|
|
|
|
},
|
2026-01-16 20:22:14 +00:00
|
|
|
|
{
|
|
|
|
|
|
route: 'clients',
|
|
|
|
|
|
name: 'Clientes',
|
|
|
|
|
|
icon: '👥',
|
2026-01-16 20:55:40 +00:00
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: true,
|
|
|
|
|
|
render: () => {
|
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
|
div.innerHTML = '<h1>Clientes</h1><p>Página en construcción...</p>';
|
|
|
|
|
|
return div;
|
|
|
|
|
|
}
|
2026-01-16 20:22:14 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
route: 'settings',
|
|
|
|
|
|
name: 'Configuración',
|
|
|
|
|
|
icon: '⚙️',
|
2026-01-16 20:55:40 +00:00
|
|
|
|
requiresAuth: true,
|
|
|
|
|
|
showInSidebar: true,
|
|
|
|
|
|
render: () => {
|
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
|
div.innerHTML = '<h1>Configuración</h1><p>Página en construcción...</p>';
|
|
|
|
|
|
return div;
|
|
|
|
|
|
}
|
2026-01-16 20:22:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// Get pages that the user can access
|
|
|
|
|
|
export function getAvailablePages(isAuthenticated) {
|
|
|
|
|
|
if (!isAuthenticated) {
|
|
|
|
|
|
return [];
|
|
|
|
|
|
}
|
2026-01-16 20:55:40 +00:00
|
|
|
|
// Filter pages based on authentication requirement and sidebar visibility
|
|
|
|
|
|
return pagesRegistry.filter(page => {
|
|
|
|
|
|
if (page.requiresAuth && !isAuthenticated) return false;
|
|
|
|
|
|
return page.showInSidebar;
|
|
|
|
|
|
});
|
2026-01-16 20:22:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get page by route
|
|
|
|
|
|
export function getPageByRoute(route) {
|
|
|
|
|
|
return pagesRegistry.find(page => page.route === route);
|
|
|
|
|
|
}
|