diff --git a/CHANGELOG.md b/CHANGELOG.md index b58071dda..d2f21a30f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Instance. Series heading has vanished in detailed view. Fixes UIIN-2601. * Remove error message after switch from Instance Edit screen to another app. Fixes UIIN-2600. * Enable/disable consortial holdings/item actions based on User permissions. Refs UIIN-2452. +* User receives an error when searching for an item in the Inventory app. Fixes UIIN-2634. ## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13) [Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0) diff --git a/src/ViewHoldingsRecord.js b/src/ViewHoldingsRecord.js index 35c0bc150..8684f4f6d 100644 --- a/src/ViewHoldingsRecord.js +++ b/src/ViewHoldingsRecord.js @@ -479,9 +479,10 @@ class ViewHoldingsRecord extends React.Component { referenceTables, goTo, stripes, - location: { state: { tenantFrom } }, + location, } = this.props; const { instance } = this.state; + const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant; if (this.isAwaitingResource()) return ; diff --git a/src/components/InstancesList/InstancesList.js b/src/components/InstancesList/InstancesList.js index afe57ce1e..49a468b63 100644 --- a/src/components/InstancesList/InstancesList.js +++ b/src/components/InstancesList/InstancesList.js @@ -16,6 +16,7 @@ import { import saveAs from 'file-saver'; import moment from 'moment'; import classnames from 'classnames'; +import { stringify } from 'query-string'; import { Pluggable, @@ -134,6 +135,7 @@ class InstancesList extends React.Component { }), stripes: PropTypes.object.isRequired, history: PropTypes.shape({ + push: PropTypes.func, listen: PropTypes.func, replace: PropTypes.func, }), @@ -956,8 +958,9 @@ class InstancesList extends React.Component { const { parentResources, parentMutator: { itemsByQuery }, - goTo, getParams, + stripes, + history, } = this.props; const { query, qindex } = parentResources?.query ?? {}; const { searchInProgress } = this.state; @@ -973,7 +976,10 @@ class InstancesList extends React.Component { } itemsByQuery.reset(); - const items = await itemsByQuery.GET({ params: { query: itemQuery } }); + const items = await itemsByQuery.GET({ + params: { query: itemQuery }, + tenant: stripes.okapi.tenant, + }); this.setState({ searchInProgress: false }); @@ -984,7 +990,13 @@ class InstancesList extends React.Component { } const { id, holdingsRecordId } = items[0]; - goTo(`/inventory/view/${instance.id}/${holdingsRecordId}/${id}`, getParams()); + const search = stringify(getParams()); + + history.push({ + pathname: `/inventory/view/${instance.id}/${holdingsRecordId}/${id}`, + search, + state: { tenantTo: stripes.okapi.tenant }, + }); return null; } diff --git a/src/components/InstancesList/InstancesList.test.js b/src/components/InstancesList/InstancesList.test.js index ea5f0f3d3..2c88470d9 100644 --- a/src/components/InstancesList/InstancesList.test.js +++ b/src/components/InstancesList/InstancesList.test.js @@ -559,6 +559,7 @@ describe('InstancesList', () => { params: { query: `${option}=="${_query}"`, }, + tenant: 'diku', }); }); }); diff --git a/src/routes/ItemRoute.js b/src/routes/ItemRoute.js index f3235ab5e..c55ec7d76 100644 --- a/src/routes/ItemRoute.js +++ b/src/routes/ItemRoute.js @@ -174,8 +174,9 @@ class ItemRoute extends React.Component { onClose = () => { const { stripes, - location: { state: { tenantFrom } }, + location, } = this.props; + const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant; switchAffiliation(stripes, tenantFrom, this.goBack); }