Skip to content

Commit

Permalink
fix: fix checkbox bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao Peng authored and Xiao Peng committed Oct 23, 2024
1 parent 4092e69 commit 0bc4ccf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@ sync/data/
schemaspy/output

# local testing
*.bat
*.bat

oracle-api/config/*
18 changes: 12 additions & 6 deletions frontend/src/components/ClientAndCodeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ const ClientAndCodeInput = ({
const clientInputRef = useRef<HTMLInputElement>(null);
const locCodeInputRef = useRef<HTMLInputElement>(null);
const [isDefault, setIsDefault] = useState<boolean>(
() => getIsDefaultVal()
!shouldSelectDefaultValue ? false : () => getIsDefaultVal()
);

const [isChecked, setIsChecked] = useState<boolean>(() => {
if (!shouldSelectDefaultValue) {
return false;
}
return checkBoxInput ? checkBoxInput.value : isDefault;
});

const [showClientValidationStatus, setShowClientValidationStatus] = useState<boolean>(true);

const [showLocCodeValidationStatus, setShowLocCodeValidationStatus] = useState<boolean>(false);
Expand All @@ -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) {
Expand Down Expand Up @@ -226,6 +235,7 @@ const ClientAndCodeInput = ({

if (!checkBoxInput) {
setIsDefault(checked);
setIsChecked(checked);
}
};

Expand Down Expand Up @@ -331,10 +341,6 @@ const ClientAndCodeInput = ({
}
};

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

Check failure on line 344 in frontend/src/components/ClientAndCodeInput/index.tsx

View workflow job for this annotation

GitHub Actions / Typescript lint

More than 1 blank line not allowed
return (
<FlexGrid className="agency-information-section">
Expand Down

0 comments on commit 0bc4ccf

Please sign in to comment.