Update 'roles' and 'users' endpoint

master
sigonasr2, Sig, Sigo 3 years ago
parent a2abaad0c3
commit 60f1bc6116
  1. 14
      src/App.js

@ -400,6 +400,7 @@ function TableEditor(p) {
const [update,setUpdate] = useState(false) const [update,setUpdate] = useState(false)
const [submitVals,setSubmitVal] = useReducer(updateVals,initialVals) const [submitVals,setSubmitVal] = useReducer(updateVals,initialVals)
const [loading,setLoading] = useState(false) const [loading,setLoading] = useState(false)
const [dependencies,setDependencies] = useState([])
function SubmitBoxes() { function SubmitBoxes() {
axios.post(BACKEND_URL+p.path,submitVals) axios.post(BACKEND_URL+p.path,submitVals)
@ -424,7 +425,19 @@ function TableEditor(p) {
var rows = data.data.rows var rows = data.data.rows
setFields(cols.filter((col)=>col.name!=="id")) 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) setData(rows)
return Promise.allSettled(promise_list)
}) })
.then(()=>{ .then(()=>{
setLoading(false) setLoading(false)
@ -437,6 +450,7 @@ function TableEditor(p) {
{!loading? {!loading?
<div className="table-responsive"> <div className="table-responsive">
<table cellPadding="10" className="table text-light table-padding"> <table cellPadding="10" className="table text-light table-padding">
<caption>{JSON.stringify(dependencies)}</caption>
<thead> <thead>
<tr> <tr>
<th className="table-padding"></th> <th className="table-padding"></th>

Loading…
Cancel
Save