Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 1634 & 1640 A few bug fixes #1673

Merged
merged 12 commits into from
Nov 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ClientAndCodeInputProps = {
readOnly?: boolean,
maxInputColSize?: number,
checkBoxInput?: BooleanInputType
shouldSelectDefaultValue?: boolean
}

export default ClientAndCodeInputProps;
13 changes: 9 additions & 4 deletions frontend/src/components/ClientAndCodeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -331,6 +331,11 @@ const ClientAndCodeInput = ({
}
};

let isChecked = checkBoxInput ? checkBoxInput.value : isDefault;
if (!shouldSelectDefaultValue) {
isChecked = false;
}

return (
<FlexGrid className="agency-information-section">
{
Expand All @@ -343,7 +348,7 @@ const ClientAndCodeInput = ({
name={textConfig.useDefaultCheckbox.name}
labelText={textConfig.useDefaultCheckbox.labelText}
readOnly={readOnly}
checked={checkBoxInput ? checkBoxInput.value : isDefault}
checked={isChecked}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
handleDefaultCheckBox(e.target.checked);
}}
Expand All @@ -363,7 +368,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
Expand Down Expand Up @@ -406,7 +411,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const LotApplicantAndInfoForm = ({
}
readOnly={isEdit}
maxInputColSize={6}
shouldSelectDefaultValue
/>
<Row className="agency-email-row">
<Column sm={4} md={8} lg={16} xlg={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,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;
};
6 changes: 3 additions & 3 deletions frontend/src/types/SeedlotType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export const emptyCollectionStep: CollectionFormSubmitType = {
collectionLocnCode: '',
collectionStartDate: '',
collectionEndDate: '',
noOfContainers: 1,
volPerContainer: 1,
clctnVolume: 1,
noOfContainers: '',
volPerContainer: '',
clctnVolume: '',
seedlotComment: '',
coneCollectionMethodCodes: []
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/Seedlot/ContextContainerClassA/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading