From e2c31632d326f5f201172dba08b06b422abfa593 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Mon, 26 Apr 2021 15:16:47 +0530 Subject: FINALLY THE BACKEND AND FRONT END ARE TALKING NOW --- src/components/BillingPage.js | 54 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) (limited to 'src/components/BillingPage.js') 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 (
- +
-- cgit v1.2.3