Can delete a movement

This commit is contained in:
2025-04-22 12:14:50 +02:00
parent 68dfbfff2b
commit bff1c2d171
4 changed files with 83 additions and 22 deletions

View File

@ -13,7 +13,7 @@ export function AmountInput(p: {
placeholder: string;
style: React.CSSProperties;
value: number;
onValueChange: (val: number) => {};
onValueChange: (val: number) => void;
}): React.ReactElement {
const [state, setState] = React.useState(InputState.Normal);
@ -32,7 +32,10 @@ export function AmountInput(p: {
{...p}
value={value}
onValueChange={(a) => {
if (a === "-") return setState(InputState.StartNeg);
if (a === "-") {
setState(InputState.StartNeg);
return;
}
if (a?.endsWith(".")) {
setState(InputState.StartDecimal);
@ -44,7 +47,7 @@ export function AmountInput(p: {
// Empty field
if (a?.length === 0) p.onValueChange(NaN);
// Input number
else if ((a?.length ?? 0 > 0) && !Number.isNaN(parsed))
else if ((a?.length ?? 0) > 0 && !Number.isNaN(parsed))
p.onValueChange(parsed);
}}
/>