aboutsummaryrefslogtreecommitdiff
path: root/src/components/editors/item-editor.js
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-01 19:48:06 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-01 19:48:06 +0530
commitfd5ed8aa4f159c8e1c0476915432e0a97a239a91 (patch)
tree42d3563472d9032c27f4e3a87dff85ec19362a94 /src/components/editors/item-editor.js
parente4dbf70d561aa3ed79379ffdb98661cb3f215fe9 (diff)
fixed warning 'component changing controlled input to uncontrolled' while editing shipping addresses
Diffstat (limited to 'src/components/editors/item-editor.js')
-rw-r--r--src/components/editors/item-editor.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/components/editors/item-editor.js b/src/components/editors/item-editor.js
index 94c6137..eb6e8c1 100644
--- a/src/components/editors/item-editor.js
+++ b/src/components/editors/item-editor.js
@@ -43,6 +43,18 @@ const ItemEditor = (props) => {
const handleSubmit = (e) => {
e.preventDefault();
+ const minQuantity = parseFloat(minQty)
+ const maxQuantity = parseFloat(maxQty)
+
+ // show error if minQty > maxQty
+ if (maxQuantity > 0) {
+ if (minQuantity > maxQuantity) {
+ // TODO: handle error
+ console.log("shiat")
+ return
+ }
+ }
+
const item = new Item();
item.Id = props.item.Id;
item.Name = name;
@@ -51,8 +63,8 @@ const ItemEditor = (props) => {
item.UnitOfMeasure = unit;
item.UnitPrice = parseFloat(unitPrice);
item.GSTPercentage = parseFloat(gstP);
- item.MinQuantity = parseFloat(minQty);
- item.MaxQuantity = parseFloat(maxQty);
+ item.MinQuantity = minQuantity;
+ item.MaxQuantity = maxQuantity;
item.Brand = brand;
// TODO: Save is for new items. implement modification too
@@ -151,7 +163,7 @@ const ItemEditor = (props) => {
Minimum Quantity:
<input
type="number"
- value={minQty}
+ value={minQty == "0" ? "" : minQty}
min="0"
onChange={(e) => setMinQty(e.target.value)} />
</label>
@@ -160,7 +172,7 @@ const ItemEditor = (props) => {
Maximum Quantity:
<input
type="number"
- value={maxQty}
+ value={maxQty == "0" ? "" : maxQty}
min="0"
onChange={(e) => setMaxQty(e.target.value)} />
</label>