Skip to content

Commit 4942c26

Browse files
Fix bug dynamically updating number of records in dashboard stats
1 parent b611cc3 commit 4942c26

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

code/mymedic/static/js/dashboard.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ document.addEventListener('DOMContentLoaded', function() {
3434
this.style.transform = 'translateY(0)';
3535
});
3636
});
37-
});
37+
});
38+
39+
document.addEventListener("DOMContentLoaded", function () {
40+
const recordCount = localStorage.getItem("medical_records_count");
41+
if (recordCount !== null) {
42+
const countElement = document.getElementById("medical-records-count");
43+
if (countElement) {
44+
countElement.textContent = recordCount;
45+
}
46+
}
47+
});

code/mymedic/static/js/medical_records.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ document.addEventListener("DOMContentLoaded", function () {
2525
{ title: "Flu Vaccination", date: "2025-03-12", summary: "Administered seasonal influenza vaccine. No adverse reactions." },
2626
{ title: "Dermatology Consultation", date: "2025-04-13", summary: "Eczema well-controlled. Continue current treatment regimen." },
2727
{ title: "Eye Examination", date: "2025-05-14", summary: "Vision remains stable at 20/20. Annual follow-up recommended." },
28-
{ title: "MRI Scan (Knee)", date: "2025-06-15", summary: "Significant improvement in inflammation. Continue physiotherapy." }
28+
{ title: "Dental Extraction", date: "2025-08-05", summary: "One extraction due to a deep cavity." },
2929
];
3030

31-
// Update dashboard stats
32-
localStorage.setItem("medical_records_count", records.length);
33-
3431
function loadRecords() {
3532
container.innerHTML = "";
33+
localStorage.setItem("medical_records_count", records.length);
3634

3735
if (records.length === 0) {
3836
if (recordMessage) {
@@ -88,4 +86,4 @@ document.addEventListener("DOMContentLoaded", function () {
8886
});
8987

9088
loadRecords();
91-
});
89+
});

code/mymedic/users/templates/users/dashboard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ <h3 class="stat-number">3</h3>
8181
</div>
8282
</div>
8383
</div>
84-
<div class="col-lg-3 col-md-6 mb-4">
84+
<div class="col-lg-3 col-md-6 mb-4">
8585
<div class="stat-card">
8686
<div class="stat-icon records"></div>
8787
<div class="stat-content">
88-
<h3 class="stat-number" id="medical-records-count">0</h3>
88+
<h3 class="stat-number" id="medical-records-count">{{ medical_records_count|default:0 }}</h3>
8989
<p class="stat-label">Medical Records</p>
9090
</div>
9191
</div>

0 commit comments

Comments
 (0)