diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 80da0d8..580e6c3 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -17,7 +17,7 @@ interface HeaderProps { export const Header = ({ breadcrumbs, currentPage, onMenuClick }: HeaderProps): ReactElement => { const navigate = useNavigate(); const dispatch = useAppDispatch(); - const { user, isLoading,roles } = useAppSelector((state) => state.auth); + const { user, isLoading, roles, tenantId } = useAppSelector((state) => state.auth); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const dropdownRef = useRef(null); @@ -61,6 +61,8 @@ export const Header = ({ breadcrumbs, currentPage, onMenuClick }: HeaderProps): }; }, [isDropdownOpen]); + const isPlatformUser = roles.includes('super_admin') || tenantId === '00000000-0000-0000-0000-000000000001'; + // Handle logout const handleLogout = async (e: React.MouseEvent): Promise => { e.preventDefault(); @@ -72,10 +74,9 @@ export const Header = ({ breadcrumbs, currentPage, onMenuClick }: HeaderProps): // Check if user is on a tenant route to determine redirect path // Note: use /tenant/ instead of /tenant to avoid matching /tenants const isTenantRoute = window.location.pathname.startsWith('/tenant/') || window.location.pathname === '/tenant'; - const isSuperAdmin = roles.includes('super_admin'); - // Super admins always go to root login, tenant users go to /tenant/login if on a tenant route - const redirectPath = isSuperAdmin ? '/' : (isTenantRoute ? '/tenant/login' : '/'); + // Platform users always go to root login, tenant users go to /tenant/login if on a tenant route + const redirectPath = isPlatformUser ? '/' : (isTenantRoute ? '/tenant/login' : '/'); try { // Call logout API with Bearer token @@ -110,7 +111,7 @@ export const Header = ({ breadcrumbs, currentPage, onMenuClick }: HeaderProps): > - + {/* Breadcrumbs */}