@@ -18,11 +18,11 @@ export default function EditItemModal({ show, item, category, onClose }: EditIte
1818 const [ discarded , setDiscarded ] = useState ( 0 ) ;
1919
2020 const total = opened + consumed + discarded ;
21- const invalid = total > item . quantity ;
21+ const exceedsAvailableQuantity = total > item . quantity ;
2222
2323 async function handleSubmit ( e : React . FormEvent ) {
2424 e . preventDefault ( ) ;
25- if ( invalid ) return ;
25+ if ( exceedsAvailableQuantity ) return ;
2626
2727 // Each operation may change the item's quantity in the DB, so we pass a
2828 // synthetic item with the remaining quantity to avoid using stale data in
@@ -55,7 +55,7 @@ export default function EditItemModal({ show, item, category, onClose }: EditIte
5555 </ div >
5656 < form onSubmit = { handleSubmit } >
5757 < div className = "modal-body" >
58- { invalid && < div className = "alert alert-danger" > { t ( 'quantity_exceeded' ) } </ div > }
58+ { exceedsAvailableQuantity && < div className = "alert alert-danger" > { t ( 'quantity_exceeded' ) } </ div > }
5959 < div className = "mb-3" >
6060 < label className = "form-label" > { t ( 'opened_items' ) } </ label >
6161 < div className = "input-group" >
@@ -83,7 +83,7 @@ export default function EditItemModal({ show, item, category, onClose }: EditIte
8383 </ div >
8484 < div className = "modal-footer" >
8585 < button type = "button" className = "btn btn-secondary" onClick = { onClose } > { t ( 'close' ) } </ button >
86- < button type = "submit" className = "btn btn-primary" disabled = { invalid } > { t ( 'edit' ) } </ button >
86+ < button type = "submit" className = "btn btn-primary" disabled = { exceedsAvailableQuantity } > { t ( 'edit' ) } </ button >
8787 </ div >
8888 </ form >
8989 </ div >
0 commit comments