()
| 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. |
| 178 | export 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 | |
| 205 | export function useIntercomJwt() { |
| 206 | const { |
no test coverage detected