MSI\derek 2 tygodni temu
rodzic
commit
5381ad80e8
1 zmienionych plików z 23 dodań i 2 usunięć
  1. +23
    -2
      src/components/PoDetail/PoDetail.tsx

+ 23
- 2
src/components/PoDetail/PoDetail.tsx Wyświetl plik

@@ -355,13 +355,34 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
acceptedQty: secondReceiveQty || 0,
// acceptedQty: row.acceptedQty,
};
if (postData.acceptedQty === 0) return
if (secondReceiveQty === 0) return
const res = await createStockInLine(postData);
console.log(res);
}, 200);
},
[],
);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const raw = e.target.value;

// Allow empty input
if (raw.trim() === '') {
setSecondReceiveQty(undefined);
return;
}

// Keep digits only
const cleaned = raw.replace(/[^\d]/g, '');
if (cleaned === '') {
// If the user typed only non-digits, keep previous value
return;
}

// Parse and clamp to non-negative integer
const next = Math.max(0, Math.floor(Number(cleaned)));
setSecondReceiveQty(next);
};
return (
<>
<TableRow
@@ -401,7 +422,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
type="text" // Use type="text" to allow validation in the change handler
variant="outlined"
value={secondReceiveQty}
// onChange={handleChange}
onChange={handleChange}
InputProps={{
inputProps: {
min: 0, // Optional: set a minimum value


Ładowanie…
Anuluj
Zapisz