diff --git a/src/OrderLinesList/Details/OrderLineDetails.js b/src/OrderLinesList/Details/OrderLineDetails.js index fe832be21..02f43e70a 100644 --- a/src/OrderLinesList/Details/OrderLineDetails.js +++ b/src/OrderLinesList/Details/OrderLineDetails.js @@ -92,6 +92,17 @@ const OrderLineDetails = ({ [lineId, order], ); + const goToReceive = useCallback( + () => { + history.push({ + pathname: '/receiving', + search: `qindex=poLine.poLineNumber&query=${line.poLineNumber}`, + }); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [lineId, line], + ); + const deleteLine = useCallback( () => { const lineNumber = line.poLineNumber; @@ -206,6 +217,7 @@ const OrderLineDetails = ({ materialTypes={materialTypes} funds={funds} goToOrderDetails={goToOrderDetails} + goToReceive={goToReceive} deleteLine={deleteLine} cancelLine={cancelLine} tagsToggle={toggleTagsPane} diff --git a/src/components/POLine/POLine.js b/src/components/POLine/POLine.js index ea73d569d..058973fe3 100644 --- a/src/components/POLine/POLine.js +++ b/src/components/POLine/POLine.js @@ -93,6 +93,17 @@ function POLine({ [orderId], ); + const goToReceive = useCallback( + () => { + history.push({ + pathname: '/receiving', + search: `qindex=poLine.poLineNumber&query=${line.poLineNumber}`, + }); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [lineId, line], + ); + const deleteLine = useCallback( () => { const lineNumber = line?.poLineNumber; @@ -211,6 +222,7 @@ function POLine({ locations={locations} poURL={poURL} funds={funds} + goToReceive={goToReceive} deleteLine={deleteLine} cancelLine={cancelLine} tagsToggle={toggleTagsPane} diff --git a/src/components/POLine/POLineActionMenu/POLineActionMenu.js b/src/components/POLine/POLineActionMenu/POLineActionMenu.js index 206ed60a6..a5c1ef126 100644 --- a/src/components/POLine/POLineActionMenu/POLineActionMenu.js +++ b/src/components/POLine/POLineActionMenu/POLineActionMenu.js @@ -28,6 +28,7 @@ export const POLineActionMenu = ({ onDeleteLine, onEditLine, onNavigateToOrder, + onReceive, onPrintLine, onPrintOrder, onReexport, @@ -56,6 +57,11 @@ export const POLineActionMenu = ({ onNavigateToOrder(); }, [onNavigateToOrder, onToggle]); + const onClickReceive = useCallback(() => { + onToggle(); + onReceive(); + }, [onReceive, onToggle]); + const onClickReexport = useCallback(() => { onToggle(); onReexport(); @@ -137,7 +143,7 @@ export const POLineActionMenu = ({ data-testid="line-details-receive-action" buttonStyle="dropdownItem" data-test-line-receive-button - to={`/receiving?qindex=poLine.poLineNumber&query=${line.poLineNumber}`} + onClick={onClickReceive} > @@ -232,6 +238,7 @@ POLineActionMenu.propTypes = { onDeleteLine: PropTypes.func.isRequired, onEditLine: PropTypes.func.isRequired, onNavigateToOrder: PropTypes.func, + onReceive: PropTypes.func, onPrintLine: PropTypes.func.isRequired, onPrintOrder: PropTypes.func.isRequired, onReexport: PropTypes.func.isRequired, diff --git a/src/components/POLine/POLineView.js b/src/components/POLine/POLineView.js index 759cb77e5..9ee7b49a0 100644 --- a/src/components/POLine/POLineView.js +++ b/src/components/POLine/POLineView.js @@ -127,6 +127,7 @@ const POLineView = ({ deleteLine, editable, goToOrderDetails, + goToReceive, history, line, location, @@ -265,6 +266,7 @@ const POLineView = ({ onDeleteLine={toggleConfirmDelete} onEditLine={onEditPOLine} onNavigateToOrder={goToOrderDetails} + onReceive={goToReceive} onPrintLine={togglePrintLineModal} onPrintOrder={togglePrintOrderModal} onReexport={toggleOrderLineReexportModal} @@ -274,6 +276,7 @@ const POLineView = ({ }, [ editable, goToOrderDetails, + goToReceive, hiddenFields, isCancelable, isRestrictionsLoading, @@ -646,6 +649,7 @@ POLineView.propTypes = { onClose: PropTypes.func, editable: PropTypes.bool, goToOrderDetails: PropTypes.func, + goToReceive: PropTypes.func, deleteLine: PropTypes.func, cancelLine: PropTypes.func, tagsToggle: PropTypes.func.isRequired, diff --git a/src/components/PurchaseOrder/getPOActionMenu.js b/src/components/PurchaseOrder/getPOActionMenu.js index 45b800997..b08bff0fb 100644 --- a/src/components/PurchaseOrder/getPOActionMenu.js +++ b/src/components/PurchaseOrder/getPOActionMenu.js @@ -152,7 +152,10 @@ export function getPOActionMenu({ buttonStyle="dropdownItem" data-test-receiving-button data-testid="order-receiving-button" - onClick={clickReceive} + onClick={() => { + onToggle(); + clickReceive(); + }} >