Fix amount input

This commit is contained in:
Pierre HUBERT 2025-05-14 18:53:03 +02:00
parent 0d30a8135c
commit 7c1cd96691
2 changed files with 7 additions and 2 deletions

View File

@ -52,6 +52,11 @@ export function NewMovementWidget(
return;
}
if (!amount && !p.isInbox) {
alert(`Please specify ${entity} amount!`);
return;
}
try {
if (!p.isInbox) {
await MovementApi.Create({

View File

@ -25,7 +25,7 @@ export function AmountInput(p: {
value = "-";
} else if (state === InputState.StartDecimal) {
value = String(p.value) + ".";
} else if (!Number.isNaN(p.value)) {
} else if (!Number.isNaN(p.value) && p.value !== 0) {
value = String(p.value);
}
@ -47,7 +47,7 @@ export function AmountInput(p: {
const parsed = Number(a);
// Empty field
if (a?.length === 0) p.onValueChange(NaN);
if (a?.length === 0 || a === undefined) p.onValueChange(NaN);
// Input number
else if ((a?.length ?? 0) > 0 && !Number.isNaN(parsed))
p.onValueChange(parsed);