Can delete a movement
This commit is contained in:
@ -13,7 +13,7 @@ import { AmountInput } from "./forms/AmountInput";
|
||||
|
||||
export function NewMovementWidget(p: {
|
||||
account: Account;
|
||||
onCreated: () => {};
|
||||
onCreated: () => void;
|
||||
}): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
const alert = useAlert();
|
||||
@ -91,7 +91,7 @@ export function NewMovementWidget(p: {
|
||||
type="text"
|
||||
placeholder="Amount"
|
||||
style={{ flex: 1, maxWidth: "110px" }}
|
||||
value={amount}
|
||||
value={amount ?? 0}
|
||||
onValueChange={setAmount}
|
||||
/>
|
||||
<Tooltip title="Add new movement">
|
||||
|
@ -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);
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user