aboutsummaryrefslogtreecommitdiff
path: root/src/components/Form/Form.js
diff options
context:
space:
mode:
authorMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-04-15 17:33:18 +0530
committerMikunoNaka <bokuwakanojogahoshii@yahoo.com>2021-04-15 17:33:18 +0530
commit8ab93681fddf6c104d02f5123e293a5da25b311b (patch)
tree93ccfe6d4ead255f16ddb517b9a79e58aaf778f9 /src/components/Form/Form.js
parenta008767f428e81669efbfa24497c613c592c361c (diff)
Added more basic functionality for BillingForm
Diffstat (limited to 'src/components/Form/Form.js')
-rw-r--r--src/components/Form/Form.js61
1 files changed, 50 insertions, 11 deletions
diff --git a/src/components/Form/Form.js b/src/components/Form/Form.js
index 3285548..5cb5675 100644
--- a/src/components/Form/Form.js
+++ b/src/components/Form/Form.js
@@ -3,43 +3,82 @@ import "./Form.css";
const BillingForm = (props) => {
- const [itemValue, setItemValue] = useState("");
- const [descValue, setDescValue] = useState("");
+ const [itemNameValue, setItemNameValue] = useState("");
+ const [itemDescValue, setItemDescValue] = useState("");
+ const [itemPriceValue, setItemPriceValue] = useState(0.00);
+ const [itemDiscountValue, setItemDiscountValue] = useState(0.00);
+ const [itemGSTValue, setItemGSTValue] = useState(18);
+ // Extract the model names from savedItems
const savedItems = props.savedItems;
- let savedItemNames = []
+ let savedItemNames = [];
for (let i = 0; i < savedItems.length; i++) {
- savedItemNames.push(savedItems[i].Model)
+ savedItemNames.push(savedItems[i].Model);
}
const filteredItems = savedItemNames.filter(
(item) => {
// case insensitive
- return item.toLowerCase().includes(itemValue.toLowerCase());
+ return item.toLowerCase().includes(itemNameValue.toLowerCase());
}
);
-
+
return (
<div>
<form onSubmit={
(event) => {
event.preventDefault();
- console.log(itemValue, descValue);
+ console.log(itemNameValue, itemDescValue, itemPriceValue);
}
}>
<label>
- Item: <input type="text" value={itemValue} onChange={
+ Item: <input type="text" value={itemNameValue} onChange={
(event) => {
- setItemValue(event.target.value);
+ setItemNameValue(event.target.value);
+ // set description and price value
+ for (let i = 0; i <= props.savedItems.length - 1; i++) {
+ const mod = props.savedItems[i].Model;
+ const desc = props.savedItems[i].Description;
+ const price = props.savedItems[i].Price;
+ if (mod === event.target.value) {
+ setItemDescValue(desc);
+ setItemPriceValue(price);
+ break;
+ }
+ }
}
} />
</label>
<label>
- Description: <input type="text" value={descValue} onChange={
+ Description: <input type="text" min="0" step="0.1" value={itemDescValue} onChange={
+ (event) => {
+ setItemDescValue(event.target.value);
+ }
+ } />
+ </label>
+
+ <label>
+ Price: <input type="number" min="0" value={itemPriceValue} onChange={
+ (event) => {
+ setItemPriceValue(event.target.value);
+ }
+ } />
+ </label>
+
+ <label>
+ Discount: <input type="number" min="0" value={itemDiscountValue} onChange={
+ (event) => {
+ setItemDiscountValue(event.target.value);
+ }
+ } />
+ </label>
+
+ <label>
+ GST: <input type="number" min="0" value={itemGSTValue} onChange={
(event) => {
- setDescValue(event.target.value);
+ setItemGSTValue(event.target.value);
}
} />
</label>