Skip to content

Commit

Permalink
UIORGS-356 Fix aliases version field
Browse files Browse the repository at this point in the history
  • Loading branch information
usavkov-epam committed Nov 28, 2024
1 parent 1b58202 commit 8dfeecd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 (
<>
<Row>
Expand Down Expand Up @@ -113,12 +123,15 @@ export const OrganizationSummaryVersionView = ({ version }) => {
</Col>

<Col xs={3}>
<VersionKeyValue
name="aliases"
label={<FormattedMessage id="ui-organizations.summary.alternativeNames" />}
value={version?.alternativeNames || <NoValue />}
multiple
/>
<KeyValue label={<FormattedMessage id="ui-organizations.summary.alternativeNames" />}>
{
version?.aliases?.map(({ value }, indx, arr) => {
const displayValue = changedFieldNameSet.has(`aliases[${indx}].value`) ? <mark>{value}</mark> : value;

return <>{displayValue}{indx !== arr.length - 1 && ', '}</>;
})
}
</KeyValue>
</Col>
</Row>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit 8dfeecd

Please sign in to comment.