diff --git a/client/.eslintcache b/client/.eslintcache index 91ed707..681d8b6 100644 --- a/client/.eslintcache +++ b/client/.eslintcache @@ -1 +1 @@ -[{"/Users/jgo/Documents/Sonobi/fe-code-challenge/client/src/index.js":"1","/Users/jgo/Documents/Sonobi/fe-code-challenge/client/src/App.js":"2"},{"size":219,"mtime":1606160019328,"results":"3","hashOfConfig":"4"},{"size":528,"mtime":1606155683575,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1qz3yvt",{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/jgo/Documents/Sonobi/fe-code-challenge/client/src/index.js",[],"/Users/jgo/Documents/Sonobi/fe-code-challenge/client/src/App.js",[]] \ No newline at end of file +[{"/home/bruno/fe-code-challenge/client/src/App.js":"1","/home/bruno/fe-code-challenge/client/src/index.js":"2"},{"size":2155,"mtime":1606199973499,"results":"3","hashOfConfig":"4"},{"size":220,"mtime":1606186125964,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"67sdn0",{"filePath":"8","messages":"9","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/bruno/fe-code-challenge/client/src/App.js",["10"],"/home/bruno/fe-code-challenge/client/src/index.js",[],{"ruleId":"11","severity":1,"message":"12","line":5,"column":5,"nodeType":"13","messageId":"14","endLine":5,"endColumn":16},"no-unused-vars","'buttonStyle' is assigned a value but never used.","Identifier","unusedVar"] \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json index 6ea42f2..2cddc42 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2818,6 +2818,14 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.1.tgz", "integrity": "sha512-5Kgy8Cz6LPC9DJcNb3yjAXTu3XihQgEdnIg50c//zOC/MyLP0Clg+Y8Sh9ZjjnvBrDZU4DgXS9C3T9r4/scGZQ==" }, + "axios": { + "version": "0.21.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz", + "integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", diff --git a/client/package.json b/client/package.json index ebaaec3..6bf9868 100644 --- a/client/package.json +++ b/client/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "axios": "^0.21.0", "react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "4.0.1", diff --git a/client/src/App.js b/client/src/App.js index 3784575..3f2e950 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,23 +1,84 @@ -import logo from './logo.svg'; import './App.css'; +import axios from 'axios'; +import React from 'react'; + +var buttonStyle = { + margin: '10px 10px 10px 0' +}; + + +class Inv extends React.Component { + constructor(props) { + super(props); + this.submitRecord = this.submitRecord.bind(this); + this.nameChange = this.nameChange.bind(this); + this.typeChange = this.typeChange.bind(this); + this.urlChange = this.urlChange.bind(this); + this.state = { list: [], name: "", type: "", url: "" }; + } + + nameChange(event) { this.setState({ name: event.target.value }); } + typeChange(event) { this.setState({ type: event.target.value }); } + urlChange(event) { this.setState({ url: event.target.value }); } + + submitRecord(event) { + + let payload = { + name: this.state.name, + type: this.state.type, + url: this.state.url + } + + axios.post('http://localhost:3001/inventoryset', payload) + .then((response) => { + console.log(response); + this.getInv(); + }) + .catch((error) => { + console.log(error); + }); + + event.preventDefault(); + } + + getInv() { + axios.get('http://localhost:3001/inventoryget') + .then((response) => { + let temp = [] + for (let x of response.data.result) + temp.push(
- Edit src/App.js and save to reload.
-