From 8d9b8d165f1be5b2ffe4e676cb6c9082efa56d79 Mon Sep 17 00:00:00 2001 From: Eduardo Carneiro Date: Sat, 4 Mar 2023 16:30:26 -0300 Subject: [PATCH] fix decimal numbers --- src/views/Burndown.js | 4 ++-- src/views/New.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/views/Burndown.js b/src/views/Burndown.js index 62ea71c..c7c9553 100644 --- a/src/views/Burndown.js +++ b/src/views/Burndown.js @@ -87,12 +87,12 @@ const Burndown = () => { return } - if (day.current !== Math.min(object.days, Math.max(1, day.current))) { + if (day.current != Math.round(Math.min(object.days, Math.max(1, day.current)))) { setError(`Dia deve ser um inteiro entre 1 e ${object.days}.`) return } - if (dayPoints.current !== Math.min(9999, Math.max(0, dayPoints.current))) { + if (dayPoints.current != Math.round(Math.min(9999, Math.max(0, dayPoints.current)))) { setError('Pontos deve ser um inteiro entre 0 e 9999.') return } diff --git a/src/views/New.js b/src/views/New.js index 20d61b6..9a85485 100644 --- a/src/views/New.js +++ b/src/views/New.js @@ -50,13 +50,13 @@ const New = () => { } else if (e.target.name === 'points') { let value = e.target.value if (value) { - value = Math.min(9999, Math.max(0, e.target.value)) + value = Math.round(Math.min(9999, Math.max(0, e.target.value))) } setPoints(value) } else if (e.target.name === 'days') { let value = e.target.value if (value) { - value = Math.min(60, Math.max(0, e.target.value)) + value = Math.round(Math.min(60, Math.max(0, e.target.value))) } setDays(value) } @@ -71,12 +71,12 @@ const New = () => { return } - if (days !== Math.min(60, Math.max(2, days))) { + if (days != Math.round(Math.min(60, Math.max(2, days)))) { setError('Dias deve ser um inteiro entre 2 e 60.') return } - if (points !== Math.min(9999, Math.max(1, points))) { + if (points != Math.round(Math.min(9999, Math.max(1, points)))) { setError('Pontos deve ser um inteiro entre 1 e 9999.') return } @@ -99,7 +99,7 @@ const New = () => { useEffect(() => { calcIdealData() - }) + }, []) return ( <>