This commit is contained in:
Alex Holliday committed 2025-12-13 23:12:02 +00:00
1 parent 9aa87f57ae
commit 6f99249d62
4 files changed
+76 -20

No files matched your search

@@ -1,5 +1,6 @@
import { useAppSelector } from "@/hooks/AppHooks";
import { Navigate } from "react-router";
import NotFound from "@/pages/errors/NotFound";
export const ProtectedRoute: React.FC<React.PropsWithChildren> = ({
children,
@@ -20,3 +21,24 @@ export const ProtectedRoute: React.FC<React.PropsWithChildren> = ({
return <>{children}</>;
};
export const MasterRoute: React.FC<React.PropsWithChildren> = ({
children,
}) => {
const user = useAppSelector((state) => state.auth.user);
if (user?.teams.length === 0) {
return <Navigate to="/no-team" replace />;
}
const perms: string[] = (user?.org?.permissions || []).map((p: any) =>
(p ?? "").toString().trim().toLowerCase()
);
const hasMaster = perms.includes("master");
if (!hasMaster) {
return <NotFound />;
}
return <>{children}</>;
};