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

Feat/596 implement edit applicant info screen #691

Merged
merged 18 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: update isInvalid value
  • Loading branch information
craigyu committed Nov 29, 2023
commit 098984fdcc4d678836a851a680913c6b9da81bbc
6 changes: 4 additions & 2 deletions frontend/src/components/ApplicantAgencyFields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const ApplicantAgencyFields = ({

const updatedAgency = {
...agency,
value: value ?? { code: '', label: '', description: '' }
value: value ?? { code: '', label: '', description: '' },
isInvalid: false
};

const updatedLocationCode = {
Expand Down Expand Up @@ -120,7 +121,8 @@ const ApplicantAgencyFields = ({

const updatedLocationCode = {
...locationCode,
value: formattedCode
value: formattedCode,
isInValid: true
};

setAgencyAndCode(isDefault, agency, updatedLocationCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
ComboBox,
RadioButton,
RadioButtonGroup,
Checkbox,
CheckboxGroup,
RadioButtonSkeleton,
TextInputSkeleton
} from '@carbon/react';
Expand Down Expand Up @@ -77,7 +75,6 @@ const SeedlotInformation = (
<RadioButton
key={source.code}
checked={seedlotFormData.sourceCode.value === source.code}
id={seedlotFormData.sourceCode.id}
labelText={source.description}
value={source.code}
/>
Expand All @@ -86,7 +83,7 @@ const SeedlotInformation = (
return <InputErrorText description="Could not retrieve seedlot sources." />;
};

const handleCheckBox = (inputName: keyof SeedlotRegFormType, checked: boolean) => {
const handleBoolRadioGroup = (inputName: keyof SeedlotRegFormType, checked: boolean) => {
setSeedlotFormData((prevData) => ({
...prevData,
[inputName]: {
Expand Down Expand Up @@ -170,7 +167,7 @@ const SeedlotInformation = (
<Row className="form-row">
<Column sm={4} md={8} lg={16}>
<RadioButtonGroup
legendText="Class A source"
legendText="Specify A-class source"
name="class-source-radiogroup"
orientation="vertical"
onChange={(e: string) => handleSource(e)}
Expand All @@ -185,32 +182,44 @@ const SeedlotInformation = (
</Row>
<Row className="form-row">
<Column sm={4} md={8} lg={16}>
<CheckboxGroup legendText="To be registered?">
<Checkbox
id="registered-tree-seed-center"
name="registered"
labelText="Yes, to be registered with the Tree Seed Centre"
<RadioButtonGroup
name="will-be-registered-radiogroup"
legendText="To be registered at the Tree Seed Centre?"
orientation="vertical"
onChange={(checkedString: string) => handleBoolRadioGroup('willBeRegistered', checkedString === 'Yes')}
>
<RadioButton
checked={seedlotFormData.willBeRegistered.value}
onChange={
(e: React.ChangeEvent<HTMLInputElement>) => handleCheckBox('willBeRegistered', e.target.checked)
}
labelText="Yes"
value="Yes"
/>
</CheckboxGroup>
<RadioButton
checked={!seedlotFormData.willBeRegistered.value}
labelText="No"
value="No"
/>
</RadioButtonGroup>
</Column>
</Row>
<Row className="form-row">
<Column sm={4} md={8} lg={16}>
<CheckboxGroup legendText="Collected from B.C. source?">
<Checkbox
id="collected-bc"
name="collectedBC"
labelText="Yes, collected from a location within B.C."
<RadioButtonGroup
name="collected-within-bc-radiogroup"
legendText="Collected from a location within B.C.?"
orientation="vertical"
onChange={(checkedString: string) => handleBoolRadioGroup('isBcSource', checkedString === 'Yes')}
>
<RadioButton
checked={seedlotFormData.isBcSource.value}
onChange={
(e: React.ChangeEvent<HTMLInputElement>) => handleCheckBox('isBcSource', e.target.checked)
}
labelText="Yes"
value="Yes"
/>
</CheckboxGroup>
<RadioButton
checked={!seedlotFormData.isBcSource.value}
labelText="No"
value="No"
/>
</RadioButtonGroup>
</Column>
</Row>
</>
Expand Down