Skip to content

Commit

Permalink
UIIN-3115: ECS | "FOLIO/MARC-shared" source is displayed in manually …
Browse files Browse the repository at this point in the history
…shared instance record
  • Loading branch information
mariia-aloshyna committed Nov 1, 2024
1 parent a7cbfe3 commit b6140a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for ui-inventory

## [12.0.1] (IN PROGRESS)

* ECS | "FOLIO/MARC-shared" source is displayed in manually shared instance record. Fixes UIIN-3115.

## [12.0.0](https://github.com/folio-org/ui-inventory/tree/v12.0.0) (2024-10-31)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.5...v12.0.0)

Expand Down
9 changes: 7 additions & 2 deletions src/common/hooks/useInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ import {
useMemo,
} from 'react';

import { useStripes } from '@folio/stripes/core';

import useSearchInstanceByIdQuery from './useSearchInstanceByIdQuery';
import useInstanceQuery from './useInstanceQuery';

const useInstance = (id) => {
const stripes = useStripes();
const centralTenantId = stripes.user.user?.consortium?.centralTenantId;

const {
refetch: refetchSearch,
isLoading: isSearchInstanceByIdLoading,
instance: _instance,
} = useSearchInstanceByIdQuery(id);

const instanceTenantId = _instance?.tenantId;
const isShared = _instance?.shared;
const instanceTenantId = isShared ? centralTenantId : _instance?.tenantId;

const {
refetch: refetchInstance,
Expand All @@ -26,7 +31,7 @@ const useInstance = (id) => {
} = useInstanceQuery(
id,
{ tenantId: instanceTenantId },
{ enabled: Boolean(id && !isSearchInstanceByIdLoading) }
{ enabled: Boolean(id && !isSearchInstanceByIdLoading && instanceTenantId) }
);

const instance = useMemo(
Expand Down

0 comments on commit b6140a1

Please sign in to comment.