diff --git a/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestEditPage.tsx b/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestEditPage.tsx index 855e30b444..11521842ef 100644 --- a/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestEditPage.tsx +++ b/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestEditPage.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { BasicSpinner, DetailContainer, @@ -27,6 +27,8 @@ export const RequestLineEditPage = () => { lines, currentItem ); + const isPacksEnabled = !!draft?.defaultPackSize; + const [isPacks, setIsPacks] = useState(isPacksEnabled); const enteredLineIds = lines ? lines .filter(line => line.requestedQuantity !== 0) @@ -71,6 +73,9 @@ export const RequestLineEditPage = () => { hasPrevious={hasPrevious} previous={previous} isProgram={!!data?.programName} + isPacksEnabled={isPacksEnabled} + isPacks={isPacks} + setIsPacks={setIsPacks} /> } diff --git a/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestLineEdit.tsx b/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestLineEdit.tsx index e698fcf2c2..4a53d2b6db 100644 --- a/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestLineEdit.tsx +++ b/client/packages/requisitions/src/RequestRequisition/DetailView/RequestLineEdit/RequestLineEdit.tsx @@ -12,6 +12,7 @@ import { NumUtils, Popover, ReasonOptionNodeType, + Switch, TextArea, useAuthContext, useToggle, @@ -33,6 +34,9 @@ interface RequestLineEditProps { hasPrevious: boolean; previous: ItemRowFragment | null; isProgram: boolean; + isPacksEnabled: boolean; + isPacks: boolean; + setIsPacks: (isPacks: boolean) => void; } export const RequestLineEdit = ({ @@ -44,6 +48,9 @@ export const RequestLineEdit = ({ hasPrevious, previous, isProgram, + isPacksEnabled, + isPacks, + setIsPacks, }: RequestLineEditProps) => { const t = useTranslation(); const { isOn, toggle } = useToggle(); @@ -180,12 +187,35 @@ export const RequestLineEdit = ({ {/* Right column content */} + + {isPacksEnabled && ( + + setIsPacks(checked)} + size="small" + /> + + {t('label.packs')} + + + )} + + { if (draft?.suggestedQuantity === value) { update({ @@ -231,6 +261,49 @@ export const RequestLineEdit = ({ )} + + {isPacksEnabled && ( + { + update({ + requestedQuantity: + (quantity ?? 0) * (draft?.defaultPackSize ?? 0), + }); + }} + /> + } + labelWidth={LABEL_WIDTH} + sx={{ marginBottom: 1 }} + label={t('label.requested-packs')} + /> + )} + + {isPacksEnabled ? ( + + } + labelWidth={LABEL_WIDTH} + label={t('label.default-pack-size')} + sx={{ marginBottom: 1 }} + /> + ) : null} + & { isCreated: boolean; requisitionId: string; + defaultPackSize: number; }; const createDraftFromItem = ( @@ -44,6 +45,7 @@ const createDraftFromItem = ( additionInUnits: 0, daysOutOfStock: 0, expiringUnits: 0, + defaultPackSize: item.defaultPackSize, }; }; @@ -58,6 +60,7 @@ const createDraftFromRequestLine = ( suggestedQuantity: line.suggestedQuantity, isCreated: false, itemStats: line.itemStats, + defaultPackSize: line.item.defaultPackSize, }); export const useDraftRequisitionLine = (