MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / useMaybeCurrentOrganizationId

Function useMaybeCurrentOrganizationId

console/src/api/auth.tsx:178–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176// items in local storage. Thus we use this hook out of convenience and return null
177// in deployment modes where the organization ID is not available.
178export function useMaybeCurrentOrganizationId() {
179 const appConfig = useAppConfig();
180 const isLocalImpersonation =
181 appConfig.mode === "cloud" &&
182 appConfig.isImpersonating &&
183 appConfig.isLocalImpersonation;
184
185 const isCurrentOrganizationFetchEnabled =
186 appConfig.mode !== "self-managed" && !isLocalImpersonation;
187
188 const res = useQuery({
189 queryKey: queryKeys.currentOrganization(),
190 queryFn: fetchCurrentOrganization,
191 enabled: isCurrentOrganizationFetchEnabled,
192 select: (data) => data.id,
193 // We don't expect the organization ID to change and we already reset the
194 // query cache on organization change.
195 staleTime: Infinity,
196 });
197
198 if (!isCurrentOrganizationFetchEnabled) {
199 return null;
200 }
201
202 return res;
203}
204
205export function useIntercomJwt() {
206 const {

Callers 5

OrgTagFunction · 0.90
EnvironmentRoutesFunction · 0.90
IndexListFunction · 0.90
useShowSystemObjectsFunction · 0.90
segment.tsFile · 0.90

Calls 1

useAppConfigFunction · 0.90

Tested by

no test coverage detected