| @@ -355,13 +355,34 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => { | |||||
| acceptedQty: secondReceiveQty || 0, | acceptedQty: secondReceiveQty || 0, | ||||
| // acceptedQty: row.acceptedQty, | // acceptedQty: row.acceptedQty, | ||||
| }; | }; | ||||
| if (postData.acceptedQty === 0) return | |||||
| if (secondReceiveQty === 0) return | |||||
| const res = await createStockInLine(postData); | const res = await createStockInLine(postData); | ||||
| console.log(res); | console.log(res); | ||||
| }, 200); | }, 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 ( | return ( | ||||
| <> | <> | ||||
| <TableRow | <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 | type="text" // Use type="text" to allow validation in the change handler | ||||
| variant="outlined" | variant="outlined" | ||||
| value={secondReceiveQty} | value={secondReceiveQty} | ||||
| // onChange={handleChange} | |||||
| onChange={handleChange} | |||||
| InputProps={{ | InputProps={{ | ||||
| inputProps: { | inputProps: { | ||||
| min: 0, // Optional: set a minimum value | min: 0, // Optional: set a minimum value | ||||