Skip to content

Commit

Permalink
UISACQCOMP-194 Update filters to support central ordering search (#801)
Browse files Browse the repository at this point in the history
* UISACQCOMP-194 Update filters to support central ordering search

* add invalid reference argument to the getHoldingLocationName fn
  • Loading branch information
usavkov-epam authored Jul 31, 2024
1 parent 29517b8 commit d4faea1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 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
3 changes: 3 additions & 0 deletions lib/LocationFilter/LocationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const LocationFilter = ({
locations = [],
onChange,
disabled = false,
tenantId,
}) => {
const intl = useIntl();

Expand Down Expand Up @@ -82,6 +83,7 @@ const LocationFilter = ({
searchButtonStyle="link"
crossTenant={crossTenant}
disabled={disabled || isLoading}
tenantId={tenantId}
/>
</FilterAccordion>
);
Expand All @@ -98,6 +100,7 @@ LocationFilter.propTypes = {
locations: PropTypes.arrayOf(PropTypes.object),
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
tenantId: PropTypes.string,
};

export default LocationFilter;
8 changes: 7 additions & 1 deletion lib/LocationFilter/LocationFilterContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ const LocationFilterContainer = ({
labelId,
onChange,
disabled,
tenantId,
}) => {
const {
locations,
isLoading,
} = useLocationsQuery({ consortium: crossTenant });
} = useLocationsQuery({
consortium: crossTenant,
tenantId,
});

return (
<LocationFilter
Expand All @@ -30,6 +34,7 @@ const LocationFilterContainer = ({
labelId={labelId}
locations={locations}
onChange={onChange}
tenantId={tenantId}
/>
);
};
Expand All @@ -43,6 +48,7 @@ LocationFilterContainer.propTypes = {
labelId: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
tenantId: PropTypes.string,
};

export default LocationFilterContainer;
4 changes: 2 additions & 2 deletions lib/OrganizationFilter/PluggableOrganizationFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PluggableOrganizationFilter = ({
onChange,
tenantId,
}) => {
const [selectedOrganization, setSelectedOrganization] = useState({});
const [selectedOrganization, setSelectedOrganization] = useState();

useOrganization(activeFilters?.[0], {
tenantId,
Expand Down Expand Up @@ -54,7 +54,7 @@ const PluggableOrganizationFilter = ({
aria-label={label}
marginBottom0
type="text"
value={(activeFilters && activeFilters[0] && selectedOrganization.name) || ''}
value={(activeFilters && activeFilters[0] && selectedOrganization?.name) || ''}
disabled
/>

Expand Down

0 comments on commit d4faea1

Please sign in to comment.