From 4e6378d3168ecaeaf6a36644e895f57318cc03fd Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Thu, 28 Nov 2024 14:32:52 +0400 Subject: [PATCH] UIORGS-356 Fix aliases version field (#659) * UIORGS-356 Fix aliases version field * update tests --- .../OrganizationSummaryVersionView.js | 25 ++++++++++++++----- .../useSelectedOrganizationVersion.js | 1 - .../useSelectedOrganizationVersion.test.js | 1 - 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Organizations/OrganizationVersion/components/OrganizationSummaryVersionView/OrganizationSummaryVersionView.js b/src/Organizations/OrganizationVersion/components/OrganizationSummaryVersionView/OrganizationSummaryVersionView.js index 2385fd1a..d3cd65f8 100644 --- a/src/Organizations/OrganizationVersion/components/OrganizationSummaryVersionView/OrganizationSummaryVersionView.js +++ b/src/Organizations/OrganizationVersion/components/OrganizationSummaryVersionView/OrganizationSummaryVersionView.js @@ -1,8 +1,13 @@ import PropTypes from 'prop-types'; +import { + useContext, + useMemo, +} from 'react'; import { FormattedMessage } from 'react-intl'; import { Col, + KeyValue, NoValue, Row, } from '@folio/stripes/components'; @@ -11,11 +16,16 @@ import { LANG_LABEL_BY_CODE, VersionCheckbox, VersionKeyValue, + VersionViewContext, } from '@folio/stripes-acq-components'; import { ORGANIZATION_SECTIONS } from '../../../constants'; export const OrganizationSummaryVersionView = ({ version }) => { + const versionContext = useContext(VersionViewContext); + + const changedFieldNameSet = useMemo(() => new Set(versionContext?.paths), [versionContext?.paths]); + return ( <> @@ -113,12 +123,15 @@ export const OrganizationSummaryVersionView = ({ version }) => { - } - value={version?.alternativeNames || } - multiple - /> + }> + { + version?.aliases?.map(({ value }, indx, arr) => { + const displayValue = changedFieldNameSet.has(`aliases[${indx}].value`) ? {value} : value; + + return <>{displayValue}{indx !== arr.length - 1 && ', '}; + }) + } + diff --git a/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.js b/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.js index be89fbf3..b8f285e8 100644 --- a/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.js +++ b/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.js @@ -104,7 +104,6 @@ export const useSelectedOrganizationVersion = ({ versionId, versions, snapshotPa acqUnits: account?.acqUnitIds?.map((acqUnitId) => acqUnitsMap[acqUnitId]?.name || deletedRecordLabel), })), acqUnits: acqUnitsIds.map(acqUnitsId => acqUnitsMap[acqUnitsId]?.name || deletedRecordLabel).join(', '), - alternativeNames: versionSnapshot?.aliases?.map(({ value }) => value).join(', '), vendorCurrenciesValue, metadata, }; diff --git a/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.test.js b/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.test.js index 752aff62..73809bb2 100644 --- a/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.test.js +++ b/src/Organizations/OrganizationVersion/hooks/useSelectedOrganizationVersion/useSelectedOrganizationVersion.test.js @@ -79,7 +79,6 @@ describe('useSelectedOrganizationVersion', () => { acqUnits: [], })), acqUnits: '', - alternativeNames: 'Amazon', contactsList: contacts, interfacesList: interfaces, vendorCurrenciesValue: 'US Dollar (USD)',