MCPcopy Create free account
hub / github.com/hashintel/hash / useUserOrOrg

Function useUserOrOrg

apps/hash-frontend/src/shared/use-user-or-org.ts:28–187  ·  view source on GitHub ↗
(
  params: {
    includePermissions?: boolean;
    includeAvatar?: boolean;
    includeMembersOfOrg?: boolean;
    traversalPaths?: TraversalPath[];
  } & (
    | { shortname?: string }
    | { accountOrAccountGroupId?: ActorEntityUuid | ActorGroupEntityUuid }
  ),
)

Source from the content-addressed store, hash-verified

26import type { TraversalPath } from "@rust/hash-graph-store/types";
27
28export const useUserOrOrg = (
29 params: {
30 includePermissions?: boolean;
31 includeAvatar?: boolean;
32 includeMembersOfOrg?: boolean;
33 traversalPaths?: TraversalPath[];
34 } & (
35 | { shortname?: string }
36 | { accountOrAccountGroupId?: ActorEntityUuid | ActorGroupEntityUuid }
37 ),
38) => {
39 const { data, loading, refetch } = useQuery<
40 QueryEntitySubgraphQuery,
41 QueryEntitySubgraphQueryVariables
42 >(queryEntitySubgraphQuery, {
43 variables: {
44 request: {
45 filter: {
46 all: [
47 ...("shortname" in params
48 ? [
49 {
50 equal: [
51 {
52 path: [
53 "properties",
54 systemPropertyTypes.shortname.propertyTypeBaseUrl,
55 ],
56 },
57 { parameter: params.shortname },
58 ],
59 },
60 ]
61 : "accountOrAccountGroupId" in params
62 ? [
63 {
64 equal: [
65 { path: ["uuid"] },
66 { parameter: params.accountOrAccountGroupId },
67 ],
68 },
69 ]
70 : []),
71 {
72 any: [
73 {
74 equal: [
75 { path: ["type", "baseUrl"] },
76 { parameter: systemEntityTypes.user.entityTypeBaseUrl },
77 ],
78 },
79 {
80 equal: [
81 { path: ["type", "baseUrl"] },
82 {
83 parameter:
84 systemEntityTypes.organization.entityTypeBaseUrl,
85 },

Callers 4

ProfilePageFunction · 0.90
MentionDisplayFunction · 0.90
AdminUserPageFunction · 0.90

Calls 6

getRootsFunction · 0.90
isEntityUserEntityFunction · 0.90
isEntityOrgEntityFunction · 0.90
reduceMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected