From 5c64bc6698edfdf6d5c676e483f925da4721c0ea Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 19 Apr 2023 23:33:01 -0300 Subject: [PATCH] created langFlowState type --- src/frontend/src/contexts/tabsContext.tsx | 4 ++-- src/frontend/src/types/tabs/index.ts | 4 +++- src/frontend/src/utils.ts | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index a2bb79081..cf55bb309 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -1,6 +1,6 @@ import { createContext, useEffect, useState, useRef, ReactNode, useContext } from "react"; import { FlowType } from "../types/flow"; -import { TabsContextType } from "../types/tabs"; +import { LangFlowState, TabsContextType } from "../types/tabs"; import { normalCaseToSnakeCase } from "../utils"; import { alertContext } from "./alertContext"; import { TemplatesContext } from "./templatesContext"; @@ -58,7 +58,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { if (cookie && Object.keys(templates).length>0) { console.log(templates) console.log(Object.keys(templates).length) - let cookieObject = JSON.parse(cookie); + let cookieObject:LangFlowState = JSON.parse(cookie); setTabIndex(cookieObject.tabIndex); setFlows(cookieObject.flows); setId(cookieObject.id); diff --git a/src/frontend/src/types/tabs/index.ts b/src/frontend/src/types/tabs/index.ts index 625073fb3..983f4b1f8 100644 --- a/src/frontend/src/types/tabs/index.ts +++ b/src/frontend/src/types/tabs/index.ts @@ -14,4 +14,6 @@ export type TabsContextType = { lockChat:boolean; setLockChat:(prevState:boolean)=>void; hardReset:()=>void; -}; \ No newline at end of file +}; + +export type LangFlowState={ tabIndex:number, flows:FlowType[], id:number, nodeId:number } \ No newline at end of file diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 5ab47f31e..79151f2d2 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -17,6 +17,7 @@ import { } from "@heroicons/react/24/outline"; import { Connection, Edge, Node, ReactFlowInstance } from "reactflow"; import { FlowType } from "./types/flow"; +import { APIClassType } from "./types/api"; var _ = require('lodash') export function classNames(...classes:Array) { @@ -383,4 +384,8 @@ export function removeApiKeys(flow:FlowType):FlowType{ } }) return cleanFLow +} + +export function UpdateTemplate(newTemplate:APIClassType,oldTemplate:APIClassType){ + } \ No newline at end of file