diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index be7a485..715c57f 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -533,7 +533,7 @@ export function setupMainPairing(): void { async function handleMainPairing(): Promise { const container = getCorrectDOM('login-4nk-component') as HTMLElement; const mainStatus = container.querySelector('#main-status') as HTMLElement; - + try { // Update UI if (mainStatus) { @@ -583,7 +583,7 @@ async function handleMainPairing(): Promise { } catch (error) { console.error('Pairing failed:', error); - + if (mainStatus) { mainStatus.innerHTML = '❌ Authentication failed'; } diff --git a/src/router.ts b/src/router.ts index a7bb116..9b71e26 100755 --- a/src/router.ts +++ b/src/router.ts @@ -22,6 +22,7 @@ const routes: { [key: string]: string } = { export let currentRoute = ''; export async function navigate(path: string) { + console.log('🧭 Navigate called with path:', path); cleanSubscriptions(); cleanPage(); path = path.replace(/^\//, ''); @@ -31,30 +32,41 @@ export async function navigate(path: string) { path = 'home'; } } + console.log('🧭 Final path after processing:', path); await handleLocation(path); + console.log('🧭 handleLocation completed for path:', path); } async function handleLocation(path: string) { + console.log('📍 handleLocation called with path:', path); const parsedPath = path.split('/'); if (path.includes('/')) { path = parsedPath[0]; } currentRoute = path; const routeHtml = routes[path] || routes['home']; + console.log('📍 Current route set to:', currentRoute); + console.log('📍 Route HTML:', routeHtml); const content = document.getElementById('containerId'); + console.log('📍 Container element found:', !!content); if (content) { if (path === 'home') { + console.log('🏠 Processing home route...'); // Use LoginComponent const loginComponent = LoginComponent; const container = document.querySelector('#containerId'); + console.log('🏠 Container for home:', !!container); const accountComponent = document.createElement('login-4nk-component'); accountComponent.setAttribute( 'style', 'width: 100vw; height: 100vh; position: relative; grid-row: 2;' ); - if (container) container.appendChild(accountComponent); + if (container) { + container.appendChild(accountComponent); + console.log('🏠 Component appended to container'); + } // Initialize the home page after component is added to DOM console.log('🏠 Initializing home page...'); @@ -66,6 +78,7 @@ async function handleLocation(path: string) { console.error('❌ Failed to initialize home page:', error); } } else { + console.log('📍 Processing other route:', path); const html = await fetch(routeHtml).then(data => data.text()); content.innerHTML = html; } @@ -186,9 +199,11 @@ export async function init(): Promise { if (isPaired) { console.log('✅ Device is paired, navigating to account page...'); await navigate('account'); + console.log('✅ Navigation to account completed'); } else { console.log('⚠️ Device not paired, navigating to home page...'); await navigate('home'); + console.log('✅ Navigation to home completed'); } console.log('✅ Application initialization completed successfully');