From ebb06540f5392d4b6e09145fbf0ce337ac78ee9b Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Mon, 28 Sep 2020 22:27:43 +0300 Subject: [PATCH] fix profile page crash when no sens set --- .../src/components/user/SensInput.tsx | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/frontend-react/src/components/user/SensInput.tsx b/frontend-react/src/components/user/SensInput.tsx index 828d674a1..e76335fcb 100644 --- a/frontend-react/src/components/user/SensInput.tsx +++ b/frontend-react/src/components/user/SensInput.tsx @@ -2,7 +2,7 @@ import { Box, NumberDecrementStepper, NumberIncrementStepper, - NumberInput as ChakraNumberInput, + NumberInput, NumberInputField, NumberInputStepper, } from "@chakra-ui/core" @@ -25,49 +25,20 @@ const MotionInput: React.FC = ({ return ( - { - const parsed = parseFloat(value.toString()) - if ( - [ - -5, - -4.5, - -4, - -3.5, - -3, - -2.5, - -2, - -1.5, - -1, - -0.5, - 0, - 0.5, - 1, - 1.5, - 2, - 2.5, - 3, - 3.5, - 4, - 4.5, - 5, - ].indexOf(parsed) !== -1 - ) { - onChange(parsed) - } - }} + onChange(Math.round(value * 2) / 2)} size="lg" min={-5} max={5} step={0.5} > - + - + ) }