mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
fix: add auth guard redirect and wire logout into NavAccountCard
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,13 +8,12 @@ import {
|
||||
faGrid2,
|
||||
faPlug,
|
||||
} from "@fortawesome/pro-regular-svg-icons";
|
||||
import { useNavigate } from "react-router";
|
||||
import { MobileNavigationHeader } from "@/components/application/app-navigation/base-components/mobile-header";
|
||||
import { NavAccountCard } from "@/components/application/app-navigation/base-components/nav-account-card";
|
||||
import { NavItemBase } from "@/components/application/app-navigation/base-components/nav-item";
|
||||
import type { NavItemType } from "@/components/application/app-navigation/config";
|
||||
|
||||
// TODO: Wire to useAuth() once auth-provider.tsx is implemented
|
||||
const isAdmin = false;
|
||||
import { useAuth } from "@/providers/auth-provider";
|
||||
|
||||
const MAIN_SIDEBAR_WIDTH = 292;
|
||||
|
||||
@@ -58,10 +57,18 @@ interface SidebarProps {
|
||||
}
|
||||
|
||||
export const Sidebar = ({ activeUrl = "/" }: SidebarProps) => {
|
||||
const { logout, isAdmin: authIsAdmin, user } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleSignOut = () => {
|
||||
logout();
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
const navSections = [
|
||||
{ label: "Main", items: mainItems },
|
||||
{ label: "Insights", items: insightsItems },
|
||||
...(isAdmin ? [{ label: "Admin", items: adminItems }] : []),
|
||||
...(authIsAdmin ? [{ label: "Admin", items: adminItems }] : []),
|
||||
];
|
||||
|
||||
const content = (
|
||||
@@ -103,7 +110,7 @@ export const Sidebar = ({ activeUrl = "/" }: SidebarProps) => {
|
||||
|
||||
{/* Account card */}
|
||||
<div className="mt-auto flex flex-col gap-5 px-2 py-4 lg:gap-6 lg:px-4 lg:py-4">
|
||||
<NavAccountCard />
|
||||
<NavAccountCard onSignOut={handleSignOut} />
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user