Added fields to request for creating new variable
This commit is contained in:
parent
a556f686e2
commit
e773227e4a
3 changed files with 8 additions and 7 deletions
|
|
@ -26,15 +26,16 @@ export default function AddNewVariableButton({ children }): JSX.Element {
|
|||
(state) => state.addGlobalVariable
|
||||
);
|
||||
function handleSaveVariable() {
|
||||
let data: { name: string; value: string; type?: string } = {
|
||||
let data: { name: string; value: string; type?: string; default_fields?: string[] } = {
|
||||
name: key,
|
||||
type,
|
||||
value,
|
||||
default_fields: fields
|
||||
};
|
||||
registerGlobalVariable(data)
|
||||
.then((res) => {
|
||||
const { name, id, type } = res.data;
|
||||
addGlobalVariable(name, id, type);
|
||||
addGlobalVariable(name, id, type, fields);
|
||||
setKey("");
|
||||
setValue("");
|
||||
setType("");
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
|||
globalVariablesEntries: Object.keys(variables),
|
||||
});
|
||||
},
|
||||
addGlobalVariable: (name, id, type) => {
|
||||
const data = { id, type };
|
||||
addGlobalVariable: (name, id, type, default_fields) => {
|
||||
const data = { id, type, default_fields };
|
||||
const newVariables = { ...get().globalVariables, [name]: data };
|
||||
set({
|
||||
globalVariables: newVariables,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export type GlobalVariablesStore = {
|
||||
globalVariablesEntries: Array<string>;
|
||||
globalVariables: { [name: string]: { id: string; type?: string } };
|
||||
globalVariables: { [name: string]: { id: string; type?: string, default_fields?: string[] } };
|
||||
setGlobalVariables: (variables: {
|
||||
[name: string]: { id: string; type?: string };
|
||||
[name: string]: { id: string; type?: string, default_fields?: string[]};
|
||||
}) => void;
|
||||
addGlobalVariable: (name: string, id: string, type?: string) => void;
|
||||
addGlobalVariable: (name: string, id: string, type?: string, default_fields?: string[]) => void;
|
||||
removeGlobalVariable: (name: string) => void;
|
||||
getVariableId: (name: string) => string | undefined;
|
||||
unavaliableFields: Set<string>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue