vineelagampa meamgodyay commited on
Commit
f8609e4
·
verified ·
1 Parent(s): 94b89e8

Update web/past_data.html (#44)

Browse files

- Update web/past_data.html (87310ed823a41aff4d95c0330caa33ee2765228b)


Co-authored-by: Vihaan Jyothiswaroop <meamgodyay@users.noreply.huggingface.co>

Files changed (1) hide show
  1. web/past_data.html +22 -5
web/past_data.html CHANGED
@@ -50,7 +50,28 @@
50
  const auth = getAuth(app);
51
  const db = getFirestore(app);
52
 
53
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  const statusEl = document.getElementById("auth-status");
55
  const recsEl = document.getElementById("recs-container");
56
 
@@ -68,10 +89,6 @@
68
  if (debugBannerEl) debugBannerEl.textContent = `Debug: ${msg}`;
69
  }
70
 
71
- window.logout = async () => {
72
- try { await signOut(auth); localStorage.clear(); location.href = 'login.html'; }
73
- catch (e) { console.error('Error signing out:', e); }
74
- };
75
 
76
  window.toggleBox = function (id) {
77
  const content = document.getElementById(`box-content-${id}`);
 
50
  const auth = getAuth(app);
51
  const db = getFirestore(app);
52
 
53
+ let currentUser = null;
54
+ onAuthStateChanged(auth, (user) => {
55
+ const authNavItem = document.getElementById("authNavItem");
56
+ if (authNavItem) {
57
+ if (user) {
58
+ authNavItem.innerHTML =
59
+ '<button onclick="logout()" class="hover:text-[#6B9080] text-red-600">Logout</button>';
60
+ } else {
61
+ authNavItem.innerHTML =
62
+ '<a href="login.html" class="hover:text-[#6B9080]">Login</a>';
63
+ }
64
+ }
65
+ });
66
+ window.logout = async () => {
67
+ try {
68
+ await signOut(auth);
69
+ localStorage.clear();
70
+ window.location.href = "login.html";
71
+ } catch (error) {
72
+ console.error("Error signing out:", error);
73
+ }
74
+ };
75
  const statusEl = document.getElementById("auth-status");
76
  const recsEl = document.getElementById("recs-container");
77
 
 
89
  if (debugBannerEl) debugBannerEl.textContent = `Debug: ${msg}`;
90
  }
91
 
 
 
 
 
92
 
93
  window.toggleBox = function (id) {
94
  const content = document.getElementById(`box-content-${id}`);