// ⚡ Firebase Config const firebaseConfig = { apiKey: "AIzaSyD8wwbYCF1e2Yh--udDvOSPWx40Ga3qBKU", authDomain: "login-timhopam.firebaseapp.com", projectId: "login-timhopam", storageBucket: "login-timhopam.firebasestorage.app", messagingSenderId: "588448339429", appId: "1:588448339429:web:07514982e72c5726150b0c", measurementId: "G-LNFSSSMKEL" }; if (!firebase.apps.length) { firebase.initializeApp(firebaseConfig); } const auth = firebase.auth(); const db = firebase.firestore(); // 🔹 Hàm render trạng thái đăng nhập trên menu function renderUserNav(user) { const navDesktop = document.getElementById("user-nav"); const navMobile = document.querySelector("#main-mobile-nav #user-nav"); let html = ""; if (user) { html = "👋 " + user.email + " | " + "👤 Trang cá nhân | " + "🚪 Đăng xuất"; } else { html = "🔑 Đăng nhập / " + "📝 Đăng ký"; } if (navDesktop) navDesktop.innerHTML = html; if (navMobile) navMobile.innerHTML = html; const logoutLink = document.getElementById("logout-link"); if (logoutLink) { logoutLink.addEventListener("click", (e) => { e.preventDefault(); auth.signOut().then(() => { window.location.href = "/"; }); }); } } // Theo dõi trạng thái user -> render menu auth.onAuthStateChanged((user) => { renderUserNav(user); });