diff --git a/.gitignore b/.gitignore index 3bcc45ec1..996bb61cf 100644 --- a/.gitignore +++ b/.gitignore @@ -210,4 +210,4 @@ schemaspy/output # local testing *.bat -oracle-api/config \ No newline at end of file +oracle-api/config diff --git a/frontend/src/components/ClientAndCodeInput/definitions.ts b/frontend/src/components/ClientAndCodeInput/definitions.ts index 4e6063f6c..9a1518e35 100644 --- a/frontend/src/components/ClientAndCodeInput/definitions.ts +++ b/frontend/src/components/ClientAndCodeInput/definitions.ts @@ -18,6 +18,7 @@ type ClientAndCodeInputProps = { readOnly?: boolean, maxInputColSize?: number, checkBoxInput?: BooleanInputType + shouldSelectDefaultValue?: boolean } export default ClientAndCodeInputProps; diff --git a/frontend/src/components/ClientAndCodeInput/index.tsx b/frontend/src/components/ClientAndCodeInput/index.tsx index c054ba2ef..67eedc36c 100644 --- a/frontend/src/components/ClientAndCodeInput/index.tsx +++ b/frontend/src/components/ClientAndCodeInput/index.tsx @@ -26,7 +26,7 @@ import './styles.scss'; const ClientAndCodeInput = ({ checkboxId, clientInput, locationCodeInput, textConfig, defaultClientNumber, defaultLocCode, setClientAndCode, readOnly, showCheckbox, maxInputColSize, - checkBoxInput + checkBoxInput, shouldSelectDefaultValue = false }: ClientAndCodeInputProps) => { const getIsDefaultVal = () => ( checkBoxInput === undefined @@ -38,9 +38,16 @@ const ClientAndCodeInput = ({ const clientInputRef = useRef(null); const locCodeInputRef = useRef(null); const [isDefault, setIsDefault] = useState( - () => getIsDefaultVal() + !shouldSelectDefaultValue ? false : () => getIsDefaultVal() ); + const [isChecked, setIsChecked] = useState(() => { + if (!shouldSelectDefaultValue) { + return false; + } + return checkBoxInput ? checkBoxInput.value : isDefault; + }); + const [showClientValidationStatus, setShowClientValidationStatus] = useState(true); const [showLocCodeValidationStatus, setShowLocCodeValidationStatus] = useState(false); @@ -60,7 +67,9 @@ const ClientAndCodeInput = ({ useEffect(() => { const areValsDefault = getIsDefaultVal(); - setIsDefault(areValsDefault); + if (shouldSelectDefaultValue) { + setIsDefault(areValsDefault); + } // Do not show validation status if isDefault is true if (areValsDefault) { @@ -223,10 +232,8 @@ const ClientAndCodeInput = ({ } : undefined ); - - if (!checkBoxInput) { - setIsDefault(checked); - } + setIsDefault(checked); + setIsChecked(checked); }; const [openAgnTooltip, setOpenAgnTooltip] = useState(false); @@ -343,7 +350,7 @@ const ClientAndCodeInput = ({ name={textConfig.useDefaultCheckbox.name} labelText={textConfig.useDefaultCheckbox.labelText} readOnly={readOnly} - checked={checkBoxInput ? checkBoxInput.value : isDefault} + checked={isChecked} onChange={(e: React.ChangeEvent) => { handleDefaultCheckBox(e.target.checked); }} @@ -363,7 +370,7 @@ const ClientAndCodeInput = ({ id={clientInput.id} autoCapitalize="on" labelText={textConfig.agencyInput.titleText} - defaultValue={forestClientQuery.data?.acronym} + defaultValue={shouldSelectDefaultValue ? forestClientQuery.data?.acronym : ''} helperText={ (readOnly || (showCheckbox && isDefault)) ? null @@ -406,7 +413,7 @@ const ClientAndCodeInput = ({ id={locationCodeInput.id} ref={locCodeInputRef} name={textConfig.locationCode.name} - defaultValue={locationCodeInput.value} + defaultValue={shouldSelectDefaultValue ? locationCodeInput.value : ''} type="number" maxCount={LOCATION_CODE_LIMIT} enableCounter diff --git a/frontend/src/components/LotApplicantAndInfoForm/index.tsx b/frontend/src/components/LotApplicantAndInfoForm/index.tsx index 6d81177da..03fb63185 100644 --- a/frontend/src/components/LotApplicantAndInfoForm/index.tsx +++ b/frontend/src/components/LotApplicantAndInfoForm/index.tsx @@ -118,6 +118,7 @@ const LotApplicantAndInfoForm = ({ } readOnly={isEdit} maxInputColSize={6} + shouldSelectDefaultValue /> diff --git a/frontend/src/components/SeedlotRegistrationSteps/CollectionStep/constants.ts b/frontend/src/components/SeedlotRegistrationSteps/CollectionStep/constants.ts index a3fa2d971..9eddccfae 100644 --- a/frontend/src/components/SeedlotRegistrationSteps/CollectionStep/constants.ts +++ b/frontend/src/components/SeedlotRegistrationSteps/CollectionStep/constants.ts @@ -49,12 +49,12 @@ export const fieldsConfig = { }, volumePerContainers: { name: 'volumePerContainers', - labelText: 'Volume per Containers (HI)', + labelText: 'Volume per containers (hl)', invalidText: 'Invalid entry. Number must be between 0 and 10,000 and up to 3 decimal places.' }, volumeOfCones: { name: 'volumeOfCones', - labelText: 'Volume of Cones (HI)', + labelText: 'Volume of cones (hl)', invalidText: 'Number has more than 3 decimals.', helperText: 'This value must be the "Volume per container" X "Number of containers".', warnText: 'The total volume of cones does not equal, please note that this value must be the "Volume per container" x "Number of containers"' diff --git a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/utils.ts b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/utils.ts index b0555def0..03fb64f29 100644 --- a/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/utils.ts +++ b/frontend/src/components/SeedlotRegistrationSteps/ParentTreeStep/utils.ts @@ -929,15 +929,11 @@ export const isMissingSecondaryOrchard = (orchardStepData: OrchardForm): boolean * Check if orchards selections are valid. */ export const areOrchardsValid = (orchardStepData: OrchardForm): boolean => { - let isValid = true; const { orchards } = orchardStepData; if (!orchards.primaryOrchard.value.code) { - isValid = false; - } - if (isMissingSecondaryOrchard(orchardStepData)) { - isValid = false; + return false; } - return isValid; + return true; }; diff --git a/frontend/src/types/SeedlotType.ts b/frontend/src/types/SeedlotType.ts index 544245034..b3581ccf8 100644 --- a/frontend/src/types/SeedlotType.ts +++ b/frontend/src/types/SeedlotType.ts @@ -207,9 +207,9 @@ export type CollectionFormSubmitType = { collectionLocnCode: string, collectionStartDate: string, collectionEndDate: string, - noOfContainers: number, - volPerContainer: number, - clctnVolume: number, + noOfContainers: string, + volPerContainer: string, + clctnVolume: string, seedlotComment: string, coneCollectionMethodCodes: Array } diff --git a/frontend/src/views/Seedlot/ContextContainerClassA/constants.tsx b/frontend/src/views/Seedlot/ContextContainerClassA/constants.tsx index 7eb64a11c..f9a33bc13 100644 --- a/frontend/src/views/Seedlot/ContextContainerClassA/constants.tsx +++ b/frontend/src/views/Seedlot/ContextContainerClassA/constants.tsx @@ -120,9 +120,9 @@ export const emptyCollectionStep: CollectionFormSubmitType = { collectionLocnCode: '', collectionStartDate: '', collectionEndDate: '', - noOfContainers: 1, - volPerContainer: 1, - clctnVolume: 1, + noOfContainers: '', + volPerContainer: '', + clctnVolume: '', seedlotComment: '', coneCollectionMethodCodes: [] }; diff --git a/frontend/src/views/Seedlot/ContextContainerClassA/utils.ts b/frontend/src/views/Seedlot/ContextContainerClassA/utils.ts index 5a480774a..590b51f1f 100644 --- a/frontend/src/views/Seedlot/ContextContainerClassA/utils.ts +++ b/frontend/src/views/Seedlot/ContextContainerClassA/utils.ts @@ -852,9 +852,9 @@ export const convertCollection = (collectionData: CollectionForm): CollectionFor // Assume the date values are present as validation has occurred before payload is generated collectionStartDate: localDateToUtcFormat(collectionData.startDate.value)!, collectionEndDate: localDateToUtcFormat(collectionData.endDate.value)!, - noOfContainers: +collectionData.numberOfContainers.value, - volPerContainer: +collectionData.volumePerContainers.value, - clctnVolume: +collectionData.volumeOfCones.value, + noOfContainers: `${+collectionData.numberOfContainers.value}`, + volPerContainer: `${+collectionData.volumePerContainers.value}`, + clctnVolume: `${+collectionData.volumeOfCones.value}`, seedlotComment: collectionData.comments.value, coneCollectionMethodCodes: collectionData .selectedCollectionCodes.value.map((code) => parseInt(code, 10))