diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a62f06e..aad606ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,10 @@
# Change history for ui-receiving
-## 6.1.0 (IN PROGRESS)
+## 7.0.0 (IN PROGRESS)
* Add "Mark late" action to the piece form action menu. Refs UIREC-413.
* Hide "Add piece" action when related order has "Pending" status and "Synchronized" workflow. Refs UIREC-362.
+* *Breaking* Update "Send claim" action to use `pieces.send-claims` interface. Refs UIREC-412.
## [6.0.5](https://github.com/folio-org/ui-receiving/tree/v6.0.5) (2024-12-13)
[Full Changelog](https://github.com/folio-org/ui-receiving/compare/v6.0.4...v6.0.5)
diff --git a/package.json b/package.json
index eb74ff82..997e1d12 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
"orders-storage.settings": "1.0",
"organizations.organizations": "1.0",
"pieces": "3.1",
+ "pieces.send-claims": "1.0",
"receiving": "2.0",
"search": "0.5 0.6 1.0",
"tags": "1.0",
@@ -158,10 +159,12 @@
"inventory.instances.collection.get",
"inventory.instances.item.get",
"orders.bind-pieces.collection.post",
+ "orders.pieces.collection.put",
"orders.routing-lists.item.delete",
"orders.routing-lists.item.put",
"orders.routing-lists.item.post",
"orders.titles.item.put",
+ "pieces.send-claims.collection.post",
"search.instances.collection.get",
"search.facets.collection.get"
]
diff --git a/src/Piece/DelayClaimModal/DelayClaimModal.js b/src/Piece/DelayClaimModal/DelayClaimModal.js
deleted file mode 100644
index 0a7688e9..00000000
--- a/src/Piece/DelayClaimModal/DelayClaimModal.js
+++ /dev/null
@@ -1,80 +0,0 @@
-import PropTypes from 'prop-types';
-import {
- FormattedMessage,
- useIntl,
-} from 'react-intl';
-
-import {
- Button,
- Col,
- Modal,
- Row,
-} from '@folio/stripes/components';
-import stripesFinalForm from '@folio/stripes/final-form';
-import { ModalFooter } from '@folio/stripes-acq-components';
-
-import { FieldClaimingDate } from '../../common/components';
-
-const DelayClaimModal = ({
- onCancel,
- handleSubmit,
- open,
-}) => {
- const intl = useIntl();
- const modalLabel = intl.formatMessage({ id: 'ui-receiving.modal.delayClaim.heading' });
-
- const start = (
-
- );
- const end = (
-
- );
-
- const footer = (
-
- );
-
- return (
-
-
-
- );
-};
-
-DelayClaimModal.propTypes = {
- handleSubmit: PropTypes.func.isRequired,
- onCancel: PropTypes.func.isRequired,
- open: PropTypes.bool,
-};
-
-export default stripesFinalForm({
- navigationCheck: true,
- subscription: { values: true },
-})(DelayClaimModal);
diff --git a/src/Piece/DelayClaimModal/DelayClaimModal.test.js b/src/Piece/DelayClaimModal/DelayClaimModal.test.js
deleted file mode 100644
index f784d351..00000000
--- a/src/Piece/DelayClaimModal/DelayClaimModal.test.js
+++ /dev/null
@@ -1,73 +0,0 @@
-import moment from 'moment';
-import { MemoryRouter } from 'react-router-dom';
-
-import user from '@folio/jest-config-stripes/testing-library/user-event';
-import { render, screen } from '@folio/jest-config-stripes/testing-library/react';
-
-import DelayClaimModal from './DelayClaimModal';
-
-const FORMAT = 'MM/DD/YYYY';
-const today = moment();
-
-const defaultProps = {
- onCancel: jest.fn(),
- onSubmit: jest.fn(),
- open: true,
-};
-
-const renderDelayClaimModal = (props = {}) => render(
- ,
- { wrapper: MemoryRouter },
-);
-
-describe('DelayClaimModal', () => {
- beforeEach(() => {
- defaultProps.onCancel.mockClear();
- defaultProps.onSubmit.mockClear();
- });
-
- it('should render delay claim modal', () => {
- renderDelayClaimModal();
-
- expect(screen.getByText('ui-receiving.modal.delayClaim.heading')).toBeInTheDocument();
- });
-
- it('should validate "Delay to" field', async () => {
- renderDelayClaimModal();
-
- const saveBtn = screen.getByRole('button', { name: 'stripes-acq-components.FormFooter.save' });
-
- await user.click(saveBtn);
- expect(screen.getByText('stripes-acq-components.validation.required')).toBeInTheDocument();
-
- await user.type(screen.getByPlaceholderText(FORMAT), today.format(FORMAT));
- await user.click(saveBtn);
- expect(screen.getByText('ui-receiving.validation.dateAfter')).toBeInTheDocument();
- });
-
- it('should submit valid form', async () => {
- renderDelayClaimModal();
-
- const date = today.add(3, 'days');
-
- await user.type(screen.getByPlaceholderText(FORMAT), date.format(FORMAT));
- await user.click(screen.getByRole('button', { name: 'stripes-acq-components.FormFooter.save' }));
-
- expect(defaultProps.onSubmit).toHaveBeenCalledWith(
- { claimingDate: date.format('YYYY-MM-DD') },
- expect.anything(),
- expect.anything(),
- );
- });
-
- it('should call "onCancel" when the modal dismissed', async () => {
- renderDelayClaimModal();
-
- await user.click(screen.getByRole('button', { name: 'stripes-acq-components.FormFooter.cancel' }));
-
- expect(defaultProps.onCancel).toHaveBeenCalled();
- });
-});
diff --git a/src/Piece/DelayClaimModal/index.js b/src/Piece/DelayClaimModal/index.js
deleted file mode 100644
index 974c50e9..00000000
--- a/src/Piece/DelayClaimModal/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default as DelayClaimModal } from './DelayClaimModal';
diff --git a/src/Piece/PieceForm/PieceForm.js b/src/Piece/PieceForm/PieceForm.js
index 6fd565ad..77ca5cf7 100644
--- a/src/Piece/PieceForm/PieceForm.js
+++ b/src/Piece/PieceForm/PieceForm.js
@@ -25,17 +25,16 @@ import {
import { useStripes } from '@folio/stripes/core';
import { ViewMetaData } from '@folio/stripes/smart-components';
import {
+ DelayClaimsModal,
DeleteHoldingsModal,
+ getClaimingIntervalFromDate,
handleKeyCommand,
PIECE_FORMAT,
PIECE_STATUS,
useModalToggle,
} from '@folio/stripes-acq-components';
-import {
- getClaimingIntervalFromDate,
- setLocationValueFormMutator,
-} from '../../common/utils';
+import { setLocationValueFormMutator } from '../../common/utils';
import {
PIECE_ACTION_NAMES,
PIECE_FORM_FIELD_NAMES,
@@ -43,10 +42,8 @@ import {
PIECE_MODAL_ACCORDION,
PIECE_MODAL_ACCORDION_LABELS,
} from '../constants';
-import { DelayClaimModal } from '../DelayClaimModal';
import { DeletePieceModal } from '../DeletePieceModal';
import { ReceivingStatusChangeLog } from '../ReceivingStatusChangeLog';
-import { SendClaimModal } from '../SendClaimModal';
import { ItemFields } from './ItemFields';
import { PieceFields } from './PieceFields';
import { PieceFormActionButtons } from './PieceFormActionButtons';
@@ -60,6 +57,7 @@ const PieceForm = ({
hasValidationErrors,
initialValues,
instanceId,
+ onClaimSend: onClaimSendProp,
onClose,
onDelete: onDeleteProp,
onUnreceive: onUnreceiveProp,
@@ -84,10 +82,8 @@ const PieceForm = ({
const {
enumeration,
- externalNote,
format,
id,
- internalNote,
itemId,
bindItemId,
isBound,
@@ -110,7 +106,6 @@ const PieceForm = ({
const [isDeleteConfirmation, toggleDeleteConfirmation] = useModalToggle();
const [isDeleteHoldingsConfirmation, toggleDeleteHoldingsConfirmation] = useModalToggle();
const [isClaimDelayModalOpen, toggleClaimDelayModal] = useModalToggle();
- const [isClaimSendModalOpen, toggleClaimSendModal] = useModalToggle();
const { protectCreate, protectUpdate, protectDelete } = restrictionsByAcqUnit;
const isEditMode = Boolean(id);
@@ -124,6 +119,11 @@ const PieceForm = ({
? PIECE_MODAL_ACCORDION.originalItemDetails
: PIECE_MODAL_ACCORDION.itemDetails;
+ const onDeleteHoldingsModalCancel = useCallback(() => {
+ change(PIECE_FORM_SERVICE_FIELD_NAMES.postSubmitAction, null);
+ toggleDeleteHoldingsConfirmation();
+ }, [change, toggleDeleteHoldingsConfirmation]);
+
const onChangeDisplayOnHolding = useCallback(({ target: { checked } }) => {
change(PIECE_FORM_FIELD_NAMES.displayOnHolding, checked);
@@ -191,13 +191,15 @@ const PieceForm = ({
onStatusChange(PIECE_STATUS.claimDelayed);
}, [change, onStatusChange]);
- const onClaimSend = useCallback(({ claimingDate, ...rest }) => {
+ const onClaimSend = useCallback(async () => {
+ const updatedFields = await onClaimSendProp(formValues);
+
batch(() => {
- change(PIECE_FORM_FIELD_NAMES.claimingInterval, getClaimingIntervalFromDate(claimingDate));
- Object.entries(rest).forEach(([field, value]) => change(field, value));
+ change(PIECE_FORM_SERVICE_FIELD_NAMES.postSubmitAction, PIECE_ACTION_NAMES.sendClaim);
+ Object.entries(updatedFields).forEach(([field, value]) => change(field, value));
});
- onStatusChange(PIECE_STATUS.claimSent);
- }, [batch, change, onStatusChange]);
+ onSave();
+ }, [batch, change, formValues, onClaimSendProp, onSave]);
const onDelete = useCallback((options) => {
return onDeleteProp({ id, enumeration }, options);
@@ -232,7 +234,7 @@ const PieceForm = ({
isEditMode={isEditMode}
onCreateAnotherPiece={onCreateAnotherPiece}
onClaimDelay={toggleClaimDelayModal}
- onClaimSend={toggleClaimSendModal}
+ onClaimSend={onClaimSend}
onDelete={toggleDeleteConfirmation}
onReceive={onQuickReceive}
onUnreceivePiece={onUnreceive}
@@ -364,25 +366,18 @@ const PieceForm = ({
{
isDeleteHoldingsConfirmation && (
)
}
-
-
-
@@ -400,6 +395,7 @@ PieceForm.propTypes = {
instanceId: PropTypes.string,
locationIds: PropTypes.arrayOf(PropTypes.string).isRequired,
locations: PropTypes.arrayOf(PropTypes.object),
+ onClaimSend: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onUnreceive: PropTypes.func.isRequired,
diff --git a/src/Piece/PieceForm/PieceForm.test.js b/src/Piece/PieceForm/PieceForm.test.js
index f766231c..7485cd5a 100644
--- a/src/Piece/PieceForm/PieceForm.test.js
+++ b/src/Piece/PieceForm/PieceForm.test.js
@@ -1,11 +1,10 @@
-import moment from 'moment';
-
import user from '@folio/jest-config-stripes/testing-library/user-event';
import {
act,
screen,
waitFor,
} from '@folio/jest-config-stripes/testing-library/react';
+import { dayjs } from '@folio/stripes/components';
import {
FieldInventory,
INVENTORY_RECORDS_TYPE,
@@ -90,7 +89,7 @@ const logs = [
];
const DATE_FORMAT = 'MM/DD/YYYY';
-const today = moment();
+const today = dayjs();
const renderPieceForm = (props = {}) => renderWithRouter(
{
await user.click(dropdownButton);
- const unReceiveButton = screen.getByTestId('unReceivable-piece-button');
+ const unreceivableButton = screen.getByTestId('unreceivable-button');
- await user.click(unReceiveButton);
+ await user.click(unreceivableButton);
expect(defaultProps.onSubmit).toHaveBeenCalled();
});
@@ -392,7 +391,7 @@ describe('PieceForm', () => {
it('should handle "Delay claim" action', async () => {
await user.click(screen.getByTestId('delay-claim-button'));
- await user.type(screen.getByRole('textbox', { name: 'ui-receiving.modal.delayClaim.field.delayTo' }), date.format(DATE_FORMAT));
+ await user.type(screen.getByRole('textbox', { name: /field.delayTo/ }), date.format(DATE_FORMAT));
await user.click(await findButton('stripes-acq-components.FormFooter.save'));
expect(defaultProps.onSubmit).toHaveBeenCalledWith(
@@ -404,20 +403,5 @@ describe('PieceForm', () => {
expect.anything(),
);
});
-
- it('should handle "Send claim" action', async () => {
- await user.click(screen.getByTestId('send-claim-button'));
- await user.type(screen.getByRole('textbox', { name: 'ui-receiving.modal.sendClaim.field.claimExpiryDate' }), date.format(DATE_FORMAT));
- await user.click(await findButton('stripes-acq-components.FormFooter.save'));
-
- expect(defaultProps.onSubmit).toHaveBeenCalledWith(
- expect.objectContaining({
- claimingInterval: 3,
- receivingStatus: PIECE_STATUS.claimSent,
- }),
- expect.anything(),
- expect.anything(),
- );
- });
});
});
diff --git a/src/Piece/PieceForm/PieceFormActionButtons/constants.js b/src/Piece/PieceForm/PieceFormActionButtons/constants.js
index d6e35765..24e56532 100644
--- a/src/Piece/PieceForm/PieceFormActionButtons/constants.js
+++ b/src/Piece/PieceForm/PieceFormActionButtons/constants.js
@@ -5,15 +5,20 @@ import {
Button,
Icon,
} from '@folio/stripes/components';
-import { PIECE_STATUS } from '@folio/stripes-acq-components';
+import {
+ DelayClaimActionMenuItem,
+ MarkUnreceivableActionMenuItem,
+ PIECE_STATUS,
+ SendClaimActionMenuItem,
+} from '@folio/stripes-acq-components';
import { PIECE_ACTION_NAMES } from '../../constants';
export const EXPECTED_PIECES_ACTIONS = [
PIECE_ACTION_NAMES.saveAndCreate,
PIECE_ACTION_NAMES.quickReceive,
- PIECE_ACTION_NAMES.sendClaim,
PIECE_ACTION_NAMES.markLate,
+ PIECE_ACTION_NAMES.sendClaim,
PIECE_ACTION_NAMES.delayClaim,
PIECE_ACTION_NAMES.unReceivable,
PIECE_ACTION_NAMES.delete,
@@ -49,19 +54,13 @@ export const PIECE_ACTIONS = ({
onUnreceivePiece,
}) => ({
[PIECE_ACTION_NAMES.delayClaim]: (
-
+ />
),
[PIECE_ACTION_NAMES.delete]: isEditMode ? (