import { Routes, Route, Navigate } from "react-router-dom"; import { useAuth } from "./auth/AuthContext"; import LoginPage from "./auth/LoginPage"; import MainLayout from "./layout/MainLayout"; import MelodyList from "./melodies/MelodyList"; import MelodyDetail from "./melodies/MelodyDetail"; import MelodyForm from "./melodies/MelodyForm"; import MelodySettings from "./melodies/MelodySettings"; import BuilderList from "./melodies/builder/BuilderList"; import BuilderForm from "./melodies/builder/BuilderForm"; import DeviceList from "./devices/DeviceList"; import DeviceDetail from "./devices/DeviceDetail"; import DeviceForm from "./devices/DeviceForm"; import UserList from "./users/UserList"; import UserDetail from "./users/UserDetail"; import UserForm from "./users/UserForm"; import MqttDashboard from "./mqtt/MqttDashboard"; import CommandPanel from "./mqtt/CommandPanel"; import LogViewer from "./mqtt/LogViewer"; import NoteList from "./equipment/NoteList"; import NoteDetail from "./equipment/NoteDetail"; import NoteForm from "./equipment/NoteForm"; import StaffList from "./settings/StaffList"; import StaffDetail from "./settings/StaffDetail"; import StaffForm from "./settings/StaffForm"; function ProtectedRoute({ children }) { const { user, loading } = useAuth(); if (loading) { return (

Loading...

); } if (!user) { return ; } return children; } function PermissionGate({ section, action = "view", children }) { const { hasPermission } = useAuth(); if (!hasPermission(section, action)) { return (

Access Denied

You don't have permission to access this feature. Please contact an administrator if you need access.

); } return children; } function RoleGate({ roles, children }) { const { hasRole } = useAuth(); if (!hasRole(...roles)) { return (

Access Denied

You don't have permission to access this feature. Please contact an administrator if you need access.

); } return children; } function DashboardPage() { const { user } = useAuth(); return (

Dashboard

Welcome, {user?.name}. You are logged in as{" "} {user?.role}.

); } export default function App() { return ( } /> } > } /> {/* Melodies */} } /> } /> } /> } /> } /> } /> } /> } /> {/* Devices */} } /> } /> } /> } /> {/* App Users */} } /> } /> } /> } /> {/* MQTT */} } /> } /> } /> {/* Equipment Notes */} } /> } /> } /> } /> {/* Settings - Staff Management */} } /> } /> } /> } /> } /> ); }