fix: repair corrupted dashboard.js and hide overview by default
Build Curio HMS / build-and-deploy (push) Successful in 44s Details

This commit is contained in:
Deep Koluguri 2026-05-14 23:28:16 -04:00
parent cb4e4406d1
commit 004339ee9f
2 changed files with 119 additions and 156 deletions

View File

@ -109,7 +109,7 @@
</div> </div>
</div> </div>
<div id="overview-section"> <div id="overview-section" class="hidden">
<section class="stats-row"> <section class="stats-row">
<div class="stat-card"> <div class="stat-card">
<span>In Queue</span> <span>In Queue</span>
@ -376,6 +376,6 @@
</div> </div>
</div> </div>
<script src="dashboard.js?v=2"></script> <script src="dashboard.js?v=3"></script>
</body> </body>
</html> </html>

View File

@ -1,3 +1,4 @@
// Core Modal & UI Elements
const modal = document.getElementById("consultationModal"); const modal = document.getElementById("consultationModal");
const addMedBtn = document.getElementById("addMed"); const addMedBtn = document.getElementById("addMed");
const medList = document.getElementById("medicineList"); const medList = document.getElementById("medicineList");
@ -9,181 +10,143 @@ const aiInsightsBox = document.getElementById("aiInsights");
const insightText = document.getElementById("insightText"); const insightText = document.getElementById("insightText");
const queueDateInput = document.getElementById("queueDate"); const queueDateInput = document.getElementById("queueDate");
const newWalkinBtn = document.getElementById("newWalkinBtn"); const newWalkinBtn = document.getElementById("newWalkinBtn");
// Initialize Date Picker to Today
if (queueDateInput) {
const today = new Date().toISOString().split('T')[0];
queueDateInput.value = today;
queueDateInput.min = today; // Prevent past dates
queueDateInput.addEventListener("change", (e) => {
console.log(`Switching view to date: ${e.target.value}`);
// In a real app, this would fetch the queue for that specific date
alert(`Now viewing appointments for: ${e.target.value}`);
});
}
// Handle New Walk-in for selected date
if (newWalkinBtn) {
newWalkinBtn.addEventListener("click", () => {
const selectedDate = queueDateInput.value;
const name = prompt("Enter Patient Name:");
if (name) {
console.log(`Booking walk-in for ${name} on ${selectedDate}`);
alert(`Token generated for ${name} on ${selectedDate}. \n\nPlease print the token and hand it to the patient.`);
}
});
}
// Open modal when clicking 'Prescribe'
document.querySelectorAll(".btn-small").forEach(btn => {
if (btn.innerText === "Prescribe") {
btn.addEventListener("click", () => {
modal.style.display = "block";
});
}
});
closeModal.onclick = () => modal.style.display = "none";
window.onclick = (event) => {
if (event.target == modal) modal.style.display = "none";
};
const labList = document.getElementById("labTestList"); const labList = document.getElementById("labTestList");
const addLabBtn = document.getElementById("addLabTest"); const addLabBtn = document.getElementById("addLabTest");
// Add new medicine row // 1. Initialize View on Load
addMedBtn.onclick = () => { document.addEventListener("DOMContentLoaded", () => {
const row = document.createElement("div"); const userRole = localStorage.getItem('userRole') || 'OWNER';
row.className = "med-row"; const userEmail = localStorage.getItem('userEmail') || 'admin@curio.app';
row.innerHTML = `
<input type="text" placeholder="Medicine Name" class="med-name"> // Set Sidebar Profile
<input type="text" placeholder="Dosage (e.g. 1-0-1)" class="med-dosage"> const roleDisplay = document.querySelector(".user-profile .info strong");
<input type="text" placeholder="Duration" class="med-duration"> const emailDisplay = document.querySelector(".user-profile .info span");
`; if (roleDisplay) roleDisplay.innerText = userRole.charAt(0) + userRole.slice(1).toLowerCase();
medList.appendChild(row); if (emailDisplay) emailDisplay.innerText = userEmail;
};
// Add new lab test row // Apply Role-Based Filtering
addLabBtn.onclick = () => { if (userRole === 'DOCTOR') {
const row = document.createElement("div"); document.querySelectorAll('.side-nav a').forEach(link => {
row.className = "lab-row"; const text = link.innerText;
row.style = "display: flex; gap: 0.5rem; margin-bottom: 0.5rem;"; if (text.includes('Billing') || text.includes('Staff') || text.includes('Overview')) {
row.innerHTML = ` link.style.display = 'none';
<input type="text" placeholder="Test Name (e.g. CBC, Lipid)" class="lab-test-name" style="flex: 1; padding: 0.6rem; border-radius: 8px; border: 1px solid var(--border);"> }
`; });
labList.appendChild(row); showSection('zen');
}; } else if (userRole === 'RECEPTIONIST') {
document.querySelectorAll('.side-nav a').forEach(link => {
// Handle sending prescription const text = link.innerText;
sendRxBtn.onclick = () => { if (text.includes('Lab') || text.includes('Staff')) {
const diagnosis = document.getElementById("rxDiagnosis").value; link.style.display = 'none';
const meds = []; }
document.querySelectorAll(".med-row").forEach(row => { });
const name = row.querySelector(".med-name").value; showSection('overview');
if (name) { } else {
meds.push({ showSection('overview');
name,
dosage: row.querySelector(".med-dosage").value,
duration: row.querySelector(".med-duration").value
});
}
});
if (!diagnosis || meds.length === 0) {
alert("Please enter diagnosis and at least one medicine.");
return;
} }
// Simulate sending to backend // Set Default Date
console.log("Sending Rx:", { diagnosis, meds }); if (queueDateInput) {
const today = new Date().toISOString().split('T')[0];
queueDateInput.value = today;
}
});
// 2. Section Switching Logic
window.showSection = (sectionId) => {
const sections = ['overview-section', 'patients-section', 'pharmacy-section', 'lab-section', 'doctor-zen-section'];
sections.forEach(id => {
const el = document.getElementById(id);
if (el) el.classList.add('hidden');
});
// UI Feedback if (sectionId === 'overview') {
sendRxBtn.innerText = "Sent! ✅"; document.getElementById('overview-section').classList.remove('hidden');
sendRxBtn.style.background = "#10B981"; } else if (sectionId === 'zen') {
document.getElementById('doctor-zen-section').classList.remove('hidden');
setTimeout(() => { } else if (sectionId === 'queue') {
modal.style.display = "none"; const role = localStorage.getItem('userRole');
sendRxBtn.innerText = "Send to WhatsApp"; if (role === 'DOCTOR') {
sendRxBtn.style.background = ""; document.getElementById('doctor-zen-section').classList.remove('hidden');
const note = document.getElementById("deptNote").value;
if (note) {
console.log("Dept Note:", note);
alert("Prescription sent. Note forwarded to Pharmacy/Lab.");
} else { } else {
alert("Prescription has been sent to the patient's WhatsApp."); document.getElementById('overview-section').classList.remove('hidden');
document.getElementById('queue-section').scrollIntoView({ behavior: 'smooth' });
} }
}, 1500); } else if (sectionId === 'patients') {
document.getElementById('patients-section').classList.remove('hidden');
} else if (sectionId === 'pharmacy') {
document.getElementById('pharmacy-section').classList.remove('hidden');
} else if (sectionId === 'lab') {
document.getElementById('lab-section').classList.remove('hidden');
}
// Nav Active State
document.querySelectorAll('.side-nav a').forEach(link => {
link.classList.remove('active');
if (link.innerText.toLowerCase().includes(sectionId)) link.classList.add('active');
});
// Mobile Auto-hide Sidebar
if (window.innerWidth <= 768) {
const sb = document.getElementById('sidebar');
if (sb) sb.style.display = 'none';
}
}; };
window.shareTip = (type) => { // 3. Clinical Consultation Logic
const tips = { if (addMedBtn) {
diabetes: "🥗 Healthy Diet Tip: Reduce white rice, add more greens.", addMedBtn.onclick = () => {
hypertension: "🧘 BP Control: Limit salt intake to 5g/day.", const row = document.createElement("div");
viral: "💧 Hydration: Drink 3L of warm water daily." row.className = "med-row";
row.innerHTML = `
<input type="text" placeholder="Medicine Name" class="med-name">
<input type="text" placeholder="Dosage (e.g. 1-0-1)" class="med-dosage">
<input type="text" placeholder="Duration" class="med-duration">
`;
medList.appendChild(row);
}; };
alert(`📤 Sent to Patient's WhatsApp:\n\n${tips[type]}`); }
};
window.printTips = () => { if (addLabBtn) {
alert("🖨️ Printing General Health Guidelines for this patient..."); addLabBtn.onclick = () => {
}; const row = document.createElement("div");
row.className = "lab-row";
row.style = "display: flex; gap: 0.5rem; margin-bottom: 0.5rem;";
row.innerHTML = `<input type="text" placeholder="Test Name" class="lab-test-name" style="flex: 1; padding: 0.6rem; border-radius: 8px; border: 1px solid var(--border);">`;
labList.appendChild(row);
};
}
// Voice AI Logic // 4. Voice AI Simulation
startRecordBtn.onclick = () => { if (startRecordBtn) {
startRecordBtn.classList.add("hidden"); startRecordBtn.onclick = () => {
recordingStatus.classList.remove("hidden"); startRecordBtn.classList.add("hidden");
recordingStatus.classList.remove("hidden");
// Simulate recording for 3 seconds setTimeout(() => {
setTimeout(() => { recordingStatus.classList.add("hidden");
recordingStatus.classList.add("hidden"); aiInsightsBox.classList.remove("hidden");
aiInsightsBox.classList.remove("hidden"); insightText.innerText = "Viral infection detected. Avoid cold drinks for 3 days. Follow-up in 1 week.";
document.getElementById("rxDiagnosis").value = "Viral Infection";
// Mock data filtering simulation }, 2000);
const mockTranscript = "Hello Rahul, how is your family? The weather is very hot today. Regarding your cough, it seems like a viral infection. You should avoid cold drinks for 3 days. Take the paracetamol after meals. I'll see you in a week."; };
}
// Filter out small talk (AI simulation)
const insights = "Viral infection detected. Avoid cold drinks for 3 days. Take paracetamol after meals. Follow-up in 1 week."; // 5. Sidebar Toggle
window.toggleSidebar = () => {
insightText.innerText = insights; const sidebar = document.getElementById('sidebar');
if (!sidebar) return;
// Auto-fill diagnosis if empty if (sidebar.style.display === 'flex') {
if (!document.getElementById("rxDiagnosis").value) { sidebar.style.display = 'none';
} else { } else {
sidebar.style.display = 'flex'; sidebar.style.display = 'flex';
sidebar.style.position = 'fixed'; sidebar.style.position = 'fixed';
sidebar.style.top = '50px'; sidebar.style.top = '50px';
sidebar.style.left = '0';
sidebar.style.width = '100%'; sidebar.style.width = '100%';
sidebar.style.height = 'calc(100vh - 50px)'; sidebar.style.height = 'calc(100vh - 50px)';
sidebar.style.zIndex = '999'; sidebar.style.zIndex = '999';
} }
}; };
// Role-Based UI Filtering (Run on Load) // Close Modals
document.addEventListener("DOMContentLoaded", () => { if (closeModal) closeModal.onclick = () => modal.style.display = "none";
const userRole = localStorage.getItem('userRole') || 'OWNER'; window.onclick = (e) => { if (e.target == modal) modal.style.display = "none"; };
const userEmail = localStorage.getItem('userEmail') || 'admin@curio.app';
const roleDisplay = document.querySelector(".user-profile .info strong");
const emailDisplay = document.querySelector(".user-profile .info span");
if (roleDisplay) roleDisplay.innerText = userRole.charAt(0) + userRole.slice(1).toLowerCase();
if (emailDisplay) emailDisplay.innerText = userEmail;
if (userRole === 'DOCTOR') {
document.querySelectorAll('.side-nav a').forEach(link => {
if (link.innerText.includes('Billing') || link.innerText.includes('Staff') || link.innerText.includes('Overview')) {
link.style.display = 'none';
}
});
showSection('zen'); // Primary view for doctors
} else if (userRole === 'RECEPTIONIST') {
document.querySelectorAll('.side-nav a').forEach(link => {
if (link.innerText.includes('Lab') || link.innerText.includes('Staff')) {
link.style.display = 'none';
}
});
showSection('overview');
}
});