73 lines
2.8 KiB
JavaScript
Executable File
73 lines
2.8 KiB
JavaScript
Executable File
import { renderDashboard } from './DashboardPage.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: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>',
|
|
requiresAuth: true,
|
|
showInSidebar: true,
|
|
render: renderDashboard
|
|
},
|
|
{
|
|
route: 'invoices',
|
|
name: 'Facturas',
|
|
icon: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>',
|
|
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: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>',
|
|
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: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24"/></svg>',
|
|
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);
|
|
}
|