const fs = require('fs');
let c = fs.readFileSync('app_final.js', 'utf8');

if (!c.includes('window.currentAuditLogs =')) {
  // Find where allNotifications is loaded inside loadData()
  const target1 = "allNotifications = ((await window.DB.getAll('notifications')) || []).filter(Boolean);";
  c = c.replace(target1, target1 + "\n  window.currentAuditLogs = ((await window.DB.getAll('activity_logs')) || []).filter(Boolean);");
}

if (!c.includes('renderAuditLogs();') && c.includes('renderDashboard();')) {
  const target2 = "renderDashboard();";
  c = c.replace(target2, target2 + "\n  if (typeof renderAuditLogs === 'function') renderAuditLogs();");
}

fs.writeFileSync('app_final.js', c);
console.log('Fixed app_final.js loadData');
