mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-22 02:55:52 -05:00
fix profile page crash when no sens set
This commit is contained in:
@@ -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<MotionInputProps> = ({
|
||||
return (
|
||||
<Box>
|
||||
<Label>{label}</Label>
|
||||
<ChakraNumberInput
|
||||
value={value}
|
||||
onChange={(value) => {
|
||||
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)
|
||||
}
|
||||
}}
|
||||
<NumberInput
|
||||
value={value ?? undefined}
|
||||
onChange={(_, value) => onChange(Math.round(value * 2) / 2)}
|
||||
size="lg"
|
||||
min={-5}
|
||||
max={5}
|
||||
step={0.5}
|
||||
>
|
||||
<NumberInputField type="number" background={darkerBgColor} />
|
||||
<NumberInputField background={darkerBgColor} />
|
||||
<NumberInputStepper>
|
||||
<NumberIncrementStepper />
|
||||
<NumberDecrementStepper />
|
||||
</NumberInputStepper>
|
||||
</ChakraNumberInput>
|
||||
</NumberInput>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user