Skip to content

Commit

Permalink
Fix data source questions bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
nasaownsky committed Nov 29, 2024
1 parent 92fa396 commit 884e7cf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
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 = "";
}

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

return (
Expand Down

0 comments on commit 884e7cf

Please sign in to comment.