From 60f1bc6116758205b23947ccbd3b57754441d0be Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Wed, 28 Jul 2021 02:04:41 +0000 Subject: [PATCH] Update 'roles' and 'users' endpoint --- src/App.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/App.js b/src/App.js index ea4dbbe..a11993e 100644 --- a/src/App.js +++ b/src/App.js @@ -400,6 +400,7 @@ function TableEditor(p) { const [update,setUpdate] = useState(false) const [submitVals,setSubmitVal] = useReducer(updateVals,initialVals) const [loading,setLoading] = useState(false) + const [dependencies,setDependencies] = useState([]) function SubmitBoxes() { axios.post(BACKEND_URL+p.path,submitVals) @@ -424,7 +425,19 @@ function TableEditor(p) { var rows = data.data.rows setFields(cols.filter((col)=>col.name!=="id")) + + var dependency_map = {} + var promise_list = [] + + cols.filter((col)=>col.name!=="id"&&col.name.includes("_id")||col.name=="user_id").forEach((col)=>{ + promise_list.push(axios.get(BACKEND_URL+"/"+col.name.replace("_id","")) + .then((data)=>{ + dependency_map[col.name]=data.data.rows.reverse() + })) + }) + setDependencies(dependency_map) setData(rows) + return Promise.allSettled(promise_list) }) .then(()=>{ setLoading(false) @@ -437,6 +450,7 @@ function TableEditor(p) { {!loading?
+
{JSON.stringify(dependencies)}