Add dashboard component and integrate into dashboard page; enable DEV_MODE for testing
This commit is contained in:
parent
6021b351a3
commit
dbd56cdc06
|
|
@ -2,7 +2,7 @@ export function renderLogin(onLogin) {
|
||||||
const loginContainer = document.createElement('div');
|
const loginContainer = document.createElement('div');
|
||||||
loginContainer.className = 'login-container';
|
loginContainer.className = 'login-container';
|
||||||
|
|
||||||
loginContainer.innerHTML = `
|
loginContainer.innerHTML = /*html*/`
|
||||||
<div class="login-card">
|
<div class="login-card">
|
||||||
<h2 class="login-title">Iniciar Sesión</h2>
|
<h2 class="login-title">Iniciar Sesión</h2>
|
||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
export function renderDashboard() {
|
||||||
|
const container = document.createElement('div');
|
||||||
|
container.className = 'dashboard-container';
|
||||||
|
|
||||||
|
container.innerHTML = /*html*/`
|
||||||
|
<h1>Welcome to the Dashboard</h1>
|
||||||
|
<p>This is the main dashboard page.</p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { auth } from '../services/auth.js';
|
import { auth } from '../services/auth.js';
|
||||||
|
import { renderDashboard as renderDashboardComponent } from '../components/dashboard.js';
|
||||||
|
|
||||||
export function renderDashboard() {
|
export function renderDashboard() {
|
||||||
const user = auth.getUser();
|
const user = auth.getUser();
|
||||||
|
|
@ -11,10 +12,13 @@ export function renderDashboard() {
|
||||||
<button id="logout-button" class="logout-button">Cerrar Sesión</button>
|
<button id="logout-button" class="logout-button">Cerrar Sesión</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard-content">
|
<div class="dashboard-content">
|
||||||
<p>Dashboard protegido</p>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
// Agregar el componente dashboard al contenido
|
||||||
|
const contentDiv = container.querySelector('.dashboard-content');
|
||||||
|
contentDiv.appendChild(renderDashboardComponent());
|
||||||
|
|
||||||
container.querySelector('#logout-button').addEventListener('click', () => {
|
container.querySelector('#logout-button').addEventListener('click', () => {
|
||||||
auth.logout();
|
auth.logout();
|
||||||
window.location.hash = '#login';
|
window.location.hash = '#login';
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { createSidebar } from './components/Sidebar.js';
|
||||||
import { getAvailablePages, getPageByRoute } from './pages/pagesRegistry.js';
|
import { getAvailablePages, getPageByRoute } from './pages/pagesRegistry.js';
|
||||||
|
|
||||||
// 🔧 Modo DEV: cambiar a false para activar login
|
// 🔧 Modo DEV: cambiar a false para activar login
|
||||||
const DEV_MODE = false;
|
const DEV_MODE = true;
|
||||||
|
|
||||||
export function initRouter() {
|
export function initRouter() {
|
||||||
const app = document.querySelector('#app');
|
const app = document.querySelector('#app');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue