Skip to content

Commit

Permalink
[Fix] Address ESLint issues in BasisPointsInput component (#3432)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Jun 20, 2024
1 parent e8dc81d commit d320777
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/dashboard/src/components/inputs/BasisPointsInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-syntax */
import {
Input,
InputGroup,
Expand Down Expand Up @@ -26,22 +27,24 @@ export const BasisPointsInput: React.FC<BasisPointsInputProps> = ({
// updated on the settings tab, when the value gets
// changed from the default 0, but only then, and not
// every time the value changes on user input
// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (value !== 0 && stringValue === "0.00") {
setStringValue((value / 100).toFixed(2));
}
}, [value, stringValue]);

// eslint-disable-next-line no-restricted-syntax
useEffect(() => {

// biome-ignore lint/correctness/useExhaustiveDependencies: we *cannot* add onChange to the dependencies here
useEffect(() => {
const validValue = stringValue.match(
/^100$|^100.00$|^\d{0,2}(\.\d{1,2})? *%?$/g,
);
if (validValue?.length) {
onChange(Math.floor(Number.parseFloat(validValue[0] || "0") * 100));
}
}, [stringValue, onChange]);


}, [stringValue]);

return (
<InputGroup {...restInputProps}>
Expand All @@ -64,4 +67,4 @@ export const BasisPointsInput: React.FC<BasisPointsInputProps> = ({
<InputRightAddon>%</InputRightAddon>
</InputGroup>
);
};
};

0 comments on commit d320777

Please sign in to comment.