diff --git a/src/ViewInstanceWrapper.js b/src/ViewInstanceWrapper.js index c50a21283..fddc7c78a 100644 --- a/src/ViewInstanceWrapper.js +++ b/src/ViewInstanceWrapper.js @@ -17,7 +17,13 @@ const ViewInstanceWrapper = (props) => { const userId = stripes?.user?.user?.id; const centralTenantId = stripes.user.user?.consortium?.centralTenantId; const consortiumId = stripes.user.user?.consortium?.id; - const { instance, isLoading, refetch, isError, error } = useInstance(id); + const { + instance, + isLoading, + refetch, + isError, + error, + } = useInstance(id); const isShared = Boolean(instance?.shared); const tenantId = instance?.tenantId ?? stripes.okapi.tenant; diff --git a/src/common/hooks/useInstance.js b/src/common/hooks/useInstance.js index 2e5df461b..585cb136d 100644 --- a/src/common/hooks/useInstance.js +++ b/src/common/hooks/useInstance.js @@ -4,12 +4,20 @@ import useSearchInstanceByIdQuery from './useSearchInstanceByIdQuery'; import useInstanceQuery from './useInstanceQuery'; const useInstance = (id) => { - const { isLoading: isSearchInstanceByIdLoading, instance: _instance } = useSearchInstanceByIdQuery(id); + const { + isLoading: isSearchInstanceByIdLoading, + instance: _instance, + } = useSearchInstanceByIdQuery(id); const instanceTenantId = _instance?.tenantId; const isShared = _instance?.shared; - const { isLoading: isInstanceLoading, instance: data, refetch, ...rest } = useInstanceQuery( + const { + isLoading: isInstanceLoading, + instance: data, + refetch, + ...rest + } = useInstanceQuery( id, { tenantId: instanceTenantId }, { enabled: Boolean(id && !isSearchInstanceByIdLoading) } diff --git a/src/common/hooks/useInstanceQuery/useInstanceQuery.js b/src/common/hooks/useInstanceQuery/useInstanceQuery.js index 05834e14d..4e478348a 100644 --- a/src/common/hooks/useInstanceQuery/useInstanceQuery.js +++ b/src/common/hooks/useInstanceQuery/useInstanceQuery.js @@ -8,7 +8,12 @@ const useInstanceQuery = (instanceId, { tenantId = '' } = {}, options = {}) => { const ky = useTenantKy({ tenantId }); const [namespace] = useNamespace({ key: 'instance' }); - const { isLoading, data: instance = {}, refetch, ...rest } = useQuery( + const { + isLoading, + data: instance = {}, + refetch, + ...rest + } = useQuery( [namespace, instanceId, tenantId], () => ky.get(`inventory/instances/${instanceId}`).json(), {