@@ -165,9 +186,9 @@ const OwnershipStep = ({ isReview }: OwnershipStepProps) => {
title={(
diff --git a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/utils.ts b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/utils.ts
index 194d62e91..d94755a98 100644
--- a/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/utils.ts
+++ b/frontend/src/components/SeedlotRegistrationSteps/OwnershipStep/utils.ts
@@ -1,3 +1,4 @@
+import { ForestClientType } from '../../../types/ForestClientTypes/ForestClientType';
import MultiOptionsObj from '../../../types/MultiOptionsObject';
import { emptyOwnershipStep } from '../../../views/Seedlot/ContextContainerClassA/constants';
import { inputText, createOwnerTemplate } from './constants';
@@ -106,7 +107,10 @@ export const arePortionsValid = (ownershipArray: Array
): boolea
return Number(sum.toFixed(2)) === 100;
};
-export const getOwnerAgencyTitle = (desc: string): string => desc.substring(
- desc.indexOf('-') + 1,
- desc.lastIndexOf('-')
-).trim();
+export const getOwnerAgencyTitle = (fc: ForestClientType | undefined): string => {
+ if (!fc) {
+ return 'Owner agency name';
+ }
+
+ return fc.clientName;
+};
diff --git a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/CalculateMetrics.tsx b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/CalculateMetrics.tsx
index 019b0b4f6..ca2e3a3ef 100644
--- a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/CalculateMetrics.tsx
+++ b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/CalculateMetrics.tsx
@@ -6,8 +6,7 @@ import { useMutation } from '@tanstack/react-query';
import ClassAContext from '../../../views/Seedlot/ContextContainerClassA/context';
import { PtValsCalcReqPayload } from '../../../types/PtCalcTypes';
import postForCalculation from '../../../api-service/parentTreeAPI';
-import { fillCalculatedInfo, generatePtValCalcPayload } from './utils';
-import { geneticWorthDict } from './constants';
+import { fillCalculatedInfo, generatePtValCalcPayload, getParentTreesForSelectedOrchards } from './utils';
type props = {
disableOptions: boolean,
@@ -18,6 +17,7 @@ type props = {
const CalculateMetrics = ({ disableOptions, setShowInfoSections, isReview }: props) => {
const {
allStepData: { parentTreeStep: state },
+ allStepData: { orchardStep },
genWorthInfoItems,
setGenWorthInfoItems,
seedlotSpecies,
@@ -72,8 +72,11 @@ const CalculateMetrics = ({ disableOptions, setShowInfoSections, isReview }: pro
calculateGenWorthQuery.mutate(
generatePtValCalcPayload(
state,
- geneticWorthDict,
- seedlotSpecies
+ seedlotSpecies,
+ getParentTreesForSelectedOrchards(
+ orchardStep,
+ state.allParentTreeData
+ )
)
);
diff --git a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/InputErrorNotification.tsx b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/InputErrorNotification.tsx
index 3c2518ca2..804f805ea 100644
--- a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/InputErrorNotification.tsx
+++ b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/InputErrorNotification.tsx
@@ -103,7 +103,7 @@ const InputErrorNotification = (
allData.forEach((row) => {
rowKeys.forEach((key) => {
- if (key !== 'rowId' && key !== 'isMixTab') {
+ if (row[key] && key !== 'rowId' && key !== 'isMixTab') {
if (row[key].isInvalid && !invalidDataFields.includes(key)) {
invalidDataFields.push(key);
hasErrorInTabs = true;
diff --git a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/PopSize.tsx b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/PopSize.tsx
index 73b9f8e5f..c250a3e77 100644
--- a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/PopSize.tsx
+++ b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/PopSize.tsx
@@ -8,7 +8,9 @@ import { formatEmptyStr } from '../../SeedlotReviewSteps/ParentTrees/utils';
import ReadOnlyInput from '../../ReadOnlyInput';
import { getOutsideParentTreeNum, validateEffectivePopSize } from './utils';
-const PopSize = () => {
+type PopSizeProps = { orchardPts: string[] }
+
+const PopSize = ({ orchardPts } : PopSizeProps) => {
const {
isFetchingData,
isCalculatingPt,
@@ -65,7 +67,13 @@ const PopSize = () => {
id="smp-parents-from-outside"
label="Number of SMP parents from outside"
value={
- formatEmptyStr(getOutsideParentTreeNum(allStepData.parentTreeStep), true)
+ formatEmptyStr(
+ getOutsideParentTreeNum(
+ allStepData.parentTreeStep,
+ orchardPts
+ ),
+ true
+ )
}
showSkeleton={isFetchingData || isCalculatingPt}
/>
diff --git a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/TableComponents/index.tsx b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/TableComponents/index.tsx
index 9632df033..70f1e0eff 100644
--- a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/TableComponents/index.tsx
+++ b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/TableComponents/index.tsx
@@ -1,26 +1,31 @@
-import React, { useEffect, useRef } from 'react';
+import React, { useContext, useEffect, useRef } from 'react';
import {
OverflowMenuItem, Checkbox, TableBody, TableRow, Row, Column,
TableCell, TextInput, ActionableNotification, Pagination, Button, Tooltip
} from '@carbon/react';
import { TrashCan } from '@carbon/icons-react';
+
+import { ParentTreeStepDataObj } from '../../../../views/Seedlot/ContextContainerClassA/definitions';
+import ClassAContext from '../../../../views/Seedlot/ContextContainerClassA/context';
+import PaginationChangeType from '../../../../types/PaginationChangeType';
+import MultiOptionsObj from '../../../../types/MultiOptionsObject';
+import OrchardDataType from '../../../../types/OrchardDataType';
+import { GeneticWorthDto } from '../../../../types/GeneticWorthType';
+import blurOnEnter from '../../../../utils/KeyboardUtil';
+import { handlePagination } from '../../../../utils/PaginationUtils';
+
import { pageText, PageSizesConfig } from '../constants';
import {
EditableCellProps,
+ GeneticWorthInputType,
HeaderObj, RowItem, StrTypeRowItem, TabTypes
} from '../definitions';
-import { ParentTreeStepDataObj } from '../../../../views/Seedlot/ContextContainerClassA/definitions';
-import { OrchardObj } from '../../OrchardStep/definitions';
-import PaginationChangeType from '../../../../types/PaginationChangeType';
-import blurOnEnter from '../../../../utils/KeyboardUtil';
-import { handlePagination } from '../../../../utils/PaginationUtils';
import {
- applyValueToAll, toggleColumn, toggleNotification
+ applyValueToAll, areOrchardsValid, toggleColumn, toggleNotification
} from '../utils';
-import { deleteMixRow, handleInput } from './utils';
-
import '../styles.scss';
-import MultiOptionsObj from '../../../../types/MultiOptionsObject';
+
+import { deleteMixRow, handleInput } from './utils';
export const renderColOptions = (
headerConfig: Array,
@@ -106,23 +111,29 @@ export const renderColOptions = (
/**
* Used to render cell that isn't a text input, e.g. delete button
*/
-const renderDeleteActionBtn = (
+type DeleteActionBtnProps = {
rowData: RowItem,
applicableGenWorths: string[],
- state: ParentTreeStepDataObj,
- setStepData: Function,
- isFormSubmitted?: boolean,
isReviewEdit?: boolean
-) => (
-
{
- // Check if it's fetching parent tree data
- (!disableOptions && allParentTreeQuery.isFetching)
+ // Check if it's fetching parent tree and dependencies data
+ (!disableOptions
+ && (allParentTreeQuery.fetchStatus === 'fetching'
+ || orchardQuery.fetchStatus === 'fetching'
+ || geneticWorthListQuery.fetchStatus === 'fetching'
+ )
+ )
? (