Browse Source

Adding top and bottom limits to pluviometer increase/decrease btns

master
GabrielTrettel 3 years ago
parent
commit
a8239a4be4
  1. 5
      src/app/components/forms/FormField.js

5
src/app/components/forms/FormField.js

@ -41,7 +41,6 @@ function RenderPluviometerInput({
width, width,
values, values,
}) { }) {
console.log(name == "pluviometer");
const [fieldVal, setFieldVal] = useState(values[name]); const [fieldVal, setFieldVal] = useState(values[name]);
useEffect(() => { useEffect(() => {
@ -49,11 +48,11 @@ function RenderPluviometerInput({
}, [fieldVal]); }, [fieldVal]);
const increase = () => { const increase = () => {
setFieldVal((Number(fieldVal) + 1).toString());
(Number(fieldVal) + 1) <= 999 && setFieldVal((Number(fieldVal) + 1).toString());
}; };
const decrease = () => { const decrease = () => {
setFieldVal((Number(fieldVal) - 1).toString());
(Number(fieldVal) - 1) >= 0 && setFieldVal((Number(fieldVal) - 1).toString());
}; };
return ( return (

Loading…
Cancel
Save