mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 21:15:41 +00:00
fix ui
This commit is contained in:
20
apps/edr-freight-web/backoffice/src/routes/RootRedirect.tsx
Normal file
20
apps/edr-freight-web/backoffice/src/routes/RootRedirect.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { ReactElement } from "react";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
import { useAuth } from "@/auth/useAuth";
|
||||
|
||||
/**
|
||||
* Root landing redirect for the vendored IAM pages. Sends super admins to the
|
||||
* user-management dashboard and everyone else to the freight overview. Minimal
|
||||
* replacement for the source app's @/routes/RootRedirect (not copied over).
|
||||
*/
|
||||
export function RootRedirect(): ReactElement {
|
||||
const { user } = useAuth();
|
||||
const roles = (user?.roles ?? []).map((r) => r.key).filter(Boolean);
|
||||
if (roles.includes("super_admin")) {
|
||||
return <Navigate to="/user-management/dashboard" replace />;
|
||||
}
|
||||
return <Navigate to="/dashboard/overview" replace />;
|
||||
}
|
||||
|
||||
export default RootRedirect;
|
||||
Reference in New Issue
Block a user