doli-front/src/pages/pagesRegistry.js

82 lines
2.0 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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