Skip to content

Commit

Permalink
add invalid reference argument to the getHoldingLocationName fn
Browse files Browse the repository at this point in the history
  • Loading branch information
usavkov-epam committed Jul 31, 2024
1 parent f359ab7 commit dbc8ce2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/FieldHolding/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ export const getCallNumber = ({ callNumber = '', callNumberPrefix = '', callNumb
`${callNumberPrefix}${callNumber}${callNumberSuffix}`.trim()
);

export const getHoldingLocationName = (holding = {}, locationsMap = {}) => {
export const getHoldingLocationName = (
holding = {},
locationsMap = {},
invalidReferenceMessage = <FormattedMessage id="stripes-acq-components.invalidReference" />,
) => {
const callNumberLabel = getCallNumber(holding);
const separator = callNumberLabel ? ' > ' : '';
const locationName = locationsMap[holding.permanentLocationId]?.name;

return locationName ? `${locationName}${separator}${callNumberLabel}` : <FormattedMessage id="stripes-acq-components.invalidReference" />;
return locationName ? `${locationName}${separator}${callNumberLabel}` : invalidReferenceMessage;
};

export const getHoldingOptions = (holdings = [], locationsMap = {}) => (
Expand Down

0 comments on commit dbc8ce2

Please sign in to comment.