diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-26 15:16:47 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-04-26 15:16:47 +0530 |
commit | e2c31632d326f5f201172dba08b06b422abfa593 (patch) | |
tree | bbaaa2b9bc37cdb0acbc9a24603a7fb39918e657 /src/components/BillingPage.js | |
parent | 1604f4cabc282e91fe27aef74545084ab92e4b9f (diff) |
FINALLY THE BACKEND AND FRONT END ARE TALKING NOW
Diffstat (limited to 'src/components/BillingPage.js')
-rw-r--r-- | src/components/BillingPage.js | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/src/components/BillingPage.js b/src/components/BillingPage.js index 06a80a6..a7e4ef0 100644 --- a/src/components/BillingPage.js +++ b/src/components/BillingPage.js @@ -1,49 +1,28 @@ import React, { useState, useEffect } from "react"; +import axios from "axios"; + import AddNewItemForm from "./Form/AddNewItemForm"; import ItemsDisplay from "./Display/ItemsDisplay"; import SummaryDisplay from "./Display/SummaryDisplay"; -const sampleData = [ - { - "Model": "Kisan Chair", - "Description": "Very good chair", - "Price": 10000, - "HSN": 9403 - }, { - "Model": "Supreme Chair", - "Description": "Even better chair", - "Price": "2134983", - "HSN": 9403 - }, { - "Model": "Action Houseware", - "Description": "Not a chair", - "Price": 69, - "HSN": 69 - }, { - "Model": "Coirfit Mattress", - "Description": "Not a chair (neither houseware)", - "Price": 19, - "HSN": 420 - }, { - "Model": "AVRO Chair", - "Description": "Formerly AVON lol", - "Price": 291, - "HSN": 9403 - }, { - "Model": "Mystery Item", - "Description": "hehe heheheheheh", - "Price": 1212312, - "HSN": 42069 - } -]; - const BillingPage = () => { + const [savedItems, getSavedItems] = useState([]) + + // get data from server on startup useEffect(() => { - alert("yo this app in beta"); + axios.get(`/api/items`) + .then((res) => { + getSavedItems(res.data); + }) + .catch((res) => { + alert("The promise returned an error idk what to do"); + console.log(res); + }) }, []); // to be handled by backend const defGSTValue = 18; + // update the items from AddNewItemForm const [items, setItems] = useState([]); const getItems = (item) => { setItems( @@ -51,12 +30,9 @@ const BillingPage = () => { ); }; - useEffect(() => { - }, [items]); - return ( <div> - <AddNewItemForm savedItems={sampleData} addItem={getItems} defGSTValue={defGSTValue}/> + <AddNewItemForm savedItems={savedItems} addItem={getItems} defGSTValue={defGSTValue}/> <ItemsDisplay items={items} defGSTValue={defGSTValue}/> <SummaryDisplay items={items}/> </div> |