update template working for import

This commit is contained in:
anovazzi1 2023-04-27 19:29:50 -03:00
commit a75f22fe21

View file

@ -66,13 +66,14 @@ export function TabsProvider({ children }: { children: ReactNode }) {
let cookieObject: LangFlowState = JSON.parse(cookie); let cookieObject: LangFlowState = JSON.parse(cookie);
cookieObject.flows.forEach((flow) => { cookieObject.flows.forEach((flow) => {
flow.data.nodes.forEach((node) => { flow.data.nodes.forEach((node) => {
node.data.node.template = updateObject( if (Object.keys(templates[node.data.type]["template"]).length>0) {
node.data.node.template as TemplateVariableType, node.data.node.template = updateObject(
templates[node.data.type][ node.data.node.template as TemplateVariableType,
"template" templates[node.data.type][
] as unknown as TemplateVariableType "template"
); ] as unknown as TemplateVariableType
console.log(node) );
}
}); });
}); });
setTabIndex(cookieObject.tabIndex); setTabIndex(cookieObject.tabIndex);
@ -127,7 +128,19 @@ export function TabsProvider({ children }: { children: ReactNode }) {
// read the file as text // read the file as text
file.text().then((text) => { file.text().then((text) => {
// parse the text into a JSON object // parse the text into a JSON object
addFlow(JSON.parse(text)); let flow: FlowType = JSON.parse(text);
flow.data.nodes.forEach((node) => {
if (Object.keys(templates[node.data.type]["template"]).length>0) {
node.data.node.template = updateObject(
node.data.node.template as TemplateVariableType,
templates[node.data.type][
"template"
] as unknown as TemplateVariableType
);
}
});
addFlow();
}); });
} }
}; };