From 16dc75ded8e8c9b3c48592fa5f9340f6fb952eb0 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 27 Jul 2021 01:40:49 +0000 Subject: [PATCH] Provide local backend testing compatibility (with gitpod) --- BACKEND_SETUP_INFO | 14 ++++++++++++++ package.json | 1 + src/App.js | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 BACKEND_SETUP_INFO diff --git a/BACKEND_SETUP_INFO b/BACKEND_SETUP_INFO new file mode 100644 index 0000000..1cd3749 --- /dev/null +++ b/BACKEND_SETUP_INFO @@ -0,0 +1,14 @@ +The backend can be run for local testing by loading a +new docker-compose workspace provided by the projectdivar +git repository. + +once loaded, you can seed the database using the seed files +from the ngsplanner_backend repository. You can use the locally +created .docker_terminal command to access the terminal of the +projectdivar_postgres_1 instance. Finally, you need to +add a .env file for your environment that includes: + +REACT_APP_BACKEND_URL=https://4501-scarlet-echidna-bpwfvar6.ws-us11.gitpod.io/ngsplanner + +Replacing the URL with the URL that points to the /server docker +hosted backend. \ No newline at end of file diff --git a/package.json b/package.json index 21d19fa..35f3dec 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", "axios": "^0.21.1", + "express": "^4.17.1", "gh-pages": "^3.2.3", "react": "^17.0.2", "react-bootstrap-icons": "^1.5.0", diff --git a/src/App.js b/src/App.js index bc8cf63..25d363b 100644 --- a/src/App.js +++ b/src/App.js @@ -430,6 +430,7 @@ function TableEditor(p) { const [data,setData] = useState([]) const [update,setUpdate] = useState(false) const [submitVals,setSubmitVal] = useReducer(updateVals,initialVals) + const [report,setReport] = useState("") function SubmitBoxes() { axios.post(BACKEND_URL+p.path,submitVals) @@ -455,6 +456,9 @@ function TableEditor(p) { setFields(cols.filter((col)=>col.name!=="id").map((col)=>col.name)) setData(rows) }) + .catch((err)=>{ + setReport(JSON.stringify(err)) + }) setUpdate(false) } },[update,p.path]) @@ -462,7 +466,7 @@ function TableEditor(p) { return <>
- +
List of users{JSON.stringify(report)}