feat: better navigation in backoffice

This commit is contained in:
Nathnael
2026-08-07 12:24:30 +00:00
parent d5d7c91e24
commit 1e9149ce00
12 changed files with 861 additions and 676 deletions

View File

@@ -40,8 +40,10 @@ export const AppLayout = () => {
drives collapse on desktop and the Sheet drawer on mobile. */}
<Sidebar collapsible="icon">
<SidebarHeader className="gap-1 border-b border-sidebar-border">
{/* "/" resolves to the user's own landing page — an IAM-only admin
has no overview to go back to. */}
<Link
to="/dashboard/overview"
to="/"
className="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
>
<ArrowLeft className="size-4 shrink-0" />

View File

@@ -2,6 +2,7 @@ import type { ReactElement } from "react";
import { Navigate, Outlet, Route } from "react-router-dom";
import { useAuth } from "@/auth/useAuth";
import { NO_ACCESS_PATH, resolveLandingPath } from "@/lib/landing";
import { isSuperAdmin } from "@/lib/permissions";
import { WithPermission } from "@/shared/hooks/useHas";
import PendingExternalUsers from "@/super-admin/components/externalUsers/PendingExternalUsers";
@@ -85,7 +86,7 @@ function PrivateRoute({ allowedRoles }: { allowedRoles: string[] }): ReactElemen
.filter((k): k is string => Boolean(k));
const allowed =
isSuperAdmin(user) || allowedRoles.some((r) => roleKeys.includes(r));
return allowed ? <Outlet /> : <Navigate to="/dashboard/overview" replace />;
return allowed ? <Outlet /> : <Navigate to={resolveLandingPath(user)} replace />;
}
export const UserManagementRedirect = () => {
@@ -100,7 +101,9 @@ export const UserManagementRedirect = () => {
return <Navigate to="/user-management/user_management-dashboard" replace />;
}
return <Navigate to="/" replace />; // fallback
// No IAM role: "/" resolves back here for anyone whose only sidebar entry is
// Staff, so bounce to the terminal page instead of ping-ponging.
return <Navigate to={NO_ACCESS_PATH} replace />;
};
/**