Skip to content

Commit

Permalink
UIREC-423 Provide the '<FieldInventory>' component with the complete …
Browse files Browse the repository at this point in the history
…list of locations for mapping (#618)
  • Loading branch information
usavkov-epam committed Dec 13, 2024
1 parent bd4cc42 commit b2499f0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 132 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 6.1.0 (IN PROGRESS)

* Provide the `<FieldInventory>` component with the complete list of locations for mapping. Refs UIREC-423.

## [6.0.4](https://github.com/folio-org/ui-receiving/tree/v6.0.4) (2024-12-06)
[Full Changelog](https://github.com/folio-org/ui-receiving/compare/v6.0.3...v6.0.4)

Expand Down
1 change: 0 additions & 1 deletion src/TitleBindPieces/TitleBindPieces.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ const TitleBindPieces = ({
<TitleBindPiecesCreateItemForm
instanceId={instanceId}
selectLocation={form.mutators.setLocationValue}
bindItemValues={values?.bindItem}
/>
<FieldArray
id={FIELD_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
} from 'react-intl';

import {
validateRequired,
ConsortiumFieldInventory,
FieldInventory,
useLocationsQuery,
validateRequired,
} from '@folio/stripes-acq-components';
import {
Col,
Expand All @@ -18,7 +19,6 @@ import {
TextField,
} from '@folio/stripes/components';

import { useHoldingsAndLocations } from '../../common/hooks';
import { useReceivingSearchContext } from '../../contexts';
import { PIECE_FORM_FIELD_NAMES } from '../constants';
import {
Expand All @@ -29,20 +29,19 @@ import { buildOptions } from '../utils';

export const TitleBindPiecesCreateItemForm = ({
instanceId,
bindItemValues = {},
selectLocation,
}) => {
const { materialTypes } = useMaterialTypes();
const { loanTypes } = useLoanTypes();
const intl = useIntl();

const { locations } = useHoldingsAndLocations({
instanceId,
tenantId: bindItemValues.tenantId,
});

const { crossTenant } = useReceivingSearchContext();

const {
isLoading: isLocationsLoading,
locations,
} = useLocationsQuery({ consortium: crossTenant });

const FieldInventoryComponent = crossTenant
? ConsortiumFieldInventory
: FieldInventory;
Expand Down Expand Up @@ -132,6 +131,7 @@ export const TitleBindPiecesCreateItemForm = ({
<FieldInventoryComponent
affiliationName={PIECE_FORM_FIELD_NAMES.tenantId}
instanceId={instanceId}
isLoading={isLocationsLoading}
locationIds={locationIds}
locations={locations}
holdingName={PIECE_FORM_FIELD_NAMES.holdingId}
Expand All @@ -149,5 +149,4 @@ export const TitleBindPiecesCreateItemForm = ({
TitleBindPiecesCreateItemForm.propTypes = {
instanceId: PropTypes.string.isRequired,
selectLocation: PropTypes.func.isRequired,
bindItemValues: PropTypes.object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import {
screen,
} from '@folio/jest-config-stripes/testing-library/react';
import stripesFinalForm from '@folio/stripes/final-form';
import { useLocationsQuery } from '@folio/stripes-acq-components';

import { TitleBindPiecesCreateItemForm } from './TitleBindPiecesCreateItemForm';

jest.mock('@folio/stripes-acq-components', () => ({
...jest.requireActual('@folio/stripes-acq-components'),
ConsortiumFieldInventory: () => 'ConsortiumFieldInventory',
FieldInventory: () => 'FieldInventory',
useLocationsQuery: jest.fn(),
}));
jest.mock('../hooks', () => ({
useMaterialTypes: jest.fn().mockReturnValue({ materialTypes: [] }),
Expand Down Expand Up @@ -59,6 +61,14 @@ const renderComponent = (props = defaultProps) => render(
);

describe('TitleBindPiecesCreateItemForm', () => {
beforeEach(() => {
useLocationsQuery.mockReturnValue({ locations: [] });
});

afterEach(() => {
jest.clearAllMocks();
});

it('should render component', () => {
renderComponent();

Expand Down
1 change: 0 additions & 1 deletion src/common/hooks/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './useHoldingItems';
export * from './useHoldingsAndLocations';
export * from './useItem';
export * from './useOrder';
export * from './useOrganizationsBatch';
Expand Down
1 change: 0 additions & 1 deletion src/common/hooks/useHoldingsAndLocations/index.js

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit b2499f0

Please sign in to comment.