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

[Publisher][Agency Settings] Fix data source questions bugs #1600

Merged
merged 2 commits into from
Dec 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const CheckboxLabel = styled.div`
display: flex;
align-items: center;
gap: 8px;
text-transform: capitalize;
`;

export const Checkbox = styled.input`
Expand Down
10 changes: 8 additions & 2 deletions common/components/CheckboxOptions/CheckboxOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export const CheckboxOptions: React.FC<CheckboxOptionsProps> = ({
options,
onChange,
}) => {
const [otherDescriptionValue, setOtherDescriptionValue] = useState("");
const [otherDescriptionValue, setOtherDescriptionValue] = useState<
string | null
>(null);

return (
<Styled.CheckboxContainer>
Expand Down Expand Up @@ -88,7 +90,11 @@ export const CheckboxOptions: React.FC<CheckboxOptionsProps> = ({
otherDescription.placeholder ||
"Please provide additional information..."
}
value={otherDescriptionValue || otherDescription.value}
value={
otherDescriptionValue !== null
? otherDescriptionValue
: otherDescription.value || ""
}
onChange={(e) => {
setOtherDescriptionValue(e.target.value);
otherDescription.onChange(e.target.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,29 @@ const QuestionCheckboxBlock: React.FC<{
};

const handleChange = (key: string) => {
if (key !== "CURRENT_AGENCY") {
updatedSetting[sourceType].collection_method.value = "";
}
if (key !== "OTHER_AGENCY_OR_SYSTEM") {
updatedSetting[sourceType].modification.value = "";
}
if (key !== "OTHER") {
updatedSetting[sourceType][settingType].other_description = "";
if (currentKey === key) {
setCurrentKey("");
updatedSetting[sourceType][settingType].value = "";
} else {
if (key !== "CURRENT_AGENCY") {
updatedSetting[sourceType].collection_method.value = "";
if (key !== "OTHER") {
updatedSetting[sourceType].collection_method.other_description = "";
}
}
if (key !== "OTHER_AGENCY_OR_SYSTEM") {
updatedSetting[sourceType].modification.value = "";
if (key !== "OTHER") {
updatedSetting[sourceType].modification.other_description = "";
}
}
if (key !== "OTHER") {
updatedSetting[sourceType][settingType].other_description = "";
}
Copy link
Contributor

@mxosman mxosman Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand this section here? I'm confused - I assumed it's wiping out the other fields, but am not totally sure.

So if I select the second choice in What is the source of biological sex data in your system?:

What is the source of biological sex data in your system?

[x] Data is collected directly by the agency

This will clear out the collection_method value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'm following now - would you mind adding a small comment here explaining what these conditionals are doing for posterity?


setCurrentKey(key);
updatedSetting[sourceType][settingType].value = key;
}
updatedSetting[sourceType][settingType].value = key;
};

return (
Expand Down
Loading