mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-21 06:23:59 +00:00
Adds an admin-gated Models tab (main/triage/research pickers) that reads/writes the mono /brain/models endpoint, shown only for Company Brain orgs. Extracts a shared useOrgMemberRole hook so the brain settings sections dedupe the getActiveMember call. Fixes ENG-1054
19 lines
713 B
TypeScript
19 lines
713 B
TypeScript
import { useQuery } from "@tanstack/react-query"
|
|
import { authClient } from "@lib/auth"
|
|
import { useAuth } from "@lib/auth-context"
|
|
|
|
// Shared active-member role for the current org. Single queryKey so the
|
|
// company-brain settings sections dedupe the getActiveMember call.
|
|
export function useOrgMemberRole(enabled = true) {
|
|
const { org } = useAuth()
|
|
const query = useQuery({
|
|
queryKey: ["org", "member-role", org?.id],
|
|
queryFn: async () =>
|
|
(await authClient.organization.getActiveMember()).data?.role ?? null,
|
|
staleTime: 60_000,
|
|
enabled: enabled && !!org?.id,
|
|
})
|
|
const role = (query.data ?? "").toLowerCase()
|
|
const isAdmin = role === "owner" || role === "admin"
|
|
return { role, isAdmin, query }
|
|
}
|