From 8582c5bdd2f2b15ecdbb87d86da351414b2abff5 Mon Sep 17 00:00:00 2001 From: Oleksandr Hladchenko <85172747+oleksandrhladchenko1@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:38:24 +0300 Subject: [PATCH] UIIN-2600: Remove error message after switch from Instance Edit screen to another app (#2311) * UIIN-2600: Remove error message after switch from Instance Edit screen to another app * UIIN-2600: Use ternary * Update CHANGELOG.md (cherry picked from commit 3411d728c864542ce30a6a91a5affc1af6fec06a) --- CHANGELOG.md | 1 + .../ConsortialHoldings/ConsortialHoldings.js | 18 +++++++++--------- src/edit/InstanceForm.js | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 943853786..2f63c6c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Edit instance success toast no longer shows the instance HRID. Fixes UIIN-2588. * Show facet options, if they exist, after clicking the +More button. Refs UIIN-2533. * If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608. +* Remove error message after switch from Instance Edit screen to another app. Fixes UIIN-2600. ## [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/Instance/InstanceDetails/ConsortialHoldings/ConsortialHoldings.js b/src/Instance/InstanceDetails/ConsortialHoldings/ConsortialHoldings.js index aae864206..e2a220c2d 100644 --- a/src/Instance/InstanceDetails/ConsortialHoldings/ConsortialHoldings.js +++ b/src/Instance/InstanceDetails/ConsortialHoldings/ConsortialHoldings.js @@ -23,20 +23,13 @@ import { } from '../../../hooks'; const ConsortialHoldings = ({ instance }) => { + const pathToAccordion = ['consortialHoldings', '_state']; const instanceId = instance?.id; - const prevInstanceId = useRef(instanceId); const stripes = useStripes(); + const prevInstanceId = useRef(instanceId); const { consortiaTenantsById } = useContext(DataContext); - const { tenants } = useSearchForShadowInstanceTenants({ instanceId }); - - const memberTenants = tenants - .map(tenant => consortiaTenantsById[tenant.id]) - .filter(tenant => !tenant?.isCentral && (tenant?.id !== stripes.okapi.tenant)) - .sort((a, b) => a.name.localeCompare(b.name)); - - const pathToAccordion = ['consortialHoldings', '_state']; const [isConsortialAccOpen, setConsortialAccOpen] = useHoldingsAccordionState({ instanceId, pathToAccordion }); useEffect(() => { @@ -46,6 +39,13 @@ const ConsortialHoldings = ({ instance }) => { } }, [instanceId]); + if (!consortiaTenantsById) return null; + + const memberTenants = tenants + .map(tenant => consortiaTenantsById[tenant.id]) + .filter(tenant => !tenant?.isCentral && (tenant?.id !== stripes.okapi.tenant)) + .sort((a, b) => a.name.localeCompare(b.name)); + return ( ({ label: refLookup(referenceTables.statisticalCodeTypes, code.statisticalCodeTypeId).name + ': ' + code.code + ' - ' + code.name, @@ -349,7 +349,7 @@ class InstanceForm extends React.Component { selected: code.id === initialValues.statisticalCodeId, }) ) - .sort((a, b) => a.label.localeCompare(b.label)); + .sort((a, b) => a.label.localeCompare(b.label)) : []; // Since preceding/succeeding title relationships are split out from other parent/child instances, // we don't want the type selection box for parent/child to include the preceding-succeeding type