From 69c3e36bfed7d4a32e67d2d575bae57c38205591 Mon Sep 17 00:00:00 2001 From: DustyD Date: Wed, 20 Nov 2024 15:31:49 -0800 Subject: [PATCH] fix: lock ownership section in review page (#1738) Co-authored-by: Xiao Peng --- .../OwnershipStep/SingleOwnerInfo/index.tsx | 18 +++++++++++------- .../OwnershipStep/index.tsx | 2 ++ .../SeedlotReview/SeedlotReviewContent.tsx | 10 +--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/SingleOwnerInfo/index.tsx b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/SingleOwnerInfo/index.tsx index f75423014..2f78c7ebf 100644 --- a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/SingleOwnerInfo/index.tsx +++ b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/SingleOwnerInfo/index.tsx @@ -35,12 +35,15 @@ interface SingleOwnerInfoProps { setState: Function, readOnly?: boolean, isReview?: boolean + isOwnershipStep?: boolean } const SingleOwnerInfo = ({ ownerInfo, defaultAgency, defaultCode, fundingSourcesQuery, - methodsOfPaymentQuery, deleteAnOwner, checkPortionSum, setState, readOnly, isReview + methodsOfPaymentQuery, deleteAnOwner, checkPortionSum, setState, + readOnly, isReview, isOwnershipStep }: SingleOwnerInfoProps) => { + const isReadOnly = readOnly && (isOwnershipStep || !isReview); const [ownerPortionInvalidText, setOwnerPortionInvalidText] = useState( inputText.portion.invalidText ); @@ -150,7 +153,7 @@ const SingleOwnerInfo = ({ locationCode: StringInputType ) => setClientAndCode(client, locationCode) } - readOnly={readOnly && !isReview} + readOnly={isReadOnly} /> @@ -168,7 +171,7 @@ const SingleOwnerInfo = ({ }} invalid={ownerInfo.ownerPortion.isInvalid} invalidText={ownerPortionInvalidText} - readOnly={readOnly && !isReview} + readOnly={isReadOnly} /> @@ -188,7 +191,7 @@ const SingleOwnerInfo = ({ onWheel={(e: React.ChangeEvent) => e.target.blur()} invalid={ownerInfo.reservedPerc.isInvalid} invalidText={reservedInvalidText} - readOnly={readOnly && !isReview} + readOnly={isReadOnly} />
@@ -206,7 +209,7 @@ const SingleOwnerInfo = ({ onWheel={(e: React.ChangeEvent) => e.target.blur()} invalid={ownerInfo.surplusPerc.isInvalid} invalidText={surplusInvalidText} - readOnly={readOnly && !isReview} + readOnly={isReadOnly} />
@@ -233,7 +236,7 @@ const SingleOwnerInfo = ({ onChange={(e: ComboBoxEvent) => handleFundingSource(e.selectedItem)} invalid={ownerInfo.fundingSource.isInvalid} invalidText={inputText.funding.invalidText} - readOnly={readOnly && !isReview} + readOnly={isReadOnly} /> ) } @@ -258,7 +261,7 @@ const SingleOwnerInfo = ({ onChange={(e: ComboBoxEvent) => handleMethodOfPayment(e.selectedItem)} invalid={ownerInfo.methodOfPayment.isInvalid} invalidText={inputText.payment.invalidText} - readOnly={readOnly && !isReview} + readOnly={isReadOnly} /> ) @@ -276,6 +279,7 @@ const SingleOwnerInfo = ({ className="owner-mod-btn" renderIcon={TrashCan} onClick={() => deleteAnOwner(ownerInfo.id)} + disabled={isReadOnly} > Delete owner diff --git a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/index.tsx b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/index.tsx index 9361c5fe0..3733db244 100644 --- a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/index.tsx +++ b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/index.tsx @@ -221,6 +221,7 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => { } readOnly={isFormSubmitted || originalSeedQty > 0} isReview={isReview} + isOwnershipStep /> )) @@ -235,6 +236,7 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => { className="owner-add-btn" renderIcon={Add} onClick={addAnOwner} + disabled={originalSeedQty > 0} > Add owner diff --git a/frontend/src/views/Seedlot/SeedlotReview/SeedlotReviewContent.tsx b/frontend/src/views/Seedlot/SeedlotReview/SeedlotReviewContent.tsx index f47855484..a7f45fb1f 100644 --- a/frontend/src/views/Seedlot/SeedlotReview/SeedlotReviewContent.tsx +++ b/frontend/src/views/Seedlot/SeedlotReview/SeedlotReviewContent.tsx @@ -13,7 +13,7 @@ import { } from '@carbon/icons-react'; import { Beforeunload } from 'react-beforeunload'; -import { getSeedlotById, putAClassSeedlotProgress, getSeedlotFromOracleDbBySeedlotNumber } from '../../../api-service/seedlotAPI'; +import { getSeedlotById, putAClassSeedlotProgress } from '../../../api-service/seedlotAPI'; import { THREE_HALF_HOURS, THREE_HOURS } from '../../../config/TimeUnits'; import getVegCodes from '../../../api-service/vegetationCodeAPI'; import Breadcrumbs from '../../../components/Breadcrumbs'; @@ -105,12 +105,6 @@ const SeedlotReviewContent = () => { refetchOnMount: true }); - const getSeedlotBySeedlotNumberQuery = useQuery({ - queryKey: ['seedlot-by-seedlotNumber', seedlotNumber], - queryFn: () => getSeedlotFromOracleDbBySeedlotNumber(seedlotNumber ?? ''), - enabled: seedlotQuery.isFetched - }); - useEffect(() => { const { status } = seedlotQuery; @@ -556,8 +550,6 @@ const SeedlotReviewContent = () => { className="edit-save-btn" renderIcon={isReadMode ? Edit : Save} onClick={handleEditSaveBtn} - disabled={getSeedlotBySeedlotNumberQuery.isSuccess - && getSeedlotBySeedlotNumberQuery.data.data.originalSeedQty > 0} > {isReadMode ? 'Edit seedlot' : 'Save edit'}