163 lines
4.1 KiB
Plaintext
163 lines
4.1 KiB
Plaintext
<%
|
|
const role = user?.role || null;
|
|
|
|
// ✅ Regeln
|
|
const canDoctorArea = role === "arzt"; // nur Arzt
|
|
const canAdminArea = role === "admin"; // nur Admin
|
|
const canPatients = role === "arzt" || role === "mitarbeiter";
|
|
const canStaffArea = role === "arzt" || role === "mitarbeiter"; // Medikamente + offene Leistungen
|
|
|
|
function hrefIfAllowed(allowed, href) {
|
|
return allowed ? href : "#";
|
|
}
|
|
|
|
function lockClass(allowed) {
|
|
return allowed ? "" : "locked";
|
|
}
|
|
|
|
function lockClick(allowed) {
|
|
return allowed ? "" : 'onclick="return false;"';
|
|
}
|
|
%>
|
|
|
|
<div class="sidebar">
|
|
<div class="logo">
|
|
<i class="bi bi-hospital"></i>
|
|
Praxis System
|
|
</div>
|
|
|
|
<!-- Dashboard -->
|
|
<a
|
|
href="/dashboard"
|
|
class="nav-item <%= active === 'dashboard' ? 'active' : '' %>"
|
|
>
|
|
<i class="bi bi-house-door"></i> Dashboard
|
|
</a>
|
|
|
|
<!-- Patienten -->
|
|
<a
|
|
href="<%= hrefIfAllowed(canPatients, '/patients') %>"
|
|
class="nav-item <%= active === 'patients' ? 'active' : '' %> <%= lockClass(canPatients) %>"
|
|
<%- lockClick(canPatients) %>
|
|
title="<%= canPatients ? '' : 'Nur Arzt oder Mitarbeiter' %>"
|
|
>
|
|
<i class="bi bi-people"></i> Patienten
|
|
<% if (!canPatients) { %>
|
|
<span style="margin-left:auto;"><i class="bi bi-lock-fill"></i></span>
|
|
<% } %>
|
|
</a>
|
|
|
|
<!-- Medikamente -->
|
|
<a
|
|
href="<%= hrefIfAllowed(canStaffArea, '/medications') %>"
|
|
class="nav-item <%= active === 'medications' ? 'active' : '' %> <%= lockClass(canStaffArea) %>"
|
|
<%- lockClick(canStaffArea) %>
|
|
title="<%= canStaffArea ? '' : 'Nur Arzt oder Mitarbeiter' %>"
|
|
>
|
|
<i class="bi bi-capsule"></i> Medikamente
|
|
<% if (!canStaffArea) { %>
|
|
<span style="margin-left:auto;"><i class="bi bi-lock-fill"></i></span>
|
|
<% } %>
|
|
</a>
|
|
|
|
<!-- Offene Leistungen -->
|
|
<a
|
|
href="<%= hrefIfAllowed(canStaffArea, '/services/open') %>"
|
|
class="nav-item <%= active === 'services' ? 'active' : '' %> <%= lockClass(canStaffArea) %>"
|
|
<%- lockClick(canStaffArea) %>
|
|
title="<%= canStaffArea ? '' : 'Nur Arzt oder Mitarbeiter' %>"
|
|
>
|
|
<i class="bi bi-receipt"></i> Offene Leistungen
|
|
<% if (!canStaffArea) { %>
|
|
<span style="margin-left:auto;"><i class="bi bi-lock-fill"></i></span>
|
|
<% } %>
|
|
</a>
|
|
|
|
<!-- Abrechnung -->
|
|
<a
|
|
href="<%= hrefIfAllowed(canDoctorArea, '/admin/invoices') %>"
|
|
class="nav-item <%= active === 'billing' ? 'active' : '' %> <%= lockClass(canDoctorArea) %>"
|
|
<%- lockClick(canDoctorArea) %>
|
|
title="<%= canDoctorArea ? '' : 'Nur Arzt' %>"
|
|
>
|
|
<i class="bi bi-cash-stack"></i> Abrechnung
|
|
<% if (!canDoctorArea) { %>
|
|
<span style="margin-left:auto;"><i class="bi bi-lock-fill"></i></span>
|
|
<% } %>
|
|
</a>
|
|
|
|
<!-- Verwaltung -->
|
|
<a
|
|
href="<%= hrefIfAllowed(canAdminArea, '/admin/users') %>"
|
|
class="nav-item <%= active === 'admin' ? 'active' : '' %> <%= lockClass(canAdminArea) %>"
|
|
<%- lockClick(canAdminArea) %>
|
|
title="<%= canAdminArea ? '' : 'Nur Admin' %>"
|
|
>
|
|
<i class="bi bi-gear"></i> Verwaltung
|
|
<% if (!canAdminArea) { %>
|
|
<span style="margin-left:auto;"><i class="bi bi-lock-fill"></i></span>
|
|
<% } %>
|
|
</a>
|
|
|
|
<div class="spacer"></div>
|
|
|
|
<a href="/logout" class="nav-item">
|
|
<i class="bi bi-box-arrow-right"></i> Logout
|
|
</a>
|
|
</div>
|
|
|
|
<style>
|
|
.sidebar {
|
|
width: 260px;
|
|
background: #111827;
|
|
color: white;
|
|
padding: 20px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.logo {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
margin-bottom: 18px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 12px 15px;
|
|
border-radius: 10px;
|
|
color: #cbd5e1;
|
|
text-decoration: none;
|
|
margin-bottom: 6px;
|
|
font-size: 14px;
|
|
border: 0;
|
|
background: transparent;
|
|
width: 100%;
|
|
}
|
|
|
|
.nav-item:hover {
|
|
background: #1f2937;
|
|
color: white;
|
|
}
|
|
|
|
.nav-item.active {
|
|
background: #2563eb;
|
|
color: white;
|
|
}
|
|
|
|
.nav-item.locked {
|
|
opacity: 0.45;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.spacer {
|
|
flex: 1;
|
|
}
|
|
</style>
|