From 0ffeb914c3dfd28486e9c336cd82f8268db4c208 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Mon, 10 Nov 2025 20:59:17 +0100 Subject: [PATCH] Fixed bug with unresponsive button --- .../resources/static/js/adminDashboard.js | 22 ++++++++++++++++--- .../resources/static/js/components/header.js | 7 ++++++ .../templates/admin/adminDashboard.html | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SmartClinicManagementSystem/app/src/main/resources/static/js/adminDashboard.js b/SmartClinicManagementSystem/app/src/main/resources/static/js/adminDashboard.js index e6bbc4b..cd8b37b 100644 --- a/SmartClinicManagementSystem/app/src/main/resources/static/js/adminDashboard.js +++ b/SmartClinicManagementSystem/app/src/main/resources/static/js/adminDashboard.js @@ -2,9 +2,15 @@ import { openModal } from "./components/modals.js"; import { getDoctors, filterDoctors, saveDoctor } from "./services/doctorServices.js"; import { createDoctorCard } from "./components/doctorCard.js"; -window.onload = function () { - loadDoctorCards(); -}; +document.addEventListener("DOMContentLoaded", () => { + const loginBtn = document.getElementById("addDocBtn"); + if (loginBtn) { + loginBtn.addEventListener("click", () => { + openModal("addDoctor"); + }); + } + loadDoctorCards(); +}); async function loadDoctorCards() { try { @@ -15,6 +21,16 @@ async function loadDoctorCards() { } } +function renderDoctorCards(doctors) { + const contentDiv = document.getElementById("content"); + contentDiv.innerHTML = ""; + + doctors.forEach(doctor => { + const card = createDoctorCard(doctor); + contentDiv.appendChild(card); + }); +} + window.adminAddDoctor = async function() { const doctor = { "name": document.getElementById("doctorName").value, diff --git a/SmartClinicManagementSystem/app/src/main/resources/static/js/components/header.js b/SmartClinicManagementSystem/app/src/main/resources/static/js/components/header.js index 6e555b4..9afe3ad 100644 --- a/SmartClinicManagementSystem/app/src/main/resources/static/js/components/header.js +++ b/SmartClinicManagementSystem/app/src/main/resources/static/js/components/header.js @@ -63,6 +63,13 @@ function attachHeaderButtonListeners() { if (signup) { signup.addEventListener('click', () => { openModal('patientSignup'); }); } + + const addDoctor = document.getElementById("addDocBtn"); + if (addDoctor) { + addDoctor.addEventListener('click', () => { openModal('addDoctor'); }); + } + + } function logout() { diff --git a/SmartClinicManagementSystem/app/src/main/resources/templates/admin/adminDashboard.html b/SmartClinicManagementSystem/app/src/main/resources/templates/admin/adminDashboard.html index bd439db..66fa693 100644 --- a/SmartClinicManagementSystem/app/src/main/resources/templates/admin/adminDashboard.html +++ b/SmartClinicManagementSystem/app/src/main/resources/templates/admin/adminDashboard.html @@ -5,11 +5,11 @@ Admin Dashboard + -