Refactor GlobalVariablesPage component to include default_fields in rowData
This commit is contained in:
parent
839822a308
commit
15de984bb6
2 changed files with 18 additions and 10 deletions
|
|
@ -860,13 +860,14 @@ export async function requestLogout() {
|
|||
}
|
||||
|
||||
export async function getGlobalVariables(): Promise<{
|
||||
[key: string]: { id: string; type: string };
|
||||
[key: string]: { id: string; type: string,default_fields:string[] };
|
||||
}> {
|
||||
const globalVariables = {};
|
||||
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
|
||||
globalVariables[element.name] = {
|
||||
id: element.id,
|
||||
type: element.type,
|
||||
default_fields:element.default_fields
|
||||
};
|
||||
});
|
||||
return globalVariables;
|
||||
|
|
|
|||
|
|
@ -33,18 +33,25 @@ export default function GlobalVariablesPage() {
|
|||
<div></div>
|
||||
);
|
||||
};
|
||||
const [rowData, setRowData] = useState<{ type: string | undefined; id: string; name: string; }[]>();
|
||||
|
||||
|
||||
const [rowData, setRowData] = useState<{ type: string | undefined;
|
||||
id: string; name: string; default_fields:string | undefined }[]>();
|
||||
|
||||
useEffect(() => {
|
||||
const rows:Array<{type: string | undefined; id: string; name: string}> = [];
|
||||
const rows:Array<{type: string | undefined; id: string;
|
||||
name: string;default_fields:string | undefined}> = [];
|
||||
globalVariablesEntries.forEach((e) => {
|
||||
const globalVariableObj = globalVariables[e];
|
||||
console.log(globalVariableObj);
|
||||
rows.push({
|
||||
type: globalVariableObj.type,
|
||||
id: globalVariableObj.id,
|
||||
default_fields: (globalVariableObj.default_fields??[]).join(", "),
|
||||
name: e,
|
||||
});
|
||||
});
|
||||
console.log(rows);
|
||||
setRowData(rows);
|
||||
}, [globalVariables]);
|
||||
|
||||
|
|
@ -75,15 +82,15 @@ export default function GlobalVariablesPage() {
|
|||
flex: 1,
|
||||
editable: false,
|
||||
},
|
||||
{
|
||||
field: "value",
|
||||
cellEditor: "agLargeTextCellEditor",
|
||||
flex: 2,
|
||||
editable: false,
|
||||
},
|
||||
// {
|
||||
// field: "value",
|
||||
// cellEditor: "agLargeTextCellEditor",
|
||||
// flex: 2,
|
||||
// editable: false,
|
||||
// },
|
||||
{
|
||||
headerName: "Apply To Fields",
|
||||
field: "defaultFields",
|
||||
field: "default_fields",
|
||||
flex: 1,
|
||||
editable: false,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue