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 (#2661)
  • Loading branch information
mariia-aloshyna authored Nov 4, 2024
1 parent 96b015c commit 3e36a66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [12.0.1] (IN PROGRESS)

* Run `history.replace` once during component mount and update to avoid URL rewriting. Refs UIIN-3099.
* 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 3e36a66

Please sign in to comment.