28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { useAuth } from "~/context/AuthContext";
|
||
import { useScriptWorkspaceStore } from "~/features/platform/state/scriptWorkspaceStore";
|
||
import { toast } from "sonner";
|
||
import { RoleManagementPage } from "~/features/admin/RoleManagementPage";
|
||
|
||
/**
|
||
* /system/roles 路由页。RoleManagementPage 内部有 useState,
|
||
* 在 user / workspace 切换时必须重挂载以重置本地状态
|
||
* (见 CLAUDE.md「Route components with their own internal state」)。
|
||
*/
|
||
export default function RoleManagementRoute() {
|
||
const { user, currentWorkspace } = useAuth();
|
||
const setApiOnline = useScriptWorkspaceStore((s) => s.setApiOnline);
|
||
const pushToast = (notice: { tone: "success" | "error" | "info"; message: string }) => {
|
||
if (notice.tone === "error") toast.error(notice.message);
|
||
else if (notice.tone === "info") toast.info(notice.message);
|
||
else toast.success(notice.message);
|
||
};
|
||
|
||
return (
|
||
<RoleManagementPage
|
||
key={`${user?.user_id ?? "anon"}-${currentWorkspace?.workspace_id ?? "none"}`}
|
||
onNotify={pushToast}
|
||
onConnectionChange={setApiOnline}
|
||
/>
|
||
);
|
||
}
|