Added loading while it's updating component
This commit is contained in:
parent
62f78e0795
commit
6d8c37a45f
1 changed files with 5 additions and 8 deletions
|
|
@ -204,7 +204,10 @@ export default function GenericNode({
|
||||||
setShowNode(data.showNode ?? true);
|
setShowNode(data.showNode ?? true);
|
||||||
}, [data.showNode]);
|
}, [data.showNode]);
|
||||||
|
|
||||||
|
const [loadingUpdate, setLoadingUpdate] = useState(false);
|
||||||
|
|
||||||
const handleUpdateCode = () => {
|
const handleUpdateCode = () => {
|
||||||
|
setLoadingUpdate(true);
|
||||||
takeSnapshot();
|
takeSnapshot();
|
||||||
// to update we must get the code from the templates in useTypesStore
|
// to update we must get the code from the templates in useTypesStore
|
||||||
const thisNodeTemplate = templates[data.type]?.template;
|
const thisNodeTemplate = templates[data.type]?.template;
|
||||||
|
|
@ -219,19 +222,12 @@ export default function GenericNode({
|
||||||
const { data } = apiReturn;
|
const { data } = apiReturn;
|
||||||
if (data && updateNodeCode) {
|
if (data && updateNodeCode) {
|
||||||
updateNodeCode(data, currentCode, "code");
|
updateNodeCode(data, currentCode, "code");
|
||||||
|
setLoadingUpdate(false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
setNode(data.id, (oldNode) => {
|
|
||||||
let newNode = cloneDeep(oldNode);
|
|
||||||
newNode.data = {
|
|
||||||
...data,
|
|
||||||
};
|
|
||||||
newNode.data.node.template.code.value = currentCode;
|
|
||||||
return newNode;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -476,6 +472,7 @@ export default function GenericNode({
|
||||||
onClick={handleUpdateCode}
|
onClick={handleUpdateCode}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
className={"h-9 px-1.5"}
|
className={"h-9 px-1.5"}
|
||||||
|
loading={loadingUpdate}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="AlertTriangle"
|
name="AlertTriangle"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue