const loginSection = document.getElementById('loginSection'); const adminDashboard = document.getElementById('adminDashboard'); const adminList = document.getElementById('adminList'); const stats = document.getElementById('stats'); // Login Function const loginBtn = document.getElementById('loginBtn'); if (loginBtn) { loginBtn.onclick = () => { const email = document.getElementById('email').value; const password = document.getElementById('pass').value; // Simple hardcoded check if (email === "admin@rokto.com" && password === "123456") { loginSection.classList.add('hidden'); adminDashboard.classList.remove('hidden'); updateAdminList(); } else { alert("ভুল তথ্য! সঠিক ইমেইল ও পাসওয়ার্ড দিন।"); } }; } // Logout function logout() { loginSection.classList.remove('hidden'); adminDashboard.classList.add('hidden'); } // Load Data into Table function updateAdminList() { if (!adminList) return; adminList.innerHTML = ''; if (stats) stats.innerText = `${donorData.length} Donors found`; donorData.forEach((d, index) => { const row = `

${d.name}

Status: Active

${d.blood_group}

${d.district}

${d.thana}

${d.phone} `; adminList.insertAdjacentHTML('beforeend', row); }); } // Delete Entry async function deleteDonor(index) { if (confirm("আপনি কি নিশ্চিতভাবে এই ডোনারকে ডিলিট করতে চান?")) { const donor = donorData[index]; // Remove from Supabase if (donor.id) { try { const { error } = await supabase .from('donors') .delete() .eq('id', donor.id); if (error) throw error; console.log("Deleted from Supabase"); } catch (e) { console.error("Supabase delete failed", e); alert("ডিলিট করতে সমস্যা হয়েছে।"); } } } }